`String#lines` with a block is deprecated style.

parent 54905e98
......@@ -320,36 +320,16 @@ static mrb_value
mrb_str_lines(mrb_state *mrb, mrb_value self)
{
mrb_value result;
mrb_value blk;
int ai;
mrb_int len;
mrb_value arg;
char *b = RSTRING_PTR(self);
char *p = b, *t;
char *e = b + RSTRING_LEN(self);
mrb_get_args(mrb, "&", &blk);
mrb_get_args(mrb, "");
result = mrb_ary_new(mrb);
ai = mrb_gc_arena_save(mrb);
if (!mrb_nil_p(blk)) {
while (p < e) {
t = p;
while (p < e && *p != '\n') p++;
if (*p == '\n') p++;
len = (mrb_int) (p - t);
arg = mrb_str_new(mrb, t, len);
mrb_yield_argv(mrb, blk, 1, &arg);
mrb_gc_arena_restore(mrb, ai);
if (b != RSTRING_PTR(self)) {
ptrdiff_t diff = p - b;
b = RSTRING_PTR(self);
p = b + diff;
}
e = b + RSTRING_LEN(self);
}
return self;
}
while (p < e) {
t = p;
while (p < e && *p != '\n') p++;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment