diff options
author | Gisle Aas <gisle@aas.no> | 2009-10-29 21:30:02 +0100 |
---|---|---|
committer | Gisle Aas <gisle@aas.no> | 2009-10-29 21:30:02 +0100 |
commit | 3c9465285f823f6b117f10189230291c75f08e05 (patch) | |
tree | 58a04a809a9c4641586f41c689fe74ce840c4887 /t | |
parent | 13f4e2ac11fc84c6dd0c9663e51e31a68e57ae37 (diff) | |
download | perl-3c9465285f823f6b117f10189230291c75f08e05.tar.gz |
Allow syswrite with offset same as length of string [perl #70095]
You are not really outside of the string then, but the effect will
always be a noop since the number of bytes written will be capped
to not exceed the length of the string as for other offsets.
Diffstat (limited to 't')
-rw-r--r-- | t/op/sysio.t | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/t/op/sysio.t b/t/op/sysio.t index 966a516997..f2c269ebaf 100644 --- a/t/op/sysio.t +++ b/t/op/sysio.t @@ -70,12 +70,16 @@ is($x, 'abc'); ok(!-s $outfile); # should not be able to write from after the buffer -eval { syswrite(O, $x, 1, 3) }; +eval { syswrite(O, $x, 1, 4) }; like($@, qr/^Offset outside string /); # $x still intact is($x, 'abc'); +# but it should be ok to write from the end of the buffer +syswrite(O, $x, 0, 3); +syswrite(O, $x, 1, 3); + # $outfile still intact if ($reopen) { # must close file to update EOF marker for stat close O; open(O, ">>$outfile") || die "sysio.t: cannot write $outfile: $!"; @@ -97,7 +101,7 @@ if ($reopen) { # must close file to update EOF marker for stat ok(!-s $outfile); # [perl #67912] syswrite prints garbage if called with empty scalar and non-zero offset -eval { my $buf = ''; syswrite(O, $buf, 1, 0) }; +eval { my $buf = ''; syswrite(O, $buf, 1, 1) }; like($@, qr/^Offset outside string /); # $x still intact @@ -109,7 +113,7 @@ if ($reopen) { # must close file to update EOF marker for stat } ok(!-s $outfile); -eval { my $buf = 'x'; syswrite(O, $buf, 1, 1) }; +eval { my $buf = 'x'; syswrite(O, $buf, 1, 2) }; like($@, qr/^Offset outside string /); # $x still intact |