diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2015-09-22 19:10:03 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2015-09-22 19:10:48 +0900 |
| commit | 2cb6c2778134575e425cd5d1bdef036100a25d0d (patch) | |
| tree | 29674e849669c4929afab4e0bd2eebfc5c0339d9 | |
| parent | e47f0fc0c2d23c8dbf196c8885d1c295c9150265 (diff) | |
| download | mruby-2cb6c2778134575e425cd5d1bdef036100a25d0d.tar.gz mruby-2cb6c2778134575e425cd5d1bdef036100a25d0d.zip | |
String#index should no longer take integer argument
| -rw-r--r-- | mrblib/string.rb | 2 | ||||
| -rw-r--r-- | src/string.c | 11 |
2 files changed, 1 insertions, 12 deletions
diff --git a/mrblib/string.rb b/mrblib/string.rb index 5765cff9b..7209f03d2 100644 --- a/mrblib/string.rb +++ b/mrblib/string.rb @@ -12,7 +12,7 @@ class String def each_line(&block) # expect that str.index accepts an Integer for 1st argument as a byte data offset = 0 - while pos = self.index(0x0a, offset) + while pos = self.index("\n", offset) block.call(self[offset, pos + 1 - offset]) offset = pos + 1 end diff --git a/src/string.c b/src/string.c index 12aefa8a0..e7049d678 100644 --- a/src/string.c +++ b/src/string.c @@ -1389,17 +1389,6 @@ mrb_str_index_m(mrb_state *mrb, mrb_value str) } 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: { mrb_value tmp; |
