Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #15144

Re: built-in printf %f parameter format depend on LC_NUMERIC

Path csiph.com!xmission!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail
From Dennis Clarke <dclarke@blastwave.org>
Newsgroups gnu.bash.bug
Subject Re: built-in printf %f parameter format depend on LC_NUMERIC
Date Fri, 12 Jul 2019 15:46:56 -0400
Lines 125
Approved bug-bash@gnu.org
Message-ID <mailman.1052.1562960851.2688.bug-bash@gnu.org> (permalink)
References <5d24be33.1c69fb81.59c43.fe4dSMTPIN_ADDED_BROKEN@mx.google.com> <a212b38c-914d-dda6-8d22-e9039063768e@case.edu> <6468b45e-5b4a-8edf-4ab8-0838843beaaf@noiraude.net> <b6f65b6b-1487-0c46-6530-fa6d700ff1ca@case.edu> <7c757690-24bd-7b1a-cf8e-af63cbe05216@noiraude.net> <91ed1981-df04-aa06-b108-23c7f89de3b4@case.edu> <4dde13d8-dc42-52b5-bc15-e5390f6d7ec5@archlinux.org> <a048b783-79c0-24fe-d456-deea9a50a149@case.edu> <51bed6f0-eeb8-c93b-33e7-6ccaf4d73b3f@blastwave.org>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding quoted-printable
X-Trace usenet.stanford.edu 1562960851 12580 209.51.188.17 (12 Jul 2019 19:47:31 GMT)
X-Complaints-To action@cs.stanford.edu
To bug-bash@gnu.org
Envelope-to bug-bash@gnu.org
X-TCPREMOTEIP 99.253.177.25
X-Authenticated-UID dclarke@blastwave.org
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.0
In-Reply-To <a048b783-79c0-24fe-d456-deea9a50a149@case.edu>
Content-Language en-US
X-MIME-Autoconverted from 8bit to quoted-printable by atl4mhob09.registeredsite.com id x6CJkuAl031318
X-detected-operating-system by eggs.gnu.org: GNU/Linux 3.x
X-Received-From 209.17.115.47
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.23
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <https://lists.gnu.org/archive/html/bug-bash>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
X-Mailman-Original-Message-ID <51bed6f0-eeb8-c93b-33e7-6ccaf4d73b3f@blastwave.org>
X-Mailman-Original-References <5d24be33.1c69fb81.59c43.fe4dSMTPIN_ADDED_BROKEN@mx.google.com> <a212b38c-914d-dda6-8d22-e9039063768e@case.edu> <6468b45e-5b4a-8edf-4ab8-0838843beaaf@noiraude.net> <b6f65b6b-1487-0c46-6530-fa6d700ff1ca@case.edu> <7c757690-24bd-7b1a-cf8e-af63cbe05216@noiraude.net> <91ed1981-df04-aa06-b108-23c7f89de3b4@case.edu> <4dde13d8-dc42-52b5-bc15-e5390f6d7ec5@archlinux.org> <a048b783-79c0-24fe-d456-deea9a50a149@case.edu>
Xref csiph.com gnu.bash.bug:15144

Show key headers only | View raw


On 7/12/19 3:25 PM, Chet Ramey wrote:
> On 7/12/19 3:22 PM, Eli Schwartz wrote:
>> On 7/12/19 3:16 PM, Chet Ramey wrote:
>>> On 7/12/19 12:46 PM, Léa Gris wrote:
>>>> Le 09/07/2019 à 22:02, Chet Ramey écrivait :
>>>>
>>>>> These are up to the system's strtol/strtod. I don't know of too many
>>>>> strtol implementations that use the thousands separator and numeric
>>>>> grouping.
>>>>
>>>> Chet and you other Bash maintainers or contributors dudes:
>>>>
>>>> I can foresee the implications and blockages even lightly considering the
>>>> possibility to align the Bash's built-in printf behavior with the %f
>>>> argument with the sibling GNU Coreutils printf implementation.
>>>
>>> I don't think I explained this very well. For input, the printf builtin
>>> relies on strtod(3) to parse the string into a floating point number. For
>>> output, it relies on printf(3) to display a floating point number as a
>>> string. I'm not really interested in re-implementing either one if the
>>> system libc provides one that's perfectly acceptable. On POSIX-conformant
>>> systems, those library functions generally honor the locale's decimal_point
>>> character as the radix character.
>>>
>>> The `bc' you're using isn't POSIX conformant.
>>>
>>
>> https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html#tag_20_09_16
>>
>> "The bc utility always uses the <period> ( '.' ) character to represent
>> a radix point, regardless of any decimal-point character specified as
>> part of the current locale.
> 
> Good catch. I went by the bc man page that Dennis Williamson posted.
> 

Well the man page for XPG6 bc in Solaris 10 claims :

ENVIRONMENT VARIABLES
      See environ(5) for descriptions of the following environment
      variables  that  affect  the  execution of bc: LANG, LC_ALL,
      LC_CTYPE, LC_MESSAGES, and NLSPATH.


Really?

Looking through "Standards, Environments, and Macros" environ(5) seems
to be bluntly saying :


          Most commands will invoke setlocale(LC_ALL, "") prior to
          any other processing. This allows the command to be used
          with  different  national  conventions  by  setting  the
          appropriate environment variables.

uh huh ...

          LC_NUMERIC

              This category specifies the  decimal  and  thousands
              delimiters.  The  information  corresponding to this
              category is stored in a  database   created  by  the
              localedef()    command.   The   default   C   locale
              corresponds to "." as the decimal delimiter  and  no
              thousands  delimiter.  This  environment variable is
              used by localeconv(3C), printf(3C), and strtod(3C).

yep.

corv $
corv $ LC_ALL=fr_FR.UTF-8 LC_NUMERIC=fr_FR.UTF-8 /usr/xpg6/bin/bc -l
a = 0,1
syntax error on line 1, teletype
a = 0.1
b = 0.11
c = a + b
c
.21

c(c)
.97803091472414824491

corv $

baloney.   :-)

I am going to look at the sources for bc just for the fun of it.


-- 
Dennis Clarke
RISC-V/SPARC/PPC/ARM/CISC
UNIX and Linux spoken
GreyBeard and suspenders optional




















Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

Re: built-in printf %f parameter format depend on LC_NUMERIC Dennis Clarke <dclarke@blastwave.org> - 2019-07-12 15:46 -0400

csiph-web