summaryrefslogtreecommitdiffstats
path: root/string.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-01-01 05:16:49 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-01-01 05:16:49 +0000
commitcd7b5c2d6c664e589062f3f400bd0498225a56cb (patch)
tree7cdff8af89fc3d7cf2f22b7329c62f396dc0cb22 /string.c
parent0a3bee229a272808edc396b5c66e244912c1c201 (diff)
downloadruby-cd7b5c2d6c664e589062f3f400bd0498225a56cb.tar.gz
ruby-cd7b5c2d6c664e589062f3f400bd0498225a56cb.tar.xz
ruby-cd7b5c2d6c664e589062f3f400bd0498225a56cb.zip
* string.c (rb_str_substr): offset movement bug. a patch from
Vincent Isambart <vincent.isambart at gmail.com> in [ruby-core:14647]. [ruby-core:14644] git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@14825 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/string.c b/string.c
index d569ce544..87f61a332 100644
--- a/string.c
+++ b/string.c
@@ -832,10 +832,10 @@ rb_str_substr(VALUE str, long beg, long len)
if (len > -beg) len = -beg;
if (-beg * rb_enc_mbmaxlen(enc) < RSTRING_LEN(str) / 8) {
beg = -beg;
- while (len++ < beg && (e = rb_enc_prev_char(s, e, enc)) != 0);
+ while (beg-- > len && (e = rb_enc_prev_char(s, e, enc)) != 0);
p = e;
if (!p) return Qnil;
- while (beg-- > 0 && (p = rb_enc_prev_char(s, p, enc)) != 0);
+ while (len-- > 0 && (p = rb_enc_prev_char(s, p, enc)) != 0);
if (!p) return Qnil;
len = e - p;
goto sub;