2004-02-17 22:02:18 +01:00
|
|
|
/*
|
|
|
|
* String manipulation functions
|
|
|
|
*
|
|
|
|
* Copyright 1998 Eric Kohl
|
|
|
|
* 1998 Juergen Schmied <j.schmied@metronet.de>
|
|
|
|
* 2000 Eric Kohl for CodeWeavers
|
2004-02-20 06:16:37 +01:00
|
|
|
* Copyright 2002 Jon Griffiths
|
2004-02-17 22:02:18 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2004-02-17 22:02:18 +01:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h> /* atoi */
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "winnls.h"
|
|
|
|
|
2006-11-02 10:25:01 +01:00
|
|
|
#include "comctl32.h"
|
|
|
|
|
2004-02-17 22:02:18 +01:00
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(commctrl);
|
|
|
|
|
2004-02-20 06:16:37 +01:00
|
|
|
/*************************************************************************
|
|
|
|
* COMCTL32_ChrCmpHelperA
|
|
|
|
*
|
|
|
|
* Internal helper for ChrCmpA/COMCTL32_ChrCmpIA.
|
|
|
|
*
|
|
|
|
* NOTES
|
2007-02-14 16:22:07 +01:00
|
|
|
* Both this function and its Unicode counterpart are very inefficient. To
|
2004-02-20 06:16:37 +01:00
|
|
|
* fix this, CompareString must be completely implemented and optimised
|
|
|
|
* first. Then the core character test can be taken out of that function and
|
|
|
|
* placed here, so that it need never be called at all. Until then, do not
|
|
|
|
* attempt to optimise this code unless you are willing to test that it
|
|
|
|
* still performs correctly.
|
|
|
|
*/
|
|
|
|
static BOOL COMCTL32_ChrCmpHelperA(WORD ch1, WORD ch2, DWORD dwFlags)
|
|
|
|
{
|
|
|
|
char str1[3], str2[3];
|
|
|
|
|
|
|
|
str1[0] = LOBYTE(ch1);
|
|
|
|
if (IsDBCSLeadByte(str1[0]))
|
|
|
|
{
|
|
|
|
str1[1] = HIBYTE(ch1);
|
|
|
|
str1[2] = '\0';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
str1[1] = '\0';
|
|
|
|
|
|
|
|
str2[0] = LOBYTE(ch2);
|
|
|
|
if (IsDBCSLeadByte(str2[0]))
|
|
|
|
{
|
|
|
|
str2[1] = HIBYTE(ch2);
|
|
|
|
str2[2] = '\0';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
str2[1] = '\0';
|
|
|
|
|
2012-06-20 23:40:13 +02:00
|
|
|
return CompareStringA(GetThreadLocale(), dwFlags, str1, -1, str2, -1) - CSTR_EQUAL;
|
2004-02-20 06:16:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* COMCTL32_ChrCmpA (internal)
|
|
|
|
*
|
|
|
|
* Internal helper function.
|
|
|
|
*/
|
|
|
|
static BOOL COMCTL32_ChrCmpA(WORD ch1, WORD ch2)
|
|
|
|
{
|
|
|
|
return COMCTL32_ChrCmpHelperA(ch1, ch2, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* COMCTL32_ChrCmpIA (internal)
|
|
|
|
*
|
|
|
|
* Compare two characters, ignoring case.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* ch1 [I] First character to compare
|
|
|
|
* ch2 [I] Second character to compare
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* FALSE, if the characters are equal.
|
|
|
|
* Non-zero otherwise.
|
|
|
|
*/
|
|
|
|
static BOOL COMCTL32_ChrCmpIA(WORD ch1, WORD ch2)
|
|
|
|
{
|
|
|
|
TRACE("(%d,%d)\n", ch1, ch2);
|
|
|
|
|
|
|
|
return COMCTL32_ChrCmpHelperA(ch1, ch2, NORM_IGNORECASE);
|
|
|
|
}
|
|
|
|
|
2004-09-22 21:10:27 +02:00
|
|
|
/*************************************************************************
|
|
|
|
* COMCTL32_ChrCmpIW
|
|
|
|
*
|
|
|
|
* Internal helper function.
|
|
|
|
*/
|
2007-06-25 13:51:00 +02:00
|
|
|
static inline BOOL COMCTL32_ChrCmpIW(WCHAR ch1, WCHAR ch2)
|
2004-09-22 21:10:27 +02:00
|
|
|
{
|
2012-06-20 23:40:13 +02:00
|
|
|
return CompareStringW(GetThreadLocale(), NORM_IGNORECASE, &ch1, 1, &ch2, 1) - CSTR_EQUAL;
|
2004-09-22 21:10:27 +02:00
|
|
|
}
|
|
|
|
|
2006-11-02 10:25:01 +01:00
|
|
|
/**************************************************************************
|
|
|
|
* Str_GetPtrA [COMCTL32.233]
|
|
|
|
*
|
|
|
|
* Copies a string into a destination buffer.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* lpSrc [I] Source string
|
|
|
|
* lpDest [O] Destination buffer
|
|
|
|
* nMaxLen [I] Size of buffer in characters
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* The number of characters copied.
|
|
|
|
*/
|
|
|
|
INT WINAPI Str_GetPtrA (LPCSTR lpSrc, LPSTR lpDest, INT nMaxLen)
|
|
|
|
{
|
|
|
|
INT len;
|
|
|
|
|
|
|
|
TRACE("(%p %p %d)\n", lpSrc, lpDest, nMaxLen);
|
|
|
|
|
2006-11-07 21:29:46 +01:00
|
|
|
if ((!lpDest || nMaxLen == 0) && lpSrc)
|
|
|
|
return (strlen(lpSrc) + 1);
|
2006-11-02 10:25:01 +01:00
|
|
|
|
|
|
|
if (nMaxLen == 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (lpSrc == NULL) {
|
|
|
|
lpDest[0] = '\0';
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-11-07 21:29:46 +01:00
|
|
|
len = strlen(lpSrc) + 1;
|
2006-11-02 10:25:01 +01:00
|
|
|
if (len >= nMaxLen)
|
2006-11-07 21:29:46 +01:00
|
|
|
len = nMaxLen;
|
2006-11-02 10:25:01 +01:00
|
|
|
|
2006-11-07 21:29:46 +01:00
|
|
|
RtlMoveMemory (lpDest, lpSrc, len - 1);
|
|
|
|
lpDest[len - 1] = '\0';
|
2006-11-02 10:25:01 +01:00
|
|
|
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* Str_SetPtrA [COMCTL32.234]
|
|
|
|
*
|
|
|
|
* Makes a copy of a string, allocating memory if necessary.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* lppDest [O] Pointer to destination string
|
|
|
|
* lpSrc [I] Source string
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE
|
|
|
|
* Failure: FALSE
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* Set lpSrc to NULL to free the memory allocated by a previous call
|
|
|
|
* to this function.
|
|
|
|
*/
|
|
|
|
BOOL WINAPI Str_SetPtrA (LPSTR *lppDest, LPCSTR lpSrc)
|
|
|
|
{
|
|
|
|
TRACE("(%p %p)\n", lppDest, lpSrc);
|
|
|
|
|
|
|
|
if (lpSrc) {
|
|
|
|
LPSTR ptr = ReAlloc (*lppDest, strlen (lpSrc) + 1);
|
|
|
|
if (!ptr)
|
|
|
|
return FALSE;
|
|
|
|
strcpy (ptr, lpSrc);
|
|
|
|
*lppDest = ptr;
|
|
|
|
}
|
|
|
|
else {
|
2007-03-07 21:55:31 +01:00
|
|
|
Free (*lppDest);
|
|
|
|
*lppDest = NULL;
|
2006-11-02 10:25:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* Str_GetPtrW [COMCTL32.235]
|
|
|
|
*
|
|
|
|
* See Str_GetPtrA.
|
|
|
|
*/
|
|
|
|
INT WINAPI Str_GetPtrW (LPCWSTR lpSrc, LPWSTR lpDest, INT nMaxLen)
|
|
|
|
{
|
|
|
|
INT len;
|
|
|
|
|
|
|
|
TRACE("(%p %p %d)\n", lpSrc, lpDest, nMaxLen);
|
|
|
|
|
|
|
|
if (!lpDest && lpSrc)
|
2019-05-29 08:44:58 +02:00
|
|
|
return lstrlenW (lpSrc);
|
2006-11-02 10:25:01 +01:00
|
|
|
|
|
|
|
if (nMaxLen == 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (lpSrc == NULL) {
|
2007-06-21 22:58:50 +02:00
|
|
|
lpDest[0] = '\0';
|
2006-11-02 10:25:01 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-05-29 08:44:58 +02:00
|
|
|
len = lstrlenW (lpSrc);
|
2006-11-02 10:25:01 +01:00
|
|
|
if (len >= nMaxLen)
|
|
|
|
len = nMaxLen - 1;
|
|
|
|
|
|
|
|
RtlMoveMemory (lpDest, lpSrc, len*sizeof(WCHAR));
|
2007-06-21 22:58:50 +02:00
|
|
|
lpDest[len] = '\0';
|
2006-11-02 10:25:01 +01:00
|
|
|
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* Str_SetPtrW [COMCTL32.236]
|
|
|
|
*
|
|
|
|
* See Str_SetPtrA.
|
|
|
|
*/
|
|
|
|
BOOL WINAPI Str_SetPtrW (LPWSTR *lppDest, LPCWSTR lpSrc)
|
|
|
|
{
|
2010-05-18 12:47:25 +02:00
|
|
|
TRACE("(%p %s)\n", lppDest, debugstr_w(lpSrc));
|
2006-11-02 10:25:01 +01:00
|
|
|
|
|
|
|
if (lpSrc) {
|
2019-05-29 08:44:58 +02:00
|
|
|
INT len = lstrlenW (lpSrc) + 1;
|
2006-11-02 10:25:01 +01:00
|
|
|
LPWSTR ptr = ReAlloc (*lppDest, len * sizeof(WCHAR));
|
|
|
|
if (!ptr)
|
|
|
|
return FALSE;
|
2019-05-29 08:44:58 +02:00
|
|
|
lstrcpyW (ptr, lpSrc);
|
2006-11-02 10:25:01 +01:00
|
|
|
*lppDest = ptr;
|
|
|
|
}
|
|
|
|
else {
|
2007-03-07 21:55:31 +01:00
|
|
|
Free (*lppDest);
|
|
|
|
*lppDest = NULL;
|
2006-11-02 10:25:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-02-17 22:02:18 +01:00
|
|
|
/**************************************************************************
|
|
|
|
* StrChrA [COMCTL32.350]
|
|
|
|
*
|
|
|
|
* Find a given character in a string.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* lpszStr [I] String to search in.
|
|
|
|
* ch [I] Character to search for.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: A pointer to the first occurrence of ch in lpszStr, or NULL if
|
|
|
|
* not found.
|
|
|
|
* Failure: NULL, if any arguments are invalid.
|
|
|
|
*/
|
2004-02-20 06:16:37 +01:00
|
|
|
LPSTR WINAPI StrChrA(LPCSTR lpszStr, WORD ch)
|
2004-02-17 22:02:18 +01:00
|
|
|
{
|
2004-02-20 06:16:37 +01:00
|
|
|
TRACE("(%s,%i)\n", debugstr_a(lpszStr), ch);
|
|
|
|
|
|
|
|
if (lpszStr)
|
|
|
|
{
|
|
|
|
while (*lpszStr)
|
|
|
|
{
|
|
|
|
if (!COMCTL32_ChrCmpA(*lpszStr, ch))
|
|
|
|
return (LPSTR)lpszStr;
|
|
|
|
lpszStr = CharNextA(lpszStr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2005-11-04 12:14:52 +01:00
|
|
|
/**************************************************************************
|
|
|
|
* StrCmpNIA [COMCTL32.353]
|
|
|
|
*
|
|
|
|
* Compare two strings, up to a maximum length, ignoring case.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* lpszStr [I] First string to compare
|
|
|
|
* lpszComp [I] Second string to compare
|
2014-11-17 09:10:39 +01:00
|
|
|
* iLen [I] Number of chars to compare
|
2005-11-04 12:14:52 +01:00
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* An integer less than, equal to or greater than 0, indicating that
|
|
|
|
* lpszStr is less than, the same, or greater than lpszComp.
|
|
|
|
*/
|
|
|
|
INT WINAPI StrCmpNIA(LPCSTR lpszStr, LPCSTR lpszComp, INT iLen)
|
|
|
|
{
|
|
|
|
TRACE("(%s,%s,%i)\n", debugstr_a(lpszStr), debugstr_a(lpszComp), iLen);
|
2012-06-20 23:40:13 +02:00
|
|
|
return CompareStringA(GetThreadLocale(), NORM_IGNORECASE, lpszStr, iLen, lpszComp, iLen) - CSTR_EQUAL;
|
2005-11-04 12:14:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* StrCmpNIW [COMCTL32.361]
|
|
|
|
*
|
|
|
|
* See StrCmpNIA.
|
|
|
|
*/
|
|
|
|
INT WINAPI StrCmpNIW(LPCWSTR lpszStr, LPCWSTR lpszComp, INT iLen)
|
|
|
|
{
|
|
|
|
TRACE("(%s,%s,%i)\n", debugstr_w(lpszStr), debugstr_w(lpszComp), iLen);
|
2012-06-20 23:40:13 +02:00
|
|
|
return CompareStringW(GetThreadLocale(), NORM_IGNORECASE, lpszStr, iLen, lpszComp, iLen) - CSTR_EQUAL;
|
2005-11-04 12:14:52 +01:00
|
|
|
}
|
|
|
|
|
2004-02-20 06:16:37 +01:00
|
|
|
/*************************************************************************
|
|
|
|
* COMCTL32_StrStrHelperA
|
|
|
|
*
|
|
|
|
* Internal implementation of StrStrA/StrStrIA
|
|
|
|
*/
|
|
|
|
static LPSTR COMCTL32_StrStrHelperA(LPCSTR lpszStr, LPCSTR lpszSearch,
|
2005-11-03 20:31:59 +01:00
|
|
|
INT (WINAPI *pStrCmpFn)(LPCSTR,LPCSTR,INT))
|
2004-02-20 06:16:37 +01:00
|
|
|
{
|
|
|
|
size_t iLen;
|
2014-11-17 09:10:39 +01:00
|
|
|
LPCSTR end;
|
2004-02-20 06:16:37 +01:00
|
|
|
|
|
|
|
if (!lpszStr || !lpszSearch || !*lpszSearch)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
iLen = strlen(lpszSearch);
|
2014-11-17 09:10:39 +01:00
|
|
|
end = lpszStr + strlen(lpszStr);
|
2004-02-20 06:16:37 +01:00
|
|
|
|
2014-11-17 09:10:39 +01:00
|
|
|
while (lpszStr + iLen <= end)
|
2004-02-20 06:16:37 +01:00
|
|
|
{
|
|
|
|
if (!pStrCmpFn(lpszStr, lpszSearch, iLen))
|
|
|
|
return (LPSTR)lpszStr;
|
|
|
|
lpszStr = CharNextA(lpszStr);
|
|
|
|
}
|
|
|
|
return NULL;
|
2004-02-17 22:02:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* StrStrIA [COMCTL32.355]
|
|
|
|
*
|
|
|
|
* Find a substring within a string, ignoring case.
|
|
|
|
*
|
|
|
|
* PARAMS
|
2004-02-20 06:16:37 +01:00
|
|
|
* lpszStr [I] String to search in
|
|
|
|
* lpszSearch [I] String to look for
|
2004-02-17 22:02:18 +01:00
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* The start of lpszSearch within lpszStr, or NULL if not found.
|
|
|
|
*/
|
2004-02-20 06:16:37 +01:00
|
|
|
LPSTR WINAPI StrStrIA(LPCSTR lpszStr, LPCSTR lpszSearch)
|
|
|
|
{
|
|
|
|
TRACE("(%s,%s)\n", debugstr_a(lpszStr), debugstr_a(lpszSearch));
|
|
|
|
|
2005-11-03 20:31:59 +01:00
|
|
|
return COMCTL32_StrStrHelperA(lpszStr, lpszSearch, StrCmpNIA);
|
2004-02-17 22:02:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* StrToIntA [COMCTL32.357]
|
|
|
|
*
|
|
|
|
* Read a signed integer from a string.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* lpszStr [I] String to read integer from
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* The signed integer value represented by the string, or 0 if no integer is
|
|
|
|
* present.
|
|
|
|
*/
|
2007-03-31 18:44:32 +02:00
|
|
|
INT WINAPI StrToIntA (LPCSTR lpszStr)
|
2004-02-17 22:02:18 +01:00
|
|
|
{
|
|
|
|
return atoi(lpszStr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* StrStrIW [COMCTL32.363]
|
|
|
|
*
|
|
|
|
* See StrStrIA.
|
|
|
|
*/
|
2004-02-20 06:16:37 +01:00
|
|
|
LPWSTR WINAPI StrStrIW(LPCWSTR lpszStr, LPCWSTR lpszSearch)
|
|
|
|
{
|
2007-06-25 13:51:00 +02:00
|
|
|
int iLen;
|
2014-11-17 09:10:39 +01:00
|
|
|
LPCWSTR end;
|
2007-06-25 13:51:00 +02:00
|
|
|
|
2004-02-20 06:16:37 +01:00
|
|
|
TRACE("(%s,%s)\n", debugstr_w(lpszStr), debugstr_w(lpszSearch));
|
|
|
|
|
2007-06-25 13:51:00 +02:00
|
|
|
if (!lpszStr || !lpszSearch || !*lpszSearch)
|
|
|
|
return NULL;
|
|
|
|
|
2019-05-29 08:44:58 +02:00
|
|
|
iLen = lstrlenW(lpszSearch);
|
|
|
|
end = lpszStr + lstrlenW(lpszStr);
|
2007-06-25 13:51:00 +02:00
|
|
|
|
2014-11-17 09:10:39 +01:00
|
|
|
while (lpszStr + iLen <= end)
|
2007-06-25 13:51:00 +02:00
|
|
|
{
|
|
|
|
if (!StrCmpNIW(lpszStr, lpszSearch, iLen))
|
|
|
|
return (LPWSTR)lpszStr;
|
|
|
|
lpszStr++;
|
|
|
|
}
|
|
|
|
return NULL;
|
2004-02-17 22:02:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* StrToIntW [COMCTL32.365]
|
|
|
|
*
|
|
|
|
* See StrToIntA.
|
|
|
|
*/
|
2007-03-31 18:44:32 +02:00
|
|
|
INT WINAPI StrToIntW (LPCWSTR lpString)
|
2004-02-17 22:02:18 +01:00
|
|
|
{
|
2019-05-29 08:44:58 +02:00
|
|
|
return wcstol(lpString, NULL, 10);
|
2004-02-17 22:02:18 +01:00
|
|
|
}
|
|
|
|
|
2004-02-20 06:16:37 +01:00
|
|
|
/*************************************************************************
|
|
|
|
* COMCTL32_StrSpnHelperA (internal)
|
|
|
|
*
|
|
|
|
* Internal implementation of StrSpnA/StrCSpnA/StrCSpnIA
|
|
|
|
*/
|
|
|
|
static int COMCTL32_StrSpnHelperA(LPCSTR lpszStr, LPCSTR lpszMatch,
|
|
|
|
LPSTR (WINAPI *pStrChrFn)(LPCSTR,WORD),
|
|
|
|
BOOL bInvert)
|
|
|
|
{
|
|
|
|
LPCSTR lpszRead = lpszStr;
|
|
|
|
if (lpszStr && *lpszStr && lpszMatch)
|
|
|
|
{
|
|
|
|
while (*lpszRead)
|
|
|
|
{
|
|
|
|
LPCSTR lpszTest = pStrChrFn(lpszMatch, *lpszRead);
|
|
|
|
|
|
|
|
if (!bInvert && !lpszTest)
|
|
|
|
break;
|
|
|
|
if (bInvert && lpszTest)
|
|
|
|
break;
|
|
|
|
lpszRead = CharNextA(lpszRead);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
return lpszRead - lpszStr;
|
|
|
|
}
|
|
|
|
|
2004-02-17 22:02:18 +01:00
|
|
|
/**************************************************************************
|
|
|
|
* StrCSpnA [COMCTL32.356]
|
|
|
|
*
|
|
|
|
* Find the length of the start of a string that does not contain certain
|
|
|
|
* characters.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* lpszStr [I] String to search
|
|
|
|
* lpszMatch [I] Characters that cannot be in the substring
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* The length of the part of lpszStr containing only chars not in lpszMatch,
|
|
|
|
* or 0 if any parameter is invalid.
|
|
|
|
*/
|
2004-02-20 06:16:37 +01:00
|
|
|
int WINAPI StrCSpnA(LPCSTR lpszStr, LPCSTR lpszMatch)
|
2004-02-17 22:02:18 +01:00
|
|
|
{
|
2004-02-20 06:16:37 +01:00
|
|
|
TRACE("(%s,%s)\n",debugstr_a(lpszStr), debugstr_a(lpszMatch));
|
|
|
|
|
|
|
|
return COMCTL32_StrSpnHelperA(lpszStr, lpszMatch, StrChrA, TRUE);
|
2004-02-17 22:02:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* StrChrW [COMCTL32.358]
|
|
|
|
*
|
|
|
|
* See StrChrA.
|
|
|
|
*/
|
2004-02-20 06:16:37 +01:00
|
|
|
LPWSTR WINAPI StrChrW(LPCWSTR lpszStr, WCHAR ch)
|
2004-02-17 22:02:18 +01:00
|
|
|
{
|
2004-02-20 06:16:37 +01:00
|
|
|
LPWSTR lpszRet = NULL;
|
|
|
|
|
|
|
|
TRACE("(%s,%i)\n", debugstr_w(lpszStr), ch);
|
|
|
|
|
|
|
|
if (lpszStr)
|
2019-05-29 08:44:58 +02:00
|
|
|
lpszRet = wcschr(lpszStr, ch);
|
2004-02-20 06:16:37 +01:00
|
|
|
return lpszRet;
|
2004-02-17 22:02:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* StrCmpNA [COMCTL32.352]
|
|
|
|
*
|
|
|
|
* Compare two strings, up to a maximum length.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* lpszStr [I] First string to compare
|
|
|
|
* lpszComp [I] Second string to compare
|
2014-11-17 09:10:39 +01:00
|
|
|
* iLen [I] Number of chars to compare
|
2004-02-17 22:02:18 +01:00
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* An integer less than, equal to or greater than 0, indicating that
|
|
|
|
* lpszStr is less than, the same, or greater than lpszComp.
|
|
|
|
*/
|
2004-02-20 06:16:37 +01:00
|
|
|
INT WINAPI StrCmpNA(LPCSTR lpszStr, LPCSTR lpszComp, INT iLen)
|
2004-02-17 22:02:18 +01:00
|
|
|
{
|
2004-02-20 06:16:37 +01:00
|
|
|
TRACE("(%s,%s,%i)\n", debugstr_a(lpszStr), debugstr_a(lpszComp), iLen);
|
2012-06-20 23:40:13 +02:00
|
|
|
return CompareStringA(GetThreadLocale(), 0, lpszStr, iLen, lpszComp, iLen) - CSTR_EQUAL;
|
2004-02-17 22:02:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2004-02-20 06:16:37 +01:00
|
|
|
* StrCmpNW [COMCTL32.360]
|
2004-02-17 22:02:18 +01:00
|
|
|
*
|
2004-02-20 06:16:37 +01:00
|
|
|
* See StrCmpNA.
|
2004-02-17 22:02:18 +01:00
|
|
|
*/
|
2004-02-20 06:16:37 +01:00
|
|
|
INT WINAPI StrCmpNW(LPCWSTR lpszStr, LPCWSTR lpszComp, INT iLen)
|
2004-02-17 22:02:18 +01:00
|
|
|
{
|
2004-02-20 06:16:37 +01:00
|
|
|
TRACE("(%s,%s,%i)\n", debugstr_w(lpszStr), debugstr_w(lpszComp), iLen);
|
2012-06-20 23:40:13 +02:00
|
|
|
return CompareStringW(GetThreadLocale(), 0, lpszStr, iLen, lpszComp, iLen) - CSTR_EQUAL;
|
2004-02-17 22:02:18 +01:00
|
|
|
}
|
|
|
|
|
2004-02-20 20:58:39 +01:00
|
|
|
/**************************************************************************
|
|
|
|
* StrRChrA [COMCTL32.351]
|
|
|
|
*
|
2005-02-25 15:07:56 +01:00
|
|
|
* Find the last occurrence of a character in string.
|
2004-02-17 22:02:18 +01:00
|
|
|
*
|
2004-02-20 20:58:39 +01:00
|
|
|
* PARAMS
|
|
|
|
* lpszStr [I] String to search in
|
|
|
|
* lpszEnd [I] Place to end search, or NULL to search until the end of lpszStr
|
|
|
|
* ch [I] Character to search for.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: A pointer to the last occurrence of ch in lpszStr before lpszEnd,
|
|
|
|
* or NULL if not found.
|
|
|
|
* Failure: NULL, if any arguments are invalid.
|
2004-02-17 22:02:18 +01:00
|
|
|
*/
|
2004-02-20 20:58:39 +01:00
|
|
|
LPSTR WINAPI StrRChrA(LPCSTR lpszStr, LPCSTR lpszEnd, WORD ch)
|
2004-02-17 22:02:18 +01:00
|
|
|
{
|
2004-02-20 06:16:37 +01:00
|
|
|
LPCSTR lpszRet = NULL;
|
2004-02-17 22:02:18 +01:00
|
|
|
|
2004-02-20 20:58:39 +01:00
|
|
|
TRACE("(%s,%s,%x)\n", debugstr_a(lpszStr), debugstr_a(lpszEnd), ch);
|
|
|
|
|
2004-02-20 06:16:37 +01:00
|
|
|
if (lpszStr)
|
|
|
|
{
|
|
|
|
WORD ch2;
|
2004-02-17 22:02:18 +01:00
|
|
|
|
2004-02-20 06:16:37 +01:00
|
|
|
if (!lpszEnd)
|
|
|
|
lpszEnd = lpszStr + lstrlenA(lpszStr);
|
2004-02-17 22:02:18 +01:00
|
|
|
|
2004-02-20 06:16:37 +01:00
|
|
|
while (*lpszStr && lpszStr <= lpszEnd)
|
2004-02-17 22:02:18 +01:00
|
|
|
{
|
2004-02-20 06:16:37 +01:00
|
|
|
ch2 = IsDBCSLeadByte(*lpszStr)? *lpszStr << 8 | lpszStr[1] : *lpszStr;
|
|
|
|
|
2004-02-20 20:58:39 +01:00
|
|
|
if (!COMCTL32_ChrCmpA(ch, ch2))
|
2004-02-20 06:16:37 +01:00
|
|
|
lpszRet = lpszStr;
|
|
|
|
lpszStr = CharNextA(lpszStr);
|
2004-02-17 22:02:18 +01:00
|
|
|
}
|
2004-02-20 06:16:37 +01:00
|
|
|
}
|
|
|
|
return (LPSTR)lpszRet;
|
2004-02-17 22:02:18 +01:00
|
|
|
}
|
|
|
|
|
2004-02-20 20:58:39 +01:00
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* StrRChrW [COMCTL32.359]
|
2004-02-20 06:16:37 +01:00
|
|
|
*
|
2004-02-20 20:58:39 +01:00
|
|
|
* See StrRChrA.
|
2004-02-20 06:16:37 +01:00
|
|
|
*/
|
2007-06-25 13:51:00 +02:00
|
|
|
LPWSTR WINAPI StrRChrW(LPCWSTR str, LPCWSTR end, WORD ch)
|
2004-02-20 06:16:37 +01:00
|
|
|
{
|
2007-06-25 13:51:00 +02:00
|
|
|
WCHAR *ret = NULL;
|
2004-02-20 06:16:37 +01:00
|
|
|
|
2007-06-25 13:51:00 +02:00
|
|
|
if (!str) return NULL;
|
2019-05-29 08:44:58 +02:00
|
|
|
if (!end) end = str + lstrlenW(str);
|
2007-06-25 13:51:00 +02:00
|
|
|
while (str < end)
|
2004-02-20 06:16:37 +01:00
|
|
|
{
|
2007-06-25 13:51:00 +02:00
|
|
|
if (*str == ch) ret = (WCHAR *)str;
|
|
|
|
str++;
|
2004-02-20 06:16:37 +01:00
|
|
|
}
|
2007-06-25 13:51:00 +02:00
|
|
|
return ret;
|
2004-02-20 06:16:37 +01:00
|
|
|
}
|
2004-02-17 22:02:18 +01:00
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* StrStrA [COMCTL32.354]
|
|
|
|
*
|
2004-02-20 06:16:37 +01:00
|
|
|
* Find a substring within a string.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* lpszStr [I] String to search in
|
|
|
|
* lpszSearch [I] String to look for
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* The start of lpszSearch within lpszStr, or NULL if not found.
|
2004-02-17 22:02:18 +01:00
|
|
|
*/
|
2004-02-20 06:16:37 +01:00
|
|
|
LPSTR WINAPI StrStrA(LPCSTR lpszStr, LPCSTR lpszSearch)
|
2004-02-17 22:02:18 +01:00
|
|
|
{
|
2004-02-20 06:16:37 +01:00
|
|
|
TRACE("(%s,%s)\n", debugstr_a(lpszStr), debugstr_a(lpszSearch));
|
|
|
|
|
2005-11-03 20:31:59 +01:00
|
|
|
return COMCTL32_StrStrHelperA(lpszStr, lpszSearch, StrCmpNA);
|
2004-02-17 22:02:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* StrStrW [COMCTL32.362]
|
|
|
|
*
|
2004-02-20 06:16:37 +01:00
|
|
|
* See StrStrA.
|
2004-02-17 22:02:18 +01:00
|
|
|
*/
|
2004-02-20 06:16:37 +01:00
|
|
|
LPWSTR WINAPI StrStrW(LPCWSTR lpszStr, LPCWSTR lpszSearch)
|
2004-02-17 22:02:18 +01:00
|
|
|
{
|
2007-06-25 13:51:00 +02:00
|
|
|
if (!lpszStr || !lpszSearch) return NULL;
|
2019-05-29 08:44:58 +02:00
|
|
|
return wcsstr( lpszStr, lpszSearch );
|
2004-02-20 06:16:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* StrChrIA [COMCTL32.366]
|
|
|
|
*
|
|
|
|
* Find a given character in a string, ignoring case.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* lpszStr [I] String to search in.
|
|
|
|
* ch [I] Character to search for.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: A pointer to the first occurrence of ch in lpszStr, or NULL if
|
|
|
|
* not found.
|
|
|
|
* Failure: NULL, if any arguments are invalid.
|
|
|
|
*/
|
|
|
|
LPSTR WINAPI StrChrIA(LPCSTR lpszStr, WORD ch)
|
|
|
|
{
|
|
|
|
TRACE("(%s,%i)\n", debugstr_a(lpszStr), ch);
|
|
|
|
|
|
|
|
if (lpszStr)
|
|
|
|
{
|
|
|
|
while (*lpszStr)
|
|
|
|
{
|
|
|
|
if (!COMCTL32_ChrCmpIA(*lpszStr, ch))
|
|
|
|
return (LPSTR)lpszStr;
|
|
|
|
lpszStr = CharNextA(lpszStr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* StrChrIW [COMCTL32.367]
|
|
|
|
*
|
|
|
|
* See StrChrA.
|
|
|
|
*/
|
|
|
|
LPWSTR WINAPI StrChrIW(LPCWSTR lpszStr, WCHAR ch)
|
|
|
|
{
|
|
|
|
TRACE("(%s,%i)\n", debugstr_w(lpszStr), ch);
|
|
|
|
|
|
|
|
if (lpszStr)
|
|
|
|
{
|
2019-05-29 08:44:58 +02:00
|
|
|
ch = towupper(ch);
|
2004-02-20 06:16:37 +01:00
|
|
|
while (*lpszStr)
|
|
|
|
{
|
2019-05-29 08:44:58 +02:00
|
|
|
if (towupper(*lpszStr) == ch)
|
2004-02-20 06:16:37 +01:00
|
|
|
return (LPWSTR)lpszStr;
|
2007-06-25 13:51:00 +02:00
|
|
|
lpszStr++;
|
2004-02-20 06:16:37 +01:00
|
|
|
}
|
|
|
|
lpszStr = NULL;
|
|
|
|
}
|
|
|
|
return (LPWSTR)lpszStr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* StrRStrIA [COMCTL32.372]
|
|
|
|
*
|
2005-02-25 15:07:56 +01:00
|
|
|
* Find the last occurrence of a substring within a string.
|
2004-02-20 06:16:37 +01:00
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* lpszStr [I] String to search in
|
|
|
|
* lpszEnd [I] End of lpszStr
|
|
|
|
* lpszSearch [I] String to look for
|
|
|
|
*
|
|
|
|
* RETURNS
|
2005-02-25 15:07:56 +01:00
|
|
|
* The last occurrence lpszSearch within lpszStr, or NULL if not found.
|
2004-02-20 06:16:37 +01:00
|
|
|
*/
|
|
|
|
LPSTR WINAPI StrRStrIA(LPCSTR lpszStr, LPCSTR lpszEnd, LPCSTR lpszSearch)
|
|
|
|
{
|
|
|
|
LPSTR lpszRet = NULL;
|
|
|
|
WORD ch1, ch2;
|
|
|
|
INT iLen;
|
|
|
|
|
|
|
|
TRACE("(%s,%s)\n", debugstr_a(lpszStr), debugstr_a(lpszSearch));
|
|
|
|
|
|
|
|
if (!lpszStr || !lpszSearch || !*lpszSearch)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (IsDBCSLeadByte(*lpszSearch))
|
2014-11-19 08:36:22 +01:00
|
|
|
ch1 = *lpszSearch << 8 | (UCHAR)lpszSearch[1];
|
2004-02-20 06:16:37 +01:00
|
|
|
else
|
|
|
|
ch1 = *lpszSearch;
|
|
|
|
iLen = lstrlenA(lpszSearch);
|
|
|
|
|
2014-11-19 08:36:22 +01:00
|
|
|
if (!lpszEnd)
|
|
|
|
lpszEnd = lpszStr + lstrlenA(lpszStr);
|
|
|
|
else /* reproduce the broken behaviour on Windows */
|
|
|
|
lpszEnd += min(iLen - 1, lstrlenA(lpszEnd));
|
|
|
|
|
2014-11-18 06:51:00 +01:00
|
|
|
while (lpszStr + iLen <= lpszEnd && *lpszStr)
|
2004-02-20 06:16:37 +01:00
|
|
|
{
|
2014-11-19 08:36:22 +01:00
|
|
|
ch2 = IsDBCSLeadByte(*lpszStr)? *lpszStr << 8 | (UCHAR)lpszStr[1] : *lpszStr;
|
2004-02-20 06:16:37 +01:00
|
|
|
if (!COMCTL32_ChrCmpIA(ch1, ch2))
|
|
|
|
{
|
|
|
|
if (!StrCmpNIA(lpszStr, lpszSearch, iLen))
|
|
|
|
lpszRet = (LPSTR)lpszStr;
|
|
|
|
}
|
|
|
|
lpszStr = CharNextA(lpszStr);
|
|
|
|
}
|
|
|
|
return lpszRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* StrRStrIW [COMCTL32.373]
|
|
|
|
*
|
|
|
|
* See StrRStrIA.
|
|
|
|
*/
|
|
|
|
LPWSTR WINAPI StrRStrIW(LPCWSTR lpszStr, LPCWSTR lpszEnd, LPCWSTR lpszSearch)
|
|
|
|
{
|
|
|
|
LPWSTR lpszRet = NULL;
|
|
|
|
INT iLen;
|
|
|
|
|
|
|
|
TRACE("(%s,%s)\n", debugstr_w(lpszStr), debugstr_w(lpszSearch));
|
|
|
|
|
|
|
|
if (!lpszStr || !lpszSearch || !*lpszSearch)
|
|
|
|
return NULL;
|
|
|
|
|
2019-05-29 08:44:58 +02:00
|
|
|
iLen = lstrlenW(lpszSearch);
|
2014-11-19 08:36:22 +01:00
|
|
|
|
2004-02-20 06:16:37 +01:00
|
|
|
if (!lpszEnd)
|
2019-05-29 08:44:58 +02:00
|
|
|
lpszEnd = lpszStr + lstrlenW(lpszStr);
|
2014-11-19 08:36:22 +01:00
|
|
|
else /* reproduce the broken behaviour on Windows */
|
|
|
|
lpszEnd += min(iLen - 1, lstrlenW(lpszEnd));
|
2004-02-20 06:16:37 +01:00
|
|
|
|
|
|
|
|
2014-11-18 06:51:00 +01:00
|
|
|
while (lpszStr + iLen <= lpszEnd && *lpszStr)
|
2004-02-20 06:16:37 +01:00
|
|
|
{
|
2004-09-22 21:10:27 +02:00
|
|
|
if (!COMCTL32_ChrCmpIW(*lpszSearch, *lpszStr))
|
2004-02-20 06:16:37 +01:00
|
|
|
{
|
|
|
|
if (!StrCmpNIW(lpszStr, lpszSearch, iLen))
|
|
|
|
lpszRet = (LPWSTR)lpszStr;
|
|
|
|
}
|
2007-06-25 13:51:00 +02:00
|
|
|
lpszStr++;
|
2004-02-20 06:16:37 +01:00
|
|
|
}
|
|
|
|
return lpszRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* StrCSpnIA [COMCTL32.374]
|
|
|
|
*
|
|
|
|
* Find the length of the start of a string that does not contain certain
|
|
|
|
* characters, ignoring case.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* lpszStr [I] String to search
|
|
|
|
* lpszMatch [I] Characters that cannot be in the substring
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* The length of the part of lpszStr containing only chars not in lpszMatch,
|
|
|
|
* or 0 if any parameter is invalid.
|
|
|
|
*/
|
|
|
|
int WINAPI StrCSpnIA(LPCSTR lpszStr, LPCSTR lpszMatch)
|
|
|
|
{
|
|
|
|
TRACE("(%s,%s)\n",debugstr_a(lpszStr), debugstr_a(lpszMatch));
|
|
|
|
|
|
|
|
return COMCTL32_StrSpnHelperA(lpszStr, lpszMatch, StrChrIA, TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* StrCSpnIW [COMCTL32.375]
|
|
|
|
*
|
|
|
|
* See StrCSpnIA.
|
|
|
|
*/
|
|
|
|
int WINAPI StrCSpnIW(LPCWSTR lpszStr, LPCWSTR lpszMatch)
|
|
|
|
{
|
2007-06-25 13:51:00 +02:00
|
|
|
LPCWSTR lpszRead = lpszStr;
|
|
|
|
|
2004-02-20 06:16:37 +01:00
|
|
|
TRACE("(%s,%s)\n",debugstr_w(lpszStr), debugstr_w(lpszMatch));
|
|
|
|
|
2007-06-25 13:51:00 +02:00
|
|
|
if (lpszStr && *lpszStr && lpszMatch)
|
|
|
|
{
|
|
|
|
while (*lpszRead)
|
|
|
|
{
|
|
|
|
if (StrChrIW(lpszMatch, *lpszRead)) break;
|
|
|
|
lpszRead++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return lpszRead - lpszStr;
|
2004-02-20 06:16:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* StrRChrIA [COMCTL32.368]
|
|
|
|
*
|
2005-02-25 15:07:56 +01:00
|
|
|
* Find the last occurrence of a character in string, ignoring case.
|
2004-02-20 06:16:37 +01:00
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* lpszStr [I] String to search in
|
|
|
|
* lpszEnd [I] Place to end search, or NULL to search until the end of lpszStr
|
|
|
|
* ch [I] Character to search for.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: A pointer to the last occurrence of ch in lpszStr before lpszEnd,
|
|
|
|
* or NULL if not found.
|
|
|
|
* Failure: NULL, if any arguments are invalid.
|
|
|
|
*/
|
|
|
|
LPSTR WINAPI StrRChrIA(LPCSTR lpszStr, LPCSTR lpszEnd, WORD ch)
|
|
|
|
{
|
|
|
|
LPCSTR lpszRet = NULL;
|
|
|
|
|
|
|
|
TRACE("(%s,%s,%x)\n", debugstr_a(lpszStr), debugstr_a(lpszEnd), ch);
|
|
|
|
|
|
|
|
if (lpszStr)
|
|
|
|
{
|
|
|
|
WORD ch2;
|
|
|
|
|
|
|
|
if (!lpszEnd)
|
|
|
|
lpszEnd = lpszStr + lstrlenA(lpszStr);
|
|
|
|
|
|
|
|
while (*lpszStr && lpszStr <= lpszEnd)
|
|
|
|
{
|
|
|
|
ch2 = IsDBCSLeadByte(*lpszStr)? *lpszStr << 8 | lpszStr[1] : *lpszStr;
|
|
|
|
|
|
|
|
if (ch == ch2)
|
|
|
|
lpszRet = lpszStr;
|
|
|
|
lpszStr = CharNextA(lpszStr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return (LPSTR)lpszRet;
|
2004-02-17 22:02:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2004-02-20 06:16:37 +01:00
|
|
|
* StrRChrIW [COMCTL32.369]
|
2004-02-17 22:02:18 +01:00
|
|
|
*
|
2004-02-20 06:16:37 +01:00
|
|
|
* See StrRChrIA.
|
2004-02-17 22:02:18 +01:00
|
|
|
*/
|
2007-06-25 13:51:00 +02:00
|
|
|
LPWSTR WINAPI StrRChrIW(LPCWSTR str, LPCWSTR end, WORD ch)
|
2004-02-17 22:02:18 +01:00
|
|
|
{
|
2007-06-25 13:51:00 +02:00
|
|
|
WCHAR *ret = NULL;
|
2004-02-20 06:16:37 +01:00
|
|
|
|
2007-06-25 13:51:00 +02:00
|
|
|
if (!str) return NULL;
|
2019-05-29 08:44:58 +02:00
|
|
|
if (!end) end = str + lstrlenW(str);
|
2007-06-25 13:51:00 +02:00
|
|
|
while (str < end)
|
2004-02-20 06:16:37 +01:00
|
|
|
{
|
2007-06-25 13:51:00 +02:00
|
|
|
if (!COMCTL32_ChrCmpIW(*str, ch)) ret = (WCHAR *)str;
|
|
|
|
str++;
|
2004-02-20 06:16:37 +01:00
|
|
|
}
|
2007-06-25 13:51:00 +02:00
|
|
|
return ret;
|
2004-02-20 06:16:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
2004-05-17 22:51:27 +02:00
|
|
|
* StrCSpnW [COMCTL32.364]
|
2004-02-20 06:16:37 +01:00
|
|
|
*
|
|
|
|
* See StrCSpnA.
|
|
|
|
*/
|
|
|
|
int WINAPI StrCSpnW(LPCWSTR lpszStr, LPCWSTR lpszMatch)
|
|
|
|
{
|
2007-06-25 13:51:00 +02:00
|
|
|
if (!lpszStr || !lpszMatch) return 0;
|
2019-05-29 08:44:58 +02:00
|
|
|
return wcscspn( lpszStr, lpszMatch );
|
2004-02-20 06:16:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* IntlStrEqWorkerA [COMCTL32.376]
|
|
|
|
*
|
|
|
|
* Compare two strings.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* bCase [I] Whether to compare case sensitively
|
|
|
|
* lpszStr [I] First string to compare
|
|
|
|
* lpszComp [I] Second string to compare
|
|
|
|
* iLen [I] Length to compare
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* TRUE If the strings are equal.
|
|
|
|
* FALSE Otherwise.
|
|
|
|
*/
|
|
|
|
BOOL WINAPI IntlStrEqWorkerA(BOOL bCase, LPCSTR lpszStr, LPCSTR lpszComp,
|
|
|
|
int iLen)
|
|
|
|
{
|
2014-10-31 03:12:23 +01:00
|
|
|
DWORD dwFlags;
|
2004-02-20 06:16:37 +01:00
|
|
|
int iRet;
|
|
|
|
|
|
|
|
TRACE("(%d,%s,%s,%d)\n", bCase,
|
|
|
|
debugstr_a(lpszStr), debugstr_a(lpszComp), iLen);
|
|
|
|
|
2012-06-20 23:40:13 +02:00
|
|
|
/* FIXME: This flag is undocumented and unknown by our CompareString.
|
2004-02-20 06:16:37 +01:00
|
|
|
*/
|
2014-10-31 03:12:23 +01:00
|
|
|
dwFlags = LOCALE_RETURN_GENITIVE_NAMES;
|
2012-06-20 23:40:13 +02:00
|
|
|
if (!bCase) dwFlags |= NORM_IGNORECASE;
|
2004-02-20 06:16:37 +01:00
|
|
|
|
|
|
|
iRet = CompareStringA(GetThreadLocale(),
|
|
|
|
dwFlags, lpszStr, iLen, lpszComp, iLen);
|
|
|
|
|
|
|
|
if (!iRet)
|
|
|
|
iRet = CompareStringA(2048, dwFlags, lpszStr, iLen, lpszComp, iLen);
|
|
|
|
|
2012-06-20 23:40:13 +02:00
|
|
|
return iRet == CSTR_EQUAL;
|
2004-02-20 06:16:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* IntlStrEqWorkerW [COMCTL32.377]
|
|
|
|
*
|
|
|
|
* See IntlStrEqWorkerA.
|
|
|
|
*/
|
|
|
|
BOOL WINAPI IntlStrEqWorkerW(BOOL bCase, LPCWSTR lpszStr, LPCWSTR lpszComp,
|
|
|
|
int iLen)
|
|
|
|
{
|
|
|
|
DWORD dwFlags;
|
|
|
|
int iRet;
|
|
|
|
|
|
|
|
TRACE("(%d,%s,%s,%d)\n", bCase,
|
|
|
|
debugstr_w(lpszStr),debugstr_w(lpszComp), iLen);
|
2004-02-17 22:02:18 +01:00
|
|
|
|
2012-06-20 23:40:13 +02:00
|
|
|
/* FIXME: This flag is undocumented and unknown by our CompareString.
|
2004-02-20 06:16:37 +01:00
|
|
|
*/
|
2014-10-31 03:12:23 +01:00
|
|
|
dwFlags = LOCALE_RETURN_GENITIVE_NAMES;
|
2012-06-20 23:40:13 +02:00
|
|
|
if (!bCase) dwFlags |= NORM_IGNORECASE;
|
2004-02-17 22:02:18 +01:00
|
|
|
|
2004-02-20 06:16:37 +01:00
|
|
|
iRet = CompareStringW(GetThreadLocale(),
|
|
|
|
dwFlags, lpszStr, iLen, lpszComp, iLen);
|
2004-02-17 22:02:18 +01:00
|
|
|
|
2004-02-20 06:16:37 +01:00
|
|
|
if (!iRet)
|
|
|
|
iRet = CompareStringW(2048, dwFlags, lpszStr, iLen, lpszComp, iLen);
|
2004-02-17 22:02:18 +01:00
|
|
|
|
2012-06-20 23:40:13 +02:00
|
|
|
return iRet == CSTR_EQUAL;
|
2004-02-17 22:02:18 +01:00
|
|
|
}
|