This is a live mirror of the Perl 5 development currently hosted at
https://github.com/perl/perl5
https://perl5.git.perl.org
/
perl5.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
8af8844
)
(PerlIO::)scalar.t: Add function for testing trailing null
author
Eric Brine
<ikegami@adaelis.com>
Fri, 20 Jan 2012 02:19:16 +0000
(18:19 -0800)
committer
Father Chrysostomos
<sprout@cpan.org>
Fri, 20 Jan 2012 06:38:36 +0000
(22:38 -0800)
ext/PerlIO-scalar/t/scalar.t
patch
|
blob
|
blame
|
history
diff --git
a/ext/PerlIO-scalar/t/scalar.t
b/ext/PerlIO-scalar/t/scalar.t
index
b59e3aa
..
48883b6
100644
(file)
--- a/
ext/PerlIO-scalar/t/scalar.t
+++ b/
ext/PerlIO-scalar/t/scalar.t
@@
-317,3
+317,17
@@
EOF
open my $fh, "<", \(my $f=*f); seek $fh, -2,2;
pass 'seeking on a glob copy from the end';
}
+
+sub has_trailing_nul(\$) {
+ my ($ref) = @_;
+ my $sv = B::svref_2object($ref);
+ return undef if !$sv->isa('B::PV');
+
+ my $cur = $sv->CUR;
+ my $len = $sv->LEN;
+ return 0 if $cur >= $len;
+
+ my $pv_addr = unpack 'J', pack 'P', $$ref;
+ my $trailing = unpack 'P', pack 'J', $pv_addr+$cur;
+ return $trailing eq "\0";
+}