unpack("C", ...) was left slightly unfinished by #8865.
Jarkko Hietaniemi [Wed, 21 Feb 2001 14:00:03 +0000 (14:00 +0000)]
p4raw-id: //depot/perl@8869

pp.c
t/op/pack.t

diff --git a/pp.c b/pp.c
index b3d769a..2b975e4 100644 (file)
--- a/pp.c
+++ b/pp.c
@@ -4335,7 +4335,8 @@ PP(pp_unpack)
                if (DO_UTF8(right)) {
                    while (len > 0) {
                        STRLEN l;
-                       auv = utf8_to_uv((U8*)s, len, &l, UTF8_ALLOW_ANYUV);
+                       auv = utf8_to_uv((U8*)s, strend - s,
+                                        &l, UTF8_ALLOW_ANYUV);
                        culong += auv;
                        s += l;
                        len -= l;
@@ -4355,7 +4356,8 @@ PP(pp_unpack)
                if (DO_UTF8(right)) {
                    while (len > 0) {
                        STRLEN l;
-                       auv = utf8_to_uv((U8*)s, len, &l, UTF8_ALLOW_ANYUV);
+                       auv = utf8_to_uv((U8*)s, strend - s,
+                                        &l, UTF8_ALLOW_ANYUV);
                        sv = NEWSV(37, 0);
                        sv_setuv(sv, auv);
                        PUSHs(sv_2mortal(sv));
index 06e47f2..3483597 100755 (executable)
@@ -426,8 +426,8 @@ print "ok $test\n"; $test++;
 
 # 160: unpack("C") and ord() equivalence for Unicode
 
-#print "not " unless unpack("C", chr(0x100)) eq ord(chr(0x100)) &&
-#                    ord(chr(0x100)) == 0x100;
+print "not " unless unpack("C", chr(0x100)) eq ord(chr(0x100)) &&
+                    ord(chr(0x100)) == 0x100;
 print "ok $test\n"; $test++;
 
 # 161: use bytes + unpack C == UTF-8 unraveling