ntdll: Use wcschr() instead of strchrW().

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2020-03-31 11:43:50 +02:00
parent 80005ee016
commit 6de0ab276b
12 changed files with 33 additions and 32 deletions

View File

@ -3140,14 +3140,14 @@ static WCHAR *lookup_manifest_file( HANDLE dir, struct assembly_identity *ai )
if (dir_info->NextEntryOffset) data_pos += dir_info->NextEntryOffset;
else data_pos = data_len;
tmp = dir_info->FileName + (strchrW(lookup, '*') - lookup);
tmp = dir_info->FileName + (wcschr(lookup, '*') - lookup);
build = wcstoul( tmp, NULL, 10 );
if (build < min_build) continue;
tmp = strchrW(tmp, '.') + 1;
tmp = wcschr(tmp, '.') + 1;
revision = wcstoul( tmp, NULL, 10 );
if (build == min_build && revision < min_revision) continue;
tmp = strchrW(tmp, '_') + 1;
tmp = strchrW(tmp, '_') + 1;
tmp = wcschr(tmp, '_') + 1;
tmp = wcschr(tmp, '_') + 1;
if (dir_info->FileNameLength - (tmp - dir_info->FileName) * sizeof(WCHAR) == sizeof(wine_trailerW) &&
!wcsnicmp( tmp, wine_trailerW, ARRAY_SIZE( wine_trailerW )))
{

View File

@ -234,7 +234,7 @@ static inline BOOL is_invalid_dos_char( WCHAR ch )
{
static const WCHAR invalid_chars[] = { INVALID_DOS_CHARS,'~','.',0 };
if (ch > 0x7f) return TRUE;
return strchrW( invalid_chars, ch ) != NULL;
return wcschr( invalid_chars, ch ) != NULL;
}
/* check if the device can be a mounted volume */
@ -2685,7 +2685,7 @@ NTSTATUS nt_to_unix_file_name_attr( const OBJECT_ATTRIBUTES *attr, ANSI_STRING *
/* check for invalid characters */
for (p = name; p < name + name_len; p++)
if (*p < 32 || strchrW( invalid_charsW, *p )) return STATUS_OBJECT_NAME_INVALID;
if (*p < 32 || wcschr( invalid_charsW, *p )) return STATUS_OBJECT_NAME_INVALID;
unix_len = name_len * 3 + MAX_DIR_ENTRY_LEN + 3;
if (!(unix_name = RtlAllocateHeap( GetProcessHeap(), 0, unix_len )))
@ -2773,7 +2773,7 @@ NTSTATUS CDECL wine_nt_to_unix_file_name( const UNICODE_STRING *nameW, ANSI_STRI
for (pos = 0; pos < name_len; pos++)
{
if (IS_SEPARATOR(name[pos])) break;
if (name[pos] < 32 || strchrW( invalid_charsW, name[pos] ))
if (name[pos] < 32 || wcschr( invalid_charsW, name[pos] ))
return STATUS_OBJECT_NAME_INVALID;
}
if (pos > MAX_DIR_ENTRY_LEN)
@ -2801,7 +2801,7 @@ NTSTATUS CDECL wine_nt_to_unix_file_name( const UNICODE_STRING *nameW, ANSI_STRI
else
{
for (p = name; p < name + name_len; p++)
if (*p < 32 || strchrW( invalid_charsW, *p )) return STATUS_OBJECT_NAME_INVALID;
if (*p < 32 || wcschr( invalid_charsW, *p )) return STATUS_OBJECT_NAME_INVALID;
}
unix_len = (prefix_len + name_len) * 3 + MAX_DIR_ENTRY_LEN + 3;

View File

@ -681,13 +681,13 @@ static void get_image_path( const char *argv0, UNICODE_STRING *path )
ntdll_umbstowcs( argv0, len, name, len );
if (RtlDetermineDosPathNameType_U( name ) != RELATIVE_PATH ||
strchrW( name, '/' ) || strchrW( name, '\\' ))
wcschr( name, '/' ) || wcschr( name, '\\' ))
{
len = RtlGetFullPathName_U( name, sizeof(full_name), full_name, &file_part );
if (!len || len > sizeof(full_name)) goto failed;
/* try first without extension */
if (RtlDoesFileExists_U( full_name )) goto done;
if (len < (MAX_PATH - 4) * sizeof(WCHAR) && !strchrW( file_part, '.' ))
if (len < (MAX_PATH - 4) * sizeof(WCHAR) && !wcschr( file_part, '.' ))
{
wcscat( file_part, exeW );
if (RtlDoesFileExists_U( full_name )) goto done;
@ -711,7 +711,7 @@ static void get_image_path( const char *argv0, UNICODE_STRING *path )
if (strlenW( name ) >= MAX_PATH - 4 - len) goto failed;
wcscpy( full_name, system_dir );
wcscat( full_name, name );
if (!strchrW( name, '.' )) wcscat( full_name, exeW );
if (!wcschr( name, '.' )) wcscat( full_name, exeW );
}
}
done:
@ -809,8 +809,8 @@ static void build_command_line( WCHAR **argv, UNICODE_STRING *cmdline )
/* check for quotes and spaces in this argument */
if (arg == argv || !**arg) has_space = TRUE;
else has_space = strchrW( *arg, ' ' ) || strchrW( *arg, '\t' );
has_quote = strchrW( *arg, '"' ) != NULL;
else has_space = wcschr( *arg, ' ' ) || wcschr( *arg, '\t' );
has_quote = wcschr( *arg, '"' ) != NULL;
/* now transfer it to the command line */
if (has_space) *p++ = '"';
@ -912,7 +912,7 @@ static LPCWSTR ENV_FindVariable(PCWSTR var, PCWSTR name, unsigned namelen)
if (len > namelen &&
var[namelen] == '=' &&
!RtlCompareUnicodeStrings( var, namelen, name, namelen, TRUE ) &&
strchrW(var + 1, '=') == var + namelen)
wcschr(var + 1, '=') == var + namelen)
{
return var + namelen + 1;
}

View File

@ -182,7 +182,7 @@ static inline void *get_rva( HMODULE module, DWORD va )
/* check whether the file name contains a path */
static inline BOOL contains_path( LPCWSTR name )
{
return ((*name && (name[1] == ':')) || strchrW(name, '/') || strchrW(name, '\\'));
return ((*name && (name[1] == ':')) || wcschr(name, '/') || wcschr(name, '\\'));
}
#define RTL_UNLOAD_EVENT_TRACE_NUMBER 64
@ -608,7 +608,7 @@ static FARPROC find_forwarded_export( HMODULE module, const char *forward, LPCWS
if ((end - forward) * sizeof(WCHAR) >= sizeof(mod_name)) return NULL;
ascii_to_unicode( mod_name, forward, end - forward );
mod_name[end - forward] = 0;
if (!strchrW( mod_name, '.' ))
if (!wcschr( mod_name, '.' ))
{
if ((end - forward) * sizeof(WCHAR) >= sizeof(mod_name) - sizeof(dllW)) return NULL;
memcpy( mod_name + (end - forward), dllW, sizeof(dllW) );
@ -2890,7 +2890,7 @@ static NTSTATUS find_dll_file( const WCHAR *load_path, const WCHAR *libname, con
if (default_ext) /* first append default extension */
{
if (!(ext = strrchrW( libname, '.')) || strchrW( ext, '/' ) || strchrW( ext, '\\'))
if (!(ext = strrchrW( libname, '.')) || wcschr( ext, '/' ) || wcschr( ext, '\\'))
{
if (!(dllname = RtlAllocateHeap( GetProcessHeap(), 0,
(strlenW(libname)+strlenW(default_ext)+1) * sizeof(WCHAR))))
@ -4162,7 +4162,7 @@ NTSTATUS WINAPI RtlGetExePath( PCWSTR name, PWSTR *path )
const WCHAR *module = NtCurrentTeb()->Peb->ProcessParameters->ImagePathName.Buffer;
/* same check as NeedCurrentDirectoryForExePathW */
if (!strchrW( name, '\\' ))
if (!wcschr( name, '\\' ))
{
static const WCHAR env_name[] = {'N','o','D','e','f','a','u','l','t','C','u','r','r','e','n','t',
'D','i','r','e','c','t','o','r','y','I','n',

View File

@ -199,7 +199,7 @@ static void add_load_order( const module_loadorder_t *plo )
static void add_load_order_set( WCHAR *entry )
{
module_loadorder_t ldo;
WCHAR *end = strchrW( entry, '=' );
WCHAR *end = wcschr( entry, '=' );
if (!end) return;
*end++ = 0;
@ -253,7 +253,7 @@ static void init_load_order(void)
{
while (*entry == ';') entry++;
if (!*entry) break;
next = strchrW( entry, ';' );
next = wcschr( entry, ';' );
if (next) *next++ = 0;
else next = entry + strlenW(entry);
add_load_order_set( entry );
@ -449,7 +449,7 @@ enum loadorder get_load_order( const WCHAR *app_name, const UNICODE_STRING *nt_n
{
const WCHAR *p = path + strlenW( system_dir );
while (*p == '\\' || *p == '/') p++;
if (!strchrW( p, '\\' ) && !strchrW( p, '/' )) path = p;
if (!wcschr( p, '\\' ) && !wcschr( p, '/' )) path = p;
}
if (!(len = strlenW(path))) return ret;

View File

@ -863,7 +863,7 @@ static LCID unix_locale_to_lcid( const char *unix_name )
{
*p++ = 0;
/* charset, ignore */
p = strchrW( p, '@' );
p = wcschr( p, '@' );
}
if (p)
{
@ -1723,7 +1723,7 @@ NTSTATUS WINAPI RtlLocaleNameToLcid( const WCHAR *name, LCID *lcid, ULONG flags
while (*p)
{
if (!wcsnicmp( p, script, len ) && (!p[len] || p[len] == ';')) break;
if (!(p = strchrW( p, ';'))) break;
if (!(p = wcschr( p, ';'))) break;
p++;
}
if (!p || !*p) continue;

View File

@ -304,6 +304,7 @@ int WINAPIV NTDLL_swprintf( WCHAR *str, const WCHAR *format, ... );
#define wcsupr(s) NTDLL__wcsupr(s)
#define wcscpy(d,s) NTDLL_wcscpy(d,s)
#define wcscat(d,s) NTDLL_wcscat(d,s)
#define wcschr(s,c) NTDLL_wcschr(s,c)
#define wcstoul(s,e,b) NTDLL_wcstoul(s,e,b)
/* convert from straight ASCII to Unicode without depending on the current codepage */

View File

@ -488,7 +488,7 @@ ULONG WINAPI RtlDosSearchPath_U(LPCWSTR paths, LPCWSTR search, LPCWSTR ext,
filelen = 1 /* for \ */ + strlenW(search) + 1 /* \0 */;
/* Windows only checks for '.' without worrying about path components */
if (strchrW( search, '.' )) ext = NULL;
if (wcschr( search, '.' )) ext = NULL;
if (ext != NULL) filelen += strlenW(ext);
while (*paths)

View File

@ -454,7 +454,7 @@ static int pf_vsnprintf( pf_output *out, const WCHAR *format, __ms_va_list valis
while (*p)
{
q = strchrW( p, '%' );
q = wcschr( p, '%' );
/* there are no % characters left: output the rest of the string */
if( !q )

View File

@ -104,7 +104,7 @@ static const WCHAR **build_list( const WCHAR *buffer )
const WCHAR *p = buffer;
const WCHAR **ret;
while ((p = strchrW( p, ';' )))
while ((p = wcschr( p, ';' )))
{
count++;
p++;
@ -121,7 +121,7 @@ static const WCHAR **build_list( const WCHAR *buffer )
for (;;)
{
ret[count++] = q;
if (!(q = strchrW( q, ';' ))) break;
if (!(q = wcschr( q, ';' ))) break;
*q++ = 0;
}
ret[count++] = NULL;

View File

@ -1228,7 +1228,7 @@ BOOLEAN WINAPI RtlIsTextUnicode( LPCVOID buf, INT len, INT *pf )
{
for (i = 0; i < len; i++)
{
if (strchrW(std_control_chars, s[i]))
if (wcschr(std_control_chars, s[i]))
{
out_flags |= IS_TEXT_UNICODE_CONTROLS;
break;
@ -1240,7 +1240,7 @@ BOOLEAN WINAPI RtlIsTextUnicode( LPCVOID buf, INT len, INT *pf )
{
for (i = 0; i < len; i++)
{
if (strchrW(byterev_control_chars, s[i]))
if (wcschr(byterev_control_chars, s[i]))
{
out_flags |= IS_TEXT_UNICODE_REVERSE_CONTROLS;
break;

View File

@ -281,7 +281,7 @@ static BOOL get_nt_registry_version( RTL_OSVERSIONINFOEXW *version )
{
WCHAR *p, *str = (WCHAR *)info->Data;
str[info->DataLength / sizeof(WCHAR)] = 0;
p = strchrW( str, '.' );
p = wcschr( str, '.' );
if (p)
{
*p++ = 0;
@ -398,13 +398,13 @@ static BOOL get_win9x_registry_version( RTL_OSVERSIONINFOEXW *version )
{
WCHAR *p, *str = (WCHAR *)info->Data;
str[info->DataLength / sizeof(WCHAR)] = 0;
p = strchrW( str, '.' );
p = wcschr( str, '.' );
if (p) *p++ = 0;
version->dwMajorVersion = wcstoul( str, NULL, 10 );
if (p)
{
str = p;
p = strchrW( str, '.' );
p = wcschr( str, '.' );
if (p)
{
*p++ = 0;