[macruby-changes] [3705] MacRuby/branches/icu/string.c

source_changes at macosforge.org source_changes at macosforge.org
Fri Mar 5 04:05:55 PST 2010


Revision: 3705
          http://trac.macosforge.org/projects/ruby/changeset/3705
Author:   vincent.isambart at gmail.com
Date:     2010-03-05 04:05:52 -0800 (Fri, 05 Mar 2010)
Log Message:
-----------
improved str_inspect

Modified Paths:
--------------
    MacRuby/branches/icu/string.c

Modified: MacRuby/branches/icu/string.c
===================================================================
--- MacRuby/branches/icu/string.c	2010-03-05 05:29:12 UTC (rev 3704)
+++ MacRuby/branches/icu/string.c	2010-03-05 12:05:52 UTC (rev 3705)
@@ -2391,7 +2391,7 @@
 static VALUE
 str_inspect(rb_str_t *str, bool dump)
 {
-    const bool uchars = str_is_stored_in_uchars(str);
+    const bool uchars = str_try_making_data_uchars(str);
     const long len = uchars
 	? str_length(str, true) : str->length_in_bytes;
 
@@ -2409,13 +2409,20 @@
 
 #define GET_UCHAR(pos) \
     ((uchars \
-      ? str->data.uchars[pos] : (UChar)str->data.bytes[pos]))
+      ? str->data.uchars[pos] : (unsigned char)str->data.bytes[pos]))
 
     inspect_append(result, '"', false);
     for (long i = 0; i < len; i++) {
 	const UChar c = GET_UCHAR(i);
 
-	if (iswprint(c)) {
+	bool print;
+	if (uchars) {
+	    print = iswprint(c);
+	}
+	else { // ASCII printable characters
+	    print = ((c >= 0x20) && (c <= 0x7E));
+	}
+	if (print) {
 	    if (c == '"' || c == '\\') {
 		inspect_append(result, c, true);
 	    }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100305/69ecb5e1/attachment-0001.html>


More information about the macruby-changes mailing list