* this version handles 64 bit numbers and so can hold values up to
* $92,233,720,368,547,758.07.
*
- * $PostgreSQL: pgsql/src/backend/utils/adt/cash.c,v 1.74 2007/11/15 21:14:38 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/cash.c,v 1.75 2007/11/23 19:54:39 momjian Exp $
*/
#include "postgres.h"
else
sprintf(buf, "%s hundred %s %s",
small[value / 100], big[tu / 10], small[tu % 10]);
-
}
else
{
{
sgn = -1;
s++;
-
}
else if (*s == psymbol)
s++;
seen_dot = 1;
}
- /* "thousands" separator? then skip... */
- else if (*s == ssymbol)
- {
-
- }
- else
+ /* not "thousands" separator? */
+ else if (*s != ssymbol)
{
/* round off */
if (isdigit((unsigned char) *s) && *s >= '5')
int minus = 0;
int count = LAST_DIGIT;
int point_pos;
- int comma_position = 0;
+ int ssymbol_position = 0;
int points,
mon_group;
- char comma;
+ char ssymbol;
const char *csymbol,
*nsymbol;
char dsymbol;
if (mon_group <= 0 || mon_group > 6)
mon_group = 3;
- comma = ((*lconvert->mon_thousands_sep != '\0') ? *lconvert->mon_thousands_sep : ',');
+ ssymbol = ((*lconvert->mon_thousands_sep != '\0') ? *lconvert->mon_thousands_sep : ',');
convention = lconvert->n_sign_posn;
dsymbol = ((*lconvert->mon_decimal_point != '\0') ? *lconvert->mon_decimal_point : '.');
csymbol = ((*lconvert->currency_symbol != '\0') ? lconvert->currency_symbol : "$");
point_pos = LAST_DIGIT - points;
/* allow more than three decimal points and separate them */
- if (comma)
+ if (ssymbol)
{
point_pos -= (points - 1) / mon_group;
- comma_position = point_pos % (mon_group + 1);
+ ssymbol_position = point_pos % (mon_group + 1);
}
/* we work with positive amounts and add the minus sign at the end */
{
if (points && count == point_pos)
buf[count--] = dsymbol;
- else if (comma && count % (mon_group + 1) == comma_position)
- buf[count--] = comma;
+ else if (ssymbol && count % (mon_group + 1) == ssymbol_position)
+ buf[count--] = ssymbol;
buf[count--] = ((uint64) value % 10) + '0';
value = ((uint64) value) / 10;