defined printf macro for mrb_int

This commit is contained in:
Yuichiro MASUI
2013-01-26 01:05:20 +09:00
parent 688cf04094
commit 5a681874dd
2 changed files with 7 additions and 8 deletions
+6 -3
View File
@@ -76,7 +76,8 @@
typedef int32_t mrb_int;
# define MRB_INT_MIN INT32_MIN
# define MRB_INT_MAX INT32_MAX
# define mrb_int_to_str(buf, i) sprintf((buf), "%" PRId32, (i))
# define MRB_INT_FORMAT PRId32
# define mrb_int_to_str(buf, i) sprintf((buf), "%" MRB_INT_FORMAT, (i))
# define str_to_mrb_int(buf) (mrb_int)strtol((buf), NULL, 10)
# endif
#else
@@ -84,13 +85,15 @@
typedef int64_t mrb_int;
# define MRB_INT_MIN INT64_MIN
# define MRB_INT_MAX INT64_MAX
# define mrb_int_to_str(buf, i) sprintf((buf), "%" PRId64, (i))
# define MRB_INT_FORMAT PRId64
# define mrb_int_to_str(buf, i) sprintf((buf), "%" MRB_INT_FORMAT, (i))
# define str_to_mrb_int(buf) (mrb_int)strtoll((buf), NULL, 10)
# else
typedef int32_t mrb_int;
# define MRB_INT_MIN INT32_MIN
# define MRB_INT_MAX INT32_MAX
# define mrb_int_to_str(buf, i) sprintf((buf), "%" PRId32, (i))
# define MRB_INT_FORMAT PRId32
# define mrb_int_to_str(buf, i) sprintf((buf), "%" MRB_INT_FORMAT, (i))
# define str_to_mrb_int(buf) (mrb_int)strtol((buf), NULL, 10)
# endif
#endif
+1 -5
View File
@@ -145,11 +145,7 @@ make_cdump_irep(mrb_state *mrb, int irep_no, FILE *f)
case MRB_TT_FLOAT:
SOURCE_CODE(" irep->pool[%d] = mrb_float_value(%.16e);", n, mrb_float(irep->pool[n])); break;
case MRB_TT_FIXNUM:
{
char num_buf[64];
mrb_int_to_str(num_buf, mrb_fixnum(irep->pool[n]));
SOURCE_CODE(" irep->pool[%d] = mrb_fixnum_value(%s);", n, num_buf); break;
}
SOURCE_CODE(" irep->pool[%d] = mrb_fixnum_value(%" MRB_INT_FORMAT ");", n, mrb_fixnum(irep->pool[n])); break;
case MRB_TT_STRING:
str_len = str_format_len(irep->pool[n]) + 1;
if ( str_len > buf_len ) {