mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
String#index should no longer take integer argument
This commit is contained in:
+1
-1
@@ -12,7 +12,7 @@ class String
|
|||||||
def each_line(&block)
|
def each_line(&block)
|
||||||
# expect that str.index accepts an Integer for 1st argument as a byte data
|
# expect that str.index accepts an Integer for 1st argument as a byte data
|
||||||
offset = 0
|
offset = 0
|
||||||
while pos = self.index(0x0a, offset)
|
while pos = self.index("\n", offset)
|
||||||
block.call(self[offset, pos + 1 - offset])
|
block.call(self[offset, pos + 1 - offset])
|
||||||
offset = pos + 1
|
offset = pos + 1
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1389,17 +1389,6 @@ mrb_str_index_m(mrb_state *mrb, mrb_value str)
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (mrb_type(sub)) {
|
switch (mrb_type(sub)) {
|
||||||
case MRB_TT_FIXNUM: {
|
|
||||||
mrb_int c = mrb_fixnum(sub);
|
|
||||||
mrb_int len = RSTRING_LEN(str);
|
|
||||||
unsigned char *p = (unsigned char*)RSTRING_PTR(str);
|
|
||||||
|
|
||||||
for (;pos<len;pos++) {
|
|
||||||
if (p[pos] == c) return mrb_fixnum_value(pos);
|
|
||||||
}
|
|
||||||
return mrb_nil_value();
|
|
||||||
}
|
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
mrb_value tmp;
|
mrb_value tmp;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user