This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Re: 5.004_04 vec() fails with 32-bit values
authorM. J. T. Guy <mjtg@cus.cam.ac.uk>
Thu, 15 Jan 1998 11:53:06 +0000 (11:53 +0000)
committerMalcolm Beattie <mbeattie@sable.ox.ac.uk>
Fri, 6 Feb 1998 16:02:57 +0000 (16:02 +0000)
p4raw-id: //depot/perl@471

pod/perlguts.pod
pp.c
t/op/vec.t

index 4806815..1aea1d8 100644 (file)
@@ -42,9 +42,10 @@ The five routines are:
     SV*  newSVpvf(const char*, ...);
     SV*  newSVsv(SV*);
 
     SV*  newSVpvf(const char*, ...);
     SV*  newSVsv(SV*);
 
-To change the value of an *already-existing* SV, there are six routines:
+To change the value of an *already-existing* SV, there are seven routines:
 
     void  sv_setiv(SV*, IV);
 
     void  sv_setiv(SV*, IV);
+    void  sv_setuv(SV*, UV);
     void  sv_setnv(SV*, double);
     void  sv_setpv(SV*, char*);
     void  sv_setpvn(SV*, char*, int)
     void  sv_setnv(SV*, double);
     void  sv_setpv(SV*, char*);
     void  sv_setpvn(SV*, char*, int)
diff --git a/pp.c b/pp.c
index 64411df..34e340d 100644 (file)
--- a/pp.c
+++ b/pp.c
@@ -1911,7 +1911,7 @@ PP(pp_vec)
        }
     }
 
        }
     }
 
-    sv_setiv(TARG, (IV)retnum);
+    sv_setuv(TARG, (UV)retnum);
     PUSHs(TARG);
     RETURN;
 }
     PUSHs(TARG);
     RETURN;
 }
index 97b6d60..7117144 100755 (executable)
@@ -2,7 +2,7 @@
 
 # $RCSfile: vec.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:36 $
 
 
 # $RCSfile: vec.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:36 $
 
-print "1..13\n";
+print "1..15\n";
 
 print vec($foo,0,1) == 0 ? "ok 1\n" : "not ok 1\n";
 print length($foo) == 0 ? "ok 2\n" : "not ok 2\n";
 
 print vec($foo,0,1) == 0 ? "ok 1\n" : "not ok 1\n";
 print length($foo) == 0 ? "ok 2\n" : "not ok 2\n";
@@ -21,4 +21,7 @@ print vec($foo,1,8) == 0xf1 ? "ok 10\n" : "not ok 10\n";
 print ((ord(substr($foo,1,1)) & 255) == 0xf1 ? "ok 11\n" : "not ok 11\n");
 print vec($foo,2,4) == 1 ? "ok 12\n" : "not ok 12\n";
 print vec($foo,3,4) == 15 ? "ok 13\n" : "not ok 13\n";
 print ((ord(substr($foo,1,1)) & 255) == 0xf1 ? "ok 11\n" : "not ok 11\n");
 print vec($foo,2,4) == 1 ? "ok 12\n" : "not ok 12\n";
 print vec($foo,3,4) == 15 ? "ok 13\n" : "not ok 13\n";
+vec($Vec, 0, 32) = 0xbaddacab;
+print $Vec eq "\xba\xdd\xac\xab" ? "ok 14\n" : "not ok 14\n";
+print vec($Vec, 0, 32) == 3135089835 ? "ok 15\n" : "not ok 15\n";