Module: wine Branch: oldstable Commit: e1460b2794d8e34a42c06e5077eaeb59b4aa838a URL: https://source.winehq.org/git/wine.git/?a=commit;h=e1460b2794d8e34a42c06e507...
Author: Robert Wilhelm robert.wilhelm@gmx.net Date: Tue Sep 15 13:33:38 2020 +0200
vbscript: Parse decimal literals between -1 and 1 without 0 in front.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49820 Signed-off-by: Robert Wilhelm robert.wilhelm@gmx.net Signed-off-by: Jacek Caban jacek@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org (cherry picked from commit a31023a67812714f503250dc25abbc086439790a) Signed-off-by: Michael Stefaniuc mstefani@winehq.org
---
dlls/vbscript/lex.c | 11 +++++++++-- dlls/vbscript/tests/lang.vbs | 3 +++ 2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/dlls/vbscript/lex.c b/dlls/vbscript/lex.c index 444774b4341..2fee702ac8f 100644 --- a/dlls/vbscript/lex.c +++ b/dlls/vbscript/lex.c @@ -390,11 +390,18 @@ static int parse_next_token(void *lval, parser_ctx_t *ctx) /* * We need to distinguish between '.' used as part of a member expression and * a beginning of a dot expression (a member expression accessing with statement - * expression). + * expression) and a floating point number like ".2" . */ c = ctx->ptr > ctx->code ? ctx->ptr[-1] : '\n'; + if (is_identifier_char(c) || c == ')') { + ctx->ptr++; + return '.'; + } + c = ctx->ptr[1]; + if('0' <= c && c <= '9') + return parse_numeric_literal(ctx, lval); ctx->ptr++; - return is_identifier_char(c) || c == ')' ? '.' : tDOT; + return tDOT; case '-': if(ctx->is_html && ctx->ptr[1] == '-' && ctx->ptr[2] == '>') return comment_line(ctx); diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs index 570b5befeaa..95988a4e1d9 100644 --- a/dlls/vbscript/tests/lang.vbs +++ b/dlls/vbscript/tests/lang.vbs @@ -47,6 +47,8 @@ Call ok(56.789e-2 = 0.56789, "56.789e-2 <> 0.56789") Call ok(1e-94938484 = 0, "1e-... <> 0") Call ok(34e0 = 34, "34e0 <> 34") Call ok(34E1 = 340, "34E0 <> 340") +Call ok(.5 = 0.5, ".5 <> 0.5") +Call ok(.5e1 = 5, ".5e1 <> 5") Call ok(--1 = 1, "--1 = " & --1) Call ok(-empty = 0, "-empty = " & (-empty)) Call ok(true = -1, "! true = -1") @@ -81,6 +83,7 @@ Call ok(getVT(null) = "VT_NULL", "getVT(null) is not VT_NULL") Call ok(getVT(0) = "VT_I2", "getVT(0) is not VT_I2") Call ok(getVT(1) = "VT_I2", "getVT(1) is not VT_I2") Call ok(getVT(0.5) = "VT_R8", "getVT(0.5) is not VT_R8") +Call ok(getVT(.5) = "VT_R8", "getVT(.5) is not VT_R8") Call ok(getVT(0.0) = "VT_R8", "getVT(0.0) is not VT_R8") Call ok(getVT(2147483647) = "VT_I4", "getVT(2147483647) is not VT_I4") Call ok(getVT(2147483648) = "VT_R8", "getVT(2147483648) is not VT_R8")