summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-06-23 07:05:59 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-06-23 07:05:59 +0000
commit552fb72159d3bb27ff40ecc121bbc52a3fff89a1 (patch)
treed6abf2514a01ce6f2ff5160cea2d132933af3973 /string.c
parent44cf56d6e70dbe06a160b004494ba40dd4cfb426 (diff)
2000-06-23
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@776 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/string.c b/string.c
index f6ae91bdf1..7943465ef3 100644
--- a/string.c
+++ b/string.c
@@ -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 &&