2 * String manipulation functions
4 * Copyright 1998 Eric Kohl
5 * 1998 Juergen Schmied <j.schmied@metronet.de>
6 * 2000 Eric Kohl for CodeWeavers
7 * Copyright 2002 Jon Griffiths
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 #include "wine/port.h"
30 #include <stdlib.h> /* atoi */
39 #include "wine/unicode.h"
41 #include "wine/debug.h"
43 WINE_DEFAULT_DEBUG_CHANNEL(commctrl
);
45 /*************************************************************************
46 * COMCTL32_ChrCmpHelperA
48 * Internal helper for ChrCmpA/COMCTL32_ChrCmpIA.
51 * Both this function and its Unicode counterpart are very inefficient. To
52 * fix this, CompareString must be completely implemented and optimised
53 * first. Then the core character test can be taken out of that function and
54 * placed here, so that it need never be called at all. Until then, do not
55 * attempt to optimise this code unless you are willing to test that it
56 * still performs correctly.
58 static BOOL
COMCTL32_ChrCmpHelperA(WORD ch1
, WORD ch2
, DWORD dwFlags
)
60 char str1
[3], str2
[3];
62 str1
[0] = LOBYTE(ch1
);
63 if (IsDBCSLeadByte(str1
[0]))
65 str1
[1] = HIBYTE(ch1
);
71 str2
[0] = LOBYTE(ch2
);
72 if (IsDBCSLeadByte(str2
[0]))
74 str2
[1] = HIBYTE(ch2
);
80 return CompareStringA(GetThreadLocale(), dwFlags
, str1
, -1, str2
, -1) - 2;
83 /*************************************************************************
84 * COMCTL32_ChrCmpHelperW
86 * Internal helper for COMCTL32_ChrCmpW/ChrCmpIW.
88 static BOOL
COMCTL32_ChrCmpHelperW(WCHAR ch1
, WCHAR ch2
, DWORD dwFlags
)
90 WCHAR str1
[2], str2
[2];
96 return CompareStringW(GetThreadLocale(), dwFlags
, str1
, 2, str2
, 2) - 2;
99 /*************************************************************************
100 * COMCTL32_ChrCmpA (internal)
102 * Internal helper function.
104 static BOOL
COMCTL32_ChrCmpA(WORD ch1
, WORD ch2
)
106 return COMCTL32_ChrCmpHelperA(ch1
, ch2
, 0);
109 /*************************************************************************
110 * COMCTL32_ChrCmpIA (internal)
112 * Compare two characters, ignoring case.
115 * ch1 [I] First character to compare
116 * ch2 [I] Second character to compare
119 * FALSE, if the characters are equal.
120 * Non-zero otherwise.
122 static BOOL
COMCTL32_ChrCmpIA(WORD ch1
, WORD ch2
)
124 TRACE("(%d,%d)\n", ch1
, ch2
);
126 return COMCTL32_ChrCmpHelperA(ch1
, ch2
, NORM_IGNORECASE
);
129 /*************************************************************************
132 * Internal helper function.
134 static BOOL
COMCTL32_ChrCmpW(WCHAR ch1
, WCHAR ch2
)
136 return COMCTL32_ChrCmpHelperW(ch1
, ch2
, 0);
139 /*************************************************************************
142 * Internal helper function.
144 static BOOL
COMCTL32_ChrCmpIW(WCHAR ch1
, WCHAR ch2
)
146 return COMCTL32_ChrCmpHelperW(ch1
, ch2
, NORM_IGNORECASE
);
149 /**************************************************************************
150 * Str_GetPtrA [COMCTL32.233]
152 * Copies a string into a destination buffer.
155 * lpSrc [I] Source string
156 * lpDest [O] Destination buffer
157 * nMaxLen [I] Size of buffer in characters
160 * The number of characters copied.
162 INT WINAPI
Str_GetPtrA (LPCSTR lpSrc
, LPSTR lpDest
, INT nMaxLen
)
166 TRACE("(%p %p %d)\n", lpSrc
, lpDest
, nMaxLen
);
168 if ((!lpDest
|| nMaxLen
== 0) && lpSrc
)
169 return (strlen(lpSrc
) + 1);
179 len
= strlen(lpSrc
) + 1;
183 RtlMoveMemory (lpDest
, lpSrc
, len
- 1);
184 lpDest
[len
- 1] = '\0';
189 /**************************************************************************
190 * Str_SetPtrA [COMCTL32.234]
192 * Makes a copy of a string, allocating memory if necessary.
195 * lppDest [O] Pointer to destination string
196 * lpSrc [I] Source string
203 * Set lpSrc to NULL to free the memory allocated by a previous call
206 BOOL WINAPI
Str_SetPtrA (LPSTR
*lppDest
, LPCSTR lpSrc
)
208 TRACE("(%p %p)\n", lppDest
, lpSrc
);
211 LPSTR ptr
= ReAlloc (*lppDest
, strlen (lpSrc
) + 1);
225 /**************************************************************************
226 * Str_GetPtrW [COMCTL32.235]
230 INT WINAPI
Str_GetPtrW (LPCWSTR lpSrc
, LPWSTR lpDest
, INT nMaxLen
)
234 TRACE("(%p %p %d)\n", lpSrc
, lpDest
, nMaxLen
);
236 if (!lpDest
&& lpSrc
)
237 return strlenW (lpSrc
);
247 len
= strlenW (lpSrc
);
251 RtlMoveMemory (lpDest
, lpSrc
, len
*sizeof(WCHAR
));
257 /**************************************************************************
258 * Str_SetPtrW [COMCTL32.236]
262 BOOL WINAPI
Str_SetPtrW (LPWSTR
*lppDest
, LPCWSTR lpSrc
)
264 TRACE("(%p %p)\n", lppDest
, lpSrc
);
267 INT len
= strlenW (lpSrc
) + 1;
268 LPWSTR ptr
= ReAlloc (*lppDest
, len
* sizeof(WCHAR
));
271 strcpyW (ptr
, lpSrc
);
282 /**************************************************************************
283 * StrChrA [COMCTL32.350]
285 * Find a given character in a string.
288 * lpszStr [I] String to search in.
289 * ch [I] Character to search for.
292 * Success: A pointer to the first occurrence of ch in lpszStr, or NULL if
294 * Failure: NULL, if any arguments are invalid.
296 LPSTR WINAPI
StrChrA(LPCSTR lpszStr
, WORD ch
)
298 TRACE("(%s,%i)\n", debugstr_a(lpszStr
), ch
);
304 if (!COMCTL32_ChrCmpA(*lpszStr
, ch
))
305 return (LPSTR
)lpszStr
;
306 lpszStr
= CharNextA(lpszStr
);
312 /**************************************************************************
313 * StrCmpNIA [COMCTL32.353]
315 * Compare two strings, up to a maximum length, ignoring case.
318 * lpszStr [I] First string to compare
319 * lpszComp [I] Second string to compare
320 * iLen [I] Maximum number of chars to compare.
323 * An integer less than, equal to or greater than 0, indicating that
324 * lpszStr is less than, the same, or greater than lpszComp.
326 INT WINAPI
StrCmpNIA(LPCSTR lpszStr
, LPCSTR lpszComp
, INT iLen
)
330 TRACE("(%s,%s,%i)\n", debugstr_a(lpszStr
), debugstr_a(lpszComp
), iLen
);
332 iRet
= CompareStringA(GetThreadLocale(), NORM_IGNORECASE
, lpszStr
, iLen
, lpszComp
, iLen
);
333 return iRet
== CSTR_LESS_THAN
? -1 : iRet
== CSTR_GREATER_THAN
? 1 : 0;
336 /*************************************************************************
337 * StrCmpNIW [COMCTL32.361]
341 INT WINAPI
StrCmpNIW(LPCWSTR lpszStr
, LPCWSTR lpszComp
, INT iLen
)
345 TRACE("(%s,%s,%i)\n", debugstr_w(lpszStr
), debugstr_w(lpszComp
), iLen
);
347 iRet
= CompareStringW(GetThreadLocale(), NORM_IGNORECASE
, lpszStr
, iLen
, lpszComp
, iLen
);
348 return iRet
== CSTR_LESS_THAN
? -1 : iRet
== CSTR_GREATER_THAN
? 1 : 0;
351 /*************************************************************************
352 * COMCTL32_StrStrHelperA
354 * Internal implementation of StrStrA/StrStrIA
356 static LPSTR
COMCTL32_StrStrHelperA(LPCSTR lpszStr
, LPCSTR lpszSearch
,
357 INT (WINAPI
*pStrCmpFn
)(LPCSTR
,LPCSTR
,INT
))
361 if (!lpszStr
|| !lpszSearch
|| !*lpszSearch
)
364 iLen
= strlen(lpszSearch
);
368 if (!pStrCmpFn(lpszStr
, lpszSearch
, iLen
))
369 return (LPSTR
)lpszStr
;
370 lpszStr
= CharNextA(lpszStr
);
375 /*************************************************************************
376 * COMCTL32_StrStrHelperW
378 * Internal implementation of StrStrW/StrStrIW
380 static LPWSTR
COMCTL32_StrStrHelperW(LPCWSTR lpszStr
, LPCWSTR lpszSearch
,
381 INT (WINAPI
*pStrCmpFn
)(LPCWSTR
,LPCWSTR
,INT
))
385 if (!lpszStr
|| !lpszSearch
|| !*lpszSearch
)
388 iLen
= strlenW(lpszSearch
);
392 if (!pStrCmpFn(lpszStr
, lpszSearch
, iLen
))
393 return (LPWSTR
)lpszStr
;
394 lpszStr
= CharNextW(lpszStr
);
399 /**************************************************************************
400 * StrStrIA [COMCTL32.355]
402 * Find a substring within a string, ignoring case.
405 * lpszStr [I] String to search in
406 * lpszSearch [I] String to look for
409 * The start of lpszSearch within lpszStr, or NULL if not found.
411 LPSTR WINAPI
StrStrIA(LPCSTR lpszStr
, LPCSTR lpszSearch
)
413 TRACE("(%s,%s)\n", debugstr_a(lpszStr
), debugstr_a(lpszSearch
));
415 return COMCTL32_StrStrHelperA(lpszStr
, lpszSearch
, StrCmpNIA
);
418 /**************************************************************************
419 * StrToIntA [COMCTL32.357]
421 * Read a signed integer from a string.
424 * lpszStr [I] String to read integer from
427 * The signed integer value represented by the string, or 0 if no integer is
430 INT WINAPI
StrToIntA (LPCSTR lpszStr
)
432 return atoi(lpszStr
);
435 /**************************************************************************
436 * StrStrIW [COMCTL32.363]
440 LPWSTR WINAPI
StrStrIW(LPCWSTR lpszStr
, LPCWSTR lpszSearch
)
442 TRACE("(%s,%s)\n", debugstr_w(lpszStr
), debugstr_w(lpszSearch
));
444 return COMCTL32_StrStrHelperW(lpszStr
, lpszSearch
, StrCmpNIW
);
447 /**************************************************************************
448 * StrToIntW [COMCTL32.365]
452 INT WINAPI
StrToIntW (LPCWSTR lpString
)
454 return atoiW(lpString
);
457 /*************************************************************************
458 * COMCTL32_StrSpnHelperA (internal)
460 * Internal implementation of StrSpnA/StrCSpnA/StrCSpnIA
462 static int COMCTL32_StrSpnHelperA(LPCSTR lpszStr
, LPCSTR lpszMatch
,
463 LPSTR (WINAPI
*pStrChrFn
)(LPCSTR
,WORD
),
466 LPCSTR lpszRead
= lpszStr
;
467 if (lpszStr
&& *lpszStr
&& lpszMatch
)
471 LPCSTR lpszTest
= pStrChrFn(lpszMatch
, *lpszRead
);
473 if (!bInvert
&& !lpszTest
)
475 if (bInvert
&& lpszTest
)
477 lpszRead
= CharNextA(lpszRead
);
480 return lpszRead
- lpszStr
;
483 /**************************************************************************
484 * StrCSpnA [COMCTL32.356]
486 * Find the length of the start of a string that does not contain certain
490 * lpszStr [I] String to search
491 * lpszMatch [I] Characters that cannot be in the substring
494 * The length of the part of lpszStr containing only chars not in lpszMatch,
495 * or 0 if any parameter is invalid.
497 int WINAPI
StrCSpnA(LPCSTR lpszStr
, LPCSTR lpszMatch
)
499 TRACE("(%s,%s)\n",debugstr_a(lpszStr
), debugstr_a(lpszMatch
));
501 return COMCTL32_StrSpnHelperA(lpszStr
, lpszMatch
, StrChrA
, TRUE
);
504 /**************************************************************************
505 * StrChrW [COMCTL32.358]
509 LPWSTR WINAPI
StrChrW(LPCWSTR lpszStr
, WCHAR ch
)
511 LPWSTR lpszRet
= NULL
;
513 TRACE("(%s,%i)\n", debugstr_w(lpszStr
), ch
);
516 lpszRet
= strchrW(lpszStr
, ch
);
520 /**************************************************************************
521 * StrCmpNA [COMCTL32.352]
523 * Compare two strings, up to a maximum length.
526 * lpszStr [I] First string to compare
527 * lpszComp [I] Second string to compare
528 * iLen [I] Maximum number of chars to compare.
531 * An integer less than, equal to or greater than 0, indicating that
532 * lpszStr is less than, the same, or greater than lpszComp.
534 INT WINAPI
StrCmpNA(LPCSTR lpszStr
, LPCSTR lpszComp
, INT iLen
)
538 TRACE("(%s,%s,%i)\n", debugstr_a(lpszStr
), debugstr_a(lpszComp
), iLen
);
540 iRet
= CompareStringA(GetThreadLocale(), 0, lpszStr
, iLen
, lpszComp
, iLen
);
541 return iRet
== CSTR_LESS_THAN
? -1 : iRet
== CSTR_GREATER_THAN
? 1 : 0;
544 /**************************************************************************
545 * StrCmpNW [COMCTL32.360]
549 INT WINAPI
StrCmpNW(LPCWSTR lpszStr
, LPCWSTR lpszComp
, INT iLen
)
553 TRACE("(%s,%s,%i)\n", debugstr_w(lpszStr
), debugstr_w(lpszComp
), iLen
);
555 iRet
= CompareStringW(GetThreadLocale(), 0, lpszStr
, iLen
, lpszComp
, iLen
);
556 return iRet
== CSTR_LESS_THAN
? -1 : iRet
== CSTR_GREATER_THAN
? 1 : 0;
559 /**************************************************************************
560 * StrRChrA [COMCTL32.351]
562 * Find the last occurrence of a character in string.
565 * lpszStr [I] String to search in
566 * lpszEnd [I] Place to end search, or NULL to search until the end of lpszStr
567 * ch [I] Character to search for.
570 * Success: A pointer to the last occurrence of ch in lpszStr before lpszEnd,
571 * or NULL if not found.
572 * Failure: NULL, if any arguments are invalid.
574 LPSTR WINAPI
StrRChrA(LPCSTR lpszStr
, LPCSTR lpszEnd
, WORD ch
)
576 LPCSTR lpszRet
= NULL
;
578 TRACE("(%s,%s,%x)\n", debugstr_a(lpszStr
), debugstr_a(lpszEnd
), ch
);
585 lpszEnd
= lpszStr
+ lstrlenA(lpszStr
);
587 while (*lpszStr
&& lpszStr
<= lpszEnd
)
589 ch2
= IsDBCSLeadByte(*lpszStr
)? *lpszStr
<< 8 | lpszStr
[1] : *lpszStr
;
591 if (!COMCTL32_ChrCmpA(ch
, ch2
))
593 lpszStr
= CharNextA(lpszStr
);
596 return (LPSTR
)lpszRet
;
600 /**************************************************************************
601 * StrRChrW [COMCTL32.359]
605 LPWSTR WINAPI
StrRChrW(LPCWSTR lpszStr
, LPCWSTR lpszEnd
, WORD ch
)
607 LPCWSTR lpszRet
= NULL
;
609 TRACE("(%s,%s,%x)\n", debugstr_w(lpszStr
), debugstr_w(lpszEnd
), ch
);
614 lpszEnd
= lpszStr
+ strlenW(lpszStr
);
616 while (*lpszStr
&& lpszStr
<= lpszEnd
)
618 if (!COMCTL32_ChrCmpW(ch
, *lpszStr
))
620 lpszStr
= CharNextW(lpszStr
);
623 return (LPWSTR
)lpszRet
;
626 /**************************************************************************
627 * StrStrA [COMCTL32.354]
629 * Find a substring within a string.
632 * lpszStr [I] String to search in
633 * lpszSearch [I] String to look for
636 * The start of lpszSearch within lpszStr, or NULL if not found.
638 LPSTR WINAPI
StrStrA(LPCSTR lpszStr
, LPCSTR lpszSearch
)
640 TRACE("(%s,%s)\n", debugstr_a(lpszStr
), debugstr_a(lpszSearch
));
642 return COMCTL32_StrStrHelperA(lpszStr
, lpszSearch
, StrCmpNA
);
645 /**************************************************************************
646 * StrStrW [COMCTL32.362]
650 LPWSTR WINAPI
StrStrW(LPCWSTR lpszStr
, LPCWSTR lpszSearch
)
652 TRACE("(%s,%s)\n", debugstr_w(lpszStr
), debugstr_w(lpszSearch
));
654 return COMCTL32_StrStrHelperW(lpszStr
, lpszSearch
, StrCmpNW
);
657 /*************************************************************************
658 * StrChrIA [COMCTL32.366]
660 * Find a given character in a string, ignoring case.
663 * lpszStr [I] String to search in.
664 * ch [I] Character to search for.
667 * Success: A pointer to the first occurrence of ch in lpszStr, or NULL if
669 * Failure: NULL, if any arguments are invalid.
671 LPSTR WINAPI
StrChrIA(LPCSTR lpszStr
, WORD ch
)
673 TRACE("(%s,%i)\n", debugstr_a(lpszStr
), ch
);
679 if (!COMCTL32_ChrCmpIA(*lpszStr
, ch
))
680 return (LPSTR
)lpszStr
;
681 lpszStr
= CharNextA(lpszStr
);
687 /*************************************************************************
688 * StrChrIW [COMCTL32.367]
692 LPWSTR WINAPI
StrChrIW(LPCWSTR lpszStr
, WCHAR ch
)
694 TRACE("(%s,%i)\n", debugstr_w(lpszStr
), ch
);
701 if (toupperW(*lpszStr
) == ch
)
702 return (LPWSTR
)lpszStr
;
703 lpszStr
= CharNextW(lpszStr
);
707 return (LPWSTR
)lpszStr
;
710 /*************************************************************************
711 * StrRStrIA [COMCTL32.372]
713 * Find the last occurrence of a substring within a string.
716 * lpszStr [I] String to search in
717 * lpszEnd [I] End of lpszStr
718 * lpszSearch [I] String to look for
721 * The last occurrence lpszSearch within lpszStr, or NULL if not found.
723 LPSTR WINAPI
StrRStrIA(LPCSTR lpszStr
, LPCSTR lpszEnd
, LPCSTR lpszSearch
)
725 LPSTR lpszRet
= NULL
;
729 TRACE("(%s,%s)\n", debugstr_a(lpszStr
), debugstr_a(lpszSearch
));
731 if (!lpszStr
|| !lpszSearch
|| !*lpszSearch
)
735 lpszEnd
= lpszStr
+ lstrlenA(lpszStr
);
737 if (IsDBCSLeadByte(*lpszSearch
))
738 ch1
= *lpszSearch
<< 8 | lpszSearch
[1];
741 iLen
= lstrlenA(lpszSearch
);
743 while (lpszStr
<= lpszEnd
&& *lpszStr
)
745 ch2
= IsDBCSLeadByte(*lpszStr
)? *lpszStr
<< 8 | lpszStr
[1] : *lpszStr
;
746 if (!COMCTL32_ChrCmpIA(ch1
, ch2
))
748 if (!StrCmpNIA(lpszStr
, lpszSearch
, iLen
))
749 lpszRet
= (LPSTR
)lpszStr
;
751 lpszStr
= CharNextA(lpszStr
);
756 /*************************************************************************
757 * StrRStrIW [COMCTL32.373]
761 LPWSTR WINAPI
StrRStrIW(LPCWSTR lpszStr
, LPCWSTR lpszEnd
, LPCWSTR lpszSearch
)
763 LPWSTR lpszRet
= NULL
;
766 TRACE("(%s,%s)\n", debugstr_w(lpszStr
), debugstr_w(lpszSearch
));
768 if (!lpszStr
|| !lpszSearch
|| !*lpszSearch
)
772 lpszEnd
= lpszStr
+ strlenW(lpszStr
);
774 iLen
= strlenW(lpszSearch
);
776 while (lpszStr
<= lpszEnd
&& *lpszStr
)
778 if (!COMCTL32_ChrCmpIW(*lpszSearch
, *lpszStr
))
780 if (!StrCmpNIW(lpszStr
, lpszSearch
, iLen
))
781 lpszRet
= (LPWSTR
)lpszStr
;
783 lpszStr
= CharNextW(lpszStr
);
788 /*************************************************************************
789 * COMCTL32_StrSpnHelperW
791 * Internal implementation of StrSpnW/StrCSpnW/StrCSpnIW
793 static int COMCTL32_StrSpnHelperW(LPCWSTR lpszStr
, LPCWSTR lpszMatch
,
794 LPWSTR (WINAPI
*pStrChrFn
)(LPCWSTR
,WCHAR
),
797 LPCWSTR lpszRead
= lpszStr
;
798 if (lpszStr
&& *lpszStr
&& lpszMatch
)
802 LPCWSTR lpszTest
= pStrChrFn(lpszMatch
, *lpszRead
);
804 if (!bInvert
&& !lpszTest
)
806 if (bInvert
&& lpszTest
)
808 lpszRead
= CharNextW(lpszRead
);
811 return lpszRead
- lpszStr
;
814 /*************************************************************************
815 * StrCSpnIA [COMCTL32.374]
817 * Find the length of the start of a string that does not contain certain
818 * characters, ignoring case.
821 * lpszStr [I] String to search
822 * lpszMatch [I] Characters that cannot be in the substring
825 * The length of the part of lpszStr containing only chars not in lpszMatch,
826 * or 0 if any parameter is invalid.
828 int WINAPI
StrCSpnIA(LPCSTR lpszStr
, LPCSTR lpszMatch
)
830 TRACE("(%s,%s)\n",debugstr_a(lpszStr
), debugstr_a(lpszMatch
));
832 return COMCTL32_StrSpnHelperA(lpszStr
, lpszMatch
, StrChrIA
, TRUE
);
835 /*************************************************************************
836 * StrCSpnIW [COMCTL32.375]
840 int WINAPI
StrCSpnIW(LPCWSTR lpszStr
, LPCWSTR lpszMatch
)
842 TRACE("(%s,%s)\n",debugstr_w(lpszStr
), debugstr_w(lpszMatch
));
844 return COMCTL32_StrSpnHelperW(lpszStr
, lpszMatch
, StrChrIW
, TRUE
);
847 /**************************************************************************
848 * StrRChrIA [COMCTL32.368]
850 * Find the last occurrence of a character in string, ignoring case.
853 * lpszStr [I] String to search in
854 * lpszEnd [I] Place to end search, or NULL to search until the end of lpszStr
855 * ch [I] Character to search for.
858 * Success: A pointer to the last occurrence of ch in lpszStr before lpszEnd,
859 * or NULL if not found.
860 * Failure: NULL, if any arguments are invalid.
862 LPSTR WINAPI
StrRChrIA(LPCSTR lpszStr
, LPCSTR lpszEnd
, WORD ch
)
864 LPCSTR lpszRet
= NULL
;
866 TRACE("(%s,%s,%x)\n", debugstr_a(lpszStr
), debugstr_a(lpszEnd
), ch
);
873 lpszEnd
= lpszStr
+ lstrlenA(lpszStr
);
875 while (*lpszStr
&& lpszStr
<= lpszEnd
)
877 ch2
= IsDBCSLeadByte(*lpszStr
)? *lpszStr
<< 8 | lpszStr
[1] : *lpszStr
;
881 lpszStr
= CharNextA(lpszStr
);
884 return (LPSTR
)lpszRet
;
887 /**************************************************************************
888 * StrRChrIW [COMCTL32.369]
892 LPWSTR WINAPI
StrRChrIW(LPCWSTR lpszStr
, LPCWSTR lpszEnd
, WORD ch
)
894 LPCWSTR lpszRet
= NULL
;
896 TRACE("(%s,%s,%x)\n", debugstr_w(lpszStr
), debugstr_w(lpszEnd
), ch
);
901 lpszEnd
= lpszStr
+ strlenW(lpszStr
);
903 while (*lpszStr
&& lpszStr
<= lpszEnd
)
907 lpszStr
= CharNextW(lpszStr
);
910 return (LPWSTR
)lpszRet
;
913 /*************************************************************************
914 * StrCSpnW [COMCTL32.364]
918 int WINAPI
StrCSpnW(LPCWSTR lpszStr
, LPCWSTR lpszMatch
)
920 TRACE("(%s,%s)\n",debugstr_w(lpszStr
), debugstr_w(lpszMatch
));
922 return COMCTL32_StrSpnHelperW(lpszStr
, lpszMatch
, StrChrW
, TRUE
);
925 /*************************************************************************
926 * IntlStrEqWorkerA [COMCTL32.376]
928 * Compare two strings.
931 * bCase [I] Whether to compare case sensitively
932 * lpszStr [I] First string to compare
933 * lpszComp [I] Second string to compare
934 * iLen [I] Length to compare
937 * TRUE If the strings are equal.
940 BOOL WINAPI
IntlStrEqWorkerA(BOOL bCase
, LPCSTR lpszStr
, LPCSTR lpszComp
,
943 DWORD dwFlags
= LOCALE_USE_CP_ACP
;
946 TRACE("(%d,%s,%s,%d)\n", bCase
,
947 debugstr_a(lpszStr
), debugstr_a(lpszComp
), iLen
);
949 /* FIXME: These flags are undocumented and unknown by our CompareString.
950 * We need defines for them.
952 dwFlags
|= bCase
? 0x10000000 : 0x10000001;
954 iRet
= CompareStringA(GetThreadLocale(),
955 dwFlags
, lpszStr
, iLen
, lpszComp
, iLen
);
958 iRet
= CompareStringA(2048, dwFlags
, lpszStr
, iLen
, lpszComp
, iLen
);
960 return iRet
== 2 ? TRUE
: FALSE
;
963 /*************************************************************************
964 * IntlStrEqWorkerW [COMCTL32.377]
966 * See IntlStrEqWorkerA.
968 BOOL WINAPI
IntlStrEqWorkerW(BOOL bCase
, LPCWSTR lpszStr
, LPCWSTR lpszComp
,
974 TRACE("(%d,%s,%s,%d)\n", bCase
,
975 debugstr_w(lpszStr
),debugstr_w(lpszComp
), iLen
);
977 /* FIXME: These flags are undocumented and unknown by our CompareString.
978 * We need defines for them.
980 dwFlags
= bCase
? 0x10000000 : 0x10000001;
982 iRet
= CompareStringW(GetThreadLocale(),
983 dwFlags
, lpszStr
, iLen
, lpszComp
, iLen
);
986 iRet
= CompareStringW(2048, dwFlags
, lpszStr
, iLen
, lpszComp
, iLen
);
988 return iRet
== 2 ? TRUE
: FALSE
;