Skip to content

Commit

Permalink
str.split('') should split into characters
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/trunk@3072 23306eb0-4c56-4727-a40e-e92c0eb68959
  • Loading branch information
psychs committed Dec 2, 2009
1 parent 316c49e commit fbab4ef
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion string.c
Original file line number Diff line number Diff line change
Expand Up @@ -3578,16 +3578,39 @@ rb_str_split_m(VALUE str, SEL sel, int argc, VALUE *argv)
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,
Expand Down

0 comments on commit fbab4ef

Please sign in to comment.