Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2ef8c1a

Browse files
committed
Fix cash_in() to behave properly in locales where frac_digits is zero,
eg Japan. Report and fix by Itagaki Takahiro. Also fix CASHDEBUG printoutformat 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.
1 parent09cba66 commit2ef8c1a

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

‎src/backend/utils/adt/cash.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* this version handles 64 bit numbers and so can hold values up to
1414
* $92,233,720,368,547,758.07.
1515
*
16-
* $PostgreSQL: pgsql/src/backend/utils/adt/cash.c,v 1.80 2008/06/09 19:58:39 tgl Exp $
16+
* $PostgreSQL: pgsql/src/backend/utils/adt/cash.c,v 1.81 2009/06/10 16:31:32 tgl Exp $
1717
*/
1818

1919
#include"postgres.h"
@@ -191,23 +191,21 @@ cash_in(PG_FUNCTION_ARGS)
191191

192192
for (;;s++)
193193
{
194-
/* we look for digits asint8 as we have less */
194+
/* we look for digits aslong as we have found less */
195195
/* than the required number of decimal places */
196-
if (isdigit((unsignedchar)*s)&&dec<fpoint)
196+
if (isdigit((unsignedchar)*s)&&(!seen_dot||dec<fpoint))
197197
{
198-
value= (value*10)+*s-'0';
198+
value= (value*10)+(*s-'0');
199199

200200
if (seen_dot)
201201
dec++;
202-
203202
}
204203
/* decimal point? then start counting fractions... */
205204
elseif (*s==dsymbol&& !seen_dot)
206205
{
207206
seen_dot=1;
208-
209207
}
210-
/*not"thousands" separator? */
208+
/*ignore if"thousands" separator, else we're done */
211209
elseif (*s!=ssymbol)
212210
{
213211
/* round off */
@@ -236,7 +234,7 @@ cash_in(PG_FUNCTION_ARGS)
236234
result=value*sgn;
237235

238236
#ifdefCASHDEBUG
239-
printf("cashin- result is%d\n",result);
237+
printf("cashin- result is"INT64_FORMAT"\n",result);
240238
#endif
241239

242240
PG_RETURN_CASH(result);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp