2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * FILE: ntoskrnl/rtl/wstring.c
5 * PURPOSE: Wide string functions
6 * PROGRAMMER: David Welch (welch@cwcom.net)
9 * 1998/12/04 RJJ Cleaned up and added i386 def checks.
10 * 1999/07/29 ekohl Added missing functions.
13 /* INCLUDES *****************************************************************/
15 #include <ddk/ntddk.h>
18 #include <internal/debug.h>
20 /* FUNCTIONS *****************************************************************/
22 int _wcsicmp (const wchar_t* cs, const wchar_t* ct)
24 while (*cs != '\0' && *ct != '\0' && towupper(*cs) == towupper(*ct))
34 wchar_t *_wcslwr (wchar_t *x)
47 int _wcsnicmp (const wchar_t * cs,const wchar_t * ct,size_t count)
52 if (towupper(*cs) != towupper(*ct++))
53 return towupper(*cs) - towupper(*--ct);
56 } while (--count != 0);
61 wchar_t *_wcsnset (wchar_t* wsToFill, wchar_t wcFill, size_t sizeMaxFill)
63 wchar_t *t = wsToFill;
65 while( *wsToFill != 0 && i < sizeMaxFill)
75 wchar_t *_wcsrev(wchar_t *s)
94 wchar_t *_wcsupr(wchar_t *x)
106 #endif /* LIBCAPTIVE */
108 wchar_t * wcscat(wchar_t *dest, const wchar_t *src)
112 for (j = 0; dest[j] != 0; j++)
114 for (i = 0; src[i] != 0; i++)
116 dest[j + i] = src[i];
123 wchar_t * wcschr(const wchar_t *str, wchar_t ch)
125 while ((*str) != ((wchar_t) 0))
129 return (wchar_t *) str;
137 int wcscmp(const wchar_t *cs, const wchar_t *ct)
139 while (*cs != '\0' && *ct != '\0' && *cs == *ct)
147 wchar_t* wcscpy(wchar_t* str1, const wchar_t* str2)
150 /* Never dump 'str1' here as it can crash due to unitialized memory access (no end-terminator). */
151 DPRINT("wcscpy(str1 <undef>, str2 %S)\n",str2);
164 size_t wcscspn(const wchar_t *str,const wchar_t *reject)
180 return s-str; /* nr of wchars */
183 #endif /* LIBCAPTIVE */
185 size_t wcslen(const wchar_t *s)
187 unsigned int len = 0;
199 wchar_t * wcsncat(wchar_t *dest, const wchar_t *src, size_t count)
203 for (j = 0; dest[j] != 0; j++)
205 for (i = 0; i < count; i++)
207 dest[j + i] = src[i];
219 int wcsncmp(const wchar_t *cs, const wchar_t *ct, size_t count)
221 while (*cs != '\0' && *ct != '\0' && *cs == *ct && --count)
230 wchar_t *wcsncpy(wchar_t *dest, const wchar_t *src, size_t count)
234 for (i = 0; i < count; i++)
247 #endif /* LIBCAPTIVE */
249 wchar_t *wcsrchr(const wchar_t *str, wchar_t ch)
251 unsigned int len = 0;
252 while (str[len] != ((wchar_t)0))
257 for (; len > 0; len--)
261 return (wchar_t *) &str[len - 1];
270 size_t wcsspn(const wchar_t *str,const wchar_t *accept)
288 return s-str; /* nr of wchars */
292 wchar_t *wcsstr(const wchar_t *s,const wchar_t *b)
304 while (*y && *c && *y==*c)
317 #endif /* LIBCAPTIVE */