From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HK_RANDOM_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 26551 invoked from network); 16 Dec 2023 19:44:01 -0000 Received: from second.openwall.net (193.110.157.125) by inbox.vuxu.org with ESMTPUTF8; 16 Dec 2023 19:44:01 -0000 Received: (qmail 7301 invoked by uid 550); 16 Dec 2023 19:43:17 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 7246 invoked from network); 16 Dec 2023 19:43:17 -0000 From: =?UTF-8?q?Pablo=20Correa=20G=C3=B3mez?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=postmarketos.org; s=donut; t=1702755816; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=54f3hHVZxt0fKruPH8HgRu2ii6VSWjJjDC4TXdmxTkk=; b=v/hKVNxDG7T44v/6VkcvXUPmxVsqK1j8fsEFVJ3SWphrmOmaU0Dp8RqWyQkz+vMGjl4xbA /djTBzXffBbat2QeYTmTukR4cLId1+3lIh27/k5wmguQuP7jSmH3nv04uKtuEcq1fmChio LS5Wt3TESq7JypEHXHGoz/wa20BKCR4= To: musl@lists.openwall.com Cc: =?UTF-8?q?Pablo=20Correa=20G=C3=B3mez?= Date: Sat, 16 Dec 2023 20:36:44 +0100 Message-ID: <20231216194325.23580-3-pabloyoyoista@postmarketos.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231216194325.23580-1-pabloyoyoista@postmarketos.org> References: <20231216194325.23580-1-pabloyoyoista@postmarketos.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [musl] [PATCH 2/2] printf: translate RADIXCHAR for floating-point numbers From: Pablo Correa Gómez 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 #include #include +#include /* 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 (; d0; 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