summaryrefslogtreecommitdiff
path: root/pp.c
diff options
context:
space:
mode:
authorGurusamy Sarathy <gsar@cpan.org>1999-10-11 20:28:32 +0000
committerGurusamy Sarathy <gsar@cpan.org>1999-10-11 20:28:32 +0000
commit98485b38a7f16148bd71cb9ff1c3ade8d491ef5f (patch)
treeec39c560e556f3529c5e0028f7a33745cc2f48e0 /pp.c
parentc453f11f2af4f3e1ab8cffd4152a877d026dd4a6 (diff)
downloadperl-98485b38a7f16148bd71cb9ff1c3ade8d491ef5f.tar.gz
more pack/unpack documentation (from Ilya Zakharevich); changed
the behavior of 'Z*' and 'Z3' to always pack a trailing null byte; changed documentation to suit; added test p4raw-id: //depot/perl@4346
Diffstat (limited to 'pp.c')
-rw-r--r--pp.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/pp.c b/pp.c
index 41aeeebe1e..7168be0eca 100644
--- a/pp.c
+++ b/pp.c
@@ -4427,10 +4427,16 @@ PP(pp_pack)
case 'a':
fromstr = NEXTFROM;
aptr = SvPV(fromstr, fromlen);
- if (pat[-1] == '*')
+ if (pat[-1] == '*') {
len = fromlen;
- if (fromlen > len)
+ if (datumtype == 'Z')
+ ++len;
+ }
+ if (fromlen >= len) {
sv_catpvn(cat, aptr, len);
+ if (datumtype == 'Z')
+ *(SvEND(cat)-1) = '\0';
+ }
else {
sv_catpvn(cat, aptr, fromlen);
len -= fromlen;