--- mysql-5.5.16.orig/strings/dtoa.c 2011-10-04 22:51:51.296875000 -0400 +++ mysql-5.5.16/strings/dtoa.c 2011-10-04 22:56:50.109375000 -0400 @@ -48,11 +48,11 @@ */ #define DTOA_BUFF_SIZE (420 * sizeof(void *)) -/* Magic value returned by dtoa() to indicate overflow */ +/* Magic value returned by _dtoa() to indicate overflow */ #define DTOA_OVERFLOW 9999 static double my_strtod_int(const char *, char **, int *, char *, size_t); -static char *dtoa(double, int, int, int *, int *, char **, char *, size_t); +static char *_dtoa(double, int, int, int *, int *, char **, char *, size_t); static void dtoa_free(char *, char *, size_t); /** @@ -61,7 +61,7 @@ representation using the 'f' format. @details - This function is a wrapper around dtoa() to do the same as + This function is a wrapper around _dtoa() to do the same as sprintf(to, "%-.*f", precision, x), though the conversion is usually more precise. The only difference is in handling [-,+]infinity and nan values, in which case we print '0\0' to the output string and indicate an overflow. @@ -93,7 +93,7 @@ char buf[DTOA_BUFF_SIZE]; DBUG_ASSERT(precision >= 0 && precision < NOT_FIXED_DEC && to != NULL); - res= dtoa(x, 5, precision, &decpt, &sign, &end, buf, sizeof(buf)); + res= _dtoa(x, 5, precision, &decpt, &sign, &end, buf, sizeof(buf)); if (decpt == DTOA_OVERFLOW) { @@ -189,7 +189,7 @@ @todo Check if it is possible and makes sense to do our own rounding on top of - dtoa() instead of calling dtoa() twice in (rare) cases when the resulting + _dtoa() instead of calling _dtoa() twice in (rare) cases when the resulting string representation does not fit in the specified field width and we want to re-round the input number with fewer significant digits. Examples: @@ -200,10 +200,10 @@ We do our best to minimize such cases by: - - passing to dtoa() the field width as the number of significant digits + - passing to _dtoa() the field width as the number of significant digits - removing the sign of the number early (and decreasing the width before - passing it to dtoa()) + passing it to _dtoa()) - choosing the proper format to preserve the most number of significant digits. @@ -222,7 +222,7 @@ if (x < 0.) width--; - res= dtoa(x, 4, type == MY_GCVT_ARG_DOUBLE ? width : min(width, FLT_DIG), + res= _dtoa(x, 4, type == MY_GCVT_ARG_DOUBLE ? width : min(width, FLT_DIG), &decpt, &sign, &end, buf, sizeof(buf)); if (decpt == DTOA_OVERFLOW) { @@ -249,7 +249,7 @@ /* Do we have enough space for all digits in the 'f' format? - Let 'len' be the number of significant digits returned by dtoa, + Let 'len' be the number of significant digits returned by _dtoa, and F be the length of the resulting decimal representation. Consider the following cases: 1. decpt <= 0, i.e. we have "0.NNN" => F = len - decpt + 2 @@ -324,11 +324,11 @@ /* We want to truncate (len - width) least significant digits after the - decimal point. For this we are calling dtoa with mode=5, passing the + decimal point. For this we are calling _dtoa with mode=5, passing the number of significant digits = (len-decpt) - (len-width) = width-decpt */ dtoa_free(res, buf, sizeof(buf)); - res= dtoa(x, 5, width - decpt, &decpt, &sign, &end, buf, sizeof(buf)); + res= _dtoa(x, 5, width - decpt, &decpt, &sign, &end, buf, sizeof(buf)); src= res; len= end - res; } @@ -342,7 +342,7 @@ /* At this point we are sure we have enough space to put all digits - returned by dtoa + returned by _dtoa */ if (sign && dst < dend) *dst++= '-'; @@ -394,7 +394,7 @@ { /* Yes, re-convert with a smaller width */ dtoa_free(res, buf, sizeof(buf)); - res= dtoa(x, 4, width, &decpt, &sign, &end, buf, sizeof(buf)); + res= _dtoa(x, 4, width, &decpt, &sign, &end, buf, sizeof(buf)); src= res; len= end - res; if (--decpt < 0) @@ -402,7 +402,7 @@ } /* At this point we are sure we have enough space to put all digits - returned by dtoa + returned by _dtoa */ if (sign && dst < dend) *dst++= '-'; @@ -445,7 +445,7 @@ Converts string to double (string does not have to be zero-terminated) @details - This is a wrapper around dtoa's version of strtod(). + This is a wrapper around _dtoa's version of strtod(). @param str input string @param end address of a pointer to the first character after the input @@ -506,7 +506,7 @@ * strtod() was modified to not expect a zero-terminated string. It now honors 'se' (end of string) argument as the input parameter, not just as the output one. - * in dtoa(), in case of overflow/underflow/NaN result string now contains "0"; + * in _dtoa(), in case of overflow/underflow/NaN result string now contains "0"; decpt is set to DTOA_OVERFLOW to indicate overflow. * support for VAX, IBM mainframe and 16-bit hardware removed * we always assume that 64-bit integer type is available @@ -524,7 +524,7 @@ /* On a machine with IEEE extended-precision registers, it is necessary to specify double-precision (53-bit) rounding precision - before invoking strtod or dtoa. If the machine uses (the equivalent + before invoking strtod or _dtoa. If the machine uses (the equivalent of) Intel 80x87 arithmetic, the call _control87(PC_53, MCW_PC); does this with many compilers. Whether this or another call is @@ -535,7 +535,7 @@ /* #define Honor_FLT_ROUNDS if FLT_ROUNDS can assume the values 2 or 3 - and dtoa should round accordingly. + and _dtoa should round accordingly. #define Check_FLT_ROUNDS if FLT_ROUNDS can assume the values 2 or 3 and Honor_FLT_ROUNDS is not #defined. @@ -612,7 +612,7 @@ #define Big1 0xffffffff #define FFFFFFFF 0xffffffffUL -/* This is tested to be enough for dtoa */ +/* This is tested to be enough for _dtoa */ #define Kmax 15 @@ -702,7 +702,7 @@ { /* Maintain free lists only for stack objects: this way we don't - have to bother with freeing lists in the end of dtoa; + have to bother with freeing lists in the end of _dtoa; heap should not be used normally anyway. */ v->p.next= alloc->freelist[v->k]; @@ -712,7 +712,7 @@ /* - This is to place return value of dtoa in: tries to use stack + This is to place return value of _dtoa in: tries to use stack as well, but passes by free lists management and just aligns len by the pointer size in order to not break the alignment rules when storing a pointer to a Bigint. @@ -734,7 +734,7 @@ /* - dtoa_free() must be used to free values s returned by dtoa() + dtoa_free() must be used to free values s returned by _dtoa() This is the counterpart of dtoa_alloc() */ @@ -2103,7 +2103,7 @@ /* - dtoa for IEEE arithmetic (dmg): convert double to ASCII string. + _dtoa for IEEE arithmetic (dmg): convert double to ASCII string. Inspired by "How to Print Floating-Point Numbers Accurately" by Guy L. Steele, Jr. and Jon L. White [Proc. ACM SIGPLAN '90, pp. 112-126]. @@ -2137,7 +2137,7 @@ calculation. */ -static char *dtoa(double dd, int mode, int ndigits, int *decpt, int *sign, +static char *_dtoa(double dd, int mode, int ndigits, int *decpt, int *sign, char **rve, char *buf, size_t buf_size) { /*