summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-11-08 09:28:42 (GMT)
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-11-08 09:28:42 (GMT)
commite640e1c56543f12795813e4eca0890751d3764a0 (patch)
treed7bd79ae780341c5a3db77b52792aa2604b674b7 /util.c
parent599a7071c1789013dc8c8a4edeb5d54bc2fb71a6 (diff)
* util.c (ruby_hdtoa): fix type cast and bufsize.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29720 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'util.c')
-rw-r--r--util.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/util.c b/util.c
index 99b8a3f..db6f83f 100644
--- a/util.c
+++ b/util.c
@@ -3934,8 +3934,8 @@ ruby_each_words(const char *str, void (*func)(const char*, int, void*), void *ar
#define SIGFIGS ((DBL_MANT_DIG + 3) / 4 + 1)
#define dexp_get(u) ((int)(word0(u) >> Exp_shift) & ~Exp_msk1)
#define dexp_set(u,v) (word0(u) = (((int)(word0(u)) & ~Exp_mask) | (v << Exp_shift)))
-#define dmanh_get(u) ((int)(word0(u) & Frac_mask))
-#define dmanl_get(u) ((int)word1(u))
+#define dmanh_get(u) ((uint32_t)(word0(u) & Frac_mask))
+#define dmanl_get(u) ((uint32_t)word1(u))
/*
@@ -4008,7 +4008,7 @@ ruby_hdtoa(double d, const char *xdigs, int ndigits, int *decpt, int *sign,
* enough space for all the digits.
*/
bufsize = (ndigits > 0) ? ndigits : SIGFIGS;
- s0 = rv_alloc(bufsize);
+ s0 = rv_alloc(bufsize+1);
/* Round to the desired number of digits. */
if (SIGFIGS > ndigits && ndigits > 0) {