[macruby-changes] [1614] MacRuby/branches/experimental

source_changes at macosforge.org source_changes at macosforge.org
Wed May 27 14:01:38 PDT 2009


Revision: 1614
          http://trac.macosforge.org/projects/ruby/changeset/1614
Author:   lsansonetti at apple.com
Date:     2009-05-27 14:01:38 -0700 (Wed, 27 May 2009)
Log Message:
-----------
reverted IO#putc workaround and fixed str_new() so that it can be called with an address to a single character (not NULL-terminated)

Modified Paths:
--------------
    MacRuby/branches/experimental/io.c
    MacRuby/branches/experimental/string.c

Modified: MacRuby/branches/experimental/io.c
===================================================================
--- MacRuby/branches/experimental/io.c	2009-05-27 20:34:34 UTC (rev 1613)
+++ MacRuby/branches/experimental/io.c	2009-05-27 21:01:38 UTC (rev 1614)
@@ -2358,8 +2358,8 @@
 static VALUE
 rb_io_putc(VALUE io, SEL sel, VALUE ch)
 {
-	char mystr[2] = {NUM2CHR(ch), '\0'};
-    rb_io_write(io, sel, rb_str_new(mystr, 1));
+    char c = NUM2CHR(ch);
+    rb_io_write(io, sel, rb_str_new(&c, 1));
     return ch;
 }
 

Modified: MacRuby/branches/experimental/string.c
===================================================================
--- MacRuby/branches/experimental/string.c	2009-05-27 20:34:34 UTC (rev 1613)
+++ MacRuby/branches/experimental/string.c	2009-05-27 21:01:38 UTC (rev 1614)
@@ -112,8 +112,10 @@
     }
 
     if (ptr != NULL && len > 0) {
-	// What in the name of all that is holy is this?!
-	const long slen = strlen(ptr);
+	const long slen = len == 1
+	    ? 1 /* XXX in the case ptr is actually a pointer to a single char
+		   character, which is not NULL-terminated. */
+	    : strlen(ptr);
 
 	if (len <= slen) {
 	    str = str_alloc(klass);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090527/d38e1471/attachment-0001.html>


More information about the macruby-changes mailing list