Akihiro Sagawa : xcopy: Avoid using isdigit() for WCHARs.

Alexandre Julliard julliard at winehq.org
Wed May 17 15:58:30 CDT 2017


Module: wine
Branch: master
Commit: 373604f2534adba65f75387c4f8b55053341d86f
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=373604f2534adba65f75387c4f8b55053341d86f

Author: Akihiro Sagawa <sagawa.aki at gmail.com>
Date:   Wed May 17 21:35:52 2017 +0900

xcopy: Avoid using isdigit() for WCHARs.

Found with Coccinelle.

Signed-off-by: Akihiro Sagawa <sagawa.aki at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 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 486e5b1..5c2f7ca 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;
                           }
 




More information about the wine-cvs mailing list