diff options
| author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2000-06-23 07:05:59 +0000 |
|---|---|---|
| committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2000-06-23 07:05:59 +0000 |
| commit | 2431451396d851174715edf98c00231581e294f2 (patch) | |
| tree | d6abf2514a01ce6f2ff5160cea2d132933af3973 /string.c | |
| parent | 623f789e46a571d4d18ba5a7ae5fd657e5d34a0f (diff) | |
| download | ruby-2431451396d851174715edf98c00231581e294f2.tar.gz ruby-2431451396d851174715edf98c00231581e294f2.tar.xz ruby-2431451396d851174715edf98c00231581e294f2.zip | |
2000-06-23
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@776 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
| -rw-r--r-- | string.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -329,7 +329,8 @@ rb_str_substr(str, beg, len) VALUE str2; if (len < 0) return Qnil; - if (beg >= RSTRING(str)->len) return Qnil; + if (beg > RSTRING(str)->len) return Qnil; + if (beg == RSTRING(str)->len && len > 0) return Qnil; if (beg < 0) { beg += RSTRING(str)->len; if (beg < 0) return Qnil; @@ -2226,7 +2227,11 @@ rb_str_split_m(argc, argv, str) } } if (!NIL_P(limit) || RSTRING(str)->len > beg || lim < 0) { - rb_ary_push(result, rb_str_substr(str, beg, RSTRING(str)->len-beg)); + if (RSTRING(str)->len == beg) + tmp = rb_str_new(0, 0); + else + tmp = rb_str_substr(str, beg, RSTRING(str)->len-beg); + rb_ary_push(result, tmp); } if (NIL_P(limit) && lim == 0) { while (RARRAY(result)->len > 0 && |
