Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 335d9af

Browse files
committed
Fix white space in MONEY type code. Rename 'comma' to more generic
'ssymbol' as used in previous function.
1 parent ba2b2a2 commit 335d9af

File tree

1 file changed

+10
-16
lines changed

1 file changed

+10
-16
lines changed

src/backend/utils/adt/cash.c

Lines changed: 10 additions & 16 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.74 2007/11/15 21:14:38 momjian Exp $
16+
* $PostgreSQL: pgsql/src/backend/utils/adt/cash.c,v 1.75 2007/11/23 19:54:39 momjian Exp $
1717
*/
1818

1919
#include "postgres.h"
@@ -83,7 +83,6 @@ num_word(Cash value)
8383
else
8484
sprintf(buf, "%s hundred %s %s",
8585
small[value / 100], big[tu / 10], small[tu % 10]);
86-
8786
}
8887
else
8988
{
@@ -185,7 +184,6 @@ cash_in(PG_FUNCTION_ARGS)
185184
{
186185
sgn = -1;
187186
s++;
188-
189187
}
190188
else if (*s == psymbol)
191189
s++;
@@ -221,12 +219,8 @@ cash_in(PG_FUNCTION_ARGS)
221219
seen_dot = 1;
222220

223221
}
224-
/* "thousands" separator? then skip... */
225-
else if (*s == ssymbol)
226-
{
227-
228-
}
229-
else
222+
/* not "thousands" separator? */
223+
else if (*s != ssymbol)
230224
{
231225
/* round off */
232226
if (isdigit((unsigned char) *s) && *s >= '5')
@@ -275,10 +269,10 @@ cash_out(PG_FUNCTION_ARGS)
275269
int minus = 0;
276270
int count = LAST_DIGIT;
277271
int point_pos;
278-
int comma_position = 0;
272+
int ssymbol_position = 0;
279273
int points,
280274
mon_group;
281-
char comma;
275+
char ssymbol;
282276
const char *csymbol,
283277
*nsymbol;
284278
char dsymbol;
@@ -299,7 +293,7 @@ cash_out(PG_FUNCTION_ARGS)
299293
if (mon_group <= 0 || mon_group > 6)
300294
mon_group = 3;
301295

302-
comma = ((*lconvert->mon_thousands_sep != '\0') ? *lconvert->mon_thousands_sep : ',');
296+
ssymbol = ((*lconvert->mon_thousands_sep != '\0') ? *lconvert->mon_thousands_sep : ',');
303297
convention = lconvert->n_sign_posn;
304298
dsymbol = ((*lconvert->mon_decimal_point != '\0') ? *lconvert->mon_decimal_point : '.');
305299
csymbol = ((*lconvert->currency_symbol != '\0') ? lconvert->currency_symbol : "$");
@@ -308,10 +302,10 @@ cash_out(PG_FUNCTION_ARGS)
308302
point_pos = LAST_DIGIT - points;
309303

310304
/* allow more than three decimal points and separate them */
311-
if (comma)
305+
if (ssymbol)
312306
{
313307
point_pos -= (points - 1) / mon_group;
314-
comma_position = point_pos % (mon_group + 1);
308+
ssymbol_position = point_pos % (mon_group + 1);
315309
}
316310

317311
/* we work with positive amounts and add the minus sign at the end */
@@ -329,8 +323,8 @@ cash_out(PG_FUNCTION_ARGS)
329323
{
330324
if (points && count == point_pos)
331325
buf[count--] = dsymbol;
332-
else if (comma && count % (mon_group + 1) == comma_position)
333-
buf[count--] = comma;
326+
else if (ssymbol && count % (mon_group + 1) == ssymbol_position)
327+
buf[count--] = ssymbol;
334328

335329
buf[count--] = ((uint64) value % 10) + '0';
336330
value = ((uint64) value) / 10;

0 commit comments

Comments
 (0)