summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xt/op/write.t8
-rw-r--r--toke.c17
2 files changed, 16 insertions, 9 deletions
diff --git a/t/op/write.t b/t/op/write.t
index 85b5f26ce8..2e90b39ffd 100755
--- a/t/op/write.t
+++ b/t/op/write.t
@@ -302,12 +302,12 @@ $v
{
# Bug #24774 format without trailing \n failed assertion
+ # but this must not compile because we'd get a ';' into the format
+
my @v = ('k');
eval "format OUT14 = \n@\n\@v";
- open(OUT14, '>Op_write.tmp') || die "Can't create Op_write.tmp";
- write(OUT14);
- close OUT14 or die "Could not close: $!";
- print "ok 14\n";
+ print $@ ? "ok 14\n" : "not ok 14\n";
+
}
#######################################
diff --git a/toke.c b/toke.c
index 3b010ec2a2..54831e7dd0 100644
--- a/toke.c
+++ b/toke.c
@@ -2427,8 +2427,12 @@ Perl_yylex(pTHX)
if (!PL_rsfp) {
PL_last_uni = 0;
PL_last_lop = 0;
- if (PL_lex_brackets)
- yyerror("Missing right curly or square bracket");
+ if (PL_lex_brackets) {
+ if (PL_lex_formbrack)
+ yyerror("Format not terminated");
+ else
+ yyerror("Missing right curly or square bracket");
+ }
DEBUG_T( { PerlIO_printf(Perl_debug_log,
"### Tokener got EOF\n");
} );
@@ -7603,6 +7607,7 @@ S_scan_formline(pTHX_ register char *s)
register char *t;
SV *stuff = newSVpvn("",0);
bool needargs = FALSE;
+ bool eofmt = FALSE;
while (!needargs) {
if (*s == '.' || *s == /*{*/'}') {
@@ -7612,8 +7617,10 @@ S_scan_formline(pTHX_ register char *s)
#else
for (t = s+1;SPACE_OR_TAB(*t) || *t == '\r'; t++) ;
#endif
- if (*t == '\n' || t == PL_bufend)
+ if (*t == '\n' || t == PL_bufend) {
+ eofmt = TRUE;
break;
+ }
}
if (PL_in_eval && !PL_rsfp) {
eol = strchr(s,'\n');
@@ -7653,7 +7660,6 @@ S_scan_formline(pTHX_ register char *s)
PL_last_lop = PL_last_uni = Nullch;
if (!s) {
s = PL_bufptr;
- yyerror("Format not terminated");
break;
}
}
@@ -7682,7 +7688,8 @@ S_scan_formline(pTHX_ register char *s)
}
else {
SvREFCNT_dec(stuff);
- PL_lex_formbrack = 0;
+ if (eofmt)
+ PL_lex_formbrack = 0;
PL_bufptr = s;
}
return s;