This adds specific width length modifiers in the form of wN and wfN (where N is 8, 16, 32, or 64) which allow printing intN_t and int_fastN_t without resorting to casts or PRI macros.
Details
Diff Detail
- Repository
- rG FreeBSD src repository
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
So this looks like it will work for well formed format strings. Unsure what is supposed to happen for poorly formatted ones, hence the question... I'll leave it up to you if you want to address it or not in this commit though. It could be a lot of rework.
lib/libc/stdio/vfwscanf.c | ||
---|---|---|
579 | General comment on all of these: I'm not sure what the spec is for this feature... But what would something like %w88d do with this code? Is the wXX supposed to be parsed as an int, or is it UB what happens when it's not one of the supported XX? |
lib/libc/stdio/vfwscanf.c | ||
---|---|---|
579 | We're required to support 8, 16, 32, and 64 because we provide int8_t, int16_t, int32_t, and int64_t. We're allowed, but not required, to also support other values of N. I choose not to, which technically means it's UB, but I've made sure we fail in a predictable manner. |
It'd be nice to include a brief reference to what N2680 is, in the commit message subject -- something like libc: Implement N2680, sized int format specifiers
in the commit message subject, i.e., the first line of the commit message. The commit message should also be wrapped to 72 columns.
I.e.,
libc: Implement N2680, sized int format specifiers This adds specific width length modifiers in the form of wN and wfN (where N is 8, 16, 32, or 64) which allow printing intN_t and int_fastN_t without resorting to casts or PRI macros.
instead of
libc: Implement N2680. This adds specific width length modifiers in the form of wN and wfN (where N is 8, 16, 32, or 64) which allow printing intN_t and int_fastN_t without resorting to casts or PRI macros.