summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2011-05-29 19:27:56 +0100
committerDavid Mitchell <davem@iabyn.com>2011-05-29 20:21:54 +0100
commit26e935cfa6e70de1bd5258e0cb0f22ee976909f3 (patch)
treec1da6bd5bd35e1114dc50c1fa5db7f38b0c6d85c /t
parentf5ada144f34d75c136b6780e10ca13d18d44c557 (diff)
downloadperl-26e935cfa6e70de1bd5258e0cb0f22ee976909f3.tar.gz
pp_formline: handle growing better
We initially grow PL_formtarget by the largest amount a formline can append (since formats are fixed width). The only thing that can exceed that is @*; but also, if PL_formtarget gets upgraded to utf8, then some of the extra buffer we allocated can get eaten up by the upgrade. Codify this so we only grow when necessary, but always enough. Prior to this commit, we were growing FF_ITEM/FF_LITERAL too much, and FF_LINEGLOB too little (the latter being my mistake from a few commits ago). Also rename 'fudge' to 'linemax', to give a better idea what it's for.
Diffstat (limited to 't')
-rw-r--r--t/op/write.t10
1 files changed, 9 insertions, 1 deletions
diff --git a/t/op/write.t b/t/op/write.t
index 27effdeb41..c2e3399305 100644
--- a/t/op/write.t
+++ b/t/op/write.t
@@ -61,7 +61,7 @@ for my $tref ( @NumTests ){
my $bas_tests = 20;
# number of tests in section 3
-my $bug_tests = 4 + 3 * 3 * 5 * 2 * 3 + 2 + 66 + 2 + 2 + 1 + 1;
+my $bug_tests = 4 + 3 * 3 * 5 * 2 * 3 + 2 + 66 + 3 + 2 + 1 + 1;
# number of tests in section 4
my $hmb_tests = 35;
@@ -704,6 +704,14 @@ ok defined *{$::{CmT}}{FORMAT}, "glob assign";
$^A = $orig;
formline $format, " ";
is $^A, "$orig\n", "end-of-line blanks and realloc";
+
+ # and check this doesn't overflow the buffer
+
+ local $^A = '';
+ $format = "@* @####\n";
+ $orig = "x" x 100 . "\n";
+ formline $format, $orig, 12345;
+ is $^A, ("x" x 100) . " 12345\n", "\@* doesn't overflow";
}