[macruby-changes] [3072] MacRuby/trunk/string.c

source_changes at macosforge.org source_changes at macosforge.org
Wed Dec 2 14:31:08 PST 2009


Revision: 3072
          http://trac.macosforge.org/projects/ruby/changeset/3072
Author:   psychs at limechat.net
Date:     2009-12-02 14:31:07 -0800 (Wed, 02 Dec 2009)
Log Message:
-----------
str.split('') should split into characters

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

Modified: MacRuby/trunk/string.c
===================================================================
--- MacRuby/trunk/string.c	2009-12-02 02:25:59 UTC (rev 3071)
+++ MacRuby/trunk/string.c	2009-12-02 22:31:07 UTC (rev 3072)
@@ -3578,16 +3578,39 @@
     if (awk_split || spat_string) {
 	CFRange search_range;
 	CFCharacterSetRef charset = NULL;
+	long spat_len = 0;
 	if (spat == Qnil) {
 	    charset = CFCharacterSetGetPredefined(
 		    kCFCharacterSetWhitespaceAndNewline);
 	}
+	else {
+            spat_len = RSTRING_LEN(spat);
+	}
 	search_range = CFRangeMake(0, clen);
 	do {
 	    CFRange result_range;
 	    CFRange substr_range;
 	    if (spat != Qnil) {
-		if (!CFStringFindWithOptions((CFStringRef)str, 
+	        if (spat_len == 0) {
+                    if (search_range.location + 1 < clen && search_range.length > 0) {
+                        result_range.location = search_range.location + 1;
+                        result_range.length = 0;
+                        UniChar c = CFStringGetCharacterAtIndex((CFStringRef)str,
+                                        search_range.location);
+                        if (CFStringIsSurrogateHighCharacter(c)) {
+                            if (result_range.location + 1 < clen) {
+                                ++result_range.location;
+                            }
+                            else {
+                                break;
+                            }
+                        }
+                    }
+                    else {
+                        break;
+                    }
+	        }
+	        else if (!CFStringFindWithOptions((CFStringRef)str, 
 			    (CFStringRef)spat,
 			    search_range,
 			    0,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20091202/27d2cbc7/attachment.html>


More information about the macruby-changes mailing list