From: Dave Mitchell Date: Tue, 30 Dec 2003 15:07:50 +0000 (+0000) Subject: Re: [perl #24774] eval + format - \n = pp_ctl.c assertion X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f5c235e79ea25787354a22de0af257a672e955a0;p=p5sagit%2Fp5-mst-13.2.git Re: [perl #24774] eval + format - \n = pp_ctl.c assertion heuristics for calculating buffer size needed to compile a format didn't allow for \0 p4raw-id: //depot/perl@22005 --- diff --git a/pp_ctl.c b/pp_ctl.c index ec79e24..48e3618 100644 --- a/pp_ctl.c +++ b/pp_ctl.c @@ -3580,7 +3580,7 @@ S_doparseform(pTHX_ SV *sv) /* estimate the buffer size needed */ for (base = s; s <= send; s++) { - if (*s == '\n' || *s == '@' || *s == '^') + if (*s == '\n' || *s == '\0' || *s == '@' || *s == '^') maxops += 10; } s = base; diff --git a/t/op/write.t b/t/op/write.t index cbf00de..85b5f26 100755 --- a/t/op/write.t +++ b/t/op/write.t @@ -5,7 +5,7 @@ BEGIN { @INC = '../lib'; } -print "1..49\n"; +print "1..50\n"; my $CAT = ($^O eq 'MSWin32' || $^O eq 'NetWare' || $^O eq 'VMS') ? 'type' : ($^O eq 'MacOS') ? 'catenate' @@ -300,14 +300,24 @@ $v print `$CAT Op_write.tmp`; } +{ + # Bug #24774 format without trailing \n failed assertion + 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"; +} + ####################################### # Easiest to add new tests above here # ####################################### -# 14..49: scary format testing from Merijn H. Brand +# 15..50: scary format testing from Merijn H. Brand -my $test = 14; -my $tests = 49; +my $test = 15; +my $tests = 50; if ($^O eq 'VMS' || $^O eq 'MSWin32' || $^O eq 'dos' || $^O eq 'MacOS' || ($^O eq 'os2' and not eval '$OS2::can_fork')) {