[macruby-changes] [2134] MacRuby/branches/experimental/sprintf.cpp

source_changes at macosforge.org source_changes at macosforge.org
Sat Aug 1 19:05:13 PDT 2009


Revision: 2134
          http://trac.macosforge.org/projects/ruby/changeset/2134
Author:   lsansonetti at apple.com
Date:     2009-08-01 19:05:11 -0700 (Sat, 01 Aug 2009)
Log Message:
-----------
changed the way %s is implemented to behave like the ruby spec and send #to_s

Modified Paths:
--------------
    MacRuby/branches/experimental/sprintf.cpp

Modified: MacRuby/branches/experimental/sprintf.cpp
===================================================================
--- MacRuby/branches/experimental/sprintf.cpp	2009-08-02 02:00:15 UTC (rev 2133)
+++ MacRuby/branches/experimental/sprintf.cpp	2009-08-02 02:05:11 UTC (rev 2134)
@@ -406,7 +406,20 @@
 				args[j] = (VALUE)CFSTR("");
 			    }
 			}
+#if 1
+			// In Ruby, '%s' is supposed to convert the argument
+			// as a string, calling #to_s on it. In order to
+			// support this behavior we are changing the format
+			// to '@' which sends the -[NSObject description]
+			// message, exactly what we want.
+			if (*new_fmt == NULL) {
+			    *new_fmt = strdup(format_str);
+			}
+			(*new_fmt)[i] = '@';
+			type = _C_ID;
+#else
 			type = _C_CHARPTR;
+#endif
 		    }
 		    break;
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090801/a4bb93c5/attachment.html>


More information about the macruby-changes mailing list