Commit 0d4a5580 authored by Alexandre Julliard's avatar Alexandre Julliard

Added a couple of Unicode string routines.

parent 9c51c96c
......@@ -118,7 +118,7 @@ static inline int strcmpW( const WCHAR *str1, const WCHAR *str2 )
static inline int strncmpW( const WCHAR *str1, const WCHAR *str2, int n )
{
if (!n) return 0;
if (n <= 0) return 0;
while ((--n > 0) && *str1 && (*str1 == *str2)) { str1++; str2++; }
return *str1 - *str2;
}
......@@ -135,15 +135,22 @@ static inline WCHAR *strchrW( const WCHAR *str, WCHAR ch )
return NULL;
}
static inline int strcmpiW( const WCHAR *str1, const WCHAR *str2 )
static inline WCHAR *strlwrW( WCHAR *str )
{
for (;;)
{
int ret = toupperW(*str1) - toupperW(*str2);
if (ret || !*str1) return ret;
str1++;
str2++;
}
WCHAR *ret = str;
while ((*str = tolowerW(*str))) str++;
return ret;
}
static inline WCHAR *struprW( WCHAR *str )
{
WCHAR *ret = str;
while ((*str = toupperW(*str))) str++;
return ret;
}
extern int strcmpiW( const WCHAR *str1, const WCHAR *str2 );
extern int strncmpiW( const WCHAR *str1, const WCHAR *str2, int n );
extern WCHAR *strstrW( const WCHAR *str, const WCHAR *sub );
#endif /* __WINE_UNICODE_H */
......@@ -65,6 +65,7 @@ C_SRCS = \
casemap.c \
cptable.c \
mbtowc.c \
string.c \
wctomb.c \
$(CODEPAGES:%=c_%.c)
......
/*
* Unicode string manipulation functions
*
* Copyright 2000 Alexandre Julliard
*/
#include "wine/unicode.h"
int strcmpiW( const WCHAR *str1, const WCHAR *str2 )
{
for (;;)
{
int ret = toupperW(*str1) - toupperW(*str2);
if (ret || !*str1) return ret;
str1++;
str2++;
}
}
int strncmpiW( const WCHAR *str1, const WCHAR *str2, int n )
{
int ret = 0;
for ( ; n > 0; n--, str1++, str2++)
if ((ret = toupperW(*str1) - toupperW(*str2)) || !*str1) break;
return ret;
}
WCHAR *strstrW( const WCHAR *str, const WCHAR *sub )
{
while (*str)
{
const WCHAR *p1 = str, *p2 = sub;
while (*p1 && *p2 && *p1 == *p2) { p1++; p2++; }
if (!*p2) return (WCHAR *)str;
str++;
}
return NULL;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment