This project is closed and read-only.
Bug #2020 ยป argf-lineno.diff
| io.c | ||
|---|---|---|
|
}
|
||
|
static VALUE
|
||
|
rb_io_getline_fast(rb_io_t *fptr, rb_encoding *enc)
|
||
|
rb_io_getline_fast(rb_io_t *fptr, rb_encoding *enc, VALUE io)
|
||
|
{
|
||
|
VALUE str = Qnil;
|
||
|
int len = 0;
|
||
| ... | ... | |
|
str = io_enc_str(str, fptr);
|
||
|
ENC_CODERANGE_SET(str, cr);
|
||
|
fptr->lineno++;
|
||
|
ARGF.last_lineno = fptr->lineno;
|
||
|
if (io == ARGF.current_file) {
|
||
|
ARGF.lineno++;
|
||
|
ARGF.last_lineno = ARGF.lineno;
|
||
|
}
|
||
|
else {
|
||
|
ARGF.last_lineno = fptr->lineno;
|
||
|
}
|
||
|
return str;
|
||
|
}
|
||
| ... | ... | |
|
}
|
||
|
else if (rs == rb_default_rs && limit < 0 && !NEED_READCONV(fptr) &&
|
||
|
rb_enc_asciicompat(enc = io_read_encoding(fptr))) {
|
||
|
return rb_io_getline_fast(fptr, enc);
|
||
|
return rb_io_getline_fast(fptr, enc, io);
|
||
|
}
|
||
|
else {
|
||
|
int c, newline = -1;
|
||
| ... | ... | |
|
if (!NIL_P(str)) {
|
||
|
if (!nolimit) {
|
||
|
fptr->lineno++;
|
||
|
ARGF.last_lineno = fptr->lineno;
|
||
|
if (io == ARGF.current_file) {
|
||
|
ARGF.lineno++;
|
||
|
ARGF.last_lineno = ARGF.lineno;
|
||
|
}
|
||
|
else {
|
||
|
ARGF.last_lineno = fptr->lineno;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
| test/ruby/test_argf.rb | ||
|---|---|---|
|
SRC
|
||
|
end
|
||
|
def test_lineno3
|
||
|
assert_in_out_err(["-", @t1.path, @t2.path], <<-INPUT, %w"1 1 1 2 2 2 3 3 1 4 4 2", [], "[ruby-core:25205]")
|
||
|
ARGF.each do |line|
|
||
|
puts [$., ARGF.lineno, ARGF.file.lineno]
|
||
|
end
|
||
|
INPUT
|
||
|
end
|
||
|
def test_inplace
|
||
|
assert_in_out_err(["-", @t1.path, @t2.path, @t3.path], <<-INPUT, [], [])
|
||
|
ARGF.inplace_mode = '.bak'
|
||