summaryrefslogtreecommitdiff
path: root/pp_pack.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2005-01-27 19:26:21 +0000
committerNicholas Clark <nick@ccl4.org>2005-01-27 19:26:21 +0000
commita72c271bac70ecc52cda8ed4ba689c8816509735 (patch)
tree759a16bf46116730f4a86af465376a76951480a7 /pp_pack.c
parent19e169bfb15baa663525996999bfeb9bd76bdc62 (diff)
downloadperl-a72c271bac70ecc52cda8ed4ba689c8816509735.tar.gz
Retrieve the flag bit that only 'p' uses, so that it is spare for
future use. p4raw-id: //depot/perl@23892
Diffstat (limited to 'pp_pack.c')
-rw-r--r--pp_pack.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/pp_pack.c b/pp_pack.c
index 413689317e..8f76d69c66 100644
--- a/pp_pack.c
+++ b/pp_pack.c
@@ -272,7 +272,7 @@ S_mul128(pTHX_ SV *sv, U8 m)
#endif
#define PACK_SIZE_CANNOT_CSUM 0x80
-#define PACK_SIZE_CANNOT_ONLY_ONE 0x40
+#define PACK_SIZE_SPARE 0x40
#define PACK_SIZE_MASK 0x3F
@@ -329,7 +329,7 @@ unsigned char size_normal[53] = {
0,
/* n */ SIZE16,
0,
- /* p */ sizeof(char *) | PACK_SIZE_CANNOT_ONLY_ONE | PACK_SIZE_CANNOT_CSUM,
+ /* p */ sizeof(char *) | PACK_SIZE_CANNOT_CSUM,
#if defined(HAS_QUAD)
/* q */ sizeof(Quad_t),
#else
@@ -398,7 +398,7 @@ unsigned char size_normal[99] = {
0,
/* n */ SIZE16,
0,
- /* p */ sizeof(char *) | PACK_SIZE_CANNOT_ONLY_ONE | PACK_SIZE_CANNOT_CSUM,
+ /* p */ sizeof(char *) | PACK_SIZE_CANNOT_CSUM,
#if defined(HAS_QUAD)
/* q */ sizeof(Quad_t),
#else
@@ -935,7 +935,8 @@ S_unpack_rec(pTHX_ register tempsym_t* symptr, register char *s, char *strbeg, c
{
int which = (symptr->code & TYPE_IS_SHRIEKING)
? PACK_SIZE_SHRIEKING : PACK_SIZE_NORMAL;
- int offset = TYPE_NO_MODIFIERS(datumtype) - packsize[which].first;
+ const int rawtype = TYPE_NO_MODIFIERS(datumtype);
+ int offset = rawtype - packsize[which].first;
if (offset >= 0 && offset < packsize[which].size) {
/* Data about this template letter */
@@ -948,9 +949,17 @@ S_unpack_rec(pTHX_ register tempsym_t* symptr, register char *s, char *strbeg, c
if (len > howmany)
len = howmany;
+ /* In the old code, 'p' was the only type without shortcut
+ code to curtail unpacking to only one. As far as I can
+ see the only point of retaining this anomaly is to make
+ code such as $_ = unpack "p2", pack "pI", "Hi", 2
+ continue to segfault. ie, it probably should be
+ construed as a bug.
+ */
+
if (!checksum || (data & PACK_SIZE_CANNOT_CSUM)) {
if (len && unpack_only_one &&
- !(data & PACK_SIZE_CANNOT_ONLY_ONE))
+ rawtype != 'p')
len = 1;
EXTEND(SP, len);
EXTEND_MORTAL(len);