ord() and unpack("U*",...) should not be negative
authorGisle Aas <gisle@aas.no>
Tue, 20 Oct 1998 14:24:44 +0000 (16:24 +0200)
committerGurusamy Sarathy <gsar@cpan.org>
Sun, 25 Oct 1998 06:45:09 +0000 (06:45 +0000)
Message-ID: <m34sszctf7.fsf@furu.g.aas.no>

p4raw-id: //depot/perl@2064

pp.c

diff --git a/pp.c b/pp.c
index 495b9ea..72599d1 100644 (file)
--- a/pp.c
+++ b/pp.c
@@ -2120,15 +2120,15 @@ PP(pp_sprintf)
 PP(pp_ord)
 {
     djSP; dTARGET;
-    I32 value;
+    UV value;
     U8 *tmps = (U8*)POPp;
     I32 retlen;
 
     if (IN_UTF8 && (*tmps & 0x80))
-       value = (I32) utf8_to_uv(tmps, &retlen);
+       value = utf8_to_uv(tmps, &retlen);
     else
-       value = (I32) (*tmps & 255);
-    XPUSHi(value);
+       value = (UV)(*tmps & 255);
+    XPUSHu(value);
     RETURN;
 }
 
@@ -3433,7 +3433,7 @@ PP(pp_unpack)
                    auint = utf8_to_uv((U8*)s, &along);
                    s += along;
                    sv = NEWSV(37, 0);
-                   sv_setiv(sv, (IV)auint);
+                   sv_setuv(sv, (UV)auint);
                    PUSHs(sv_2mortal(sv));
                }
            }