diff options
author | Jeremy Evans <code@jeremyevans.net> | 2022-05-26 12:17:55 -0700 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2022-05-30 13:01:17 +0900 |
commit | adaaf12857ce41d35b282e3fb5aa330934ce45c6 (patch) | |
tree | cc2cd096b6302f0a24a0378ad741192db19a1391 /ext/stringio | |
parent | 1f82269f4e1bf037e3e5504c6071b905f26fec6f (diff) | |
download | ruby-adaaf12857ce41d35b282e3fb5aa330934ce45c6.tar.gz |
[ruby/stringio] Ignore chomp keyword for nil separator
nil separator means no separator at all, so nothing should be
chomped.
Partial fix for Ruby [Bug #18770]
https://github.com/ruby/stringio/commit/feaa2ec631
Diffstat (limited to 'ext/stringio')
-rw-r--r-- | ext/stringio/stringio.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c index 04ca25b0b8..8cf5113ac8 100644 --- a/ext/stringio/stringio.c +++ b/ext/stringio/stringio.c @@ -1127,6 +1127,7 @@ prepare_getline_args(struct getline_arg *arg, int argc, VALUE *argv) long limit = -1; argc = rb_scan_args(argc, argv, "02:", &str, &lim, &opts); + int respect_chomp = argc == 0 || !NIL_P(str); switch (argc) { case 0: str = rb_rs; @@ -1160,7 +1161,9 @@ prepare_getline_args(struct getline_arg *arg, int argc, VALUE *argv) keywords[0] = rb_intern_const("chomp"); } rb_get_kwargs(opts, keywords, 0, 1, &vchomp); - arg->chomp = (vchomp != Qundef) && RTEST(vchomp); + if (respect_chomp) { + arg->chomp = (vchomp != Qundef) && RTEST(vchomp); + } } return arg; } |