Process and thread id now use the server-side id instead of an
[wine/multimedia.git] / memory / string.c
blob700db59ad5720f0bf12ab14a7d261c43fd0c67b4
1 /*
2 * String functions
4 * Copyright 1993 Yngvi Sigurjonsson
5 * Copyright 1996 Alexandre Julliard
6 */
8 #include <ctype.h>
9 #include <string.h>
10 #include "winbase.h"
11 #include "winuser.h"
12 #include "winerror.h"
13 #include "ldt.h"
14 #include "debug.h"
15 #include "winnls.h"
17 static const BYTE STRING_Oem2Ansi[256] =
18 "\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\244"
19 "\020\021\022\023\266\247\026\027\030\031\032\033\034\035\036\037"
20 "\040\041\042\043\044\045\046\047\050\051\052\053\054\055\056\057"
21 "\060\061\062\063\064\065\066\067\070\071\072\073\074\075\076\077"
22 "\100\101\102\103\104\105\106\107\110\111\112\113\114\115\116\117"
23 "\120\121\122\123\124\125\126\127\130\131\132\133\134\135\136\137"
24 "\140\141\142\143\144\145\146\147\150\151\152\153\154\155\156\157"
25 "\160\161\162\163\164\165\166\167\170\171\172\173\174\175\176\177"
26 "\307\374\351\342\344\340\345\347\352\353\350\357\356\354\304\305"
27 "\311\346\306\364\366\362\373\371\377\326\334\242\243\245\120\203"
28 "\341\355\363\372\361\321\252\272\277\137\254\275\274\241\253\273"
29 "\137\137\137\246\246\246\246\053\053\246\246\053\053\053\053\053"
30 "\053\055\055\053\055\053\246\246\053\053\055\055\246\055\053\055"
31 "\055\055\055\053\053\053\053\053\053\053\053\137\137\246\137\137"
32 "\137\337\137\266\137\137\265\137\137\137\137\137\137\137\137\137"
33 "\137\261\137\137\137\137\367\137\260\225\267\137\156\262\137\137";
35 static const BYTE STRING_Ansi2Oem[256] =
36 "\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017"
37 "\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037"
38 "\040\041\042\043\044\045\046\047\050\051\052\053\054\055\056\057"
39 "\060\061\062\063\064\065\066\067\070\071\072\073\074\075\076\077"
40 "\100\101\102\103\104\105\106\107\110\111\112\113\114\115\116\117"
41 "\120\121\122\123\124\125\126\127\130\131\132\133\134\135\136\137"
42 "\140\141\142\143\144\145\146\147\150\151\152\153\154\155\156\157"
43 "\160\161\162\163\164\165\166\167\170\171\172\173\174\175\176\177"
44 "\200\201\054\237\054\137\375\374\210\045\123\074\117\215\216\217"
45 "\220\140\047\042\042\371\055\137\230\231\163\076\157\235\236\131"
46 "\040\255\233\234\017\235\335\025\042\143\246\256\252\055\162\137"
47 "\370\361\375\063\047\346\024\372\054\061\247\257\254\253\137\250"
48 "\101\101\101\101\216\217\222\200\105\220\105\105\111\111\111\111"
49 "\104\245\117\117\117\117\231\170\117\125\125\125\232\131\137\341"
50 "\205\240\203\141\204\206\221\207\212\202\210\211\215\241\214\213"
51 "\144\244\225\242\223\157\224\366\157\227\243\226\201\171\137\230";
53 #define OEM_TO_ANSI(ch) (STRING_Oem2Ansi[(unsigned char)(ch)])
54 #define ANSI_TO_OEM(ch) (STRING_Ansi2Oem[(unsigned char)(ch)])
56 /* Internaly used by strchr family functions */
57 static BOOL ChrCmpA( WORD word1, WORD word2);
58 static BOOL ChrCmpW( WORD word1, WORD word2);
60 extern LPWSTR __cdecl CRTDLL_wcschr(LPCWSTR str,WCHAR xchar);
63 /***********************************************************************
64 * hmemcpy (KERNEL.348)
66 void WINAPI hmemcpy16( LPVOID dst, LPCVOID src, LONG count )
68 memcpy( dst, src, count );
72 /***********************************************************************
73 * lstrcat16 (KERNEL.89)
75 SEGPTR WINAPI lstrcat16( SEGPTR dst, LPCSTR src )
77 lstrcatA( (LPSTR)PTR_SEG_TO_LIN(dst), src );
78 return dst;
82 /***********************************************************************
83 * lstrcat32A (KERNEL32.599)
85 LPSTR WINAPI lstrcatA( LPSTR dst, LPCSTR src )
87 TRACE(string,"Append %s to %s\n",
88 debugstr_a (src), debugstr_a (dst));
89 /* Windows does not check for NULL pointers here, so we don't either */
90 strcat( dst, src );
91 return dst;
95 /***********************************************************************
96 * lstrcat32W (KERNEL32.600)
98 LPWSTR WINAPI lstrcatW( LPWSTR dst, LPCWSTR src )
100 register LPWSTR p = dst;
101 TRACE(string,"Append L%s to L%s\n",
102 debugstr_w (src), debugstr_w (dst));
103 /* Windows does not check for NULL pointers here, so we don't either */
104 while (*p) p++;
105 while ((*p++ = *src++));
106 return dst;
110 /***********************************************************************
111 * lstrcatn16 (KERNEL.352)
113 SEGPTR WINAPI lstrcatn16( SEGPTR dst, LPCSTR src, INT16 n )
115 lstrcatnA( (LPSTR)PTR_SEG_TO_LIN(dst), src, n );
116 return dst;
120 /***********************************************************************
121 * lstrcatn32A (Not a Windows API)
123 LPSTR WINAPI lstrcatnA( LPSTR dst, LPCSTR src, INT n )
125 register LPSTR p = dst;
126 TRACE(string,"strcatn add %d chars from %s to %s\n",
127 n, debugstr_an (src, n), debugstr_a (dst));
128 while (*p) p++;
129 if ((n -= (INT)(p - dst)) <= 0) return dst;
130 lstrcpynA( p, src, n );
131 return dst;
135 /***********************************************************************
136 * lstrcatn32W (Not a Windows API)
138 LPWSTR WINAPI lstrcatnW( LPWSTR dst, LPCWSTR src, INT n )
140 register LPWSTR p = dst;
141 TRACE(string,"strcatn add %d chars from L%s to L%s\n",
142 n, debugstr_wn (src, n), debugstr_w (dst));
143 while (*p) p++;
144 if ((n -= (INT)(p - dst)) <= 0) return dst;
145 lstrcpynW( p, src, n );
146 return dst;
150 /***********************************************************************
151 * lstrcmp16 (USER.430)
153 INT16 WINAPI lstrcmp16( LPCSTR str1, LPCSTR str2 )
155 return (INT16)strcmp( str1, str2 );
159 /***********************************************************************
160 * lstrcmp32A (KERNEL.602)
162 INT WINAPI lstrcmpA( LPCSTR str1, LPCSTR str2 )
164 return CompareStringA(LOCALE_SYSTEM_DEFAULT,0,str1,-1,str2,-1) - 2 ;
168 /***********************************************************************
169 * lstrcmp32W (KERNEL.603)
170 * FIXME : should call CompareString32W, when it is implemented.
171 * This implementation is not "word sort", as it should.
173 INT WINAPI lstrcmpW( LPCWSTR str1, LPCWSTR str2 )
175 TRACE(string,"L%s and L%s\n",
176 debugstr_w (str1), debugstr_w (str2));
177 if (!str1 || !str2) {
178 SetLastError(ERROR_INVALID_PARAMETER);
179 return 0;
181 while (*str1 && (*str1 == *str2)) { str1++; str2++; }
182 return (INT)(*str1 - *str2);
186 /***********************************************************************
187 * lstrcmpi16 (USER.471)
189 INT16 WINAPI lstrcmpi16( LPCSTR str1, LPCSTR str2 )
191 return (INT16)lstrcmpiA( str1, str2 );
195 /***********************************************************************
196 * lstrcmpi32A (KERNEL32.605)
198 INT WINAPI lstrcmpiA( LPCSTR str1, LPCSTR str2 )
199 { TRACE(string,"strcmpi %s and %s\n",
200 debugstr_a (str1), debugstr_a (str2));
201 return CompareStringA(LOCALE_SYSTEM_DEFAULT,NORM_IGNORECASE,str1,-1,str2,-1)-2;
205 /***********************************************************************
206 * lstrcmpi32W (KERNEL32.606)
208 INT WINAPI lstrcmpiW( LPCWSTR str1, LPCWSTR str2 )
210 INT res;
212 #if 0
213 /* Too much! (From registry loading.) */
214 TRACE(string,"strcmpi L%s and L%s\n",
215 debugstr_w (str1), debugstr_w (str2));
216 #endif
217 if (!str1 || !str2) {
218 SetLastError(ERROR_INVALID_PARAMETER);
219 return 0;
221 while (*str1)
223 if ((*str1<0x100 ) && (*str2<0x100)) {
224 if ((res = toupper(*str1) - toupper(*str2)) != 0) return res;
225 } else {
226 if ((res = towupper(*str1) - towupper(*str2)) != 0) return res;
228 str1++;
229 str2++;
231 return towupper(*str1) - towupper(*str2);
235 /***********************************************************************
236 * lstrcpy16 (KERNEL.88)
238 SEGPTR WINAPI lstrcpy16( SEGPTR dst, LPCSTR src )
240 lstrcpyA( (LPSTR)PTR_SEG_TO_LIN(dst), src );
241 return dst;
245 /***********************************************************************
246 * lstrcpy32A (KERNEL32.608)
248 LPSTR WINAPI lstrcpyA( LPSTR dst, LPCSTR src )
250 TRACE(string,"strcpy %s\n", debugstr_a (src));
251 /* In real windows the whole function is protected by an exception handler
252 * that returns ERROR_INVALID_PARAMETER on faulty parameters
253 * We currently just check for NULL.
255 if (!dst || !src) {
256 SetLastError(ERROR_INVALID_PARAMETER);
257 return 0;
259 strcpy( dst, src );
260 return dst;
264 /***********************************************************************
265 * lstrcpy32W (KERNEL32.609)
267 LPWSTR WINAPI lstrcpyW( LPWSTR dst, LPCWSTR src )
269 register LPWSTR p = dst;
270 TRACE(string,"strcpy L%s\n", debugstr_w (src));
271 /* In real windows the whole function is protected by an exception handler
272 * that returns ERROR_INVALID_PARAMETER on faulty parameters
273 * We currently just check for NULL.
275 if (!dst || !src) {
276 SetLastError(ERROR_INVALID_PARAMETER);
277 return 0;
279 while ((*p++ = *src++));
280 return dst;
284 /***********************************************************************
285 * lstrcpyn16 (KERNEL.353)
287 SEGPTR WINAPI lstrcpyn16( SEGPTR dst, LPCSTR src, INT16 n )
289 lstrcpynA( (LPSTR)PTR_SEG_TO_LIN(dst), src, n );
290 return dst;
294 /***********************************************************************
295 * lstrcpyn32A (KERNEL32.611)
296 * Note: this function differs from the UNIX strncpy, it _always_ writes
297 * a terminating \0
299 LPSTR WINAPI lstrcpynA( LPSTR dst, LPCSTR src, INT n )
301 LPSTR p = dst;
302 TRACE(string,"strcpyn %s for %d chars\n",
303 debugstr_an (src,n), n);
304 /* In real windows the whole function is protected by an exception handler
305 * that returns ERROR_INVALID_PARAMETER on faulty parameters
306 * We currently just check for NULL.
308 if (!dst || !src) {
309 SetLastError(ERROR_INVALID_PARAMETER);
310 return 0;
312 while ((n-- > 1) && *src) *p++ = *src++;
313 if (n >= 0) *p = 0;
314 return dst;
318 /***********************************************************************
319 * lstrcpyn32W (KERNEL32.612)
320 * Note: this function differs from the UNIX strncpy, it _always_ writes
321 * a terminating \0
323 LPWSTR WINAPI lstrcpynW( LPWSTR dst, LPCWSTR src, INT n )
325 LPWSTR p = dst;
326 TRACE(string,"strcpyn L%s for %d chars\n",
327 debugstr_wn (src,n), n);
328 /* In real windows the whole function is protected by an exception handler
329 * that returns ERROR_INVALID_PARAMETER on faulty parameters
330 * We currently just check for NULL.
332 if (!dst || !src) {
333 SetLastError(ERROR_INVALID_PARAMETER);
334 return 0;
336 while ((n-- > 1) && *src) *p++ = *src++;
337 if (n >= 0) *p = 0;
338 return dst;
342 /***********************************************************************
343 * lstrlen16 (KERNEL.90)
345 INT16 WINAPI lstrlen16( LPCSTR str )
347 return (INT16)lstrlenA( str );
351 /***********************************************************************
352 * lstrlen32A (KERNEL32.614)
354 INT WINAPI lstrlenA( LPCSTR str )
356 /* looks weird, but win3.1 KERNEL got a GeneralProtection handler
357 * in lstrlen() ... we check only for NULL pointer reference.
358 * - Marcus Meissner
360 TRACE(string,"strlen %s\n", debugstr_a (str));
361 if (!str) return 0;
362 return (INT)strlen(str);
366 /***********************************************************************
367 * lstrlen32W (KERNEL32.615)
369 INT WINAPI lstrlenW( LPCWSTR str )
371 INT len = 0;
372 TRACE(string,"strlen L%s\n", debugstr_w (str));
373 if (!str) return 0;
374 while (*str++) len++;
375 return len;
379 /***********************************************************************
380 * lstrncmp32A (Not a Windows API)
382 INT WINAPI lstrncmpA( LPCSTR str1, LPCSTR str2, INT n )
384 TRACE(string,"strncmp %s and %s for %d chars\n",
385 debugstr_an (str1, n), debugstr_an (str2, n), n);
386 return (INT)strncmp( str1, str2, n );
390 /***********************************************************************
391 * lstrncmp32W (Not a Windows API)
393 INT WINAPI lstrncmpW( LPCWSTR str1, LPCWSTR str2, INT n )
395 TRACE(string,"strncmp L%s and L%s for %d chars\n",
396 debugstr_wn (str1, n), debugstr_wn (str2, n), n);
397 if (!n) return 0;
398 while ((--n > 0) && *str1 && (*str1 == *str2)) { str1++; str2++; }
399 return (INT)(*str1 - *str2);
403 /***********************************************************************
404 * lstrncmpi32A (Not a Windows API)
406 INT WINAPI lstrncmpiA( LPCSTR str1, LPCSTR str2, INT n )
408 INT res;
410 TRACE(string,"strncmpi %s and %s for %d chars\n",
411 debugstr_an (str1, n), debugstr_an (str2, n), n);
412 if (!n) return 0;
413 while ((--n > 0) && *str1)
414 if ( (res = toupper(*str1++) - toupper(*str2++)) ) return res;
416 return toupper(*str1) - toupper(*str2);
420 /***********************************************************************
421 * lstrncmpi32W (Not a Windows API)
423 INT WINAPI lstrncmpiW( LPCWSTR str1, LPCWSTR str2, INT n )
425 INT res;
427 TRACE(string,"strncmpi L%s and L%s for %d chars\n",
428 debugstr_wn (str1, n), debugstr_wn (str2, n), n);
429 if (!n) return 0;
430 while ((--n > 0) && *str1)
432 if ((res = towupper(*str1) - towupper(*str2)) != 0) return res;
433 str1++;
434 str2++;
436 return towupper(*str1) - towupper(*str2);
440 /***********************************************************************
441 * lstrcpyAtoW (Not a Windows API)
443 LPWSTR WINAPI lstrcpyAtoW( LPWSTR dst, LPCSTR src )
445 register LPWSTR p = dst;
447 TRACE(string,"%s\n",src);
449 while ((*p++ = (WCHAR)(unsigned char)*src++));
450 return dst;
454 /***********************************************************************
455 * lstrcpyWtoA (Not a Windows API)
457 LPSTR WINAPI lstrcpyWtoA( LPSTR dst, LPCWSTR src )
459 register LPSTR p = dst;
461 TRACE(string,"L%s\n",debugstr_w(src));
463 while ((*p++ = (CHAR)*src++));
464 return dst;
468 /***********************************************************************
469 * lstrcpynAtoW (Not a Windows API)
470 * Note: this function differs from the UNIX strncpy, it _always_ writes
471 * a terminating \0
473 LPWSTR WINAPI lstrcpynAtoW( LPWSTR dst, LPCSTR src, INT n )
475 LPWSTR p = dst;
477 TRACE(string,"%s %i\n",src, n);
479 while ((n-- > 1) && *src) *p++ = (WCHAR)(unsigned char)*src++;
480 if (n >= 0) *p = 0;
481 return dst;
485 /***********************************************************************
486 * lstrcpynWtoA (Not a Windows API)
487 * Note: this function differs from the UNIX strncpy, it _always_ writes
488 * a terminating \0
490 LPSTR WINAPI lstrcpynWtoA( LPSTR dst, LPCWSTR src, INT n )
492 LPSTR p = dst;
494 TRACE(string,"L%s %i\n",debugstr_w(src), n);
496 while ((n-- > 1) && *src) *p++ = (CHAR)*src++;
497 if (n >= 0) *p = 0;
498 return dst;
501 /***********************************************************************
502 * UnicodeToAnsi (KERNEL.434)
504 INT16 WINAPI UnicodeToAnsi16( LPCWSTR src, LPSTR dst, INT16 codepage )
506 if ( codepage != -1 )
507 FIXME( string, "codepage %d not supported\n", codepage );
509 lstrcpyWtoA( dst, src );
511 return (INT16)lstrlenA( dst );
515 /***********************************************************************
516 * Copy (GDI.250)
518 void WINAPI Copy16( LPVOID src, LPVOID dst, WORD size )
520 memcpy( dst, src, size );
524 /***********************************************************************
525 * RtlFillMemory (KERNEL32.441)
527 VOID WINAPI RtlFillMemory( LPVOID ptr, UINT len, UINT fill )
529 memset( ptr, fill, len );
533 /***********************************************************************
534 * RtlMoveMemory (KERNEL32.442)
536 VOID WINAPI RtlMoveMemory( LPVOID dst, LPCVOID src, UINT len )
538 memmove( dst, src, len );
542 /***********************************************************************
543 * RtlZeroMemory (KERNEL32.444)
545 VOID WINAPI RtlZeroMemory( LPVOID ptr, UINT len )
547 memset( ptr, 0, len );
551 /***********************************************************************
552 * AnsiToOem16 (KEYBOARD.5)
554 INT16 WINAPI AnsiToOem16( LPCSTR s, LPSTR d )
556 CharToOemA( s, d );
557 return -1;
561 /***********************************************************************
562 * OemToAnsi16 (KEYBOARD.6)
564 INT16 WINAPI OemToAnsi16( LPCSTR s, LPSTR d )
566 OemToCharA( s, d );
567 return -1;
571 /***********************************************************************
572 * AnsiToOemBuff16 (KEYBOARD.134)
574 void WINAPI AnsiToOemBuff16( LPCSTR s, LPSTR d, UINT16 len )
576 CharToOemBuffA( s, d, len ? len : 65536 );
580 /***********************************************************************
581 * OemToAnsiBuff16 (KEYBOARD.135)
583 void WINAPI OemToAnsiBuff16( LPCSTR s, LPSTR d, UINT16 len )
585 OemToCharBuffA( s, d, len ? len : 65536 );
589 /***********************************************************************
590 * CharToOem32A (USER32.37)
592 BOOL WINAPI CharToOemA( LPCSTR s, LPSTR d )
594 LPSTR oldd = d;
595 if (!s || !d) return TRUE;
596 TRACE(string,"CharToOem %s\n", debugstr_a (s));
597 while ((*d++ = ANSI_TO_OEM(*s++)));
598 TRACE(string," to %s\n", debugstr_a (oldd));
599 return TRUE;
603 /***********************************************************************
604 * CharToOemBuff32A (USER32.38)
606 BOOL WINAPI CharToOemBuffA( LPCSTR s, LPSTR d, DWORD len )
608 while (len--) *d++ = ANSI_TO_OEM(*s++);
609 return TRUE;
613 /***********************************************************************
614 * CharToOemBuff32W (USER32.39)
616 BOOL WINAPI CharToOemBuffW( LPCWSTR s, LPSTR d, DWORD len )
618 while (len--) *d++ = ANSI_TO_OEM(*s++);
619 return TRUE;
623 /***********************************************************************
624 * CharToOem32W (USER32.40)
626 BOOL WINAPI CharToOemW( LPCWSTR s, LPSTR d )
628 LPSTR oldd = d;
629 if (!s || !d) return TRUE;
630 TRACE(string,"CharToOem L%s\n", debugstr_w (s));
631 while ((*d++ = ANSI_TO_OEM(*s++)));
632 TRACE(string," to %s\n", debugstr_a (oldd));
633 return TRUE;
637 /***********************************************************************
638 * OemToChar32A (USER32.402)
640 BOOL WINAPI OemToCharA( LPCSTR s, LPSTR d )
642 LPSTR oldd = d;
643 TRACE(string,"OemToChar %s\n", debugstr_a (s));
644 while ((*d++ = OEM_TO_ANSI(*s++)));
645 TRACE(string," to %s\n", debugstr_a (oldd));
646 return TRUE;
650 /***********************************************************************
651 * OemToCharBuff32A (USER32.403)
653 BOOL WINAPI OemToCharBuffA( LPCSTR s, LPSTR d, DWORD len )
655 TRACE(string,"OemToCharBuff %s\n", debugstr_an (s, len));
656 while (len--) *d++ = OEM_TO_ANSI(*s++);
657 return TRUE;
661 /***********************************************************************
662 * OemToCharBuff32W (USER32.404)
664 BOOL WINAPI OemToCharBuffW( LPCSTR s, LPWSTR d, DWORD len )
666 TRACE(string,"OemToCharBuff %s\n", debugstr_an (s, len));
667 while (len--) *d++ = (WCHAR)OEM_TO_ANSI(*s++);
668 return TRUE;
672 /***********************************************************************
673 * OemToChar32W (USER32.405)
675 BOOL WINAPI OemToCharW( LPCSTR s, LPWSTR d )
677 while ((*d++ = (WCHAR)OEM_TO_ANSI(*s++)));
678 return TRUE;
681 /***********************************************************************
682 * WideCharToLocal (Not a Windows API)
683 * similar lstrcpyWtoA, should handle codepages properly
685 * RETURNS
686 * strlen of the destination string
689 INT WINAPI WideCharToLocal(
690 LPSTR pLocal,
691 LPWSTR pWide,
692 INT dwChars)
693 { *pLocal = 0;
694 TRACE(string,"(%p, %s, %i)\n", pLocal, debugstr_w(pWide),dwChars);
695 WideCharToMultiByte(CP_ACP,0,pWide,-1,pLocal,dwChars,NULL,NULL);
696 return strlen(pLocal);
698 /***********************************************************************
699 * LocalToWideChar (Not a Windows API)
700 * similar lstrcpyAtoW, should handle codepages properly
702 * RETURNS
703 * strlen of the destination string
705 INT WINAPI LocalToWideChar(
706 LPWSTR pWide,
707 LPSTR pLocal,
708 INT dwChars)
709 { *pWide = 0;
710 TRACE(string,"(%p, %s, %i)\n",pWide, pLocal, dwChars);
711 MultiByteToWideChar(CP_ACP,0,pLocal,-1,pWide,dwChars);
712 return lstrlenW(pWide);
716 /***********************************************************************
717 * lstrrchr (Not a Windows API)
719 * This is the implementation meant to be invoked form within
720 * COMCTL32_StrRChrA and shell32(TODO)...
722 * Return a pointer to the last occurence of wMatch in lpStart
723 * not looking further than lpEnd...
725 LPSTR WINAPI lstrrchr( LPCSTR lpStart, LPCSTR lpEnd, WORD wMatch )
727 LPCSTR lpGotIt = NULL;
729 TRACE(string,"(%s, %s)\n", lpStart, lpEnd);
731 if (!lpEnd) lpEnd = lpStart + strlen(lpStart);
733 for(; lpStart < lpEnd; lpStart = CharNextA(lpStart))
734 if (!ChrCmpA( GET_WORD(lpStart), wMatch))
735 lpGotIt = lpStart;
737 return ((LPSTR)lpGotIt);
740 /***********************************************************************
741 * lstrrchrw (Not a Windows API)
743 * This is the implementation meant to be invoked form within
744 * COMCTL32_StrRChrW and shell32(TODO)...
746 * Return a pointer to the last occurence of wMatch in lpStart
747 * not looking further than lpEnd...
749 LPWSTR WINAPI lstrrchrw( LPCWSTR lpStart, LPCWSTR lpEnd, WORD wMatch )
751 LPCWSTR lpGotIt = NULL;
753 TRACE(string,"(%p, %p, %c)\n", lpStart, lpEnd, wMatch);
754 if (!lpEnd) lpEnd = lpStart + lstrlenW(lpStart);
756 for(; lpStart < lpEnd; lpStart = CharNextW(lpStart))
757 if (!ChrCmpW( GET_WORD(lpStart), wMatch))
758 lpGotIt = lpStart;
760 return (LPWSTR)lpGotIt;
763 /***********************************************************************
764 * strstrw (Not a Windows API)
766 * This is the implementation meant to be invoked form within
767 * COMCTL32_StrStrW and shell32(TODO)...
770 LPWSTR WINAPI strstrw( LPCWSTR lpFirst, LPCWSTR lpSrch) {
771 UINT uSrchLen = (UINT)lstrlenW(lpSrch);
772 WORD wMatchBeg = *(WORD*)lpSrch;
774 TRACE(string,"(%p, %p)\n", lpFirst, lpSrch);
776 for(;
777 ((lpFirst=CRTDLL_wcschr(lpFirst, wMatchBeg))!=0) &&
778 lstrncmpW(lpFirst, lpSrch, uSrchLen);
779 lpFirst++) {
780 continue;
782 return (LPWSTR)lpFirst;
786 /***********************************************************************
787 * ChrCmpA
788 * This fuction returns FALSE if both words match, TRUE otherwise...
790 static BOOL ChrCmpA( WORD word1, WORD word2) {
791 if (LOBYTE(word1) == LOBYTE(word2)) {
792 if (IsDBCSLeadByte(LOBYTE(word1))) {
793 return (word1 != word2);
795 return FALSE;
797 return TRUE;
800 /***********************************************************************
801 * ChrCmpW
802 * This fuction returns FALSE if both words match, TRUE otherwise...
804 static BOOL ChrCmpW( WORD word1, WORD word2) {
805 return (word1 != word2);