diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2009-06-10 16:31:44 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2009-06-10 16:31:44 +0000 |
commit | 0e4fb9c6504970c490194ce589fae909c6c12109 (patch) | |
tree | 9769f447b9a65171c27f37eea0cb38d9a7b727ae /src/backend | |
parent | 1236e18563b7283936e22dd74abb6195e54b0ed9 (diff) | |
download | postgresql-0e4fb9c6504970c490194ce589fae909c6c12109.tar.gz postgresql-0e4fb9c6504970c490194ce589fae909c6c12109.zip |
Fix cash_in() to behave properly in locales where frac_digits is zero,
eg Japan. Report and fix by Itagaki Takahiro. Also fix CASHDEBUG printout
format for branches with 64-bit money type, and some minor comment cleanup.
Back-patch to 7.4, because it's broken all the way back.
Diffstat (limited to 'src/backend')
-rw-r--r-- | src/backend/utils/adt/cash.c | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/src/backend/utils/adt/cash.c b/src/backend/utils/adt/cash.c index 76962bdcf6d..ca0a0453683 100644 --- a/src/backend/utils/adt/cash.c +++ b/src/backend/utils/adt/cash.c @@ -9,7 +9,7 @@ * workings can be found in the book "Software Solutions in C" by * Dale Schumacher, Academic Press, ISBN: 0-12-632360-7. * - * $PostgreSQL: pgsql/src/backend/utils/adt/cash.c,v 1.68 2006/07/14 14:52:23 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/cash.c,v 1.68.2.1 2009/06/10 16:31:44 tgl Exp $ */ #include "postgres.h" @@ -152,28 +152,22 @@ cash_in(PG_FUNCTION_ARGS) for (;; s++) { - /* we look for digits as int4 as we have less */ + /* we look for digits as long as we have found less */ /* than the required number of decimal places */ - if (isdigit((unsigned char) *s) && dec < fpoint) + if (isdigit((unsigned char) *s) && (!seen_dot || dec < fpoint)) { - value = (value * 10) + *s - '0'; + value = (value * 10) + (*s - '0'); if (seen_dot) dec++; - - /* decimal point? then start counting fractions... */ } + /* decimal point? then start counting fractions... */ else if (*s == dsymbol && !seen_dot) { seen_dot = 1; - - /* "thousands" separator? then skip... */ - } - else if (*s == ssymbol) - { - } - else + /* ignore if "thousands" separator, else we're done */ + else if (*s != ssymbol) { /* round off */ if (isdigit((unsigned char) *s) && *s >= '5') |