diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2001-09-11 02:27:25 +0000 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2001-09-11 02:27:25 +0000 |
commit | 35bcd33832d74e56bb99eb6538654e7d815f1ecb (patch) | |
tree | c0c43519dc41a137b1ccb0aefeea8b4dc196d1ca /pp_pack.c | |
parent | b99a9337068178db918a66ac51ed0232330878fc (diff) | |
download | perl-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.c | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -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) { |