winehq.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
January
2003
December
November
October
September
August
July
June
May
April
March
February
January
2002
December
November
October
September
August
July
June
May
April
March
February
January
2001
December
November
October
September
August
July
June
May
April
March
February
List overview
wine-commits
January 2020
----- 2025 -----
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
----- 2003 -----
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
----- 2002 -----
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
----- 2001 -----
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
wine-commits@winehq.org
1 participants
535 discussions
Start a n
N
ew thread
Zebediah Figura : quartz: Simplify FilterMapper_RegisterPin().
by Alexandre Julliard
23 Jan '20
23 Jan '20
Module: wine Branch: master Commit: 48976108665a9c1f4af99e9e85f3c8fcf82daa7b URL:
https://source.winehq.org/git/wine.git/?a=commit;h=48976108665a9c1f4af99e9e…
Author: Zebediah Figura <z.figura12(a)gmail.com> Date: Wed Jan 22 16:30:49 2020 -0600 quartz: Simplify FilterMapper_RegisterPin(). Avoid some unnecessary allocations. Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/quartz/filtermapper.c | 127 +++++++++++++++------------------------------ 1 file changed, 42 insertions(+), 85 deletions(-) diff --git a/dlls/quartz/filtermapper.c b/dlls/quartz/filtermapper.c index bb718ed1ce..f7259a1650 100644 --- a/dlls/quartz/filtermapper.c +++ b/dlls/quartz/filtermapper.c @@ -87,10 +87,6 @@ static const WCHAR wszFilterDataName[] = {'F','i','l','t','e','r','D','a','t','a static const WCHAR wszFilter[] = {'F','i','l','t','e','r',0}; /* For pins registered with IFilterMapper */ static const WCHAR wszPins[] = {'P','i','n','s',0}; -static const WCHAR wszAllowedMany[] = {'A','l','l','o','w','e','d','M','a','n','y',0}; -static const WCHAR wszAllowedZero[] = {'A','l','l','o','w','e','d','Z','e','r','o',0}; -static const WCHAR wszDirection[] = {'D','i','r','e','c','t','i','o','n',0}; -static const WCHAR wszIsRendered[] = {'I','s','R','e','n','d','e','r','e','d',0}; /* For types registered with IFilterMapper */ static const WCHAR wszTypes[] = {'T','y','p','e','s',0}; @@ -1162,98 +1158,59 @@ static HRESULT WINAPI FilterMapper_RegisterFilterInstance(IFilterMapper * iface, return E_NOTIMPL; } -static HRESULT WINAPI FilterMapper_RegisterPin( - IFilterMapper * iface, - CLSID Filter, - LPCWSTR szName, - BOOL bRendered, - BOOL bOutput, - BOOL bZero, - BOOL bMany, - CLSID ConnectsToFilter, - LPCWSTR ConnectsToPin) +static HRESULT WINAPI FilterMapper_RegisterPin(IFilterMapper *iface, CLSID clsid, + const WCHAR *name, BOOL rendered, BOOL output, BOOL zero, BOOL many, + CLSID external_filter, const WCHAR *external_pin) { - HRESULT hr; - LONG lRet; - LPWSTR wszClsid = NULL; - HKEY hKey = NULL; - HKEY hPinsKey = NULL; - WCHAR * wszPinsKeyName; - WCHAR wszKeyName[ARRAY_SIZE(wszClsidSlash)-1 + (CHARS_IN_GUID-1) + 1]; - - TRACE("(%p)->(%s, %s, %d, %d, %d, %d, %s, %s)\n", iface, debugstr_guid(&Filter), debugstr_w(szName), bRendered, - bOutput, bZero, bMany, debugstr_guid(&ConnectsToFilter), debugstr_w(ConnectsToPin)); - - hr = StringFromCLSID(&Filter, &wszClsid); - - if (SUCCEEDED(hr)) - { - lstrcpyW(wszKeyName, wszClsidSlash); - lstrcatW(wszKeyName, wszClsid); - - lRet = RegOpenKeyExW(HKEY_CLASSES_ROOT, wszKeyName, 0, KEY_WRITE, &hKey); - hr = HRESULT_FROM_WIN32(lRet); - } - - if (SUCCEEDED(hr)) - { - wszPinsKeyName = CoTaskMemAlloc((lstrlenW(wszPins) + 1 + lstrlenW(szName) + 1) * 2); - if (!wszPinsKeyName) - hr = E_OUTOFMEMORY; - } - - if (SUCCEEDED(hr)) - { - lstrcpyW(wszPinsKeyName, wszPins); - lstrcatW(wszPinsKeyName, wszSlash); - lstrcatW(wszPinsKeyName, szName); - - lRet = RegCreateKeyExW(hKey, wszPinsKeyName, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hPinsKey, NULL); - hr = HRESULT_FROM_WIN32(lRet); - CoTaskMemFree(wszPinsKeyName); - } - - if (SUCCEEDED(hr)) - { - lRet = RegSetValueExW(hPinsKey, wszAllowedMany, 0, REG_DWORD, (LPBYTE)&bMany, sizeof(bMany)); - hr = HRESULT_FROM_WIN32(lRet); - } + WCHAR keypath[6 + 38 + 1], *pin_keypath; + HKEY key, pin_key, type_key; + LONG ret; - if (SUCCEEDED(hr)) - { - lRet = RegSetValueExW(hPinsKey, wszAllowedZero, 0, REG_DWORD, (LPBYTE)&bZero, sizeof(bZero)); - hr = HRESULT_FROM_WIN32(lRet); - } + TRACE("iface %p, clsid %s, name %s, rendered %d, output %d, zero %d, " + "many %d, external_filter %s, external_pin %s.\n", + iface, debugstr_guid(&clsid), debugstr_w(name), rendered, output, + zero, many, debugstr_guid(&external_filter), debugstr_w(external_pin)); - if (SUCCEEDED(hr)) - { - lRet = RegSetValueExW(hPinsKey, wszDirection, 0, REG_DWORD, (LPBYTE)&bOutput, sizeof(bOutput)); - hr = HRESULT_FROM_WIN32(lRet); - } + wcscpy(keypath, L"CLSID\\"); + StringFromGUID2(&clsid, keypath + wcslen(keypath), ARRAY_SIZE(keypath) - wcslen(keypath)); + if ((ret = RegOpenKeyExW(HKEY_CLASSES_ROOT, keypath, 0, KEY_WRITE, &key))) + return HRESULT_FROM_WIN32(ret); - if (SUCCEEDED(hr)) + if (!(pin_keypath = malloc((5 + wcslen(name) + 1) * sizeof(WCHAR)))) { - lRet = RegSetValueExW(hPinsKey, wszIsRendered, 0, REG_DWORD, (LPBYTE)&bRendered, sizeof(bRendered)); - hr = HRESULT_FROM_WIN32(lRet); + RegCloseKey(key); + return E_OUTOFMEMORY; } + wcscpy(pin_keypath, L"Pins\\"); + wcscat(pin_keypath, name); - if (SUCCEEDED(hr)) + if ((ret = RegCreateKeyExW(key, pin_keypath, 0, NULL, 0, KEY_WRITE, NULL, &pin_key, NULL))) { - HKEY hkeyDummy = NULL; - - lRet = RegCreateKeyExW(hPinsKey, wszTypes, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hkeyDummy, NULL); - hr = HRESULT_FROM_WIN32(lRet); - - if (hkeyDummy) RegCloseKey(hkeyDummy); + ERR("Failed to open pin key, error %u.\n", ret); + free(pin_keypath); + RegCloseKey(key); + return HRESULT_FROM_WIN32(ret); } + free(pin_keypath); + + if ((ret = RegSetValueExW(pin_key, L"AllowedMany", 0, REG_DWORD, (const BYTE *)&many, sizeof(DWORD)))) + ERR("Failed to set AllowedMany value, error %u.\n", ret); + if ((ret = RegSetValueExW(pin_key, L"AllowedZero", 0, REG_DWORD, (const BYTE *)&zero, sizeof(DWORD)))) + ERR("Failed to set AllowedZero value, error %u.\n", ret); + if ((ret = RegSetValueExW(pin_key, L"Direction", 0, REG_DWORD, (const BYTE *)&output, sizeof(DWORD)))) + ERR("Failed to set Direction value, error %u.\n", ret); + if ((ret = RegSetValueExW(pin_key, L"IsRendered", 0, REG_DWORD, (const BYTE *)&rendered, sizeof(DWORD)))) + ERR("Failed to set IsRendered value, error %u.\n", ret); + + if (!(ret = RegCreateKeyExW(pin_key, L"Types", 0, NULL, 0, 0, NULL, &type_key, NULL))) + RegCloseKey(type_key); + else + ERR("Failed to create Types subkey, error %u.\n", ret); - CoTaskMemFree(wszClsid); - if (hKey) - RegCloseKey(hKey); - if (hPinsKey) - RegCloseKey(hPinsKey); + RegCloseKey(pin_key); + RegCloseKey(key); - return hr; + return S_OK; }
1
0
0
0
Jacek Caban : vbscript: Support reporting error location to script host.
by Alexandre Julliard
23 Jan '20
23 Jan '20
Module: wine Branch: master Commit: e35564b36df5a0f1c5a141f28fb86e8b4c2495b3 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=e35564b36df5a0f1c5a141f2…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Wed Jan 22 23:28:01 2020 +0100 vbscript: Support reporting error location to script host. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/vbscript/compile.c | 17 ++++++++++------- dlls/vbscript/interp.c | 20 +++++++++++++++++--- dlls/vbscript/tests/run.c | 3 +-- dlls/vbscript/vbscript.c | 24 +++++++++++++++++++----- dlls/vbscript/vbscript.h | 4 +++- 5 files changed, 50 insertions(+), 18 deletions(-) diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c index 1f9462aee8..e52d8b1a24 100644 --- a/dlls/vbscript/compile.c +++ b/dlls/vbscript/compile.c @@ -374,7 +374,7 @@ static inline BOOL emit_catch(compile_ctx_t *ctx, unsigned off) return emit_catch_jmp(ctx, off, ctx->instr_cnt); } -static HRESULT compile_error(script_ctx_t *ctx, HRESULT error) +static HRESULT compile_error(script_ctx_t *ctx, compile_ctx_t *compiler, HRESULT error) { if(error == SCRIPT_E_REPORTED) return error; @@ -383,7 +383,7 @@ static HRESULT compile_error(script_ctx_t *ctx, HRESULT error) ctx->ei.scode = error = map_hres(error); ctx->ei.bstrSource = get_vbscript_string(VBS_COMPILE_ERROR); ctx->ei.bstrDescription = get_vbscript_error_string(error); - return report_script_error(ctx); + return report_script_error(ctx, compiler->code, compiler->loc); } static expression_t *lookup_const_decls(compile_ctx_t *ctx, const WCHAR *name, BOOL lookup_global) @@ -1926,18 +1926,19 @@ HRESULT compile_script(script_ctx_t *script, const WCHAR *src, const WCHAR *deli if(FAILED(hres)) { if(ctx.parser.error_loc != -1) ctx.loc = ctx.parser.error_loc; - hres = compile_error(script, hres); + hres = compile_error(script, &ctx, hres); release_vbscode(code); return hres; } hres = compile_func(&ctx, ctx.parser.stats, &ctx.code->main_code); if(FAILED(hres)) { - hres = compile_error(script, hres); + hres = compile_error(script, &ctx, hres); release_compiler(&ctx); return hres; } + code->option_explicit = ctx.parser.option_explicit; ctx.global_consts = ctx.const_decls; code->option_explicit = ctx.parser.option_explicit; @@ -1945,7 +1946,7 @@ HRESULT compile_script(script_ctx_t *script, const WCHAR *src, const WCHAR *deli for(func_decl = ctx.func_decls; func_decl; func_decl = func_decl->next) { hres = create_function(&ctx, func_decl, &new_func); if(FAILED(hres)) { - hres = compile_error(script, hres); + hres = compile_error(script, &ctx, hres); release_compiler(&ctx); return hres; } @@ -1957,15 +1958,17 @@ HRESULT compile_script(script_ctx_t *script, const WCHAR *src, const WCHAR *deli for(class_decl = ctx.parser.class_decls; class_decl; class_decl = class_decl->next) { hres = compile_class(&ctx, class_decl); if(FAILED(hres)) { + hres = compile_error(script, &ctx, hres); release_compiler(&ctx); - return compile_error(script, hres); + return hres; } } hres = check_script_collisions(&ctx, script); if(FAILED(hres)) { + hres = compile_error(script, &ctx, hres); release_compiler(&ctx); - return compile_error(script, hres); + return hres; } code->is_persistent = (flags & SCRIPTTEXT_ISPERSISTENT) != 0; diff --git a/dlls/vbscript/interp.c b/dlls/vbscript/interp.c index 66ad206837..9c07535517 100644 --- a/dlls/vbscript/interp.c +++ b/dlls/vbscript/interp.c @@ -275,6 +275,14 @@ void clear_ei(EXCEPINFO *ei) memset(ei, 0, sizeof(*ei)); } +static void clear_error_loc(script_ctx_t *ctx) +{ + if(ctx->error_loc_code) { + release_vbscode(ctx->error_loc_code); + ctx->error_loc_code = NULL; + } +} + static inline VARIANT *stack_pop(exec_ctx_t *ctx) { assert(ctx->top); @@ -2396,6 +2404,7 @@ HRESULT exec_script(script_ctx_t *ctx, BOOL extern_caller, function_t *func, vbd TRACE("unwind jmp %d stack_off %d\n", exec.instr->arg1.uint, exec.instr->arg2.uint); + clear_error_loc(ctx); stack_off = exec.instr->arg2.uint; instr_jmp(&exec, exec.instr->arg1.uint); @@ -2414,7 +2423,11 @@ HRESULT exec_script(script_ctx_t *ctx, BOOL extern_caller, function_t *func, vbd continue; }else { - WARN("Failed %08x\n", hres); + if(!ctx->error_loc_code) { + grab_vbscode(exec.code); + ctx->error_loc_code = exec.code; + ctx->error_loc_offset = exec.instr->loc; + } stack_popn(&exec, exec.top); break; } @@ -2426,12 +2439,13 @@ HRESULT exec_script(script_ctx_t *ctx, BOOL extern_caller, function_t *func, vbd assert(!exec.top); if(extern_caller) { - IActiveScriptSite_OnLeaveScript(ctx->site); if(FAILED(hres)) { if(!ctx->ei.scode) ctx->ei.scode = hres; - hres = report_script_error(ctx); + hres = report_script_error(ctx, ctx->error_loc_code, ctx->error_loc_offset); + clear_error_loc(ctx); } + IActiveScriptSite_OnLeaveScript(ctx->site); } if(SUCCEEDED(hres) && res) { diff --git a/dlls/vbscript/tests/run.c b/dlls/vbscript/tests/run.c index 696c3f530b..015f2b816a 100644 --- a/dlls/vbscript/tests/run.c +++ b/dlls/vbscript/tests/run.c @@ -2530,10 +2530,9 @@ static void test_parse_errors(void) ok(hres == SCRIPT_E_REPORTED, "[%u] script returned: %08x\n", i, hres); CHECK_CALLED(OnScriptError); - todo_wine_if(invalid_scripts[i].error_line) ok(error_line == invalid_scripts[i].error_line, "[%u] error line %u expected %u\n", i, error_line, invalid_scripts[i].error_line); - todo_wine_if(invalid_scripts[i].error_char) + todo_wine_if(invalid_scripts[i].error_char < 0) ok(error_char == abs(invalid_scripts[i].error_char), "[%u] error char %d expected %d\n", i, error_char, invalid_scripts[i].error_char); } diff --git a/dlls/vbscript/vbscript.c b/dlls/vbscript/vbscript.c index 12681672ca..2b691af583 100644 --- a/dlls/vbscript/vbscript.c +++ b/dlls/vbscript/vbscript.c @@ -61,6 +61,9 @@ typedef struct { IActiveScriptError IActiveScriptError_iface; LONG ref; EXCEPINFO ei; + DWORD_PTR cookie; + unsigned line; + unsigned character; } VBScriptError; static inline WCHAR *heap_pool_strdup(heap_pool_t *heap, const WCHAR *str) @@ -377,14 +380,14 @@ static HRESULT WINAPI VBScriptError_GetSourcePosition(IActiveScriptError *iface, { VBScriptError *This = impl_from_IActiveScriptError(iface); - FIXME("(%p)->(%p %p %p)\n", This, source_context, line, character); + TRACE("(%p)->(%p %p %p)\n", This, source_context, line, character); if(source_context) - *source_context = 0; + *source_context = This->cookie; if(line) - *line = 0; + *line = This->line; if(character) - *character = 0; + *character = This->character; return S_OK; } @@ -404,9 +407,10 @@ static const IActiveScriptErrorVtbl VBScriptErrorVtbl = { VBScriptError_GetSourceLineText }; -HRESULT report_script_error(script_ctx_t *ctx) +HRESULT report_script_error(script_ctx_t *ctx, const vbscode_t *code, unsigned loc) { VBScriptError *error; + const WCHAR *p, *nl; HRESULT hres, result; if(!(error = heap_alloc(sizeof(*error)))) @@ -418,6 +422,16 @@ HRESULT report_script_error(script_ctx_t *ctx) memset(&ctx->ei, 0, sizeof(ctx->ei)); result = error->ei.scode; + p = code->source; + error->cookie = code->cookie; + error->line = code->start_line; + for(nl = p = code->source; p < code->source + loc; p++) { + if(*p != '\n') continue; + error->line++; + nl = p + 1; + } + error->character = code->source + loc - nl; + hres = IActiveScriptSite_OnScriptError(ctx->site, &error->IActiveScriptError_iface); IActiveScriptError_Release(&error->IActiveScriptError_iface); return hres == S_OK ? SCRIPT_E_REPORTED : result; diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h index 51797fbdfc..33ecb45bf4 100644 --- a/dlls/vbscript/vbscript.h +++ b/dlls/vbscript/vbscript.h @@ -192,6 +192,8 @@ struct _script_ctx_t { BuiltinDisp *err_obj; EXCEPINFO ei; + vbscode_t *error_loc_code; + unsigned error_loc_offset; struct list objects; struct list code_list; @@ -372,7 +374,7 @@ HRESULT exec_script(script_ctx_t*,BOOL,function_t*,vbdisp_t*,DISPPARAMS*,VARIANT void release_dynamic_var(dynamic_var_t*) DECLSPEC_HIDDEN; IDispatch *lookup_named_item(script_ctx_t*,const WCHAR*,unsigned) DECLSPEC_HIDDEN; void clear_ei(EXCEPINFO*) DECLSPEC_HIDDEN; -HRESULT report_script_error(script_ctx_t*) DECLSPEC_HIDDEN; +HRESULT report_script_error(script_ctx_t*,const vbscode_t*,unsigned) DECLSPEC_HIDDEN; void detach_global_objects(script_ctx_t*) DECLSPEC_HIDDEN; HRESULT get_builtin_id(BuiltinDisp*,const WCHAR*,DISPID*) DECLSPEC_HIDDEN;
1
0
0
0
Jacek Caban : vbscript: Pass parser error location to compiler.
by Alexandre Julliard
23 Jan '20
23 Jan '20
Module: wine Branch: master Commit: eb73571fe987344c0caca9ada621a129d1883c2b URL:
https://source.winehq.org/git/wine.git/?a=commit;h=eb73571fe987344c0caca9ad…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Wed Jan 22 23:27:54 2020 +0100 vbscript: Pass parser error location to compiler. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/vbscript/compile.c | 15 +++++++-------- dlls/vbscript/parse.h | 1 + dlls/vbscript/parser.y | 3 +++ 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c index 769bbf15ba..1f9462aee8 100644 --- a/dlls/vbscript/compile.c +++ b/dlls/vbscript/compile.c @@ -1917,27 +1917,25 @@ HRESULT compile_script(script_ctx_t *script, const WCHAR *src, const WCHAR *deli vbscode_t *code; HRESULT hres; + memset(&ctx, 0, sizeof(ctx)); code = ctx.code = alloc_vbscode(&ctx, src, cookie, start_line); if(!ctx.code) return E_OUTOFMEMORY; hres = parse_script(&ctx.parser, code->source, delimiter, flags); if(FAILED(hres)) { + if(ctx.parser.error_loc != -1) + ctx.loc = ctx.parser.error_loc; hres = compile_error(script, hres); release_vbscode(code); return hres; } - ctx.func_decls = NULL; - ctx.labels = NULL; - ctx.global_consts = NULL; - ctx.stat_ctx = NULL; - ctx.labels_cnt = ctx.labels_size = 0; - hres = compile_func(&ctx, ctx.parser.stats, &ctx.code->main_code); if(FAILED(hres)) { + hres = compile_error(script, hres); release_compiler(&ctx); - return compile_error(script, hres); + return hres; } ctx.global_consts = ctx.const_decls; @@ -1947,8 +1945,9 @@ HRESULT compile_script(script_ctx_t *script, const WCHAR *src, const WCHAR *deli for(func_decl = ctx.func_decls; func_decl; func_decl = func_decl->next) { hres = create_function(&ctx, func_decl, &new_func); if(FAILED(hres)) { + hres = compile_error(script, hres); release_compiler(&ctx); - return compile_error(script, hres); + return hres; } new_func->next = ctx.code->funcs; diff --git a/dlls/vbscript/parse.h b/dlls/vbscript/parse.h index 8d68e781fb..568d8b9a42 100644 --- a/dlls/vbscript/parse.h +++ b/dlls/vbscript/parse.h @@ -286,6 +286,7 @@ typedef struct { BOOL option_explicit; BOOL is_html; HRESULT hres; + int error_loc; int last_token; unsigned last_nl; diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y index 16a673fac7..8ebfc82f00 100644 --- a/dlls/vbscript/parser.y +++ b/dlls/vbscript/parser.y @@ -505,6 +505,8 @@ StSep static int parser_error(unsigned *loc, parser_ctx_t *ctx, const char *str) { + if(ctx->error_loc == -1) + ctx->error_loc = *loc; if(ctx->hres == S_OK) { FIXME("%s: %s\n", debugstr_w(ctx->code + *loc), debugstr_a(str)); ctx->hres = E_FAIL; @@ -1142,6 +1144,7 @@ HRESULT parse_script(parser_ctx_t *ctx, const WCHAR *code, const WCHAR *delimite heap_pool_init(&ctx->heap); ctx->hres = S_OK; + ctx->error_loc = -1; ctx->last_token = tNL; ctx->last_nl = 0; ctx->stats = ctx->stats_tail = NULL;
1
0
0
0
Jacek Caban : vbscript: Simplify option explicit parsing.
by Alexandre Julliard
23 Jan '20
23 Jan '20
Module: wine Branch: master Commit: 12b1bcdb950b0ef5b9e849e7165a653880300909 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=12b1bcdb950b0ef5b9e849e7…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Wed Jan 22 23:27:45 2020 +0100 vbscript: Simplify option explicit parsing. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/vbscript/parser.y | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y index b54d4af32f..16a673fac7 100644 --- a/dlls/vbscript/parser.y +++ b/dlls/vbscript/parser.y @@ -27,7 +27,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(vbscript); static int parser_error(unsigned*,parser_ctx_t*,const char*); -static void parse_complete(parser_ctx_t*,BOOL); static void handle_isexpression_script(parser_ctx_t *ctx, expression_t *expr); static void source_add_statement(parser_ctx_t*,statement_t*); @@ -138,7 +137,7 @@ static statement_t *link_statements(statement_t*,statement_t*); %type <expression> ConstExpression NumericLiteralExpression %type <member> MemberExpression %type <expression> Arguments Arguments_opt ArgumentList ArgumentList_opt Step_opt ExpressionList -%type <boolean> OptionExplicit_opt DoType Preserve_opt +%type <boolean> DoType Preserve_opt %type <arg_decl> ArgumentsDecl_opt ArgumentDeclList ArgumentDecl %type <func_decl> FunctionDecl PropertyDecl %type <elseif> ElseIfs_opt ElseIfs ElseIf @@ -153,12 +152,12 @@ static statement_t *link_statements(statement_t*,statement_t*); %% Program - : OptionExplicit_opt SourceElements { parse_complete(ctx, $1); } + : OptionExplicit_opt SourceElements | tEXPRESSION ExpressionNl_opt { handle_isexpression_script(ctx, $2); } OptionExplicit_opt - : /* empty */ { $$ = FALSE; } - | tOPTION tEXPLICIT StSep { $$ = TRUE; } + : /* empty */ + | tOPTION tEXPLICIT StSep { ctx->option_explicit = TRUE; } SourceElements : /* empty */ @@ -534,11 +533,6 @@ static void source_add_class(parser_ctx_t *ctx, class_decl_t *class_decl) ctx->class_decls = class_decl; } -static void parse_complete(parser_ctx_t *ctx, BOOL option_explicit) -{ - ctx->option_explicit = option_explicit; -} - static void handle_isexpression_script(parser_ctx_t *ctx, expression_t *expr) { retval_statement_t *stat;
1
0
0
0
Jacek Caban : vbscript: Use parser_error to set unhandled parser error.
by Alexandre Julliard
23 Jan '20
23 Jan '20
Module: wine Branch: master Commit: b2de64eeedbc5ed2cf76b4aa079745dad60b8dbb URL:
https://source.winehq.org/git/wine.git/?a=commit;h=b2de64eeedbc5ed2cf76b4aa…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Wed Jan 22 23:27:35 2020 +0100 vbscript: Use parser_error to set unhandled parser error. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/vbscript/lex.c | 2 +- dlls/vbscript/parse.h | 1 - dlls/vbscript/parser.y | 25 ++++++++++--------------- 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/dlls/vbscript/lex.c b/dlls/vbscript/lex.c index 986693e3e1..db104fd892 100644 --- a/dlls/vbscript/lex.c +++ b/dlls/vbscript/lex.c @@ -351,7 +351,7 @@ static int parse_next_token(void *lval, unsigned *loc, parser_ctx_t *ctx) skip_spaces(ctx); *loc = ctx->ptr - ctx->code; if(ctx->ptr == ctx->end) - return ctx->last_token == tNL ? tEOF : tNL; + return ctx->last_token == tNL ? 0 : tNL; c = *ctx->ptr; diff --git a/dlls/vbscript/parse.h b/dlls/vbscript/parse.h index 37ddd7a11c..8d68e781fb 100644 --- a/dlls/vbscript/parse.h +++ b/dlls/vbscript/parse.h @@ -284,7 +284,6 @@ typedef struct { const WCHAR *end; BOOL option_explicit; - BOOL parse_complete; BOOL is_html; HRESULT hres; diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y index 7a09d0c074..b54d4af32f 100644 --- a/dlls/vbscript/parser.y +++ b/dlls/vbscript/parser.y @@ -110,7 +110,7 @@ static statement_t *link_statements(statement_t*,statement_t*); double dbl; } -%token tEXPRESSION tEOF tNL tEMPTYBRACKETS tEXPRLBRACKET +%token tEXPRESSION tNL tEMPTYBRACKETS tEXPRLBRACKET %token tLTEQ tGTEQ tNEQ %token tSTOP tME tREM tDOT %token <string> tTRUE tFALSE @@ -153,8 +153,8 @@ static statement_t *link_statements(statement_t*,statement_t*); %% Program - : OptionExplicit_opt SourceElements tEOF { parse_complete(ctx, $1); } - | tEXPRESSION ExpressionNl_opt tEOF { handle_isexpression_script(ctx, $2); } + : OptionExplicit_opt SourceElements { parse_complete(ctx, $1); } + | tEXPRESSION ExpressionNl_opt { handle_isexpression_script(ctx, $2); } OptionExplicit_opt : /* empty */ { $$ = FALSE; } @@ -506,6 +506,12 @@ StSep static int parser_error(unsigned *loc, parser_ctx_t *ctx, const char *str) { + if(ctx->hres == S_OK) { + FIXME("%s: %s\n", debugstr_w(ctx->code + *loc), debugstr_a(str)); + ctx->hres = E_FAIL; + }else { + WARN("%s: %08x\n", debugstr_w(ctx->code + *loc), ctx->hres); + } return 0; } @@ -530,7 +536,6 @@ static void source_add_class(parser_ctx_t *ctx, class_decl_t *class_decl) static void parse_complete(parser_ctx_t *ctx, BOOL option_explicit) { - ctx->parse_complete = TRUE; ctx->option_explicit = option_explicit; } @@ -538,7 +543,6 @@ static void handle_isexpression_script(parser_ctx_t *ctx, expression_t *expr) { retval_statement_t *stat; - ctx->parse_complete = TRUE; if(!expr) return; @@ -1143,9 +1147,7 @@ HRESULT parse_script(parser_ctx_t *ctx, const WCHAR *code, const WCHAR *delimite heap_pool_init(&ctx->heap); - ctx->parse_complete = FALSE; ctx->hres = S_OK; - ctx->last_token = tNL; ctx->last_nl = 0; ctx->stats = ctx->stats_tail = NULL; @@ -1158,14 +1160,7 @@ HRESULT parse_script(parser_ctx_t *ctx, const WCHAR *code, const WCHAR *delimite parser_parse(ctx); - if(FAILED(ctx->hres)) - return ctx->hres; - if(!ctx->parse_complete) { - FIXME("parser failed around %s\n", debugstr_w(ctx->code+20 > ctx->ptr ? ctx->code : ctx->ptr-20)); - return E_FAIL; - } - - return S_OK; + return ctx->hres; } void parser_release(parser_ctx_t *ctx)
1
0
0
0
Jacek Caban : vbscript: Store source cookie and starting line in vbscode_t.
by Alexandre Julliard
23 Jan '20
23 Jan '20
Module: wine Branch: master Commit: 5436fc90f458ce86f2a7e073e1d4a08ebf967254 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=5436fc90f458ce86f2a7e073…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Wed Jan 22 23:27:25 2020 +0100 vbscript: Store source cookie and starting line in vbscode_t. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/vbscript/compile.c | 15 ++++++++++----- dlls/vbscript/vbscript.c | 5 +++-- dlls/vbscript/vbscript.h | 9 ++++++--- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c index 6e86bb07d0..769bbf15ba 100644 --- a/dlls/vbscript/compile.c +++ b/dlls/vbscript/compile.c @@ -1856,7 +1856,7 @@ void release_vbscode(vbscode_t *code) heap_free(code); } -static vbscode_t *alloc_vbscode(compile_ctx_t *ctx, const WCHAR *source) +static vbscode_t *alloc_vbscode(compile_ctx_t *ctx, const WCHAR *source, DWORD_PTR cookie, unsigned start_line) { vbscode_t *ret; size_t len; @@ -1878,6 +1878,9 @@ static vbscode_t *alloc_vbscode(compile_ctx_t *ctx, const WCHAR *source) memcpy(ret->source, source, len * sizeof(WCHAR)); ret->source[len] = 0; + ret->cookie = cookie; + ret->start_line = start_line; + ret->instrs = heap_alloc(32*sizeof(instr_t)); if(!ret->instrs) { release_vbscode(ret); @@ -1904,7 +1907,8 @@ static void release_compiler(compile_ctx_t *ctx) release_vbscode(ctx->code); } -HRESULT compile_script(script_ctx_t *script, const WCHAR *src, const WCHAR *delimiter, DWORD flags, vbscode_t **ret) +HRESULT compile_script(script_ctx_t *script, const WCHAR *src, const WCHAR *delimiter, DWORD_PTR cookie, + unsigned start_line, DWORD flags, vbscode_t **ret) { function_decl_t *func_decl; class_decl_t *class_decl; @@ -1913,7 +1917,7 @@ HRESULT compile_script(script_ctx_t *script, const WCHAR *src, const WCHAR *deli vbscode_t *code; HRESULT hres; - code = ctx.code = alloc_vbscode(&ctx, src); + code = ctx.code = alloc_vbscode(&ctx, src, cookie, start_line); if(!ctx.code) return E_OUTOFMEMORY; @@ -1978,13 +1982,14 @@ HRESULT compile_script(script_ctx_t *script, const WCHAR *src, const WCHAR *deli return S_OK; } -HRESULT compile_procedure(script_ctx_t *script, const WCHAR *src, const WCHAR *delimiter, DWORD flags, class_desc_t **ret) +HRESULT compile_procedure(script_ctx_t *script, const WCHAR *src, const WCHAR *delimiter, DWORD_PTR cookie, + unsigned start_line, DWORD flags, class_desc_t **ret) { class_desc_t *desc; vbscode_t *code; HRESULT hres; - hres = compile_script(script, src, delimiter, flags & ~SCRIPTTEXT_ISPERSISTENT, &code); + hres = compile_script(script, src, delimiter, cookie, start_line, flags & ~SCRIPTTEXT_ISPERSISTENT, &code); if(FAILED(hres)) return hres; diff --git a/dlls/vbscript/vbscript.c b/dlls/vbscript/vbscript.c index e068d19161..12681672ca 100644 --- a/dlls/vbscript/vbscript.c +++ b/dlls/vbscript/vbscript.c @@ -875,7 +875,7 @@ static HRESULT WINAPI VBScriptParse_ParseScriptText(IActiveScriptParse *iface, } } - hres = compile_script(This->ctx, pstrCode, pstrDelimiter, dwFlags, &code); + hres = compile_script(This->ctx, pstrCode, pstrDelimiter, dwSourceContextCookie, ulStartingLine, dwFlags, &code); if(FAILED(hres)) return hres; @@ -939,7 +939,8 @@ static HRESULT WINAPI VBScriptParseProcedure_ParseProcedureText(IActiveScriptPar if(This->thread_id != GetCurrentThreadId() || This->state == SCRIPTSTATE_CLOSED) return E_UNEXPECTED; - hres = compile_procedure(This->ctx, pstrCode, pstrDelimiter, dwFlags, &desc); + hres = compile_procedure(This->ctx, pstrCode, pstrDelimiter, dwSourceContextCookie, ulStartingLineNumber, + dwFlags, &desc); if(FAILED(hres)) return hres; diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h index d8b571b7d1..51797fbdfc 100644 --- a/dlls/vbscript/vbscript.h +++ b/dlls/vbscript/vbscript.h @@ -335,9 +335,12 @@ struct _function_t { struct _vbscode_t { instr_t *instrs; - WCHAR *source; unsigned ref; + WCHAR *source; + DWORD_PTR cookie; + unsigned start_line; + BOOL option_explicit; BOOL pending_exec; @@ -363,8 +366,8 @@ static inline void grab_vbscode(vbscode_t *code) } void release_vbscode(vbscode_t*) DECLSPEC_HIDDEN; -HRESULT compile_script(script_ctx_t*,const WCHAR*,const WCHAR*,DWORD,vbscode_t**) DECLSPEC_HIDDEN; -HRESULT compile_procedure(script_ctx_t*,const WCHAR*,const WCHAR*,DWORD,class_desc_t**) DECLSPEC_HIDDEN; +HRESULT compile_script(script_ctx_t*,const WCHAR*,const WCHAR*,DWORD_PTR,unsigned,DWORD,vbscode_t**) DECLSPEC_HIDDEN; +HRESULT compile_procedure(script_ctx_t*,const WCHAR*,const WCHAR*,DWORD_PTR,unsigned,DWORD,class_desc_t**) DECLSPEC_HIDDEN; HRESULT exec_script(script_ctx_t*,BOOL,function_t*,vbdisp_t*,DISPPARAMS*,VARIANT*) DECLSPEC_HIDDEN; void release_dynamic_var(dynamic_var_t*) DECLSPEC_HIDDEN; IDispatch *lookup_named_item(script_ctx_t*,const WCHAR*,unsigned) DECLSPEC_HIDDEN;
1
0
0
0
Jacek Caban : vbscript: Store source location in instr_t.
by Alexandre Julliard
23 Jan '20
23 Jan '20
Module: wine Branch: master Commit: 7a76856e2d1652c0a7f6dd05dac26524c3d1f276 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=7a76856e2d1652c0a7f6dd05…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Wed Jan 22 23:27:20 2020 +0100 vbscript: Store source location in instr_t. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/vbscript/compile.c | 8 ++++++++ dlls/vbscript/vbscript.h | 1 + 2 files changed, 9 insertions(+) diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c index 4a1f1a5c6a..6e86bb07d0 100644 --- a/dlls/vbscript/compile.c +++ b/dlls/vbscript/compile.c @@ -44,6 +44,7 @@ typedef struct { unsigned instr_size; vbscode_t *code; + unsigned loc; statement_ctx_t *stat_ctx; unsigned *labels; @@ -162,6 +163,7 @@ static unsigned push_instr(compile_ctx_t *ctx, vbsop_t op) } ctx->code->instrs[ctx->instr_cnt].op = op; + ctx->code->instrs[ctx->instr_cnt].loc = ctx->loc; return ctx->instr_cnt++; } @@ -630,6 +632,8 @@ static HRESULT compile_if_statement(compile_ctx_t *ctx, if_statement_t *stat) for(elseif_decl = stat->elseifs; elseif_decl; elseif_decl = elseif_decl->next) { instr_ptr(ctx, cnd_jmp)->arg1.uint = ctx->instr_cnt; + ctx->loc = elseif_decl->loc; + hres = compile_expression(ctx, elseif_decl->expr); if(FAILED(hres)) return hres; @@ -723,6 +727,7 @@ static HRESULT compile_dowhile_statement(compile_ctx_t *ctx, while_statement_t * if(FAILED(hres)) return hres; + ctx->loc = stat->stat.loc; if(stat->expr) { hres = compile_expression(ctx, stat->expr); if(FAILED(hres)) @@ -778,6 +783,7 @@ static HRESULT compile_foreach_statement(compile_ctx_t *ctx, foreach_statement_t return hres; /* We need a separated enumnext here, because we need to jump out of the loop on exception. */ + ctx->loc = stat->stat.loc; hres = push_instr_uint_bstr(ctx, OP_enumnext, loop_ctx.for_end_label, stat->identifier); if(FAILED(hres)) return hres; @@ -1295,6 +1301,8 @@ static HRESULT compile_statement(compile_ctx_t *ctx, statement_ctx_t *stat_ctx, } while(stat) { + ctx->loc = stat->loc; + switch(stat->type) { case STAT_ASSIGN: hres = compile_assign_statement(ctx, (assign_statement_t*)stat, FALSE); diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h index 19431e23c3..d8b571b7d1 100644 --- a/dlls/vbscript/vbscript.h +++ b/dlls/vbscript/vbscript.h @@ -294,6 +294,7 @@ typedef union { typedef struct { vbsop_t op; + unsigned loc; instr_arg_t arg1; instr_arg_t arg2; } instr_t;
1
0
0
0
Jacek Caban : vbscript: Store source location in statement_t.
by Alexandre Julliard
23 Jan '20
23 Jan '20
Module: wine Branch: master Commit: 21346c76b4f8dae3cff5ac915bf59e08cfdfc3a9 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=21346c76b4f8dae3cff5ac91…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Wed Jan 22 23:27:14 2020 +0100 vbscript: Store source location in statement_t. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/vbscript/lex.c | 7 ++- dlls/vbscript/parse.h | 4 +- dlls/vbscript/parser.y | 163 +++++++++++++++++++++++++------------------------ 3 files changed, 90 insertions(+), 84 deletions(-) Diff:
https://source.winehq.org/git/wine.git/?a=commitdiff;h=21346c76b4f8dae3cff5…
1
0
0
0
Jacek Caban : vbscript: Alloc vbscode_t before parsing the script.
by Alexandre Julliard
23 Jan '20
23 Jan '20
Module: wine Branch: master Commit: 70cd4153c558fbfba9ddb86a591872ce55d4184e URL:
https://source.winehq.org/git/wine.git/?a=commit;h=70cd4153c558fbfba9ddb86a…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Wed Jan 22 23:27:09 2020 +0100 vbscript: Alloc vbscode_t before parsing the script. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/vbscript/compile.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c index c76ba73bd8..4a1f1a5c6a 100644 --- a/dlls/vbscript/compile.c +++ b/dlls/vbscript/compile.c @@ -1851,16 +1851,24 @@ void release_vbscode(vbscode_t *code) static vbscode_t *alloc_vbscode(compile_ctx_t *ctx, const WCHAR *source) { vbscode_t *ret; + size_t len; + + len = source ? lstrlenW(source) : 0; + if(len > INT32_MAX) + return NULL; ret = heap_alloc_zero(sizeof(*ret)); if(!ret) return NULL; - ret->source = heap_strdupW(source); + ret->source = heap_alloc((len + 1) * sizeof(WCHAR)); if(!ret->source) { heap_free(ret); return NULL; } + if(len) + memcpy(ret->source, source, len * sizeof(WCHAR)); + ret->source[len] = 0; ret->instrs = heap_alloc(32*sizeof(instr_t)); if(!ret->instrs) { @@ -1872,8 +1880,6 @@ static vbscode_t *alloc_vbscode(compile_ctx_t *ctx, const WCHAR *source) ctx->instr_size = 32; heap_pool_init(&ret->heap); - ret->option_explicit = ctx->parser.option_explicit; - ret->main_code.type = FUNC_GLOBAL; ret->main_code.code_ctx = ret; ret->ref = 1; @@ -1899,15 +1905,16 @@ HRESULT compile_script(script_ctx_t *script, const WCHAR *src, const WCHAR *deli vbscode_t *code; HRESULT hres; - if (!src) src = L""; - - hres = parse_script(&ctx.parser, src, delimiter, flags); - if(FAILED(hres)) - return compile_error(script, hres); - code = ctx.code = alloc_vbscode(&ctx, src); if(!ctx.code) - return compile_error(script, E_OUTOFMEMORY); + return E_OUTOFMEMORY; + + hres = parse_script(&ctx.parser, code->source, delimiter, flags); + if(FAILED(hres)) { + hres = compile_error(script, hres); + release_vbscode(code); + return hres; + } ctx.func_decls = NULL; ctx.labels = NULL; @@ -1922,6 +1929,8 @@ HRESULT compile_script(script_ctx_t *script, const WCHAR *src, const WCHAR *deli } ctx.global_consts = ctx.const_decls; + code->option_explicit = ctx.parser.option_explicit; + for(func_decl = ctx.func_decls; func_decl; func_decl = func_decl->next) { hres = create_function(&ctx, func_decl, &new_func);
1
0
0
0
Jacek Caban : vbscript/tests: Add error position tests.
by Alexandre Julliard
23 Jan '20
23 Jan '20
Module: wine Branch: master Commit: d12de646635d717e7a580f23d5ae35da7da81319 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=d12de646635d717e7a580f23…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Wed Jan 22 23:27:03 2020 +0100 vbscript/tests: Add error position tests. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/vbscript/tests/run.c | 194 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 143 insertions(+), 51 deletions(-) diff --git a/dlls/vbscript/tests/run.c b/dlls/vbscript/tests/run.c index d45416a94a..696c3f530b 100644 --- a/dlls/vbscript/tests/run.c +++ b/dlls/vbscript/tests/run.c @@ -1829,21 +1829,22 @@ static HRESULT WINAPI ActiveScriptSite_OnStateChange(IActiveScriptSite *iface, S } static IActiveScriptError **store_script_error; +static ULONG error_line; +static LONG error_char; static HRESULT WINAPI ActiveScriptSite_OnScriptError(IActiveScriptSite *iface, IActiveScriptError *pscripterror) { HRESULT hr = onerror_hres, hres; + hres = IActiveScriptError_GetSourcePosition(pscripterror, NULL, &error_line, &error_char); + ok(hres == S_OK, "GetSourcePosition failed: %08x\n", hres); + if(!expect_OnScriptError) { EXCEPINFO info; - ULONG line; - HRESULT hres; - hres = IActiveScriptError_GetSourcePosition(pscripterror, NULL, &line, NULL); + hres = IActiveScriptError_GetExceptionInfo(pscripterror, &info); if(SUCCEEDED(hres)) - hres = IActiveScriptError_GetExceptionInfo(pscripterror, &info); - if(SUCCEEDED(hres)) - trace("Error in line %u: %x %s\n", line+1, info.wCode, wine_dbgstr_w(info.bstrDescription)); + trace("Error in line %u: %x %s\n", error_line + 1, info.wCode, wine_dbgstr_w(info.bstrDescription)); }else { IDispatchEx *dispex; @@ -2390,60 +2391,151 @@ static void test_gc(void) static void test_parse_errors(void) { - static const char *invalid_scripts[] = + static const struct + { + const char *src; + unsigned error_line; + int error_char; + } + invalid_scripts[] = { - /* If...End If */ - "If 0 > 1 Then\n" - " x = 0 End If\n", - - /* While...End While */ - "While False\n" - " x = 0 End While\n", - - /* While...Wend */ - "While False\n" - " x = 0 Wend\n", - - /* Do While...Loop */ - "Do While False\n" - " x = 0 Loop\n", - - /* Do Until...Loop */ - "Do Until True\n" - " x = 0 Loop\n", - - /* Do...Loop While */ - "Do\n" - " x = 0 Loop While False\n", - - /* Do...Loop Until */ - "Do\n" - " x = 0 Loop Until True\n", - - /* Select...End Select */ - "x = False\n" - "Select Case 42\n" - " Case 0\n" - " Call ok(False, \"unexpected case\")\n" - " Case 42\n" - " x = True End Select\n" - "Call ok(x, \"wrong case\")\n", - - /* Class...End Class (empty) */ - "Class C End Class", - - /* invalid use of parentheses for call statement */ - "strcomp(\"x\", \"y\")" + { + /* If...End If */ + "If 0 > 1 Then\n" + " x = 0 End If\n", + 1, 10 + }, + { + /* While...End While */ + "While False\n" + " x = 0 End While\n", + 1, 10 + }, + { + /* While...Wend */ + "While False\n" + " x = 0 Wend\n", + 1, 10 + }, + { + /* Do While...Loop */ + "Do While False\n" + " x = 0 Loop\n", + 1, 10 + }, + { + /* Do Until...Loop */ + "Do Until True\n" + " x = 0 Loop\n", + 1, 10 + }, + { + /* Do...Loop While */ + "Do\n" + " x = 0 Loop While False\n", + 1, 10 + }, + { + /* Do...Loop Until */ + "Do\n" + " x = 0 Loop Until True\n", + 1, 10 + }, + { + /* Select...End Select */ + "x = False\n" + "Select Case 42\n" + " Case 0\n" + " Call ok(False, \"unexpected case\")\n" + " Case 42\n" + " x = True End Select\n" + "Call ok(x, \"wrong case\")\n", + 5, 17 + }, + { + /* Class...End Class (empty) */ + "Class C End Class", + 0, 8 + }, + { + /* Class...End Class (empty) */ + "Class C _\nEnd Class", + 1, 0 + }, + { + /* invalid use of parentheses for call statement */ + "strcomp(\"x\", \"y\")", + 0, -17 + }, + { + "\n\n\n cint _\n throwInt(&h80001234&)", + 3, 2 + }, + { + "dim x\n" + "if true then throwInt(&h80001234&)", + 1, 13 + }, + { + "dim x\n" + "if x = throwInt(&h80001234&) then x = 1", + 1, 0 + }, + { + "sub test\n" + " dim x\n" + " if x = throwInt(&h80001234&) then x = 1\n" + "end sub\n" + "test\n", + 2, 4 + }, + { + "dim x\n" + "do\n" + " x = 1\n" + "loop until throwInt(&h80001234&)\n", + 3, 0 + }, + { + "\n select case 3\n" + " case 2\n" + " ok false, \"unexpected case\"\n" + " case throwInt(&h80001234&)\n" + " throwInt &h87001234&\n" + "end select\n", + 1, 2 + }, + { + "if false then\n" + " ok false, \"unexpected case\"\n" + " elseif throwInt(&h80001234&) then\n" + " throwInt &h87001234&\n" + "else\n" + " throwInt &h87001234&\n" + "end if\n", + 2, 1 + } }; HRESULT hres; UINT i; for (i = 0; i < ARRAY_SIZE(invalid_scripts); i++) { + error_line = ~0; + error_char = -1; + onerror_hres = S_OK; + SET_EXPECT(OnScriptError); - hres = parse_script_ar(invalid_scripts[i]); - ok(FAILED(hres), "[%u] script did not fail\n", i); + hres = parse_script_ar(invalid_scripts[i].src); + ok(hres == SCRIPT_E_REPORTED, "[%u] script returned: %08x\n", i, hres); CHECK_CALLED(OnScriptError); + + todo_wine_if(invalid_scripts[i].error_line) + ok(error_line == invalid_scripts[i].error_line, "[%u] error line %u expected %u\n", + i, error_line, invalid_scripts[i].error_line); + todo_wine_if(invalid_scripts[i].error_char) + ok(error_char == abs(invalid_scripts[i].error_char), "[%u] error char %d expected %d\n", + i, error_char, invalid_scripts[i].error_char); } }
1
0
0
0
← Newer
1
...
26
27
28
29
30
31
32
...
54
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
Results per page:
10
25
50
100
200