summaryrefslogtreecommitdiff
path: root/ext/bigdecimal/bigdecimal.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-10-04 00:55:14 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-10-04 00:55:14 +0000
commit1ae50df95d72f02dc4e8f2edf9502609fd95a8fd (patch)
tree32ffe8132577fd9621d77137dded962bdce100e6 /ext/bigdecimal/bigdecimal.c
parentee1acb555e1350b003cce6ed5d339d0e881add1b (diff)
bigdecimal.c: fix debug print
* ext/bigdecimal/bigdecimal.c (VpFree, VpInit): fix debug print format. * ext/bigdecimal/bigdecimal.c (VPrint): fix argument description, and embed NaN, Infinity, and zero in the format. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56335 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/bigdecimal/bigdecimal.c')
-rw-r--r--ext/bigdecimal/bigdecimal.c50
1 files changed, 22 insertions, 28 deletions
diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c
index b1c887c7563..8f41c725f83 100644
--- a/ext/bigdecimal/bigdecimal.c
+++ b/ext/bigdecimal/bigdecimal.c
@@ -3423,12 +3423,12 @@ VpFree(Real *pv)
#ifdef BIGDECIMAL_DEBUG
gnAlloc--; /* Decrement allocation count */
if (gnAlloc == 0) {
- printf(" *************** All memories allocated freed ****************");
- getchar();
+ printf(" *************** All memories allocated freed ****************\n");
+ /*getchar();*/
}
if (gnAlloc < 0) {
printf(" ??????????? Too many memory free calls(%d) ?????????????\n", gnAlloc);
- getchar();
+ /*getchar();*/
}
#endif /* BIGDECIMAL_DEBUG */
}
@@ -3824,11 +3824,11 @@ VpInit(BDIGIT BaseVal)
#ifdef BIGDECIMAL_DEBUG
if (gfDebug) {
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);
+ printf("\tBASE = %"PRIuBDIGIT"\n", BASE);
+ printf("\tHALF_BASE = %"PRIuBDIGIT"\n", HALF_BASE);
+ printf("\tBASE1 = %"PRIuBDIGIT"\n", BASE1);
+ printf("\tBASE_FIG = %u\n", BASE_FIG);
+ printf("\tDBLE_FIG = %d\n", DBLE_FIG);
}
#endif /* BIGDECIMAL_DEBUG */
@@ -5023,7 +5023,7 @@ Exit:
* % ... VP variable. To print '%', use '%%'.
* \n ... new line
* \b ... backspace
- * ... tab
+ * \t ... tab
* Note: % must not appear more than once
* a ... VP variable to be printed
*/
@@ -5034,24 +5034,6 @@ VPrint(FILE *fp, const char *cntl_chr, Real *a)
size_t i, j, nc, nd, ZeroSup, sep = 10;
BDIGIT m, e, nn;
- /* Check if NaN & Inf. */
- if (VpIsNaN(a)) {
- fprintf(fp, SZ_NaN);
- return 8;
- }
- if (VpIsPosInf(a)) {
- fprintf(fp, SZ_INF);
- return 8;
- }
- if (VpIsNegInf(a)) {
- fprintf(fp, SZ_NINF);
- return 9;
- }
- if (VpIsZero(a)) {
- fprintf(fp, "0.0");
- return 3;
- }
-
j = 0;
nd = nc = 0; /* nd : number of digits in fraction part(every 10 digits, */
/* nd<=10). */
@@ -5060,7 +5042,19 @@ VPrint(FILE *fp, const char *cntl_chr, Real *a)
while (*(cntl_chr + j)) {
if (*(cntl_chr + j) == '%' && *(cntl_chr + j + 1) != '%') {
nc = 0;
- if (!VpIsZero(a)) {
+ if (VpIsNaN(a)) {
+ fprintf(fp, SZ_NaN);
+ nc += 8;
+ }
+ else if (VpIsPosInf(a)) {
+ fprintf(fp, SZ_INF);
+ nc += 8;
+ }
+ else if (VpIsNegInf(a)) {
+ fprintf(fp, SZ_NINF);
+ nc += 9;
+ }
+ else if (!VpIsZero(a)) {
if (VpGetSign(a) < 0) {
fprintf(fp, "-");
++nc;