Fix puts to print newline with empty strings; ref b184772

This commit is contained in:
Yukihiro "Matz" Matsumoto
2020-07-22 17:50:01 +09:00
parent b920270508
commit 0e9bd24827
+1 -1
View File
@@ -76,7 +76,7 @@ mrb_puts(mrb_state *mrb, mrb_value self)
mrb_value s = mrb_str_to_str(mrb, argv[i]);
mrb_int len = RSTRING_LEN(s);
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);
}
}