diff options
author | Nobuyoshi Nakada <[email protected]> | 2020-01-21 08:37:44 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <[email protected]> | 2020-02-23 13:37:40 +0900 |
commit | 8a7e0aaaef3b19f90d6debe6781e4b3031f56237 (patch) | |
tree | e4c6fb0dd79b1d856cd8a200f550170114bbf30a /string.c | |
parent | 6298ec2875a6f1a1e75698c96ceac94362f20bcf (diff) |
Warn non-nil `$/` [Feature #14240]
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/2920
Diffstat (limited to 'string.c')
-rw-r--r-- | string.c | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -8246,6 +8246,21 @@ chomp_newline(const char *p, const char *e, rb_encoding *enc) } static VALUE +get_rs(void) +{ + VALUE rs = rb_rs; + if (!NIL_P(rs) && + (!RB_TYPE_P(rs, T_STRING) || + RSTRING_LEN(rs) != 1 || + RSTRING_PTR(rs)[0] != '\n')) { + rb_warn("$/ is set to non-default value"); + } + return rs; +} + +#define rb_rs get_rs() + +static VALUE rb_str_enumerate_lines(int argc, VALUE *argv, VALUE str, VALUE ary) { rb_encoding *enc; |