Module: wine Branch: master Commit: 98223b96e74d9d7403b00ba4acd11c6ebf74f3e0 URL: http://source.winehq.org/git/wine.git/?a=commit;h=98223b96e74d9d7403b00ba4ac...
Author: Piotr Caban piotr.caban@gmail.com Date: Fri Jul 24 09:35:56 2009 +0200
jscript: Throw SyntaxError in eval function.
---
dlls/jscript/error.c | 5 +++-- dlls/jscript/global.c | 2 +- dlls/jscript/jscript.h | 2 ++ dlls/jscript/jscript_En.rc | 1 + dlls/jscript/parser.y | 2 +- dlls/jscript/resource.h | 1 + dlls/jscript/tests/api.js | 1 + 7 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/dlls/jscript/error.c b/dlls/jscript/error.c index fb37fba..25a3836 100644 --- a/dlls/jscript/error.c +++ b/dlls/jscript/error.c @@ -424,7 +424,8 @@ static HRESULT throw_error(script_ctx_t *ctx, jsexcept_t *ei, UINT id, const WCH DispatchEx *err; HRESULT hres;
- LoadStringW(jscript_hinstance, id, buf, sizeof(buf)/sizeof(WCHAR)); + buf[0] = '\0'; + LoadStringW(jscript_hinstance, id&0xFFFF, buf, sizeof(buf)/sizeof(WCHAR));
if(str) pos = strchrW(buf, '|'); if(pos) { @@ -435,7 +436,7 @@ static HRESULT throw_error(script_ctx_t *ctx, jsexcept_t *ei, UINT id, const WCH
WARN("%s\n", debugstr_w(buf));
- id |= 0x800A0000; + id |= JSCRIPT_ERROR; hres = create_error(ctx, constr, &id, buf, &err); if(FAILED(hres)) return hres; diff --git a/dlls/jscript/global.c b/dlls/jscript/global.c index 1ec113d..7d59e19 100644 --- a/dlls/jscript/global.c +++ b/dlls/jscript/global.c @@ -330,7 +330,7 @@ static HRESULT JSGlobal_eval(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARA hres = script_parse(dispex->ctx, V_BSTR(arg), NULL, &parser_ctx); if(FAILED(hres)) { WARN("parse (%s) failed: %08x\n", debugstr_w(V_BSTR(arg)), hres); - return hres; + return throw_syntax_error(dispex->ctx, ei, hres, NULL); }
hres = exec_source(dispex->ctx->exec_ctx, parser_ctx, parser_ctx->source, ei, retv); diff --git a/dlls/jscript/jscript.h b/dlls/jscript/jscript.h index f99299f..70c9fea 100644 --- a/dlls/jscript/jscript.h +++ b/dlls/jscript/jscript.h @@ -33,6 +33,8 @@ #include "wine/unicode.h" #include "wine/list.h"
+#define JSCRIPT_ERROR 0x800A0000 + typedef struct _script_ctx_t script_ctx_t; typedef struct _exec_ctx_t exec_ctx_t; typedef struct _dispex_prop_t dispex_prop_t; diff --git a/dlls/jscript/jscript_En.rc b/dlls/jscript/jscript_En.rc index df8ee2f..154479a 100644 --- a/dlls/jscript/jscript_En.rc +++ b/dlls/jscript/jscript_En.rc @@ -26,6 +26,7 @@ STRINGTABLE DISCARDABLE IDS_INVALID_CALL_ARG "Invalid procedure call or argument" IDS_NO_PROPERTY "Object doesn't support this property or method" IDS_ARG_NOT_OPT "Argument not optional" + IDS_SYNTAX_ERROR "Syntax error" IDS_NOT_FUNC "Function expected" IDS_NOT_DATE "'[object]' is not a date object" IDS_NOT_NUM "Number expected" diff --git a/dlls/jscript/parser.y b/dlls/jscript/parser.y index d47d40d..adec6bc 100644 --- a/dlls/jscript/parser.y +++ b/dlls/jscript/parser.y @@ -1568,7 +1568,7 @@ HRESULT script_parse(script_ctx_t *ctx, const WCHAR *code, const WCHAR *delimite return E_OUTOFMEMORY;
parser_ctx->ref = 1; - parser_ctx->hres = E_FAIL; + parser_ctx->hres = JSCRIPT_ERROR|IDS_SYNTAX_ERROR; parser_ctx->is_html = delimiter && !strcmpiW(delimiter, html_tagW);
parser_ctx->begin = parser_ctx->ptr = code; diff --git a/dlls/jscript/resource.h b/dlls/jscript/resource.h index 0f5af9b..fd2cb82 100644 --- a/dlls/jscript/resource.h +++ b/dlls/jscript/resource.h @@ -22,6 +22,7 @@ #define IDS_INVALID_CALL_ARG 0x0005 #define IDS_NO_PROPERTY 0x01B6 #define IDS_ARG_NOT_OPT 0x01c1 +#define IDS_SYNTAX_ERROR 0x03EA #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 7428413..a71c0aa 100644 --- a/dlls/jscript/tests/api.js +++ b/dlls/jscript/tests/api.js @@ -1317,5 +1317,6 @@ exception_test(function() {not_existing_variable.something();}, "TypeError", -21 exception_test(function() {arr.toString = Function.prototype.toString; arr.toString();}, "TypeError", -2146823286); exception_test(function() {date();}, "TypeError", -2146823286); exception_test(function() {arr();}, "TypeError", -2146823286); +exception_test(function() {eval("for(i=0;) {}");}, "SyntaxError", -2146827286);
reportSuccess();