summaryrefslogtreecommitdiff
path: root/pp_pack.c
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2001-09-11 02:27:25 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2001-09-11 02:27:25 +0000
commit35bcd33832d74e56bb99eb6538654e7d815f1ecb (patch)
treec0c43519dc41a137b1ccb0aefeea8b4dc196d1ca /pp_pack.c
parentb99a9337068178db918a66ac51ed0232330878fc (diff)
downloadperl-35bcd33832d74e56bb99eb6538654e7d815f1ecb.tar.gz
Fix unpack U to be the reverse of pack U
(but implement unpack U0U as a backdoor to get the UTF-8 malformed warnings from un-UTF-8 data) p4raw-id: //depot/perl@11993
Diffstat (limited to 'pp_pack.c')
-rw-r--r--pp_pack.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/pp_pack.c b/pp_pack.c
index 7dc28747eb..54ed0b711b 100644
--- a/pp_pack.c
+++ b/pp_pack.c
@@ -167,6 +167,7 @@ PP(pp_unpack)
int natint; /* native integer */
int unatint; /* unsigned native integer */
#endif
+ bool do_utf8 = DO_UTF8(right);
if (gimme != G_ARRAY) { /* arrange to do first one only */
/*SUPPRESS 530*/
@@ -205,7 +206,7 @@ PP(pp_unpack)
DIE(aTHX_ "'!' allowed only after types %s", natstr);
}
star = 0;
- if (pat >= patend)
+ if (pat > patend)
len = 1;
else if (*pat == '*') {
len = strend - strbeg; /* long enough */
@@ -416,6 +417,11 @@ PP(pp_unpack)
}
break;
case 'C':
+ unpack_C: /* unpack U will jump here if not UTF-8 */
+ if (len == 0) {
+ do_utf8 = FALSE;
+ break;
+ }
if (len > strend - s)
len = strend - s;
if (checksum) {
@@ -437,6 +443,12 @@ PP(pp_unpack)
}
break;
case 'U':
+ if (len == 0) {
+ do_utf8 = TRUE;
+ break;
+ }
+ if (!do_utf8)
+ goto unpack_C;
if (len > strend - s)
len = strend - s;
if (checksum) {