From 21938ae5a278f0b48443561333c47714921e7566 Mon Sep 17 00:00:00 2001 From: Yves Orton Date: Sun, 25 Sep 2022 15:09:52 +0200 Subject: [PATCH] perl.h, pp_ctl.c - switch to standard way of terminating compilation I did not fully understand the use of yyquit() when I implemented the SYNTAX_ERROR related stuff. It is not needed, and switching to this makes eval compile error messages more consistent. --- perl.h | 4 +--- perly.c | 3 ++- pp_ctl.c | 6 ------ t/op/eval.t | 3 ++- t/op/signatures.t | 9 +++++++-- t/uni/parser.t | 1 + toke.c | 10 +--------- 7 files changed, 14 insertions(+), 22 deletions(-) diff --git a/perl.h b/perl.h index 1247788682ce..4ad758265a2e 100644 --- a/perl.h +++ b/perl.h @@ -9094,9 +9094,7 @@ END_EXTERN_C #define PERL_STOP_PARSING_AFTER_N_ERRORS 10 -#define PERL_PARSE_IS_SYNTAX_ERROR_FLAG 128 -#define PERL_PARSE_IS_SYNTAX_ERROR(f) ((f) & PERL_PARSE_IS_SYNTAX_ERROR_FLAG) -#define PERL_PARSE_ERROR_COUNT(f) ((f) & (PERL_PARSE_IS_SYNTAX_ERROR_FLAG-1)) +#define PERL_PARSE_ERROR_COUNT(f) (f) /* diff --git a/perly.c b/perly.c index 20854ae542b3..fb4abdfcc129 100644 --- a/perly.c +++ b/perly.c @@ -488,7 +488,8 @@ Perl_yyparse (pTHX_ int gramtype) yyerrlab: /* If not already recovering from an error, report this error. */ if (!parser->yyerrstatus) { - yyerror ("syntax error"); + yyerror("syntax error"); + yyquit(); } diff --git a/pp_ctl.c b/pp_ctl.c index 6ee2360f62eb..b1e06f4d5225 100644 --- a/pp_ctl.c +++ b/pp_ctl.c @@ -1671,13 +1671,7 @@ Perl_qerror(pTHX_ SV *err) Perl_warn(aTHX_ "%" SVf, SVfARG(err)); if (PL_parser) { - STRLEN len; - char *err_pv = SvPV(err,len); ++PL_parser->error_count; - if (memBEGINs(err_pv,len,"syntax error")) - { - PL_parser->error_count |= PERL_PARSE_IS_SYNTAX_ERROR_FLAG; - } } } diff --git a/t/op/eval.t b/t/op/eval.t index f2f06b1a744f..6847a5beabaf 100644 --- a/t/op/eval.t +++ b/t/op/eval.t @@ -6,7 +6,7 @@ BEGIN { set_up_inc('../lib'); } -plan(tests => 162); +plan(tests => 167); eval 'pass();'; @@ -625,6 +625,7 @@ for("{;", "{") { eval $_; is $@ =~ s/eval \d+/eval 1/rag, <<'EOE', Missing right curly or square bracket at (eval 1) line 1, at end of line syntax error at (eval 1) line 1, at EOF +Execution of (eval 1) aborted due to compilation errors. EOE qq'Right line number for eval "$_"'; } diff --git a/t/op/signatures.t b/t/op/signatures.t index e3204224e9f1..bf568023c99f 100644 --- a/t/op/signatures.t +++ b/t/op/signatures.t @@ -1013,10 +1013,10 @@ like $@, _create_mismatch_regexp('main::t081', 4, 2); is $a, 123; eval "#line 8 foo\nsub t082 (, \$a) { }"; -is $@, qq{syntax error at foo line 8, near "(,"\n}; +is $@, qq{syntax error at foo line 8, near "(,"\nExecution of foo aborted due to compilation errors.\n}; eval "#line 8 foo\nsub t083 (,) { }"; -is $@, qq{syntax error at foo line 8, near "(,"\n}; +is $@, qq{syntax error at foo line 8, near "(,"\nExecution of foo aborted due to compilation errors.\n}; sub t084($a,$b){ $a.$b } is prototype(\&t084), undef; @@ -1132,30 +1132,35 @@ eval "#line 8 foo\nsub t095 (\$a, 123) { }"; is $@, <