Re: Fixes for MONEY type using locale

From: "D'Arcy J(dot)M(dot) Cain" <darcy(at)druid(dot)net>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Fixes for MONEY type using locale
Date: 2007-11-24 14:24:41
Message-ID: 20071124092441.e04d4003.darcy@druid.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

On Fri, 23 Nov 2007 15:59:29 -0500 (EST)
Bruce Momjian <bruce(at)momjian(dot)us> wrote:
> I also removed a ssymbol test because ssymbol will never be \0 based on
> the code. Also, what does this do:
>
> if (buf[LAST_DIGIT] == ',')
> buf[LAST_DIGIT] = buf[LAST_PAREN];

Good question. This has been in the code since day one. I had to go
back to the book it came from (Software Solutions in C - ISBN
0-12-632360-7) to see what I wrote back in 1994. Here is what the text
says about that.

"The next part may look a little strange, but the previous code is a
little simpler if we just put a comma at the end of the string when
there are no decimal points and strip it off here. Otherwise we would
have to adjust the comma_position variable and test in the main loop
for the special case."

The if block has a second statement though which is effectively this;

buf[LAST_PAREN] = ' ';

This is followed by;

"The Two assignments deal with the case where there is a trailing
parenthesis without having to do another test."

So that's what I know now. I'm not sure what the edge case is. For
one thing it would only be triggered in locales with no places after
the decimal point. I'll try to work up some test later.

--
D'Arcy J.M. Cain <darcy(at)druid(dot)net> | Democracy is three wolves
http://www.druid.net/darcy/ | and a sheep voting on
+1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2007-11-24 15:28:54 Re: Fixes for MONEY type using locale
Previous Message Guillaume Smet 2007-11-24 14:15:15 Re: 8.3devel slower than 8.2 under read-only load

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2007-11-24 15:28:54 Re: Fixes for MONEY type using locale
Previous Message Bruce Momjian 2007-11-24 01:33:34 Re: [BUGS] BUG #3769: Fail to make bcc32.mak for libpq