[prev in list] [next in list] [prev in thread] [next in thread]
List: musl
Subject: [musl] [PATCH 2/2] printf: translate RADIXCHAR for floating-point numbers
From: Pablo Correa Gómez <pabloyoyoista () postmarketos ! org>
Date: 2023-12-16 19:36:44
Message-ID: 20231216194325.23580-3-pabloyoyoista () postmarketos ! org
[Download RAW message or body]
From: Pablo Correa Gómez <ablocorrea@hotmail.com>
This honors POSIX.1-2017, and allows to get the RADIXCHAR when the
locale is correctly translated.
---
src/stdio/vfprintf.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/stdio/vfprintf.c b/src/stdio/vfprintf.c
index 497c5e19..33f98532 100644
--- a/src/stdio/vfprintf.c
+++ b/src/stdio/vfprintf.c
@@ -10,6 +10,7 @@
#include <inttypes.h>
#include <math.h>
#include <float.h>
+#include <langinfo.h>
/* Some useful macros */
@@ -389,7 +390,7 @@ static int fmt_fp(FILE *f, long double y, int w, int p, int fl, int t)
else if (s==buf+9) *--s='0';
out(f, s, buf+9-s);
}
- if (p || (fl&ALT_FORM)) out(f, ".", 1);
+ if (p || (fl&ALT_FORM)) out(f, nl_langinfo(RADIXCHAR), 1);
for (; d<z && p>0; d++, p-=9) {
char *s = fmt_u(*d, buf+9);
while (s>buf) *--s='0';
@@ -404,7 +405,7 @@ static int fmt_fp(FILE *f, long double y, int w, int p, int fl, int t)
if (d!=a) while (s>buf) *--s='0';
else {
out(f, s++, 1);
- if (p>0||(fl&ALT_FORM)) out(f, ".", 1);
+ if (p>0||(fl&ALT_FORM)) out(f, nl_langinfo(RADIXCHAR), 1);
}
out(f, s, MIN(buf+9-s, p));
p -= buf+9-s;
--
2.43.0
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic