Commit 373604f2 authored by Akihiro Sagawa's avatar Akihiro Sagawa Committed by Alexandre Julliard

xcopy: Avoid using isdigit() for WCHARs.

Found with Coccinelle. Signed-off-by: 's avatarAkihiro Sagawa <sagawa.aki@gmail.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 505be073
...@@ -643,7 +643,7 @@ cleanup: ...@@ -643,7 +643,7 @@ cleanup:
/* ========================================================================= /* =========================================================================
XCOPY_ParseCommandLine - Parses the command line XCOPY_ParseCommandLine - Parses the command line
========================================================================= */ ========================================================================= */
static BOOL is_whitespace(WCHAR c) static inline BOOL is_whitespace(WCHAR c)
{ {
return c == ' ' || c == '\t'; return c == ' ' || c == '\t';
} }
...@@ -654,6 +654,11 @@ static WCHAR *skip_whitespace(WCHAR *p) ...@@ -654,6 +654,11 @@ static WCHAR *skip_whitespace(WCHAR *p)
return p; return p;
} }
static inline BOOL is_digit(WCHAR c)
{
return c >= '0' && c <= '9';
}
/* Windows XCOPY uses a simplified command line parsing algorithm /* Windows XCOPY uses a simplified command line parsing algorithm
that lacks the escaped-quote logic of build_argv(), because that lacks the escaped-quote logic of build_argv(), because
literal double quotes are illegal in any of its arguments. literal double quotes are illegal in any of its arguments.
...@@ -770,7 +775,7 @@ static int XCOPY_ParseCommandLine(WCHAR *suppliedsource, ...@@ -770,7 +775,7 @@ static int XCOPY_ParseCommandLine(WCHAR *suppliedsource,
break; break;
/* D can be /D or /D: */ /* D can be /D or /D: */
case 'D': if (word[2]==':' && isdigit(word[3])) { case 'D': if (word[2]==':' && is_digit(word[3])) {
SYSTEMTIME st; SYSTEMTIME st;
WCHAR *pos = &word[3]; WCHAR *pos = &word[3];
BOOL isError = FALSE; BOOL isError = FALSE;
...@@ -781,18 +786,18 @@ static int XCOPY_ParseCommandLine(WCHAR *suppliedsource, ...@@ -781,18 +786,18 @@ static int XCOPY_ParseCommandLine(WCHAR *suppliedsource,
* It is hardcoded to month-day-year. * It is hardcoded to month-day-year.
*/ */
st.wMonth = _wtol(pos); st.wMonth = _wtol(pos);
while (*pos && isdigit(*pos)) pos++; while (*pos && is_digit(*pos)) pos++;
if (*pos++ != '-') isError = TRUE; if (*pos++ != '-') isError = TRUE;
if (!isError) { if (!isError) {
st.wDay = _wtol(pos); st.wDay = _wtol(pos);
while (*pos && isdigit(*pos)) pos++; while (*pos && is_digit(*pos)) pos++;
if (*pos++ != '-') isError = TRUE; if (*pos++ != '-') isError = TRUE;
} }
if (!isError) { if (!isError) {
st.wYear = _wtol(pos); st.wYear = _wtol(pos);
while (*pos && isdigit(*pos)) pos++; while (*pos && is_digit(*pos)) pos++;
if (st.wYear < 100) st.wYear+=2000; if (st.wYear < 100) st.wYear+=2000;
} }
......
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