Skip to content

Commit

Permalink
change backtrace sep from const char* to char
Browse files Browse the repository at this point in the history
  • Loading branch information
matz committed Mar 7, 2016
1 parent 4e95779 commit 0c28c7d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion include/mruby.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ typedef struct {
const char *filename;
int lineno;
struct RClass *klass;
const char *sep;
char sep;
mrb_sym method_id;
} mrb_backtrace_entry;

Expand Down
16 changes: 8 additions & 8 deletions src/backtrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ struct backtrace_location_raw {
int lineno;
const char *filename;
mrb_sym method_id;
const char *sep;
char sep;
struct RClass *klass;
};

Expand All @@ -28,7 +28,7 @@ struct backtrace_location {
int lineno;
const char *filename;
const char *method;
const char *sep;
char sep;
const char *class_name;
};

Expand Down Expand Up @@ -58,7 +58,7 @@ print_backtrace_i(mrb_state *mrb, struct backtrace_location *loc, void *data)

if (loc->method) {
if (loc->class_name) {
fprintf(args->stream, ":in %s%s%s", loc->class_name, loc->sep, loc->method);
fprintf(args->stream, ":in %s%c%s", loc->class_name, loc->sep, loc->method);
}
else {
fprintf(args->stream, ":in %s", loc->method);
Expand Down Expand Up @@ -88,7 +88,7 @@ get_backtrace_i(mrb_state *mrb, struct backtrace_location *loc, void *data)

if (loc->class_name) {
mrb_str_cat_cstr(mrb, str, loc->class_name);
mrb_str_cat_cstr(mrb, str, loc->sep);
mrb_str_cat(mrb, str, &loc->sep, 1);
}

mrb_str_cat_cstr(mrb, str, loc->method);
Expand Down Expand Up @@ -134,10 +134,10 @@ each_backtrace(mrb_state *mrb, mrb_int ciidx, mrb_code *pc0, each_backtrace_func
if (loc.lineno == -1) continue;

if (ci->target_class == ci->proc->target_class) {
loc.sep = ".";
loc.sep = '.';
}
else {
loc.sep = "#";
loc.sep = '#';
}

if (!loc.filename) {
Expand Down Expand Up @@ -241,7 +241,7 @@ print_backtrace_saved(mrb_state *mrb)

method_name = mrb_sym2name(mrb, entry->method_id);
if (entry->klass) {
fprintf(stream, ":in %s%s%s",
fprintf(stream, ":in %s%c%s",
mrb_class_name(mrb, entry->klass),
entry->sep,
method_name);
Expand Down Expand Up @@ -409,7 +409,7 @@ mrb_restore_backtrace(mrb_state *mrb)

if (entry->klass) {
mrb_str_cat_cstr(mrb, mrb_entry, mrb_class_name(mrb, entry->klass));
mrb_str_cat_cstr(mrb, mrb_entry, entry->sep);
mrb_str_cat(mrb, mrb_entry, &entry->sep, 1);
}

mrb_str_cat_cstr(mrb, mrb_entry, mrb_sym2name(mrb, entry->method_id));
Expand Down

0 comments on commit 0c28c7d

Please sign in to comment.