Module: wine Branch: master Commit: 1a89ea7043e2ea10ff4a29c1c15f45ec80f3dbd7 URL: http://source.winehq.org/git/wine.git/?a=commit;h=1a89ea7043e2ea10ff4a29c1c1...
Author: Jacek Caban jacek@codeweavers.com Date: Wed Nov 6 17:18:38 2013 +0100
jscript: Improved error handling in numeric literal parser.
---
dlls/jscript/lex.c | 10 +++++++--- dlls/jscript/tests/api.js | 7 +++++++ 2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/dlls/jscript/lex.c b/dlls/jscript/lex.c index dfadccd..363e18d 100644 --- a/dlls/jscript/lex.c +++ b/dlls/jscript/lex.c @@ -454,6 +454,11 @@ static int parse_double_literal(parser_ctx_t *ctx, LONG int_part, literal_t **li else exp += e; }
+ if(is_identifier_char(*ctx->ptr)) { + WARN("wrong char after zero\n"); + return lex_error(ctx, JS_E_MISSING_SEMICOLON); + } + *literal = new_double_literal(ctx, exp>=0 ? d*pow(10, exp) : d/pow(10, -exp)); return tNumericLiteral; } @@ -477,7 +482,7 @@ static int parse_numeric_literal(parser_ctx_t *ctx, literal_t **literal)
if(ctx->ptr < ctx->end && is_identifier_char(*ctx->ptr)) { WARN("unexpected identifier char\n"); - return lex_error(ctx, E_FAIL); + return lex_error(ctx, JS_E_MISSING_SEMICOLON); }
*literal = new_double_literal(ctx, l); @@ -512,9 +517,8 @@ static int parse_numeric_literal(parser_ctx_t *ctx, literal_t **literal)
if(is_identifier_char(*ctx->ptr)) { WARN("wrong char after zero\n"); - return lex_error(ctx, E_FAIL); + return lex_error(ctx, JS_E_MISSING_SEMICOLON); } - }
return parse_double_literal(ctx, l, literal); diff --git a/dlls/jscript/tests/api.js b/dlls/jscript/tests/api.js index eb16176..e1f91c0 100644 --- a/dlls/jscript/tests/api.js +++ b/dlls/jscript/tests/api.js @@ -2357,6 +2357,13 @@ testSyntaxError("ok(false, 'unexpected execution'); while(true) continue some_la testSyntaxError("ok(false, 'unexpected execution'); some_label: { while(true) continue some_label; }", "E_INVALID_CONTINUE"); testSyntaxError("ok(false, 'unexpected execution'); some_label: { some_label: while(true); }", "E_LABEL_REDEFINED"); testSyntaxError("return;", "E_MISPLACED_RETURN"); +testSyntaxError("001.5;", "E_SEMICOLON"); +testSyntaxError("001.5", "E_SEMICOLON"); +testSyntaxError("0a", "E_SEMICOLON"); +testSyntaxError("01a", "E_SEMICOLON"); +testSyntaxError("0x1r", "E_SEMICOLON"); +testSyntaxError("1a", "E_SEMICOLON"); +testSyntaxError("1_", "E_SEMICOLON");
// ReferenceError tests testException(function() {test = function() {}}, "E_ILLEGAL_ASSIGN");