Piotr Caban : jscript: Added 'unterminated string' error.

Alexandre Julliard julliard at winehq.org
Thu Aug 6 10:49:09 CDT 2009


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

Author: Piotr Caban <piotr.caban at gmail.com>
Date:   Wed Aug  5 23:27:09 2009 +0200

jscript: Added 'unterminated string' error.

---

 dlls/jscript/engine.h      |    1 +
 dlls/jscript/jscript_En.rc |    1 +
 dlls/jscript/lex.c         |    9 ++++-----
 dlls/jscript/parser.y      |    3 ++-
 dlls/jscript/resource.h    |    1 +
 dlls/jscript/tests/api.js  |    1 +
 6 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/dlls/jscript/engine.h b/dlls/jscript/engine.h
index f1a78ec..8d53f00 100644
--- a/dlls/jscript/engine.h
+++ b/dlls/jscript/engine.h
@@ -56,6 +56,7 @@ typedef struct _parser_ctx_t {
     source_elements_t *source;
     BOOL nl;
     BOOL is_html;
+    BOOL lexer_error;
     HRESULT hres;
 
     jsheap_t heap;
diff --git a/dlls/jscript/jscript_En.rc b/dlls/jscript/jscript_En.rc
index b47e951..697c1ab 100644
--- a/dlls/jscript/jscript_En.rc
+++ b/dlls/jscript/jscript_En.rc
@@ -30,6 +30,7 @@ STRINGTABLE DISCARDABLE
     IDS_SEMICOLON           "Expected ';'"
     IDS_LBRACKET            "Expected '('"
     IDS_RBRACKET            "Expected ')'"
+    IDS_UNTERMINATED_STR    "Unterminated string constant"
     IDS_NOT_FUNC            "Function expected"
     IDS_NOT_DATE            "'[object]' is not a date object"
     IDS_NOT_NUM             "Number expected"
diff --git a/dlls/jscript/lex.c b/dlls/jscript/lex.c
index 5b7e7a4..eb9b835 100644
--- a/dlls/jscript/lex.c
+++ b/dlls/jscript/lex.c
@@ -100,7 +100,8 @@ static const struct {
 
 static int lex_error(parser_ctx_t *ctx, HRESULT hres)
 {
-    ctx->hres = hres;
+    ctx->hres = JSCRIPT_ERROR|hres;
+    ctx->lexer_error = TRUE;
     return -1;
 }
 
@@ -342,10 +343,8 @@ static int parse_string_literal(parser_ctx_t *ctx, const WCHAR **ret, WCHAR endc
             ctx->ptr++;
     }
 
-    if(ctx->ptr == ctx->end) {
-        WARN("unexpected end of file\n");
-        return lex_error(ctx, E_FAIL);
-    }
+    if(ctx->ptr == ctx->end)
+        return lex_error(ctx, IDS_UNTERMINATED_STR);
 
     len = ctx->ptr-ptr;
 
diff --git a/dlls/jscript/parser.y b/dlls/jscript/parser.y
index a0ae471..29d805f 100644
--- a/dlls/jscript/parser.y
+++ b/dlls/jscript/parser.y
@@ -1577,7 +1577,8 @@ static void program_parsed(parser_ctx_t *ctx, source_elements_t *source)
     pop_func(ctx);
 
     ctx->source = source;
-    ctx->hres = S_OK;
+    if(!ctx->lexer_error)
+        ctx->hres = S_OK;
 }
 
 void parser_release(parser_ctx_t *ctx)
diff --git a/dlls/jscript/resource.h b/dlls/jscript/resource.h
index 0503961..f7e94b9 100644
--- a/dlls/jscript/resource.h
+++ b/dlls/jscript/resource.h
@@ -26,6 +26,7 @@
 #define IDS_SEMICOLON                       0x03EC
 #define IDS_LBRACKET                        0x03ED
 #define IDS_RBRACKET                        0x03EE
+#define IDS_UNTERMINATED_STR                0x03F7
 #define IDS_NOT_FUNC                        0x138A
 #define IDS_NOT_DATE                        0x138E
 #define IDS_NOT_NUM                         0x1389
diff --git a/dlls/jscript/tests/api.js b/dlls/jscript/tests/api.js
index 53b7f92..66fea75 100644
--- a/dlls/jscript/tests/api.js
+++ b/dlls/jscript/tests/api.js
@@ -1333,5 +1333,6 @@ exception_test(function() {eval("for(i=0")}, "SyntaxError", -2146827284);
 exception_test(function() {eval("for(i=0;i<10")}, "SyntaxError", -2146827284);
 exception_test(function() {eval("while(")}, "SyntaxError", -2146827286);
 exception_test(function() {eval("if(")}, "SyntaxError", -2146827286);
+exception_test(function() {eval("'unterminated")}, "SyntaxError", -2146827273);
 
 reportSuccess();




More information about the wine-cvs mailing list