summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-08-17 09:02:40 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-08-17 09:02:40 +0000
commit67232b21511423f82ab18db04f941e6925338a7b (patch)
tree922299c561755f4a987420495fbf1392ef7ea1cc /string.c
parent4af25f5813cd98baa93c459c49718ef62882913a (diff)
* io.c (rb_io_reopen): should clear allocated OpenFile. pointed
out by Guy Decoux. [ruby-core:03288] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6781 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/string.c b/string.c
index e68dfcc20a..0b32ddeb4c 100644
--- a/string.c
+++ b/string.c
@@ -1079,10 +1079,10 @@ rb_str_index_m(argc, argv, str)
{
int c = FIX2INT(sub);
long len = RSTRING(str)->len;
- unsigned char *p = RSTRING(str)->ptr;
+ char *p = RSTRING(str)->ptr;
for (;pos<len;pos++) {
- if (p[pos] == c) return LONG2NUM(pos);
+ if ((unsigned char)p[pos] == c) return LONG2NUM(pos);
}
return Qnil;
}
@@ -1201,15 +1201,16 @@ rb_str_rindex_m(argc, argv, str)
case T_FIXNUM:
{
int c = FIX2INT(sub);
- unsigned char *p = RSTRING(str)->ptr + pos;
- unsigned char *pbeg = RSTRING(str)->ptr;
+ char *p = RSTRING(str)->ptr + pos;
+ char *pbeg = RSTRING(str)->ptr;
if (pos == RSTRING(str)->len) {
if (pos == 0) return Qnil;
--p;
}
while (pbeg <= p) {
- if (*p == c) return LONG2NUM((char*)p - RSTRING(str)->ptr);
+ if ((unsigned char)*p == c)
+ return LONG2NUM((char*)p - RSTRING(str)->ptr);
p--;
}
return Qnil;