summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-proc-ext/src/proc.c
diff options
context:
space:
mode:
authorTakeshi Watanabe <[email protected]>2014-04-14 20:34:49 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2014-04-14 22:01:52 +0900
commit6e0c48d7584d27883d8fb7e5c6fe8eb6f1db0a91 (patch)
tree957324b72a56e9e45efcd35acb51d5ca196d87ca /mrbgems/mruby-proc-ext/src/proc.c
parent4685a43dd69b8303cc0fbff063d6e2812ce7489c (diff)
downloadmruby-6e0c48d7584d27883d8fb7e5c6fe8eb6f1db0a91.tar.gz
mruby-6e0c48d7584d27883d8fb7e5c6fe8eb6f1db0a91.zip
Fix and add test to Proc#inspect .
Diffstat (limited to 'mrbgems/mruby-proc-ext/src/proc.c')
-rw-r--r--mrbgems/mruby-proc-ext/src/proc.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/mrbgems/mruby-proc-ext/src/proc.c b/mrbgems/mruby-proc-ext/src/proc.c
index 8b6ee4740..b105c95d7 100644
--- a/mrbgems/mruby-proc-ext/src/proc.c
+++ b/mrbgems/mruby-proc-ext/src/proc.c
@@ -84,18 +84,17 @@ mrb_proc_inspect(mrb_state *mrb, mrb_value self)
if (!MRB_PROC_CFUNC_P(p)) {
mrb_irep *irep = p->body.irep;
+ const char *filename;
+ int32_t line;
mrb_str_cat_lit(mrb, str, "@");
- if (irep->filename) {
- mrb_str_cat_cstr(mrb, str, irep->filename);
- }
- else {
- mrb_str_cat_lit(mrb, str, "-");
- }
+ filename = mrb_debug_get_filename(irep, 0);
+ mrb_str_cat_cstr(mrb, str, filename ? filename : "-");
mrb_str_cat_lit(mrb, str, ":");
- if (irep->lines) {
- mrb_str_append(mrb, str, mrb_fixnum_value(*irep->lines));
+ line = mrb_debug_get_line(irep, 0);
+ if (line != -1) {
+ mrb_str_append(mrb, str, mrb_fixnum_value(line));
}
else {
mrb_str_cat_lit(mrb, str, "-");