From: Jens Gustedt <Jens.Gustedt@inria.fr>
To: musl@lists.openwall.com, jens.gustedt@posteo.eu
Subject: [musl] [C23 printf 3/3] C23: implement the wfN length modifiers for printf
Date: Tue, 30 May 2023 08:55:28 +0200 [thread overview]
Message-ID: <38fa333702f25af17ded23815881735cf540b7ce.1685429467.git.Jens.Gustedt@inria.fr> (raw)
In-Reply-To: <cover.1685429467.git.Jens.Gustedt@inria.fr>
Musl only has a difference between fixed-width and fastest-width
integer types for N == 16. And even here all architectures have made
the same choice, namely mapping to 32 bit types.
---
src/stdio/vfprintf.c | 3 +++
src/stdio/vfwprintf.c | 3 +++
2 files changed, 6 insertions(+)
diff --git a/src/stdio/vfprintf.c b/src/stdio/vfprintf.c
index 265fb7ad..a531a513 100644
--- a/src/stdio/vfprintf.c
+++ b/src/stdio/vfprintf.c
@@ -534,8 +534,11 @@ static int printf_core(FILE *f, const char *fmt, va_list *ap, union arg *nl_arg,
ps=st;
st=states[st]S(*s++);
if (st == WPRE) {
+ _Bool fast = (*s == 'f');
+ if (fast) ++s;
if (*s == '0') goto inval;
width = getint(&s);
+ if (fast && width == 16) width = 32;
}
} while (st-1<STOP);
if (!st) goto inval;
diff --git a/src/stdio/vfwprintf.c b/src/stdio/vfwprintf.c
index c3e81d2a..3689c2d5 100644
--- a/src/stdio/vfwprintf.c
+++ b/src/stdio/vfwprintf.c
@@ -249,8 +249,11 @@ static int wprintf_core(FILE *f, const wchar_t *fmt, va_list *ap, union arg *nl_
ps=st;
st=states[st]S(*s++);
if (st == WPRE) {
+ _Bool fast = (*s == L'f');
+ if (fast) ++s;
if (*s == L'0') goto inval;
width = getint(&s);
+ if (fast && width == 16) width = 32;
}
} while (st-1<STOP);
if (!st) goto inval;
--
2.34.1
next prev parent reply other threads:[~2023-05-30 6:59 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1685429467.git.Jens.Gustedt@inria.fr>
2023-05-30 6:55 ` [musl] [C23 printf 1/3] C23: implement the b and B printf specifiers Jens Gustedt
2023-05-30 6:55 ` [musl] [C23 printf 2/3] C23: implement the wN length specifiers for printf Jens Gustedt
2023-06-02 14:38 ` Rich Felker
2023-06-02 15:09 ` Jₑₙₛ Gustedt
2023-06-02 15:16 ` Rich Felker
2023-06-02 15:37 ` Jₑₙₛ Gustedt
2023-05-30 6:55 ` Jens Gustedt [this message]
2023-05-31 14:04 [musl] [C23 printf 0/3] to be replaced Jens Gustedt
2023-05-31 14:04 ` [musl] [C23 printf 3/3] C23: implement the wfN length modifiers for printf Jens Gustedt
-- strict thread matches above, loose matches on Subject: below --
2023-05-26 19:41 [musl] [C23 printf 0/3] Jens Gustedt
2023-05-26 19:41 ` [musl] [C23 printf 3/3] C23: implement the wfN length modifiers for printf Jens Gustedt
2023-05-26 20:33 ` Rich Felker
2023-05-26 21:00 ` Jₑₙₛ Gustedt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=38fa333702f25af17ded23815881735cf540b7ce.1685429467.git.Jens.Gustedt@inria.fr \
--to=jens.gustedt@inria.fr \
--cc=jens.gustedt@posteo.eu \
--cc=musl@lists.openwall.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).