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
commit2b6c5635bc48c0253928a53128e6cda1b8ab68c0 (patch)
treeec39c560e556f3529c5e0028f7a33745cc2f48e0 /pp.c
parent082ab4105db91207118a22ff2c45d50a1b772838 (diff)
downloadperl-2b6c5635bc48c0253928a53128e6cda1b8ab68c0.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;