From 90b3fa398f328fba7e13fbea2edbb3e6fa7a9241 Mon Sep 17 00:00:00 2001 From: matz Date: Mon, 24 Jul 2000 07:19:34 +0000 Subject: matz git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@844 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- string.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'string.c') diff --git a/string.c b/string.c index 7943465ef..678b1b880 100644 --- a/string.c +++ b/string.c @@ -684,6 +684,10 @@ rb_str_rindex(argc, argv, str) if (rb_scan_args(argc, argv, "11", &sub, &position) == 2) { pos = NUM2INT(position); + if (pos < 0) { + pos += RSTRING(str)->len; + if (pos < 0) return Qnil; + } if (pos > RSTRING(str)->len) pos = RSTRING(str)->len; } else { -- cgit