ruby-changes:37411
From: nobu <ko1@a...>
Date: Wed, 4 Feb 2015 16:33:03 +0900 (JST)
Subject: [ruby-changes:37411] nobu:r49492 (trunk): bigdecimal.c: format specifiers
nobu 2015-02-04 16:32:58 +0900 (Wed, 04 Feb 2015) New Revision: 49492 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=49492 Log: bigdecimal.c: format specifiers * ext/bigdecimal/bigdecimal.c (VpInit, VpPower, VpVarCheck): fix format specifiers of BDIGIT. Modified files: trunk/ext/bigdecimal/bigdecimal.c trunk/ext/bigdecimal/bigdecimal.h Index: ext/bigdecimal/bigdecimal.c =================================================================== --- ext/bigdecimal/bigdecimal.c (revision 49491) +++ ext/bigdecimal/bigdecimal.c (revision 49492) @@ -3831,10 +3831,10 @@ VpInit(BDIGIT BaseVal) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L3831 #ifdef BIGDECIMAL_DEBUG if (gfDebug) { - printf("VpInit: BaseVal = %lu\n", BaseVal); - printf(" BASE = %lu\n", BASE); - printf(" HALF_BASE = %lu\n", HALF_BASE); - printf(" BASE1 = %lu\n", BASE1); + printf("VpInit: BaseVal = %"PRIuBDIGIT"\n", BaseVal); + printf(" BASE = %"PRIuBDIGIT"\n", BASE); + printf(" HALF_BASE = %"PRIuBDIGIT"\n", HALF_BASE); + printf(" BASE1 = %"PRIuBDIGIT"\n", BASE1); printf(" BASE_FIG = %u\n", BASE_FIG); printf(" DBLE_FIG = %d\n", DBLE_FIG); } @@ -6261,7 +6261,7 @@ Exit: https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L6261 if (gfDebug) { VPrint(stdout, "VpPower y=%\n", y); VPrint(stdout, "VpPower x=%\n", x); - printf(" n=%d\n", n); + printf(" n=%"PRIdVALUE"\n", n); } #endif /* BIGDECIMAL_DEBUG */ VpFree(w2); @@ -6296,10 +6296,10 @@ VpVarCheck(Real * v) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L6296 for (i = 0; i < v->Prec; ++i) { if (v->frac[i] >= BASE) { printf("ERROR(VpVarCheck): Illegal fraction\n"); - printf(" Frac[%"PRIuSIZE"]=%lu\n", i, v->frac[i]); + printf(" Frac[%"PRIuSIZE"]=%"PRIuBDIGIT"\n", i, v->frac[i]); printf(" Prec. =%"PRIuSIZE"\n", v->Prec); printf(" Exp. =%"PRIdVALUE"\n", v->exponent); - printf(" BASE =%lu\n", BASE); + printf(" BASE =%"PRIuBDIGIT"\n", BASE); return 3; } } Index: ext/bigdecimal/bigdecimal.h =================================================================== --- ext/bigdecimal/bigdecimal.h (revision 49491) +++ ext/bigdecimal/bigdecimal.h (revision 49492) @@ -43,13 +43,35 @@ https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.h#L43 # define BDIGIT_DBL uint64_t # define BDIGIT_DBL_SIGNED int64_t # define SIZEOF_BDIGITS 4 +# define PRI_BDIGIT_PREFIX "" +# ifdef PRI_LL_PREFIX +# define PRI_BDIGIT_DBL_PREFIX PRI_LL_PREFIX +# else +# define PRI_BDIGIT_DBL_PREFIX "l" +# endif #else # define BDIGIT uint16_t # define BDIGIT_DBL uint32_t # define BDIGIT_DBL_SIGNED int32_t # define SIZEOF_BDIGITS 2 +# define PRI_BDIGIT_PREFIX "h" +# define PRI_BDIGIT_DBL_PREFIX "" #endif +#define PRIdBDIGIT PRI_BDIGIT_PREFIX"d" +#define PRIiBDIGIT PRI_BDIGIT_PREFIX"i" +#define PRIoBDIGIT PRI_BDIGIT_PREFIX"o" +#define PRIuBDIGIT PRI_BDIGIT_PREFIX"u" +#define PRIxBDIGIT PRI_BDIGIT_PREFIX"x" +#define PRIXBDIGIT PRI_BDIGIT_PREFIX"X" + +#define PRIdBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"d" +#define PRIiBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"i" +#define PRIoBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"o" +#define PRIuBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"u" +#define PRIxBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"x" +#define PRIXBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"X" + #if defined(__cplusplus) extern "C" { #if 0 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/