From 5e9b7bacc3731b909ea6341d7158ef6b34e09f2d Mon Sep 17 00:00:00 2001 From: nobu Date: Sun, 12 Jan 2014 00:21:37 +0000 Subject: ruby/util.h: DECIMAL_SIZE_OF_BITS * include/ruby/util.h (DECIMAL_SIZE_OF_BITS): a preprocessor constant macro to approximate decimal representation size of n-bits integer. * iseq.c (register_label): use DECIMAL_SIZE_OF_BITS for better approximation. * ext/bigdecimal/bigdecimal.c (BigMath_s_log): ditto. * common.mk (iseq.o), ext/bigdecimal/depend (bigdecimal.o): add dependency to ruby/util.h for DECIMAL_SIZE_OF_BITS. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44562 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- iseq.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'iseq.c') diff --git a/iseq.c b/iseq.c index a829089ea4..befa0364dc 100644 --- a/iseq.c +++ b/iseq.c @@ -10,6 +10,7 @@ **********************************************************************/ #include "ruby/ruby.h" +#include "ruby/util.h" #include "internal.h" #include "eval_intern.h" @@ -1612,7 +1613,7 @@ static VALUE register_label(struct st_table *table, unsigned long idx) { VALUE sym; - char buff[8 + (sizeof(idx) * CHAR_BIT * 32 / 100)]; + char buff[7 + DECIMAL_SIZE_OF_BITS(sizeof(idx) * CHAR_BIT)]; snprintf(buff, sizeof(buff), "label_%lu", idx); sym = ID2SYM(rb_intern(buff)); -- cgit v1.2.3