Changes in X11DRV_KEYBOARD_DetectLayout in order to implement Russian
[wine/multimedia.git] / memory / string.c
blobf59950f734449f036ed3e4a8f1bad3d403430ead
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 "wine/winbase16.h"
11 #include "wine/winuser16.h"
12 #include "wine/keyboard16.h"
13 #include "winerror.h"
14 #include "ldt.h"
15 #include "debug.h"
16 #include "winnls.h"
18 static const BYTE STRING_Oem2Ansi[256] =
19 "\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\244"
20 "\020\021\022\023\266\247\026\027\030\031\032\033\034\035\036\037"
21 "\040\041\042\043\044\045\046\047\050\051\052\053\054\055\056\057"
22 "\060\061\062\063\064\065\066\067\070\071\072\073\074\075\076\077"
23 "\100\101\102\103\104\105\106\107\110\111\112\113\114\115\116\117"
24 "\120\121\122\123\124\125\126\127\130\131\132\133\134\135\136\137"
25 "\140\141\142\143\144\145\146\147\150\151\152\153\154\155\156\157"
26 "\160\161\162\163\164\165\166\167\170\171\172\173\174\175\176\177"
27 "\307\374\351\342\344\340\345\347\352\353\350\357\356\354\304\305"
28 "\311\346\306\364\366\362\373\371\377\326\334\242\243\245\120\203"
29 "\341\355\363\372\361\321\252\272\277\137\254\275\274\241\253\273"
30 "\137\137\137\246\246\246\246\053\053\246\246\053\053\053\053\053"
31 "\053\055\055\053\055\053\246\246\053\053\055\055\246\055\053\055"
32 "\055\055\055\053\053\053\053\053\053\053\053\137\137\246\137\137"
33 "\137\337\137\266\137\137\265\137\137\137\137\137\137\137\137\137"
34 "\137\261\137\137\137\137\367\137\260\225\267\137\156\262\137\137";
36 static const BYTE STRING_Ansi2Oem[256] =
37 "\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017"
38 "\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037"
39 "\040\041\042\043\044\045\046\047\050\051\052\053\054\055\056\057"
40 "\060\061\062\063\064\065\066\067\070\071\072\073\074\075\076\077"
41 "\100\101\102\103\104\105\106\107\110\111\112\113\114\115\116\117"
42 "\120\121\122\123\124\125\126\127\130\131\132\133\134\135\136\137"
43 "\140\141\142\143\144\145\146\147\150\151\152\153\154\155\156\157"
44 "\160\161\162\163\164\165\166\167\170\171\172\173\174\175\176\177"
45 "\200\201\054\237\054\137\375\374\210\045\123\074\117\215\216\217"
46 "\220\140\047\042\042\371\055\137\230\231\163\076\157\235\236\131"
47 "\040\255\233\234\017\235\335\025\042\143\246\256\252\055\162\137"
48 "\370\361\375\063\047\346\024\372\054\061\247\257\254\253\137\250"
49 "\101\101\101\101\216\217\222\200\105\220\105\105\111\111\111\111"
50 "\104\245\117\117\117\117\231\170\117\125\125\125\232\131\137\341"
51 "\205\240\203\141\204\206\221\207\212\202\210\211\215\241\214\213"
52 "\144\244\225\242\223\157\224\366\157\227\243\226\201\171\137\230";
54 #define OEM_TO_ANSI(ch) (STRING_Oem2Ansi[(unsigned char)(ch)])
55 #define ANSI_TO_OEM(ch) (STRING_Ansi2Oem[(unsigned char)(ch)])
57 /* Internaly used by strchr family functions */
58 static BOOL ChrCmpA( WORD word1, WORD word2);
59 static BOOL ChrCmpW( WORD word1, WORD word2);
61 extern LPWSTR __cdecl CRTDLL_wcschr(LPCWSTR str,WCHAR xchar);
64 /***********************************************************************
65 * hmemcpy (KERNEL.348)
67 void WINAPI hmemcpy16( LPVOID dst, LPCVOID src, LONG count )
69 memcpy( dst, src, count );
73 /***********************************************************************
74 * lstrcat16 (KERNEL.89)
76 SEGPTR WINAPI lstrcat16( SEGPTR dst, LPCSTR src )
78 lstrcatA( (LPSTR)PTR_SEG_TO_LIN(dst), src );
79 return dst;
83 /***********************************************************************
84 * lstrcat32A (KERNEL32.599)
86 LPSTR WINAPI lstrcatA( LPSTR dst, LPCSTR src )
88 TRACE(string,"Append %s to %s\n",
89 debugstr_a (src), debugstr_a (dst));
90 /* Windows does not check for NULL pointers here, so we don't either */
91 strcat( dst, src );
92 return dst;
96 /***********************************************************************
97 * lstrcat32W (KERNEL32.600)
99 LPWSTR WINAPI lstrcatW( LPWSTR dst, LPCWSTR src )
101 register LPWSTR p = dst;
102 TRACE(string,"Append L%s to L%s\n",
103 debugstr_w (src), debugstr_w (dst));
104 /* Windows does not check for NULL pointers here, so we don't either */
105 while (*p) p++;
106 while ((*p++ = *src++));
107 return dst;
111 /***********************************************************************
112 * lstrcatn16 (KERNEL.352)
114 SEGPTR WINAPI lstrcatn16( SEGPTR dst, LPCSTR src, INT16 n )
116 lstrcatnA( (LPSTR)PTR_SEG_TO_LIN(dst), src, n );
117 return dst;
121 /***********************************************************************
122 * lstrcatn32A (Not a Windows API)
124 LPSTR WINAPI lstrcatnA( LPSTR dst, LPCSTR src, INT n )
126 register LPSTR p = dst;
127 TRACE(string,"strcatn add %d chars from %s to %s\n",
128 n, debugstr_an (src, n), debugstr_a (dst));
129 while (*p) p++;
130 if ((n -= (INT)(p - dst)) <= 0) return dst;
131 lstrcpynA( p, src, n );
132 return dst;
136 /***********************************************************************
137 * lstrcatn32W (Not a Windows API)
139 LPWSTR WINAPI lstrcatnW( LPWSTR dst, LPCWSTR src, INT n )
141 register LPWSTR p = dst;
142 TRACE(string,"strcatn add %d chars from L%s to L%s\n",
143 n, debugstr_wn (src, n), debugstr_w (dst));
144 while (*p) p++;
145 if ((n -= (INT)(p - dst)) <= 0) return dst;
146 lstrcpynW( p, src, n );
147 return dst;
151 /***********************************************************************
152 * lstrcmp16 (USER.430)
154 INT16 WINAPI lstrcmp16( LPCSTR str1, LPCSTR str2 )
156 return (INT16)strcmp( str1, str2 );
160 /***********************************************************************
161 * lstrcmp32A (KERNEL.602)
163 INT WINAPI lstrcmpA( LPCSTR str1, LPCSTR str2 )
165 return CompareStringA(LOCALE_SYSTEM_DEFAULT,0,str1,-1,str2,-1) - 2 ;
169 /***********************************************************************
170 * lstrcmp32W (KERNEL.603)
171 * FIXME : should call CompareString32W, when it is implemented.
172 * This implementation is not "word sort", as it should.
174 INT WINAPI lstrcmpW( LPCWSTR str1, LPCWSTR str2 )
176 TRACE(string,"L%s and L%s\n",
177 debugstr_w (str1), debugstr_w (str2));
178 if (!str1 || !str2) {
179 SetLastError(ERROR_INVALID_PARAMETER);
180 return 0;
182 while (*str1 && (*str1 == *str2)) { str1++; str2++; }
183 return (INT)(*str1 - *str2);
187 /***********************************************************************
188 * lstrcmpi16 (USER.471)
190 INT16 WINAPI lstrcmpi16( LPCSTR str1, LPCSTR str2 )
192 return (INT16)lstrcmpiA( str1, str2 );
196 /***********************************************************************
197 * lstrcmpi32A (KERNEL32.605)
199 INT WINAPI lstrcmpiA( LPCSTR str1, LPCSTR str2 )
200 { TRACE(string,"strcmpi %s and %s\n",
201 debugstr_a (str1), debugstr_a (str2));
202 return CompareStringA(LOCALE_SYSTEM_DEFAULT,NORM_IGNORECASE,str1,-1,str2,-1)-2;
206 /***********************************************************************
207 * lstrcmpi32W (KERNEL32.606)
209 INT WINAPI lstrcmpiW( LPCWSTR str1, LPCWSTR str2 )
211 INT res;
213 #if 0
214 /* Too much! (From registry loading.) */
215 TRACE(string,"strcmpi L%s and L%s\n",
216 debugstr_w (str1), debugstr_w (str2));
217 #endif
218 if (!str1 || !str2) {
219 SetLastError(ERROR_INVALID_PARAMETER);
220 return 0;
222 while (*str1)
224 if ((*str1<0x100 ) && (*str2<0x100)) {
225 if ((res = toupper(*str1) - toupper(*str2)) != 0) return res;
226 } else {
227 if ((res = towupper(*str1) - towupper(*str2)) != 0) return res;
229 str1++;
230 str2++;
232 return towupper(*str1) - towupper(*str2);
236 /***********************************************************************
237 * lstrcpy16 (KERNEL.88)
239 SEGPTR WINAPI lstrcpy16( SEGPTR dst, LPCSTR src )
241 lstrcpyA( (LPSTR)PTR_SEG_TO_LIN(dst), src );
242 return dst;
246 /***********************************************************************
247 * lstrcpyA (KERNEL32.608)
249 LPSTR WINAPI lstrcpyA( LPSTR dst, LPCSTR src )
251 TRACE(string,"strcpy %s\n", debugstr_a (src));
252 /* In real windows the whole function is protected by an exception handler
253 * that returns ERROR_INVALID_PARAMETER on faulty parameters
254 * We currently just check for NULL.
256 if (!dst || !src) {
257 SetLastError(ERROR_INVALID_PARAMETER);
258 return 0;
260 /* this is how Windows does it */
261 memmove( dst, src, strlen(src)+1 );
262 return dst;
266 /***********************************************************************
267 * lstrcpy32W (KERNEL32.609)
269 LPWSTR WINAPI lstrcpyW( LPWSTR dst, LPCWSTR src )
271 register LPWSTR p = dst;
272 TRACE(string,"strcpy L%s\n", debugstr_w (src));
273 /* In real windows the whole function is protected by an exception handler
274 * that returns ERROR_INVALID_PARAMETER on faulty parameters
275 * We currently just check for NULL.
277 if (!dst || !src) {
278 SetLastError(ERROR_INVALID_PARAMETER);
279 return 0;
281 while ((*p++ = *src++));
282 return dst;
286 /***********************************************************************
287 * lstrcpyn16 (KERNEL.353)
289 SEGPTR WINAPI lstrcpyn16( SEGPTR dst, LPCSTR src, INT16 n )
291 lstrcpynA( (LPSTR)PTR_SEG_TO_LIN(dst), src, n );
292 return dst;
296 /***********************************************************************
297 * lstrcpyn32A (KERNEL32.611)
298 * Note: this function differs from the UNIX strncpy, it _always_ writes
299 * a terminating \0
301 LPSTR WINAPI lstrcpynA( LPSTR dst, LPCSTR src, INT n )
303 LPSTR p = dst;
304 TRACE(string,"strcpyn %s for %d chars\n",
305 debugstr_an (src,n), n);
306 /* In real windows the whole function is protected by an exception handler
307 * that returns ERROR_INVALID_PARAMETER on faulty parameters
308 * We currently just check for NULL.
310 if (!dst || !src) {
311 SetLastError(ERROR_INVALID_PARAMETER);
312 return 0;
314 while ((n-- > 1) && *src) *p++ = *src++;
315 if (n >= 0) *p = 0;
316 return dst;
320 /***********************************************************************
321 * lstrcpyn32W (KERNEL32.612)
322 * Note: this function differs from the UNIX strncpy, it _always_ writes
323 * a terminating \0
325 LPWSTR WINAPI lstrcpynW( LPWSTR dst, LPCWSTR src, INT n )
327 LPWSTR p = dst;
328 TRACE(string,"strcpyn L%s for %d chars\n",
329 debugstr_wn (src,n), n);
330 /* In real windows the whole function is protected by an exception handler
331 * that returns ERROR_INVALID_PARAMETER on faulty parameters
332 * We currently just check for NULL.
334 if (!dst || !src) {
335 SetLastError(ERROR_INVALID_PARAMETER);
336 return 0;
338 while ((n-- > 1) && *src) *p++ = *src++;
339 if (n >= 0) *p = 0;
340 return dst;
344 /***********************************************************************
345 * lstrlen16 (KERNEL.90)
347 INT16 WINAPI lstrlen16( LPCSTR str )
349 return (INT16)lstrlenA( str );
353 /***********************************************************************
354 * lstrlen32A (KERNEL32.614)
356 INT WINAPI lstrlenA( LPCSTR str )
358 /* looks weird, but win3.1 KERNEL got a GeneralProtection handler
359 * in lstrlen() ... we check only for NULL pointer reference.
360 * - Marcus Meissner
362 TRACE(string,"strlen %s\n", debugstr_a (str));
363 if (!str) return 0;
364 return (INT)strlen(str);
368 /***********************************************************************
369 * lstrlen32W (KERNEL32.615)
371 INT WINAPI lstrlenW( LPCWSTR str )
373 INT len = 0;
374 TRACE(string,"strlen L%s\n", debugstr_w (str));
375 if (!str) return 0;
376 while (*str++) len++;
377 return len;
381 /***********************************************************************
382 * lstrncmp32A (Not a Windows API)
384 INT WINAPI lstrncmpA( LPCSTR str1, LPCSTR str2, INT n )
386 TRACE(string,"strncmp %s and %s for %d chars\n",
387 debugstr_an (str1, n), debugstr_an (str2, n), n);
388 return (INT)strncmp( str1, str2, n );
392 /***********************************************************************
393 * lstrncmp32W (Not a Windows API)
395 INT WINAPI lstrncmpW( LPCWSTR str1, LPCWSTR str2, INT n )
397 TRACE(string,"strncmp L%s and L%s for %d chars\n",
398 debugstr_wn (str1, n), debugstr_wn (str2, n), n);
399 if (!n) return 0;
400 while ((--n > 0) && *str1 && (*str1 == *str2)) { str1++; str2++; }
401 return (INT)(*str1 - *str2);
405 /***********************************************************************
406 * lstrncmpi32A (Not a Windows API)
408 INT WINAPI lstrncmpiA( LPCSTR str1, LPCSTR str2, INT n )
410 INT res;
412 TRACE(string,"strncmpi %s and %s for %d chars\n",
413 debugstr_an (str1, n), debugstr_an (str2, n), n);
414 if (!n) return 0;
415 while ((--n > 0) && *str1)
416 if ( (res = toupper(*str1++) - toupper(*str2++)) ) return res;
418 return toupper(*str1) - toupper(*str2);
422 /***********************************************************************
423 * lstrncmpi32W (Not a Windows API)
425 INT WINAPI lstrncmpiW( LPCWSTR str1, LPCWSTR str2, INT n )
427 INT res;
429 TRACE(string,"strncmpi L%s and L%s for %d chars\n",
430 debugstr_wn (str1, n), debugstr_wn (str2, n), n);
431 if (!n) return 0;
432 while ((--n > 0) && *str1)
434 if ((res = towupper(*str1) - towupper(*str2)) != 0) return res;
435 str1++;
436 str2++;
438 return towupper(*str1) - towupper(*str2);
442 /***********************************************************************
443 * lstrcpyAtoW (Not a Windows API)
445 LPWSTR WINAPI lstrcpyAtoW( LPWSTR dst, LPCSTR src )
447 register LPWSTR p = dst;
449 TRACE(string,"%s\n",src);
451 while ((*p++ = (WCHAR)(unsigned char)*src++));
452 return dst;
456 /***********************************************************************
457 * lstrcpyWtoA (Not a Windows API)
459 LPSTR WINAPI lstrcpyWtoA( LPSTR dst, LPCWSTR src )
461 register LPSTR p = dst;
463 TRACE(string,"L%s\n",debugstr_w(src));
465 while ((*p++ = (CHAR)*src++));
466 return dst;
470 /***********************************************************************
471 * lstrcpynAtoW (Not a Windows API)
472 * Note: this function differs from the UNIX strncpy, it _always_ writes
473 * a terminating \0
475 LPWSTR WINAPI lstrcpynAtoW( LPWSTR dst, LPCSTR src, INT n )
477 LPWSTR p = dst;
479 TRACE(string,"%s %i\n",src, n);
481 while ((n-- > 1) && *src) *p++ = (WCHAR)(unsigned char)*src++;
482 if (n >= 0) *p = 0;
483 return dst;
487 /***********************************************************************
488 * lstrcpynWtoA (Not a Windows API)
489 * Note: this function differs from the UNIX strncpy, it _always_ writes
490 * a terminating \0
492 LPSTR WINAPI lstrcpynWtoA( LPSTR dst, LPCWSTR src, INT n )
494 LPSTR p = dst;
496 TRACE(string,"L%s %i\n",debugstr_w(src), n);
498 while ((n-- > 1) && *src) *p++ = (CHAR)*src++;
499 if (n >= 0) *p = 0;
500 return dst;
503 /***********************************************************************
504 * UnicodeToAnsi (KERNEL.434)
506 INT16 WINAPI UnicodeToAnsi16( LPCWSTR src, LPSTR dst, INT16 codepage )
508 if ( codepage != -1 )
509 FIXME( string, "codepage %d not supported\n", codepage );
511 lstrcpyWtoA( dst, src );
513 return (INT16)lstrlenA( dst );
517 /***********************************************************************
518 * Copy (GDI.250)
520 void WINAPI Copy16( LPVOID src, LPVOID dst, WORD size )
522 memcpy( dst, src, size );
526 /***********************************************************************
527 * RtlFillMemory (KERNEL32.441)
529 VOID WINAPI RtlFillMemory( LPVOID ptr, UINT len, UINT fill )
531 memset( ptr, fill, len );
535 /***********************************************************************
536 * RtlMoveMemory (KERNEL32.442)
538 VOID WINAPI RtlMoveMemory( LPVOID dst, LPCVOID src, UINT len )
540 memmove( dst, src, len );
544 /***********************************************************************
545 * RtlZeroMemory (KERNEL32.444)
547 VOID WINAPI RtlZeroMemory( LPVOID ptr, UINT len )
549 memset( ptr, 0, len );
553 /***********************************************************************
554 * AnsiToOem16 (KEYBOARD.5)
556 INT16 WINAPI AnsiToOem16( LPCSTR s, LPSTR d )
558 CharToOemA( s, d );
559 return -1;
563 /***********************************************************************
564 * OemToAnsi16 (KEYBOARD.6)
566 INT16 WINAPI OemToAnsi16( LPCSTR s, LPSTR d )
568 OemToCharA( s, d );
569 return -1;
573 /***********************************************************************
574 * AnsiToOemBuff16 (KEYBOARD.134)
576 void WINAPI AnsiToOemBuff16( LPCSTR s, LPSTR d, UINT16 len )
578 if (len != 0) CharToOemBuffA( s, d, len );
582 /***********************************************************************
583 * OemToAnsiBuff16 (KEYBOARD.135)
585 void WINAPI OemToAnsiBuff16( LPCSTR s, LPSTR d, UINT16 len )
587 if (len != 0) OemToCharBuffA( s, d, len );
591 /***********************************************************************
592 * CharToOem32A (USER32.37)
594 BOOL WINAPI CharToOemA( LPCSTR s, LPSTR d )
596 LPSTR oldd = d;
597 if (!s || !d) return TRUE;
598 TRACE(string,"CharToOem %s\n", debugstr_a (s));
599 while ((*d++ = ANSI_TO_OEM(*s++)));
600 TRACE(string," to %s\n", debugstr_a (oldd));
601 return TRUE;
605 /***********************************************************************
606 * CharToOemBuff32A (USER32.38)
608 BOOL WINAPI CharToOemBuffA( LPCSTR s, LPSTR d, DWORD len )
610 while (len--) *d++ = ANSI_TO_OEM(*s++);
611 return TRUE;
615 /***********************************************************************
616 * CharToOemBuff32W (USER32.39)
618 BOOL WINAPI CharToOemBuffW( LPCWSTR s, LPSTR d, DWORD len )
620 while (len--) *d++ = ANSI_TO_OEM(*s++);
621 return TRUE;
625 /***********************************************************************
626 * CharToOem32W (USER32.40)
628 BOOL WINAPI CharToOemW( LPCWSTR s, LPSTR d )
630 LPSTR oldd = d;
631 if (!s || !d) return TRUE;
632 TRACE(string,"CharToOem L%s\n", debugstr_w (s));
633 while ((*d++ = ANSI_TO_OEM(*s++)));
634 TRACE(string," to %s\n", debugstr_a (oldd));
635 return TRUE;
639 /***********************************************************************
640 * OemToChar32A (USER32.402)
642 BOOL WINAPI OemToCharA( LPCSTR s, LPSTR d )
644 LPSTR oldd = d;
645 TRACE(string,"OemToChar %s\n", debugstr_a (s));
646 while ((*d++ = OEM_TO_ANSI(*s++)));
647 TRACE(string," to %s\n", debugstr_a (oldd));
648 return TRUE;
652 /***********************************************************************
653 * OemToCharBuff32A (USER32.403)
655 BOOL WINAPI OemToCharBuffA( LPCSTR s, LPSTR d, DWORD len )
657 TRACE(string,"OemToCharBuff %s\n", debugstr_an (s, len));
658 while (len--) *d++ = OEM_TO_ANSI(*s++);
659 return TRUE;
663 /***********************************************************************
664 * OemToCharBuff32W (USER32.404)
666 BOOL WINAPI OemToCharBuffW( LPCSTR s, LPWSTR d, DWORD len )
668 TRACE(string,"OemToCharBuff %s\n", debugstr_an (s, len));
669 while (len--) *d++ = (WCHAR)OEM_TO_ANSI(*s++);
670 return TRUE;
674 /***********************************************************************
675 * OemToChar32W (USER32.405)
677 BOOL WINAPI OemToCharW( LPCSTR s, LPWSTR d )
679 while ((*d++ = (WCHAR)OEM_TO_ANSI(*s++)));
680 return TRUE;
683 /***********************************************************************
684 * WideCharToLocal (Not a Windows API)
685 * similar lstrcpyWtoA, should handle codepages properly
687 * RETURNS
688 * strlen of the destination string
691 INT WINAPI WideCharToLocal(
692 LPSTR pLocal,
693 LPWSTR pWide,
694 INT dwChars)
695 { *pLocal = 0;
696 TRACE(string,"(%p, %s, %i)\n", pLocal, debugstr_w(pWide),dwChars);
697 WideCharToMultiByte(CP_ACP,0,pWide,-1,pLocal,dwChars,NULL,NULL);
698 return strlen(pLocal);
700 /***********************************************************************
701 * LocalToWideChar (Not a Windows API)
702 * similar lstrcpyAtoW, should handle codepages properly
704 * RETURNS
705 * strlen of the destination string
707 INT WINAPI LocalToWideChar(
708 LPWSTR pWide,
709 LPSTR pLocal,
710 INT dwChars)
711 { *pWide = 0;
712 TRACE(string,"(%p, %s, %i)\n",pWide, pLocal, dwChars);
713 MultiByteToWideChar(CP_ACP,0,pLocal,-1,pWide,dwChars);
714 return lstrlenW(pWide);
718 /***********************************************************************
719 * lstrrchr (Not a Windows API)
721 * This is the implementation meant to be invoked form within
722 * COMCTL32_StrRChrA and shell32(TODO)...
724 * Return a pointer to the last occurence of wMatch in lpStart
725 * not looking further than lpEnd...
727 LPSTR WINAPI lstrrchr( LPCSTR lpStart, LPCSTR lpEnd, WORD wMatch )
729 LPCSTR lpGotIt = NULL;
731 TRACE(string,"(%s, %s)\n", lpStart, lpEnd);
733 if (!lpEnd) lpEnd = lpStart + strlen(lpStart);
735 for(; lpStart < lpEnd; lpStart = CharNextA(lpStart))
736 if (!ChrCmpA( GET_WORD(lpStart), wMatch))
737 lpGotIt = lpStart;
739 return ((LPSTR)lpGotIt);
742 /***********************************************************************
743 * lstrrchrw (Not a Windows API)
745 * This is the implementation meant to be invoked form within
746 * COMCTL32_StrRChrW and shell32(TODO)...
748 * Return a pointer to the last occurence of wMatch in lpStart
749 * not looking further than lpEnd...
751 LPWSTR WINAPI lstrrchrw( LPCWSTR lpStart, LPCWSTR lpEnd, WORD wMatch )
753 LPCWSTR lpGotIt = NULL;
755 TRACE(string,"(%p, %p, %c)\n", lpStart, lpEnd, wMatch);
756 if (!lpEnd) lpEnd = lpStart + lstrlenW(lpStart);
758 for(; lpStart < lpEnd; lpStart = CharNextW(lpStart))
759 if (!ChrCmpW( GET_WORD(lpStart), wMatch))
760 lpGotIt = lpStart;
762 return (LPWSTR)lpGotIt;
765 /***********************************************************************
766 * strstrw (Not a Windows API)
768 * This is the implementation meant to be invoked form within
769 * COMCTL32_StrStrW and shell32(TODO)...
772 LPWSTR WINAPI strstrw( LPCWSTR lpFirst, LPCWSTR lpSrch) {
773 UINT uSrchLen = (UINT)lstrlenW(lpSrch);
774 WORD wMatchBeg = *(WORD*)lpSrch;
776 TRACE(string,"(%p, %p)\n", lpFirst, lpSrch);
778 for(;
779 ((lpFirst=CRTDLL_wcschr(lpFirst, wMatchBeg))!=0) &&
780 lstrncmpW(lpFirst, lpSrch, uSrchLen);
781 lpFirst++) {
782 continue;
784 return (LPWSTR)lpFirst;
788 /***********************************************************************
789 * ChrCmpA
790 * This fuction returns FALSE if both words match, TRUE otherwise...
792 static BOOL ChrCmpA( WORD word1, WORD word2) {
793 if (LOBYTE(word1) == LOBYTE(word2)) {
794 if (IsDBCSLeadByte(LOBYTE(word1))) {
795 return (word1 != word2);
797 return FALSE;
799 return TRUE;
802 /***********************************************************************
803 * ChrCmpW
804 * This fuction returns FALSE if both words match, TRUE otherwise...
806 static BOOL ChrCmpW( WORD word1, WORD word2) {
807 return (word1 != word2);