Fix white space in MONEY type code. Rename 'comma' to more generic
'ssymbol' as used in previous function.
This commit is contained in:
parent
ba2b2a2c4e
commit
335d9aff6f
@ -13,7 +13,7 @@
|
|||||||
* this version handles 64 bit numbers and so can hold values up to
|
* this version handles 64 bit numbers and so can hold values up to
|
||||||
* $92,233,720,368,547,758.07.
|
* $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"
|
#include "postgres.h"
|
||||||
@ -83,7 +83,6 @@ num_word(Cash value)
|
|||||||
else
|
else
|
||||||
sprintf(buf, "%s hundred %s %s",
|
sprintf(buf, "%s hundred %s %s",
|
||||||
small[value / 100], big[tu / 10], small[tu % 10]);
|
small[value / 100], big[tu / 10], small[tu % 10]);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -185,7 +184,6 @@ cash_in(PG_FUNCTION_ARGS)
|
|||||||
{
|
{
|
||||||
sgn = -1;
|
sgn = -1;
|
||||||
s++;
|
s++;
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (*s == psymbol)
|
else if (*s == psymbol)
|
||||||
s++;
|
s++;
|
||||||
@ -221,12 +219,8 @@ cash_in(PG_FUNCTION_ARGS)
|
|||||||
seen_dot = 1;
|
seen_dot = 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
/* "thousands" separator? then skip... */
|
/* not "thousands" separator? */
|
||||||
else if (*s == ssymbol)
|
else if (*s != ssymbol)
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
/* round off */
|
/* round off */
|
||||||
if (isdigit((unsigned char) *s) && *s >= '5')
|
if (isdigit((unsigned char) *s) && *s >= '5')
|
||||||
@ -275,10 +269,10 @@ cash_out(PG_FUNCTION_ARGS)
|
|||||||
int minus = 0;
|
int minus = 0;
|
||||||
int count = LAST_DIGIT;
|
int count = LAST_DIGIT;
|
||||||
int point_pos;
|
int point_pos;
|
||||||
int comma_position = 0;
|
int ssymbol_position = 0;
|
||||||
int points,
|
int points,
|
||||||
mon_group;
|
mon_group;
|
||||||
char comma;
|
char ssymbol;
|
||||||
const char *csymbol,
|
const char *csymbol,
|
||||||
*nsymbol;
|
*nsymbol;
|
||||||
char dsymbol;
|
char dsymbol;
|
||||||
@ -299,7 +293,7 @@ cash_out(PG_FUNCTION_ARGS)
|
|||||||
if (mon_group <= 0 || mon_group > 6)
|
if (mon_group <= 0 || mon_group > 6)
|
||||||
mon_group = 3;
|
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;
|
convention = lconvert->n_sign_posn;
|
||||||
dsymbol = ((*lconvert->mon_decimal_point != '\0') ? *lconvert->mon_decimal_point : '.');
|
dsymbol = ((*lconvert->mon_decimal_point != '\0') ? *lconvert->mon_decimal_point : '.');
|
||||||
csymbol = ((*lconvert->currency_symbol != '\0') ? lconvert->currency_symbol : "$");
|
csymbol = ((*lconvert->currency_symbol != '\0') ? lconvert->currency_symbol : "$");
|
||||||
@ -308,10 +302,10 @@ cash_out(PG_FUNCTION_ARGS)
|
|||||||
point_pos = LAST_DIGIT - points;
|
point_pos = LAST_DIGIT - points;
|
||||||
|
|
||||||
/* allow more than three decimal points and separate them */
|
/* allow more than three decimal points and separate them */
|
||||||
if (comma)
|
if (ssymbol)
|
||||||
{
|
{
|
||||||
point_pos -= (points - 1) / mon_group;
|
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 */
|
/* we work with positive amounts and add the minus sign at the end */
|
||||||
@ -329,8 +323,8 @@ cash_out(PG_FUNCTION_ARGS)
|
|||||||
{
|
{
|
||||||
if (points && count == point_pos)
|
if (points && count == point_pos)
|
||||||
buf[count--] = dsymbol;
|
buf[count--] = dsymbol;
|
||||||
else if (comma && count % (mon_group + 1) == comma_position)
|
else if (ssymbol && count % (mon_group + 1) == ssymbol_position)
|
||||||
buf[count--] = comma;
|
buf[count--] = ssymbol;
|
||||||
|
|
||||||
buf[count--] = ((uint64) value % 10) + '0';
|
buf[count--] = ((uint64) value % 10) + '0';
|
||||||
value = ((uint64) value) / 10;
|
value = ((uint64) value) / 10;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user