Path: csiph.com!xmission!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail From: Dennis Clarke Newsgroups: gnu.bash.bug Subject: Re: built-in printf %f parameter format depend on LC_NUMERIC Date: Fri, 12 Jul 2019 15:36:07 -0400 Lines: 82 Approved: bug-bash@gnu.org Message-ID: References: <5d24be33.1c69fb81.59c43.fe4dSMTPIN_ADDED_BROKEN@mx.google.com> <6468b45e-5b4a-8edf-4ab8-0838843beaaf@noiraude.net> <7c757690-24bd-7b1a-cf8e-af63cbe05216@noiraude.net> <91ed1981-df04-aa06-b108-23c7f89de3b4@case.edu> <4dde13d8-dc42-52b5-bc15-e5390f6d7ec5@archlinux.org> <162f2f7d-8776-a2ec-5bed-3fc07ec7306d@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 1562960251 12411 209.51.188.17 (12 Jul 2019 19:37: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: <4dde13d8-dc42-52b5-bc15-e5390f6d7ec5@archlinux.org> Content-Language: en-US X-MIME-Autoconverted: from 8bit to quoted-printable by atl4mhfb04.myregisteredsite.com id x6CJbLt9022591 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.17.115.120 X-BeenThere: bug-bash@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Bug reports for the GNU Bourne Again SHell List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: <162f2f7d-8776-a2ec-5bed-3fc07ec7306d@blastwave.org> X-Mailman-Original-References: <5d24be33.1c69fb81.59c43.fe4dSMTPIN_ADDED_BROKEN@mx.google.com> <6468b45e-5b4a-8edf-4ab8-0838843beaaf@noiraude.net> <7c757690-24bd-7b1a-cf8e-af63cbe05216@noiraude.net> <91ed1981-df04-aa06-b108-23c7f89de3b4@case.edu> <4dde13d8-dc42-52b5-bc15-e5390f6d7ec5@archlinux.org> Xref: csiph.com gnu.bash.bug:15143 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=C3=A9a Gris wrote: >>> Le 09/07/2019 =C3=A0 22:02, Chet Ramey =C3=A9crivait=E2=80=AF: >>> >>>> 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 builti= n >> 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-conform= ant >> 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. >> >=20 > https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html#tag_= 20_09_16 >=20 > "The bc utility always uses the ( '.' ) character to represent > a radix point, regardless of any decimal-point character specified as Imagine that ... learn something new from something very old : corv $ locale -a | grep -i 'utf' | grep 'fr' fr.UTF-8 fr_BE.UTF-8 fr_BE.UTF-8@euro fr_CA.UTF-8 fr_CH.UTF-8 fr_FR.UTF-8 fr_FR.UTF-8@euro fr_LU.UTF-8 corv $ corv $ LC_ALL=3Dfr_FR.UTF-8 bc scale=3D8 a =3D 0,1 syntax error on line 2, teletype a =3D 0.1 b =3D 0.01 c =3D a + b c .11 corv $ corv $ LC_ALL=3Dfr_FR.UTF-8 /usr/xpg6/bin/bc -l a =3D 0,1 syntax error on line 1, teletype a =3D 0.1 b =3D 0.01 c =3D a + b c .11 c(c) .99395609795669685035 corv $ Well now. That is XPG6 compliant bc on Solaris 10 sparc. It could care less about locale it seems. Nifty. --=20 Dennis Clarke RISC-V/SPARC/PPC/ARM/CISC UNIX and Linux spoken GreyBeard and suspenders optional