diff options
Diffstat (limited to 'toke.c')
-rw-r--r-- | toke.c | 56 |
1 files changed, 41 insertions, 15 deletions
@@ -12521,15 +12521,24 @@ S_yywarn(pTHX_ const char *const s, U32 flags) } void -Perl_abort_execution(pTHX_ const char * const msg, const char * const name) +Perl_abort_execution(pTHX_ SV* msg_sv, const char * const name) { PERL_ARGS_ASSERT_ABORT_EXECUTION; - if (PL_minus_c) - Perl_croak(aTHX_ "%s%s had compilation errors.\n", msg, name); - else { - Perl_croak(aTHX_ - "%sExecution of %s aborted due to compilation errors.\n", msg, name); + if (msg_sv) { + if (PL_minus_c) + Perl_croak(aTHX_ "%" SVf "%s had compilation errors.\n", SVfARG(msg_sv), name); + else { + Perl_croak(aTHX_ + "%" SVf "Execution of %s aborted due to compilation errors.\n", SVfARG(msg_sv), name); + } + } else { + if (PL_minus_c) + Perl_croak(aTHX_ "%s had compilation errors.\n", name); + else { + Perl_croak(aTHX_ + "Execution of %s aborted due to compilation errors.\n", name); + } } NOT_REACHED; /* NOTREACHED */ } @@ -12644,22 +12653,39 @@ Perl_yyerror_pvn(pTHX_ const char *const s, STRLEN len, U32 flags) qerror(msg); } } - if (s == NULL || PL_error_count >= 10) { - const char * msg = ""; + if ( s == NULL || + PL_error_count >= PERL_STOP_PARSING_AFTER_N_ERRORS + ) { const char * const name = OutCopFILE(PL_curcop); + SV * errsv = NULL; + U8 raw_error_count = PERL_PARSE_ERROR_COUNT(PL_error_count); + bool syntax_error = PERL_PARSE_IS_SYNTAX_ERROR(PL_error_count); if (PL_in_eval) { - SV * errsv = ERRSV; - if (SvCUR(errsv)) { - msg = Perl_form(aTHX_ "%" SVf, SVfARG(errsv)); - } + errsv = ERRSV; } if (s == NULL) { - abort_execution(msg, name); + abort_execution(errsv, name); } - else { - Perl_croak(aTHX_ "%s%s has too many errors.\n", msg, name); + else + if (raw_error_count >= PERL_STOP_PARSING_AFTER_N_ERRORS) { + if (errsv) { + Perl_croak(aTHX_ "%" SVf "%s has too many errors.\n", + SVfARG(errsv), name); + } else { + Perl_croak(aTHX_ "%s has too many errors.\n", name); + } + } + else + /* if (syntax_error) - implied */ + { + assert(syntax_error); + if (errsv) { + Perl_croak_sv(aTHX_ errsv); + } else { + abort_execution(errsv, name); + } } } PL_in_my = 0; |