summaryrefslogtreecommitdiff
path: root/pp_pack.c
diff options
context:
space:
mode:
authorTon Hospel <perl5-porters@ton.iguana.be>2005-01-29 12:54:34 +0000
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2005-02-02 19:50:53 +0000
commit21c16052ffb70c4bff066e455c6d4bea74622e34 (patch)
treeb2b575ba0a4d46b84ab8494e3b47ce3aa747888c /pp_pack.c
parent0c81e54bc30e3e0dec16be656a10a6c616817930 (diff)
downloadperl-21c16052ffb70c4bff066e455c6d4bea74622e34.tar.gz
Re: encoding neutral unpack
From: perl5-porters[at]ton.iguana.be (Ton Hospel) Message-ID: <ctg12a$j0e$2[at]post.home.lunix> Counted length prefixes shouldn't change C0/U0 mode in pack/unpack (plus a regression test) p4raw-id: //depot/perl@23924
Diffstat (limited to 'pp_pack.c')
-rw-r--r--pp_pack.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/pp_pack.c b/pp_pack.c
index cf020d6153..3ee7128511 100644
--- a/pp_pack.c
+++ b/pp_pack.c
@@ -908,6 +908,7 @@ S_unpack_rec(pTHX_ register tempsym_t* symptr, register char *s, char *strbeg, c
const int bits_in_uv = 8 * sizeof(cuv);
char* strrelbeg = s;
bool beyond = FALSE;
+ bool explicit_length;
bool unpack_only_one = (symptr->flags & FLAG_UNPACK_ONLY_ONE) != 0;
while (next_symbol(symptr)) {
@@ -930,6 +931,7 @@ S_unpack_rec(pTHX_ register tempsym_t* symptr, register char *s, char *strbeg, c
break;
}
+ explicit_length = TRUE;
redo_switch:
beyond = s >= strend;
{
@@ -1180,7 +1182,8 @@ S_unpack_rec(pTHX_ register tempsym_t* symptr, register char *s, char *strbeg, c
case 'C':
unpack_C: /* unpack U will jump here if not UTF-8 */
if (len == 0) {
- symptr->flags &= ~FLAG_UNPACK_DO_UTF8;
+ if (explicit_length)
+ symptr->flags &= ~FLAG_UNPACK_DO_UTF8;
break;
}
if (checksum) {
@@ -1202,7 +1205,8 @@ S_unpack_rec(pTHX_ register tempsym_t* symptr, register char *s, char *strbeg, c
break;
case 'U':
if (len == 0) {
- symptr->flags |= FLAG_UNPACK_DO_UTF8;
+ if (explicit_length)
+ symptr->flags |= FLAG_UNPACK_DO_UTF8;
break;
}
if ((symptr->flags & FLAG_UNPACK_DO_UTF8) == 0)
@@ -1753,6 +1757,7 @@ S_unpack_rec(pTHX_ register tempsym_t* symptr, register char *s, char *strbeg, c
Perl_croak(aTHX_ "Code missing after '/' in unpack" );
}
datumtype = symptr->code;
+ explicit_length = FALSE;
goto redo_switch;
}
}