Revision: 3625 http://trac.macosforge.org/projects/ruby/changeset/3625 Author: lsansonetti@apple.com Date: 2010-02-25 15:58:38 -0800 (Thu, 25 Feb 2010) Log Message: ----------- fixed #[] to use rb_range_beg_len() Modified Paths: -------------- MacRuby/branches/icu/string.c Modified: MacRuby/branches/icu/string.c =================================================================== --- MacRuby/branches/icu/string.c 2010-02-25 22:26:18 UTC (rev 3624) +++ MacRuby/branches/icu/string.c 2010-02-25 23:58:38 UTC (rev 3625) @@ -1536,24 +1536,21 @@ default: { - VALUE rb_start = 0, rb_end = 0; - int exclude_end = false; - if (rb_range_values(indx, &rb_start, &rb_end, - &exclude_end)) { - long start = NUM2LONG(rb_start); - long end = NUM2LONG(rb_end); - if (exclude_end) { - --end; - } - return str_substr(str, start, end - start + 1); - } - else { - str = str_substr(str, NUM2LONG(indx), 1); - if (!NIL_P(str) && str_length(RSTR(str), true) == 0) { + long beg = 0, len = 0; + switch (rb_range_beg_len(indx, &beg, &len, str_length(RSTR(str), + false), 0)) { + case Qfalse: + break; + case Qnil: return Qnil; - } - return str; + default: + return str_substr(str, beg, len); } + str = str_substr(str, NUM2LONG(indx), 1); + if (!NIL_P(str) && str_length(RSTR(str), true) == 0) { + return Qnil; + } + return str; } } }
participants (1)
-
source_changes@macosforge.org