aboutsummaryrefslogtreecommitdiffstats
path: root/error.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-01-20 01:02:37 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-01-20 01:02:37 +0000
commit878c91810ac55e3c2beecfa450bab610aeea211d (patch)
tree38bc6da68ed33681de01d779075e7736af479e48 /error.c
parent852500c963b991fe0e4175ecc9217215c1ad4094 (diff)
downloadruby-878c91810ac55e3c2beecfa450bab610aeea211d.tar.gz
error.c: print default RS
* error.c (rb_warn_m): print the default RS instead of an empty string with a newline. [Feature #12944] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57377 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'error.c')
-rw-r--r--error.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/error.c b/error.c
index d4c38f8cbb..0ec0cf895a 100644
--- a/error.c
+++ b/error.c
@@ -303,7 +303,10 @@ rb_warn_m(int argc, VALUE *argv, VALUE exc)
VALUE str;
for (i = 0; i < argc; i++) {
str = rb_obj_as_string(argv[i]);
- if (RSTRING_LEN(str) == 0 || !rb_str_end_with_asciichar(str, '\n')) {
+ if (RSTRING_LEN(str) == 0) {
+ str = rb_default_rs;
+ }
+ else if (!rb_str_end_with_asciichar(str, '\n')) {
str = rb_str_cat(rb_str_dup(str), "\n", 1);
}
rb_write_warning_str(str);