From: Gurusamy Sarathy Date: Sun, 8 Dec 1996 19:58:32 +0000 (-0500) Subject: Re: Bug in formline X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=35617a9ea5dfb088885c21ff0af766189f92eaa2;p=p5sagit%2Fp5-mst-13.2.git Re: Bug in formline On Sun, 08 Dec 1996 19:06:42 +0100, Gary Howland wrote: >Is this a bug? > >The following program: > > #!/usr/local/bin/perl -w > > sub format_text > { > my $format = shift; > $^A = ""; > formline($format, @_); > return $^A; > } > > my $picture = ' > A: @<<< > B: @||| > C: @>>> > '; > > print format_text($picture, 1, 2, 3); > >gives this output: > > A: 1 > B: 2 > C: 3 > >when I would have expected: > > A: 1 > B: 2 > C: 3 > >it seems that the carriage returns are incorrectly placed. > > >If I change $picture to this: > > my $picture = ' > A: @<<< a > B: @||| b > C: @>>> c > '; > >I get a segmentation violation from perl. The latter should work flawlessly in 5.003_05 and later ("my" variables as formline picture arguments were broken before). The attached patch (against 5.00308, but should apply clean over 3_11 as well), should cure the first problem. - Sarathy. gsar@engin.umich.edu p5p-msgid: <199612081958.OAA26025@aatma.engin.umich.edu> --- diff --git a/pp_ctl.c b/pp_ctl.c index 962cf04..1e0825a 100644 --- a/pp_ctl.c +++ b/pp_ctl.c @@ -2362,13 +2362,12 @@ SV *sv; skipspaces++; arg -= skipspaces; if (arg) { - if (postspace) { + if (postspace) *fpc++ = FF_SPACE; - postspace = FALSE; - } *fpc++ = FF_LITERAL; *fpc++ = arg; } + postspace = FALSE; if (s <= send) skipspaces--; if (skipspaces) {