mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Pass keyword arguments to IOs properly [Bug #16639]
This commit is contained in:
parent
38070ccdeb
commit
041c2932e3
2 changed files with 13 additions and 2 deletions
8
io.c
8
io.c
|
@ -12430,10 +12430,14 @@ argf_block_call_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, argf))
|
|||
return Qnil;
|
||||
}
|
||||
|
||||
#define ARGF_block_call(mid, argc, argv, func, argf) \
|
||||
rb_block_call_kw(ARGF.current_file, mid, argc, argv, \
|
||||
func, argf, rb_keyword_given_p())
|
||||
|
||||
static void
|
||||
argf_block_call(ID mid, int argc, VALUE *argv, VALUE argf)
|
||||
{
|
||||
VALUE ret = rb_block_call(ARGF.current_file, mid, argc, argv, argf_block_call_i, argf);
|
||||
VALUE ret = ARGF_block_call(mid, argc, argv, argf_block_call_i, argf);
|
||||
if (ret != Qundef) ARGF.next_p = 1;
|
||||
}
|
||||
|
||||
|
@ -12449,7 +12453,7 @@ argf_block_call_line_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, argf))
|
|||
static void
|
||||
argf_block_call_line(ID mid, int argc, VALUE *argv, VALUE argf)
|
||||
{
|
||||
VALUE ret = rb_block_call(ARGF.current_file, mid, argc, argv, argf_block_call_line_i, argf);
|
||||
VALUE ret = ARGF_block_call(mid, argc, argv, argf_block_call_line_i, argf);
|
||||
if (ret != Qundef) ARGF.next_p = 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -725,6 +725,13 @@ class TestArgf < Test::Unit::TestCase
|
|||
["\"a\\n\\n\"", "\"b\\n\""], [])
|
||||
end
|
||||
|
||||
def test_each_line_chomp
|
||||
assert_in_out_err(['-e', 'ARGF.each_line(chomp: false) {|para| p para}'], "a\nb\n",
|
||||
["\"a\\n\"", "\"b\\n\""], [])
|
||||
assert_in_out_err(['-e', 'ARGF.each_line(chomp: true) {|para| p para}'], "a\nb\n",
|
||||
["\"a\"", "\"b\""], [])
|
||||
end
|
||||
|
||||
def test_each_byte
|
||||
ruby('-e', "#{<<~"{#"}\n#{<<~'};'}", @t1.path, @t2.path, @t3.path) do |f|
|
||||
{#
|
||||
|
|
Loading…
Add table
Reference in a new issue