From 373604f2534adba65f75387c4f8b55053341d86f Mon Sep 17 00:00:00 2001 From: Akihiro Sagawa Date: Wed, 17 May 2017 21:35:52 +0900 Subject: [PATCH] xcopy: Avoid using isdigit() for WCHARs. Found with Coccinelle. Signed-off-by: Akihiro Sagawa Signed-off-by: Alexandre Julliard --- programs/xcopy/xcopy.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/programs/xcopy/xcopy.c b/programs/xcopy/xcopy.c index 486e5b108ce..5c2f7ca1931 100644 --- a/programs/xcopy/xcopy.c +++ b/programs/xcopy/xcopy.c @@ -643,7 +643,7 @@ cleanup: /* ========================================================================= XCOPY_ParseCommandLine - Parses the command line ========================================================================= */ -static BOOL is_whitespace(WCHAR c) +static inline BOOL is_whitespace(WCHAR c) { return c == ' ' || c == '\t'; } @@ -654,6 +654,11 @@ static WCHAR *skip_whitespace(WCHAR *p) return p; } +static inline BOOL is_digit(WCHAR c) +{ + return c >= '0' && c <= '9'; +} + /* Windows XCOPY uses a simplified command line parsing algorithm that lacks the escaped-quote logic of build_argv(), because literal double quotes are illegal in any of its arguments. @@ -770,7 +775,7 @@ static int XCOPY_ParseCommandLine(WCHAR *suppliedsource, break; /* 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; WCHAR *pos = &word[3]; BOOL isError = FALSE; @@ -781,18 +786,18 @@ static int XCOPY_ParseCommandLine(WCHAR *suppliedsource, * It is hardcoded to month-day-year. */ st.wMonth = _wtol(pos); - while (*pos && isdigit(*pos)) pos++; + while (*pos && is_digit(*pos)) pos++; if (*pos++ != '-') isError = TRUE; if (!isError) { st.wDay = _wtol(pos); - while (*pos && isdigit(*pos)) pos++; + while (*pos && is_digit(*pos)) pos++; if (*pos++ != '-') isError = TRUE; } if (!isError) { st.wYear = _wtol(pos); - while (*pos && isdigit(*pos)) pos++; + while (*pos && is_digit(*pos)) pos++; if (st.wYear < 100) st.wYear+=2000; }