Commit e71ffcde authored by Alexandre Julliard's avatar Alexandre Julliard

kernel32: Avoid using memchrW().

parent ce30db50
...@@ -311,7 +311,7 @@ static PROFILESECTION *PROFILE_Load(HANDLE hFile, ENCODING * pEncoding) ...@@ -311,7 +311,7 @@ static PROFILESECTION *PROFILE_Load(HANDLE hFile, ENCODING * pEncoding)
WCHAR * szFile; WCHAR * szFile;
const WCHAR *szLineStart, *szLineEnd; const WCHAR *szLineStart, *szLineEnd;
const WCHAR *szValueStart, *szEnd, *next_line; const WCHAR *szValueStart, *szEnd, *next_line;
int line = 0, len; int len;
PROFILESECTION *section, *first_section; PROFILESECTION *section, *first_section;
PROFILESECTION **next_section; PROFILESECTION **next_section;
PROFILEKEY *key, *prev_key, **next_key; PROFILEKEY *key, *prev_key, **next_key;
...@@ -402,14 +402,10 @@ static PROFILESECTION *PROFILE_Load(HANDLE hFile, ENCODING * pEncoding) ...@@ -402,14 +402,10 @@ static PROFILESECTION *PROFILE_Load(HANDLE hFile, ENCODING * pEncoding)
while (next_line < szEnd) while (next_line < szEnd)
{ {
szLineStart = next_line; szLineStart = next_line;
next_line = memchrW(szLineStart, '\n', szEnd - szLineStart); while (next_line < szEnd && *next_line != '\n' && *next_line != '\r') next_line++;
if (!next_line) next_line = memchrW(szLineStart, '\r', szEnd - szLineStart); while (next_line < szEnd && (*next_line == '\n' || *next_line == '\r')) next_line++;
if (!next_line) next_line = szEnd;
else next_line++;
szLineEnd = next_line; szLineEnd = next_line;
line++;
/* get rid of white space */ /* get rid of white space */
while (szLineStart < szLineEnd && PROFILE_isspaceW(*szLineStart)) szLineStart++; while (szLineStart < szLineEnd && PROFILE_isspaceW(*szLineStart)) szLineStart++;
while ((szLineEnd > szLineStart) && PROFILE_isspaceW(szLineEnd[-1])) szLineEnd--; while ((szLineEnd > szLineStart) && PROFILE_isspaceW(szLineEnd[-1])) szLineEnd--;
...@@ -421,8 +417,8 @@ static PROFILESECTION *PROFILE_Load(HANDLE hFile, ENCODING * pEncoding) ...@@ -421,8 +417,8 @@ static PROFILESECTION *PROFILE_Load(HANDLE hFile, ENCODING * pEncoding)
for (len = szLineEnd - szLineStart; len > 0; len--) if (szLineStart[len - 1] == ']') break; for (len = szLineEnd - szLineStart; len > 0; len--) if (szLineStart[len - 1] == ']') break;
if (!len) if (!len)
{ {
WARN("Invalid section header at line %d: %s\n", WARN("Invalid section header: %s\n",
line, debugstr_wn(szLineStart, (int)(szLineEnd - szLineStart)) ); debugstr_wn(szLineStart, (int)(szLineEnd - szLineStart)) );
} }
else else
{ {
...@@ -450,7 +446,8 @@ static PROFILESECTION *PROFILE_Load(HANDLE hFile, ENCODING * pEncoding) ...@@ -450,7 +446,8 @@ static PROFILESECTION *PROFILE_Load(HANDLE hFile, ENCODING * pEncoding)
/* get rid of white space after the name and before the start /* get rid of white space after the name and before the start
* of the value */ * of the value */
len = szLineEnd - szLineStart; 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; const WCHAR *szNameEnd = szValueStart;
while ((szNameEnd > szLineStart) && PROFILE_isspaceW(szNameEnd[-1])) szNameEnd--; while ((szNameEnd > szLineStart) && PROFILE_isspaceW(szNameEnd[-1])) szNameEnd--;
...@@ -458,6 +455,7 @@ static PROFILESECTION *PROFILE_Load(HANDLE hFile, ENCODING * pEncoding) ...@@ -458,6 +455,7 @@ static PROFILESECTION *PROFILE_Load(HANDLE hFile, ENCODING * pEncoding)
szValueStart++; szValueStart++;
while (szValueStart < szLineEnd && PROFILE_isspaceW(*szValueStart)) szValueStart++; while (szValueStart < szLineEnd && PROFILE_isspaceW(*szValueStart)) szValueStart++;
} }
else szValueStart = NULL;
if (len || !prev_key || *prev_key->name) if (len || !prev_key || *prev_key->name)
{ {
......
...@@ -674,7 +674,7 @@ BOOL WINAPI GetVolumeInformationW( LPCWSTR root, LPWSTR label, DWORD label_len, ...@@ -674,7 +674,7 @@ BOOL WINAPI GetVolumeInformationW( LPCWSTR root, LPWSTR label, DWORD label_len,
IO_STATUS_BLOCK io; IO_STATUS_BLOCK io;
OBJECT_ATTRIBUTES attr; OBJECT_ATTRIBUTES attr;
FILE_FS_DEVICE_INFORMATION info; FILE_FS_DEVICE_INFORMATION info;
WCHAR *p; unsigned int i;
enum fs_type type = FS_UNKNOWN; enum fs_type type = FS_UNKNOWN;
BOOL ret = FALSE; BOOL ret = FALSE;
...@@ -685,8 +685,8 @@ BOOL WINAPI GetVolumeInformationW( LPCWSTR root, LPWSTR label, DWORD label_len, ...@@ -685,8 +685,8 @@ BOOL WINAPI GetVolumeInformationW( LPCWSTR root, LPWSTR label, DWORD label_len,
return FALSE; return FALSE;
} }
/* there must be exactly one backslash in the name, at the end */ /* there must be exactly one backslash in the name, at the end */
p = memchrW( nt_name.Buffer + 4, '\\', (nt_name.Length - 4) / sizeof(WCHAR) ); for (i = 4; i < nt_name.Length / sizeof(WCHAR); i++) if (nt_name.Buffer[i] == '\\') break;
if (p != nt_name.Buffer + nt_name.Length / sizeof(WCHAR) - 1) if (i != nt_name.Length / sizeof(WCHAR) - 1)
{ {
/* check if root contains an explicit subdir */ /* check if root contains an explicit subdir */
if (root[0] && root[1] == ':') root += 2; if (root[0] && root[1] == ':') root += 2;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment