summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authorNobuyoshi Nakada <[email protected]>2020-01-21 08:37:44 +0900
committerNobuyoshi Nakada <[email protected]>2020-02-23 13:37:40 +0900
commit8a7e0aaaef3b19f90d6debe6781e4b3031f56237 (patch)
treee4c6fb0dd79b1d856cd8a200f550170114bbf30a /string.c
parent6298ec2875a6f1a1e75698c96ceac94362f20bcf (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.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/string.c b/string.c
index 28a1b293d6..0607726a07 100644
--- a/string.c
+++ b/string.c
@@ -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;