[PATCH 0/1] MR10497: vbscript: Return specific error codes for unterminated block statements.
When a block statement reaches EOF without its closing keyword, Windows returns a specific error code. Add error productions in the bison grammar for four unterminated block types: - If without End If (error 1014) - While without Wend (error 1018) - Do without Loop (error 1019) - For/For Each without Next (error 1020) Previously these all fell through to the generic E_FAIL path. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10497
From: Francis De Brabandere <francisdb@gmail.com> When a block statement reaches EOF without its closing keyword, Windows returns a specific error code. Add error productions in the bison grammar for four unterminated block types: - If without End If (error 1014) - While without Wend (error 1018) - Do without Loop (error 1019) - For/For Each without Next (error 1020) Previously these all fell through to the generic E_FAIL path. --- dlls/vbscript/parser.y | 11 +++++++++++ dlls/vbscript/tests/run.c | 8 ++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y index c1a5b944268..f592139a68a 100644 --- a/dlls/vbscript/parser.y +++ b/dlls/vbscript/parser.y @@ -223,13 +223,18 @@ SimpleStatement | IfStatement { $$ = $1; } | tWHILE Expression StSep StatementsNl_opt tWEND { $$ = new_while_statement(ctx, @$, STAT_WHILE, $2, $4); CHECK_ERROR; } + | tWHILE Expression StSep StatementsNl_opt error + { ctx->hres = MAKE_VBSERROR(VBSE_EXPECTED_WEND); YYABORT; } | tDO DoType Expression StSep StatementsNl_opt tLOOP { $$ = new_while_statement(ctx, @$, $2 ? STAT_WHILELOOP : STAT_UNTIL, $3, $5); CHECK_ERROR; } + | tDO DoType Expression StSep StatementsNl_opt error + { ctx->hres = MAKE_VBSERROR(VBSE_EXPECTED_LOOP); YYABORT; } | tDO StSep StatementsNl_opt tLOOP DoType Expression { $$ = new_while_statement(ctx, @4, $5 ? STAT_DOWHILE : STAT_DOUNTIL, $6, $3); CHECK_ERROR; } | tDO StSep StatementsNl_opt tLOOP { $$ = new_while_statement(ctx, @$, STAT_DOWHILE, NULL, $3); CHECK_ERROR; } + | tDO StSep StatementsNl_opt error { ctx->hres = MAKE_VBSERROR(VBSE_EXPECTED_LOOP); YYABORT; } | FunctionDecl { $$ = new_function_statement(ctx, @$, $1); CHECK_ERROR; } | tEXIT tDO { $$ = new_statement(ctx, STAT_EXITDO, 0, @$); CHECK_ERROR; } | tEXIT tFOR { $$ = new_statement(ctx, STAT_EXITFOR, 0, @$); CHECK_ERROR; } @@ -243,8 +248,12 @@ SimpleStatement | tCONST ConstDeclList { $$ = new_const_statement(ctx, @$, $2); CHECK_ERROR; } | tFOR Identifier '=' Expression tTO Expression Step_opt StSep StatementsNl_opt tNEXT { $$ = new_forto_statement(ctx, @$, $2, $4, $6, $7, $9); CHECK_ERROR; } + | tFOR Identifier '=' Expression tTO Expression Step_opt StSep StatementsNl_opt error + { ctx->hres = MAKE_VBSERROR(VBSE_EXPECTED_NEXT); YYABORT; } | tFOR tEACH Identifier tIN Expression StSep StatementsNl_opt tNEXT { $$ = new_foreach_statement(ctx, @$, $3, $5, $7); } + | tFOR tEACH Identifier tIN Expression StSep StatementsNl_opt error + { ctx->hres = MAKE_VBSERROR(VBSE_EXPECTED_NEXT); YYABORT; } | tSELECT tCASE Expression StSep CaseClausules tEND tSELECT { $$ = new_select_statement(ctx, @$, $3, $5); } | tWITH Expression StSep StatementsNl_opt tEND tWITH @@ -311,6 +320,8 @@ Step_opt IfStatement : tIF Expression tTHEN tNL StSep_opt StatementsNl_opt ElseIfs_opt Else_opt tEND tIF { $$ = new_if_statement(ctx, @$, $2, $6, $7, $8); CHECK_ERROR; } + | tIF Expression tTHEN tNL StSep_opt StatementsNl_opt ElseIfs_opt Else_opt error + { ctx->hres = MAKE_VBSERROR(VBSE_EXPECTED_END); YYABORT; } | tIF Expression tTHEN Statement EndIf_opt { $$ = new_if_statement(ctx, @$, $2, $4, NULL, NULL); CHECK_ERROR; } | tIF Expression tTHEN Statement tELSE Statement EndIf_opt { $$ = new_if_statement(ctx, @$, $2, $4, NULL, $6); CHECK_ERROR; } diff --git a/dlls/vbscript/tests/run.c b/dlls/vbscript/tests/run.c index d3aebff098a..b3459a4c486 100644 --- a/dlls/vbscript/tests/run.c +++ b/dlls/vbscript/tests/run.c @@ -2885,7 +2885,7 @@ static void test_parse_errors(void) /* Expected 'End' - error 1014 */ L"If True Then\nx = 1\n", 2, 0, - NULL, S_OK, -1014 + NULL, S_OK, 1014 }, { /* Name redefined - error 1041 */ @@ -2939,19 +2939,19 @@ static void test_parse_errors(void) /* Expected 'Wend' - error 1018 */ L"While True\nx = 1\n", 2, 0, - NULL, S_OK, -1018 + NULL, S_OK, 1018 }, { /* Expected 'Loop' - error 1019 */ L"Do\nx = 1\n", 2, 0, - NULL, S_OK, -1019 + NULL, S_OK, 1019 }, { /* Expected 'Next' - error 1020 */ L"For i = 1 To 10\nx = 1\n", 2, 0, - NULL, S_OK, -1020 + NULL, S_OK, 1020 }, { /* Expected 'Case' - error 1021 */ -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10497
participants (2)
-
Francis De Brabandere -
Francis De Brabandere (@francisdb)