[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
format is locale aware
From: |
Bruno Haible |
Subject: |
format is locale aware |
Date: |
Tue, 08 Jun 2021 04:15:36 +0200 |
User-agent: |
KMail/5.1.3 (Linux/4.4.0-210-generic; KDE/5.18.0; x86_64; ; ) |
Hi,
After building m4-1.4.19 on DragonFly BSD 6.0, with LC_ALL=fr_FR.UTF-8,
"make check" shows a test failure:
Checking ../../checks/180.format
@ ../doc/m4.texi:6066: Origin of test
../../checks/180.format: stdout mismatch
--- m4-tmp.452851/m4-xout 2021-06-08 03:26:41.805343000 +0200
+++ m4-tmp.452851/m4-out 2021-06-08 03:26:41.797573000 +0200
@@ -1,8 +1,8 @@
The string "The brown fox jumped over the lazy dog" uses 38 characters
1
-56790
+56789
5000
success
-success
-20
+0P+0
+10
@ ../doc/m4.texi:6066: Origin of test
../../checks/180.format: stderr mismatch
--- m4-tmp.452851/m4-xerr 2021-06-08 03:26:41.805343000 +0200
+++ m4-tmp.452851/m4-err 2021-06-08 03:26:41.797573000 +0200
@@ -0,0 +1,5 @@
+m4:stdin:4: non-numeric argument 56789.9876
+m4:stdin:9: non-numeric argument 1.999
+m4:stdin:10: non-numeric argument 1.999
+m4:stdin:11: non-numeric argument 1.999
+m4:stdin:12: non-numeric argument 0xa.P+1
And indeed, the src/m4 program behaves in a locale dependent manner:
$ src/m4
format(`%.0f', `9.9')
src/m4:stdin:1: non-numeric argument 9.9
9
format(`%.0f', `9,9')
10
format(`%.1f', `4')
4,0
I see the same behaviour also on a glibc system.
1) Is the number parsing and printing of numbers in 'format' supposed to
be locale dependent? If yes, it would be good to document it in
https://www.gnu.org/software/m4/manual/html_node/Format.html .
If no, the fix would be in main.c: Add a
setlocale (LC_NUMERIC, "C");
after setlocale (LC_ALL, "").
2) Why do I see the test 180 fail on DragonFly BSD but not on a glibc
system? In both cases, I have LC_ALL set to fr_FR.UTF-8, and this locale
exists (verified with 'locale -a').
Bruno
- format is locale aware,
Bruno Haible <=