Jacek Caban : vbscript: Treat only ASCII digits as digits.

Alexandre Julliard julliard at winehq.org
Fri Nov 8 17:25:26 CST 2019


Module: wine
Branch: master
Commit: a35adb1950b4eaadc0c53b77a6bd9dd89e1a73cf
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=a35adb1950b4eaadc0c53b77a6bd9dd89e1a73cf

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Fri Nov  8 21:28:32 2019 +0100

vbscript: Treat only ASCII digits as digits.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/vbscript/lex.c      | 14 +++++++-------
 dlls/vbscript/vbregexp.c |  4 ++--
 dlls/vbscript/vbscript.h |  5 +++++
 3 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/dlls/vbscript/lex.c b/dlls/vbscript/lex.c
index 005e7c3d58..197285c98e 100644
--- a/dlls/vbscript/lex.c
+++ b/dlls/vbscript/lex.c
@@ -214,7 +214,7 @@ static int parse_numeric_literal(parser_ctx_t *ctx, void **ret)
     if(*ctx->ptr == '0' && !('0' <= ctx->ptr[1] && ctx->ptr[1] <= '9') && ctx->ptr[1] != '.')
         return *ctx->ptr++;
 
-    while(ctx->ptr < ctx->end && iswdigit(*ctx->ptr)) {
+    while(ctx->ptr < ctx->end && is_digit(*ctx->ptr)) {
         hlp = d*10 + *(ctx->ptr++) - '0';
         if(d>MAXLONGLONG/10 || hlp<0) {
             exp++;
@@ -223,7 +223,7 @@ static int parse_numeric_literal(parser_ctx_t *ctx, void **ret)
         else
             d = hlp;
     }
-    while(ctx->ptr < ctx->end && iswdigit(*ctx->ptr)) {
+    while(ctx->ptr < ctx->end && is_digit(*ctx->ptr)) {
         exp++;
         ctx->ptr++;
     }
@@ -232,7 +232,7 @@ static int parse_numeric_literal(parser_ctx_t *ctx, void **ret)
         use_int = FALSE;
         ctx->ptr++;
 
-        while(ctx->ptr < ctx->end && iswdigit(*ctx->ptr)) {
+        while(ctx->ptr < ctx->end && is_digit(*ctx->ptr)) {
             hlp = d*10 + *(ctx->ptr++) - '0';
             if(d>MAXLONGLONG/10 || hlp<0)
                 break;
@@ -240,7 +240,7 @@ static int parse_numeric_literal(parser_ctx_t *ctx, void **ret)
             d = hlp;
             exp--;
         }
-        while(ctx->ptr < ctx->end && iswdigit(*ctx->ptr))
+        while(ctx->ptr < ctx->end && is_digit(*ctx->ptr))
             ctx->ptr++;
     }
 
@@ -255,7 +255,7 @@ static int parse_numeric_literal(parser_ctx_t *ctx, void **ret)
             ctx->ptr++;
         }
 
-        if(!iswdigit(*ctx->ptr)) {
+        if(!is_digit(*ctx->ptr)) {
             FIXME("Invalid numeric literal\n");
             return 0;
         }
@@ -266,7 +266,7 @@ static int parse_numeric_literal(parser_ctx_t *ctx, void **ret)
             e = e*10 + *(ctx->ptr++) - '0';
             if(sign == -1 && -e+exp < -(INT_MAX/100)) {
                 /* The literal will be rounded to 0 anyway. */
-                while(iswdigit(*ctx->ptr))
+                while(is_digit(*ctx->ptr))
                     ctx->ptr++;
                 *(double*)ret = 0;
                 return tDouble;
@@ -276,7 +276,7 @@ static int parse_numeric_literal(parser_ctx_t *ctx, void **ret)
                 FIXME("Invalid numeric literal\n");
                 return 0;
             }
-        } while(iswdigit(*ctx->ptr));
+        } while(is_digit(*ctx->ptr));
 
         exp += sign*e;
     }
diff --git a/dlls/vbscript/vbregexp.c b/dlls/vbscript/vbregexp.c
index ac667da442..60c99772d3 100644
--- a/dlls/vbscript/vbregexp.c
+++ b/dlls/vbscript/vbregexp.c
@@ -1560,14 +1560,14 @@ static HRESULT WINAPI RegExp2_Replace(IRegExp2 *iface, BSTR source, VARIANT repl
             default: {
                 DWORD idx;
 
-                if(!iswdigit(ptr[1])) {
+                if(!is_digit(ptr[1])) {
                     hres = strbuf_append(&buf, ptr, 1);
                     prev_ptr = ptr + 1;
                     break;
                 }
 
                 idx = ptr[1] - '0';
-                if(iswdigit(ptr[2]) && idx * 10 + (ptr[2] - '0') <= state->paren_count) {
+                if(is_digit(ptr[2]) && idx * 10 + (ptr[2] - '0') <= state->paren_count) {
                     idx = idx * 10 + (ptr[2] - '0');
                     prev_ptr = ptr + 3;
                 }else if(idx && idx <= state->paren_count) {
diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h
index 04a9b8372d..ef5cee23bf 100644
--- a/dlls/vbscript/vbscript.h
+++ b/dlls/vbscript/vbscript.h
@@ -373,6 +373,11 @@ static inline BOOL is_int32(double d)
     return INT32_MIN <= d && d <= INT32_MAX && (double)(int)d == d;
 }
 
+static inline BOOL is_digit(WCHAR c)
+{
+    return '0' <= c && c <= '9';
+}
+
 HRESULT create_regexp(IDispatch**) DECLSPEC_HIDDEN;
 BSTR string_replace(BSTR,BSTR,BSTR,int,int) DECLSPEC_HIDDEN;
 




More information about the wine-cvs mailing list