Fix `puts` to print newline with empty strings; ref b1847721

parent b9202705
...@@ -76,7 +76,7 @@ mrb_puts(mrb_state *mrb, mrb_value self) ...@@ -76,7 +76,7 @@ mrb_puts(mrb_state *mrb, mrb_value self)
mrb_value s = mrb_str_to_str(mrb, argv[i]); mrb_value s = mrb_str_to_str(mrb, argv[i]);
mrb_int len = RSTRING_LEN(s); mrb_int len = RSTRING_LEN(s);
printstr(mrb, RSTRING_PTR(s), len); printstr(mrb, RSTRING_PTR(s), len);
if (len > 0 && RSTRING_PTR(s)[len-1] != '\n') { if (len == 0 || RSTRING_PTR(s)[len-1] != '\n') {
printstr(mrb, "\n", 1); printstr(mrb, "\n", 1);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment