Module: wine Branch: master Commit: e71ffcde30a7b21ea929dd770876873177024e0f URL: https://source.winehq.org/git/wine.git/?a=commit;h=e71ffcde30a7b21ea929dd770...
Author: Alexandre Julliard julliard@winehq.org Date: Wed Apr 1 10:30:13 2020 +0200
kernel32: Avoid using memchrW().
Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/kernel32/profile.c | 18 ++++++++---------- dlls/kernel32/volume.c | 6 +++--- 2 files changed, 11 insertions(+), 13 deletions(-)
diff --git a/dlls/kernel32/profile.c b/dlls/kernel32/profile.c index c7382fd7b3..434728c267 100644 --- a/dlls/kernel32/profile.c +++ b/dlls/kernel32/profile.c @@ -311,7 +311,7 @@ static PROFILESECTION *PROFILE_Load(HANDLE hFile, ENCODING * pEncoding) WCHAR * szFile; const WCHAR *szLineStart, *szLineEnd; const WCHAR *szValueStart, *szEnd, *next_line; - int line = 0, len; + int len; PROFILESECTION *section, *first_section; PROFILESECTION **next_section; PROFILEKEY *key, *prev_key, **next_key; @@ -402,14 +402,10 @@ static PROFILESECTION *PROFILE_Load(HANDLE hFile, ENCODING * pEncoding) while (next_line < szEnd) { szLineStart = next_line; - next_line = memchrW(szLineStart, '\n', szEnd - szLineStart); - if (!next_line) next_line = memchrW(szLineStart, '\r', szEnd - szLineStart); - if (!next_line) next_line = szEnd; - else next_line++; + while (next_line < szEnd && *next_line != '\n' && *next_line != '\r') next_line++; + while (next_line < szEnd && (*next_line == '\n' || *next_line == '\r')) next_line++; szLineEnd = next_line;
- line++; - /* get rid of white space */ while (szLineStart < szLineEnd && PROFILE_isspaceW(*szLineStart)) szLineStart++; while ((szLineEnd > szLineStart) && PROFILE_isspaceW(szLineEnd[-1])) szLineEnd--; @@ -421,8 +417,8 @@ static PROFILESECTION *PROFILE_Load(HANDLE hFile, ENCODING * pEncoding) for (len = szLineEnd - szLineStart; len > 0; len--) if (szLineStart[len - 1] == ']') break; if (!len) { - WARN("Invalid section header at line %d: %s\n", - line, debugstr_wn(szLineStart, (int)(szLineEnd - szLineStart)) ); + WARN("Invalid section header: %s\n", + debugstr_wn(szLineStart, (int)(szLineEnd - szLineStart)) ); } else { @@ -450,7 +446,8 @@ static PROFILESECTION *PROFILE_Load(HANDLE hFile, ENCODING * pEncoding) /* get rid of white space after the name and before the start * of the value */ len = szLineEnd - szLineStart; - if ((szValueStart = memchrW( szLineStart, '=', szLineEnd - szLineStart )) != NULL) + for (szValueStart = szLineStart; szValueStart < szLineEnd; szValueStart++) if (*szValueStart == '=') break; + if (szValueStart < szLineEnd) { const WCHAR *szNameEnd = szValueStart; while ((szNameEnd > szLineStart) && PROFILE_isspaceW(szNameEnd[-1])) szNameEnd--; @@ -458,6 +455,7 @@ static PROFILESECTION *PROFILE_Load(HANDLE hFile, ENCODING * pEncoding) szValueStart++; while (szValueStart < szLineEnd && PROFILE_isspaceW(*szValueStart)) szValueStart++; } + else szValueStart = NULL;
if (len || !prev_key || *prev_key->name) { diff --git a/dlls/kernel32/volume.c b/dlls/kernel32/volume.c index 7967a55b2f..4f0f4a0a0f 100644 --- a/dlls/kernel32/volume.c +++ b/dlls/kernel32/volume.c @@ -674,7 +674,7 @@ BOOL WINAPI GetVolumeInformationW( LPCWSTR root, LPWSTR label, DWORD label_len, IO_STATUS_BLOCK io; OBJECT_ATTRIBUTES attr; FILE_FS_DEVICE_INFORMATION info; - WCHAR *p; + unsigned int i; enum fs_type type = FS_UNKNOWN; BOOL ret = FALSE;
@@ -685,8 +685,8 @@ BOOL WINAPI GetVolumeInformationW( LPCWSTR root, LPWSTR label, DWORD label_len, return FALSE; } /* there must be exactly one backslash in the name, at the end */ - p = memchrW( nt_name.Buffer + 4, '\', (nt_name.Length - 4) / sizeof(WCHAR) ); - if (p != nt_name.Buffer + nt_name.Length / sizeof(WCHAR) - 1) + for (i = 4; i < nt_name.Length / sizeof(WCHAR); i++) if (nt_name.Buffer[i] == '\') break; + if (i != nt_name.Length / sizeof(WCHAR) - 1) { /* check if root contains an explicit subdir */ if (root[0] && root[1] == ':') root += 2;