[macruby-changes] [2673] MacRuby/trunk/numeric.c

source_changes at macosforge.org source_changes at macosforge.org
Mon Sep 28 21:20:03 PDT 2009


Revision: 2673
          http://trac.macosforge.org/projects/ruby/changeset/2673
Author:   lsansonetti at apple.com
Date:     2009-09-28 21:20:03 -0700 (Mon, 28 Sep 2009)
Log Message:
-----------
fix a random bug of Numeric#chr

Modified Paths:
--------------
    MacRuby/trunk/numeric.c

Modified: MacRuby/trunk/numeric.c
===================================================================
--- MacRuby/trunk/numeric.c	2009-09-29 04:18:42 UTC (rev 2672)
+++ MacRuby/trunk/numeric.c	2009-09-29 04:20:03 UTC (rev 2673)
@@ -1987,22 +1987,23 @@
 static VALUE
 int_chr(VALUE num, SEL sel, int argc, VALUE *argv)
 {
-    char c;
+    char c[2];
     long i = NUM2LONG(num);
     rb_encoding *enc;
     VALUE str;
 
+    c[1] = '\0';
     switch (argc) {
       case 0:
 	if (i < 0 || 0xff < i) {
 	    rb_raise(rb_eRangeError, "%"PRIdVALUE " out of char range", i);
 	}
-	c = i;
+	c[0] = i;
 	if (i < 0x80) {
-	    return rb_usascii_str_new(&c, 1);
+	    return rb_usascii_str_new(c, 1);
 	}
 	else {
-	    return rb_str_new(&c, 1);
+	    return rb_str_new(c, 1);
 	}
       case 1:
 	break;
@@ -2011,7 +2012,7 @@
 	break;
     }
     enc = rb_to_encoding(argv[0]);
-    str = rb_enc_str_new(&c, 1, enc);
+    str = rb_enc_str_new(c, 1, enc);
     return str;
 }
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090928/48bc8ef4/attachment.html>


More information about the macruby-changes mailing list