Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/ntdll/ntdll.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec index bd8e1f5efe6..7fc46231ae9 100644 --- a/dlls/ntdll/ntdll.spec +++ b/dlls/ntdll/ntdll.spec @@ -1581,7 +1581,7 @@ @ cdecl strncat(str str long) @ cdecl strncmp(str str long) @ cdecl strncpy(ptr str long) -@ cdecl strnlen(ptr long) +@ cdecl strnlen(str long) @ cdecl strpbrk(str str) @ cdecl strrchr(str long) @ cdecl strspn(str str)
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/ntdll/ntdll.spec | 1 + dlls/ntdll/wcstring.c | 11 +++++++++++ 2 files changed, 12 insertions(+)
diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec index 7fc46231ae9..5824cd147e1 100644 --- a/dlls/ntdll/ntdll.spec +++ b/dlls/ntdll/ntdll.spec @@ -1609,6 +1609,7 @@ @ cdecl wcsncat(wstr wstr long) @ cdecl wcsncmp(wstr wstr long) @ cdecl wcsncpy(ptr wstr long) +@ cdecl wcsnlen(wstr long) @ cdecl wcspbrk(wstr wstr) @ cdecl wcsrchr(wstr long) @ cdecl wcsspn(wstr wstr) diff --git a/dlls/ntdll/wcstring.c b/dlls/ntdll/wcstring.c index a727e4defac..9422e4f676c 100644 --- a/dlls/ntdll/wcstring.c +++ b/dlls/ntdll/wcstring.c @@ -251,6 +251,17 @@ LPWSTR __cdecl wcsncpy( LPWSTR s1, LPCWSTR s2, size_t n ) }
+/********************************************************************* + * wcsnlen (NTDLL.@) + */ +size_t __cdecl wcsnlen( const WCHAR *str, size_t len ) +{ + const WCHAR *s = str; + for (s = str; len && *s; s++, len--) ; + return s - str; +} + + /********************************************************************* * wcspbrk (NTDLL.@) */
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/kernelbase/path.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-)
diff --git a/dlls/kernelbase/path.c b/dlls/kernelbase/path.c index b4b31410a3a..3503286a82a 100644 --- a/dlls/kernelbase/path.c +++ b/dlls/kernelbase/path.c @@ -105,15 +105,6 @@ static WCHAR *heap_strdupAtoW(const char *str) return ret; }
-static SIZE_T strnlenW(const WCHAR *string, SIZE_T maxlen) -{ - SIZE_T i; - - for (i = 0; i < maxlen; i++) - if (!string[i]) break; - return i; -} - static BOOL is_drive_spec( const WCHAR *str ) { return ((str[0] >= 'A' && str[0] <= 'Z') || (str[0] >= 'a' && str[0] <= 'z')) && str[1] == ':'; @@ -517,7 +508,7 @@ HRESULT WINAPI PathCchAddExtension(WCHAR *path, SIZE_T size, const WCHAR *extens if (FAILED(hr)) return hr; if (*existing_extension) return S_FALSE;
- path_length = strnlenW(path, size); + path_length = wcsnlen(path, size); dot_length = has_dot ? 0 : 1; extension_length = lstrlenW(extension);
@@ -752,7 +743,7 @@ HRESULT WINAPI PathCchRemoveBackslashEx(WCHAR *path, SIZE_T path_size, WCHAR **p return E_INVALIDARG; }
- path_length = strnlenW(path, path_size); + path_length = wcsnlen(path, path_size); if (path_length == path_size && !path[path_length]) return E_INVALIDARG;
root_end = get_root_end(path);
These were open-coded in 5933c2a6901218bc6ef7b6e808b0571fa96b542e, but there's no reason not to use the ASCII versions from ntdll.
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/kernelbase/path.c | 18 ++++-------------- dlls/kernelbase/string.c | 4 ---- 2 files changed, 4 insertions(+), 18 deletions(-)
diff --git a/dlls/kernelbase/path.c b/dlls/kernelbase/path.c index 3503286a82a..5f983895576 100644 --- a/dlls/kernelbase/path.c +++ b/dlls/kernelbase/path.c @@ -36,13 +36,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(path);
-#define isalnum(ch) (((ch) >= '0' && (ch) <= '9') || \ - ((ch) >= 'A' && (ch) <= 'Z') || \ - ((ch) >= 'a' && (ch) <= 'z')) -#define isxdigit(ch) (((ch) >= '0' && (ch) <= '9') || \ - ((ch) >= 'A' && (ch) <= 'F') || \ - ((ch) >= 'a' && (ch) <= 'f')) - static const char hexDigits[] = "0123456789ABCDEF";
static const unsigned char hashdata_lookup[256] = @@ -107,13 +100,12 @@ static WCHAR *heap_strdupAtoW(const char *str)
static BOOL is_drive_spec( const WCHAR *str ) { - return ((str[0] >= 'A' && str[0] <= 'Z') || (str[0] >= 'a' && str[0] <= 'z')) && str[1] == ':'; + return isalpha( str[0] ) && str[1] == ':'; }
static BOOL is_escaped_drive_spec( const WCHAR *str ) { - return ((str[0] >= 'A' && str[0] <= 'Z') || (str[0] >= 'a' && str[0] <= 'z')) && - (str[1] == ':' || str[1] == '|'); + return isalpha( str[0] ) && (str[1] == ':' || str[1] == '|'); }
static BOOL is_prefixed_unc(const WCHAR *string) @@ -2794,8 +2786,7 @@ HRESULT WINAPI ParseURLA(const char *url, PARSEDURLA *result) if (result->cbSize != sizeof(*result)) return E_INVALIDARG;
- while (*ptr && ((*ptr >= 'a' && *ptr <= 'z') || (*ptr >= 'A' && *ptr <= 'Z') || - (*ptr >= '0' && *ptr <= '9') || *ptr == '-' || *ptr == '+' || *ptr == '.')) + while (*ptr && (isalnum( *ptr ) || *ptr == '-' || *ptr == '+' || *ptr == '.')) ptr++;
if (*ptr != ':' || ptr <= url + 1) @@ -4177,8 +4168,7 @@ static const WCHAR * scan_url(const WCHAR *start, DWORD *size, enum url_scan_typ switch (type) { case SCHEME: - while ((*start >= 'a' && *start <= 'z') || (*start >= '0' && *start <= '9') || - *start == '+' || *start == '-' || *start == '.') + while ((isalnum( *start ) && !isupper( *start )) || *start == '+' || *start == '-' || *start == '.') { start++; (*size)++; diff --git a/dlls/kernelbase/string.c b/dlls/kernelbase/string.c index 29cc158202f..f5d4468ae6c 100644 --- a/dlls/kernelbase/string.c +++ b/dlls/kernelbase/string.c @@ -30,10 +30,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(string);
-#define isxdigit(ch) (((ch) >= '0' && (ch) <= '9') || \ - ((ch) >= 'A' && (ch) <= 'F') || \ - ((ch) >= 'a' && (ch) <= 'f')) - static BOOL char_compare(WORD ch1, WORD ch2, DWORD flags) { char str1[3], str2[3];
On Saturday, January 29, 2022 5:05:27 PM PST Zebediah Figura wrote:
-@ cdecl strnlen(ptr long) +@ cdecl strnlen(str long)
Is this safe, since strnlen doesn't have to be given a null-terminated string?
On 1/29/22 19:27, Chris Robinson wrote:
On Saturday, January 29, 2022 5:05:27 PM PST Zebediah Figura wrote:
-@ cdecl strnlen(ptr long) +@ cdecl strnlen(str long)
Is this safe, since strnlen doesn't have to be given a null-terminated string?
Eh, I don't think it is, sorry for the noise. I'll send an updated patch series.