mailing list of musl libc
 help / color / mirror / code / Atom feed
* [PATCH] Allow %lf in wprintf
@ 2019-09-12  6:09 Brion Vibber
  2019-09-13 18:06 ` Rich Felker
  0 siblings, 1 reply; 2+ messages in thread
From: Brion Vibber @ 2019-09-12  6:09 UTC (permalink / raw)
  To: musl


[-- Attachment #1.1: Type: text/plain, Size: 541 bytes --]

On the emscripten mailing list we got a report that using %lf as a format
specifier for doubles worked in printf but not wprintf, which I was able to
confirm looking at the musl implementation we're using.

It looks like support for %lf in printf was added in 2012 in
commit cc3a44666, but didn't get copied to the wprintf implementation so
they're just out of sync. I've attached a small patch which copies the same
fix to the wprintf side.

Please let me know if there's any test cases I should add to, or anything
else. Thanks!

-- brion

[-- Attachment #1.2: Type: text/html, Size: 656 bytes --]

[-- Attachment #2: 0001-Fix-lf-in-wprintf.patch --]
[-- Type: application/octet-stream, Size: 974 bytes --]

From 169aeac343552c9a5f52df0f398c84370ce68c41 Mon Sep 17 00:00:00 2001
From: Brion Vibber <brion@pobox.com>
Date: Wed, 11 Sep 2019 22:43:34 -0700
Subject: [PATCH] Fix %lf in wprintf

This was fixed for printf in 2012 via cc3a44666; took
the same fix and applied it to wprintf here so they
match.

Previously, %lf caused a failure to output.
---
 src/stdio/vfwprintf.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/stdio/vfwprintf.c b/src/stdio/vfwprintf.c
index 0adf0b7a..85b036c3 100644
--- a/src/stdio/vfwprintf.c
+++ b/src/stdio/vfwprintf.c
@@ -53,6 +53,8 @@ static const unsigned char states[]['z'-'A'+1] = {
 	}, { /* 1: l-prefixed */
 		S('d') = LONG, S('i') = LONG,
 		S('o') = ULONG, S('u') = ULONG, S('x') = ULONG, S('X') = ULONG,
+		S('e') = DBL, S('f') = DBL, S('g') = DBL, S('a') = DBL,
+		S('E') = DBL, S('F') = DBL, S('G') = DBL, S('A') = DBL,
 		S('c') = INT, S('s') = PTR, S('n') = PTR,
 		S('l') = LLPRE,
 	}, { /* 2: ll-prefixed */
-- 
2.20.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Allow %lf in wprintf
  2019-09-12  6:09 [PATCH] Allow %lf in wprintf Brion Vibber
@ 2019-09-13 18:06 ` Rich Felker
  0 siblings, 0 replies; 2+ messages in thread
From: Rich Felker @ 2019-09-13 18:06 UTC (permalink / raw)
  To: musl

On Wed, Sep 11, 2019 at 11:09:03PM -0700, Brion Vibber wrote:
> On the emscripten mailing list we got a report that using %lf as a format
> specifier for doubles worked in printf but not wprintf, which I was able to
> confirm looking at the musl implementation we're using.
> 
> It looks like support for %lf in printf was added in 2012 in
> commit cc3a44666, but didn't get copied to the wprintf implementation so
> they're just out of sync. I've attached a small patch which copies the same
> fix to the wprintf side.

Thanks! Applying.

> Please let me know if there's any test cases I should add to, or anything
> else. Thanks!

Coverage for wide printf in libc-test is probably poor. Please feel
free (but not obligated) to submit either a regression test for this
specific bug or some general functionality tests covering this case
and others. You can submit libc-test patches on the musl list too.

Rich


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-09-13 18:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-12  6:09 [PATCH] Allow %lf in wprintf Brion Vibber
2019-09-13 18:06 ` Rich Felker

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).