backtrace.c: do not print trace line if there's no backtrace history

parent 48b08fec
...@@ -102,7 +102,9 @@ print_backtrace(mrb_state *mrb, struct RObject *exc, mrb_value backtrace) ...@@ -102,7 +102,9 @@ print_backtrace(mrb_state *mrb, struct RObject *exc, mrb_value backtrace)
FILE *stream = stderr; FILE *stream = stderr;
if (n != 0) { if (n != 0) {
if (n > 1) {
fprintf(stream, "trace (most recent call last):\n"); fprintf(stream, "trace (most recent call last):\n");
}
for (i=n-1,loc=&RARRAY_PTR(backtrace)[i]; i>0; i--,loc--) { for (i=n-1,loc=&RARRAY_PTR(backtrace)[i]; i>0; i--,loc--) {
if (mrb_string_p(*loc)) { if (mrb_string_p(*loc)) {
fprintf(stream, "\t[%d] %.*s\n", fprintf(stream, "\t[%d] %.*s\n",
......
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