summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-06-26 18:24:58 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-06-26 18:24:58 +0000
commit7a425f71e38df08a35d0d416b508bd5c95ed5fa6 (patch)
tree3ba10893d2e9cca6d1a2b197e191bd1ea1eb208d /string.c
parent894d2b643d67ffa9919208327146911e56020ad4 (diff)
* io.c (io_fflush): need to check if closed after thread switch.
[ruby-dev:20351] * io.c (fptr_finalize): ditto. * string.c (rb_str_rindex_m): fixed wrong fix. should move backward first only when matching from the end. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4006 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/string.c b/string.c
index 473eccef7f..52c3a70b5b 100644
--- a/string.c
+++ b/string.c
@@ -1010,8 +1010,13 @@ rb_str_rindex_m(argc, argv, str)
char *p = RSTRING(str)->ptr + pos;
char *pbeg = RSTRING(str)->ptr;
- while (pbeg <= --p) {
+ if (pos == RSTRING(str)->len) {
+ if (pos == 0) return Qnil;
+ --p;
+ }
+ while (pbeg <= p) {
if (*p == c) return LONG2NUM(p - RSTRING(str)->ptr);
+ p--;
}
return Qnil;
}