summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-compiler
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2017-04-25 10:39:11 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2017-04-25 10:41:50 +0900
commit88cd807379152ea3fec5f534e5f4d6ebebd53982 (patch)
treef6b27a76821b8b92f6fc474ce56aab5795afb51b /mrbgems/mruby-compiler
parent03cdb8e9dd3447115530418c2b8183c94dee2a53 (diff)
downloadmruby-88cd807379152ea3fec5f534e5f4d6ebebd53982.tar.gz
mruby-88cd807379152ea3fec5f534e5f4d6ebebd53982.zip
Avoid use of `snprintf()` when DISABLE_STDIO is set; fix #3632
ref #3492 #3515 #3517
Diffstat (limited to 'mrbgems/mruby-compiler')
-rw-r--r--mrbgems/mruby-compiler/core/codegen.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/mrbgems/mruby-compiler/core/codegen.c b/mrbgems/mruby-compiler/core/codegen.c
index e790e6dfc..f863ef337 100644
--- a/mrbgems/mruby-compiler/core/codegen.c
+++ b/mrbgems/mruby-compiler/core/codegen.c
@@ -1024,9 +1024,9 @@ gen_assignment(codegen_scope *s, node *tree, int sp, int val)
default:
#ifndef MRB_DISABLE_STDIO
- printf("unknown lhs %d\n", type);
+ fprintf(stderr, "unknown lhs %d\n", type);
#endif
- break;
+ return;
}
if (val) push();
}
@@ -2195,11 +2195,11 @@ codegen(codegen_scope *s, node *tree, int val)
case NODE_NTH_REF:
if (val) {
mrb_state *mrb = s->mrb;
- char buf[32];
+ mrb_value str;
int sym;
- snprintf(buf, sizeof(buf), "$%" MRB_PRId, (mrb_int)(intptr_t)tree);
- sym = new_sym(s, mrb_intern_cstr(mrb, buf));
+ str = mrb_format(mrb, "$%S", mrb_fixnum_value((mrb_int)(intptr_t)tree));
+ sym = new_sym(s, mrb_intern_str(mrb, str));
genop(s, MKOP_ABx(OP_GETGLOBAL, cursp(), sym));
push();
}