Fixed _wcsnicmp()

svn path=/trunk/; revision=981
This commit is contained in:
Eric Kohl 2000-02-05 23:46:14 +00:00
parent 326a3cd58b
commit 5f71c29e2c
3 changed files with 60 additions and 61 deletions

View file

@ -1,14 +1,14 @@
#include <crtdll/wchar.h> #include <crtdll/wchar.h>
int _wcsnicmp(const wchar_t * cs,const wchar_t * ct,size_t count) int _wcsnicmp (const wchar_t *cs, const wchar_t *ct, size_t count)
{ {
wchar_t *save = (wchar_t *)cs; if (count == 0)
while (towlower(*cs) == towlower(*ct) && (int)(cs - save) < count) return 0;
{ do {
if (*cs == 0) if (towupper(*cs) != towupper(*ct++))
return towupper(*cs) - towupper(*--ct);
if (*cs++ == 0)
break;
} while (--count != 0);
return 0; return 0;
cs++;
ct++;
}
return towlower(*cs) - towlower(*ct);
} }

View file

@ -1,4 +1,5 @@
/* /* $Id: wstring.c,v 1.7 2000/02/05 23:45:46 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
* FILE: lib/ntdll/string/wstring.c * FILE: lib/ntdll/string/wstring.c
@ -14,13 +15,10 @@
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
#include <wchar.h> #include <wchar.h>
/* GLOBALS *******************************************************************/
// static wchar_t * ___wcstok = NULL;
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
int _wcsicmp(const wchar_t* cs,const wchar_t * ct) int _wcsicmp (const wchar_t* cs, const wchar_t * ct)
{ {
while (towlower(*cs) == towlower(*ct)) while (towlower(*cs) == towlower(*ct))
{ {
@ -33,7 +31,7 @@ int _wcsicmp(const wchar_t* cs,const wchar_t * ct)
} }
wchar_t* _wcslwr(wchar_t *x) wchar_t *_wcslwr (wchar_t *x)
{ {
wchar_t *y=x; wchar_t *y=x;
@ -44,17 +42,18 @@ wchar_t* _wcslwr(wchar_t *x)
return x; return x;
} }
int _wcsnicmp(const wchar_t * cs,const wchar_t * ct,size_t count)
int _wcsnicmp (const wchar_t * cs, const wchar_t * ct, size_t count)
{ {
wchar_t *save = (wchar_t *)cs; if (count == 0)
while (towlower(*cs) == towlower(*ct) && (int)(cs - save) < count) return 0;
{ do {
if (*cs == 0) if (towupper(*cs) != towupper(*ct++))
return towupper(*cs) - towupper(*--ct);
if (*cs++ == 0)
break;
} while (--count != 0);
return 0; return 0;
cs++;
ct++;
}
return towlower(*cs) - towlower(*ct);
} }
@ -70,7 +69,7 @@ wchar_t *_wcsupr(wchar_t *x)
} }
wchar_t* wcscat(wchar_t *dest, const wchar_t *src) wchar_t *wcscat (wchar_t *dest, const wchar_t *src)
{ {
int i, j; int i, j;
@ -85,7 +84,7 @@ wchar_t* wcscat(wchar_t *dest, const wchar_t *src)
return dest; return dest;
} }
wchar_t* wcschr(const wchar_t *str, wchar_t ch) wchar_t *wcschr (const wchar_t *str, wchar_t ch)
{ {
while ((*str) != ((wchar_t) 0)) while ((*str) != ((wchar_t) 0))
{ {
@ -155,8 +154,7 @@ size_t wcslen(const wchar_t *s)
return len; return len;
} }
wchar_t * wchar_t *wcsncat(wchar_t *dest, const wchar_t *src, size_t count)
wcsncat(wchar_t *dest, const wchar_t *src, size_t count)
{ {
int i, j; int i, j;
@ -286,3 +284,5 @@ wchar_t *wcsstr(const wchar_t *s,const wchar_t *b)
} }
return NULL; return NULL;
} }
/* EOF */

View file

@ -31,7 +31,7 @@ int _wcsicmp (const wchar_t* cs, const wchar_t* ct)
return *cs - *ct; return *cs - *ct;
} }
wchar_t * _wcslwr (wchar_t *x) wchar_t *_wcslwr (wchar_t *x)
{ {
wchar_t *y=x; wchar_t *y=x;
@ -46,19 +46,19 @@ wchar_t * _wcslwr (wchar_t *x)
int _wcsnicmp (const wchar_t * cs,const wchar_t * ct,size_t count) int _wcsnicmp (const wchar_t * cs,const wchar_t * ct,size_t count)
{ {
wchar_t *save = (wchar_t *)cs; if (count == 0)
while (towlower(*cs) == towlower(*ct) && (int)(cs - save) < count) return 0;
{ do {
if (*cs == 0) if (towupper(*cs) != towupper(*ct++))
return towupper(*cs) - towupper(*--ct);
if (*cs++ == 0)
break;
} while (--count != 0);
return 0; return 0;
cs++;
ct++;
}
return towlower(*cs) - towlower(*ct);
} }
wchar_t* _wcsnset (wchar_t* wsToFill, wchar_t wcFill, size_t sizeMaxFill) wchar_t *_wcsnset (wchar_t* wsToFill, wchar_t wcFill, size_t sizeMaxFill)
{ {
wchar_t *t = wsToFill; wchar_t *t = wsToFill;
int i = 0; int i = 0;
@ -72,7 +72,7 @@ wchar_t* _wcsnset (wchar_t* wsToFill, wchar_t wcFill, size_t sizeMaxFill)
} }
wchar_t * _wcsrev(wchar_t *s) wchar_t *_wcsrev(wchar_t *s)
{ {
wchar_t *e; wchar_t *e;
wchar_t a; wchar_t a;
@ -235,8 +235,7 @@ int wcsncmp(const wchar_t *cs, const wchar_t *ct, size_t count)
} }
wchar_t * wchar_t *wcsncpy(wchar_t *dest, const wchar_t *src, size_t count)
wcsncpy(wchar_t *dest, const wchar_t *src, size_t count)
{ {
int i; int i;
@ -254,7 +253,7 @@ wcsncpy(wchar_t *dest, const wchar_t *src, size_t count)
} }
wchar_t * wcsrchr(const wchar_t *str, wchar_t ch) wchar_t *wcsrchr(const wchar_t *str, wchar_t ch)
{ {
unsigned int len = 0; unsigned int len = 0;
while (str[len] != ((wchar_t)0)) while (str[len] != ((wchar_t)0))