Fix psql's code for locale-aware formatting of numeric output.
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 25 Sep 2015 03:01:04 +0000 (23:01 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 25 Sep 2015 03:01:04 +0000 (23:01 -0400)
commit7e327ecd2b4e4ded1c4375a085bdf34e08885ee6
tree19339524b147fbf33369ee108de959a08f2e50ba
parentb7dcb2dd4a1d0b89488b1275ccc865c684cf11b5
Fix psql's code for locale-aware formatting of numeric output.

This code did the wrong thing entirely for numbers with an exponent
but no decimal point (e.g., '1e6'), as reported by Jeff Janes in
bug #13636.  More generally, it made lots of unverified assumptions
about what the input string could possibly look like.  Rearrange so
that it only fools with leading digits that it's directly verified
are there, and an immediately adjacent decimal point.  While at it,
get rid of some useless inefficiencies, like converting the grouping
count string to integer over and over (and over).

This has been broken for a long time, so back-patch to all supported
branches.
src/bin/psql/print.c