Commit graph

9 commits

Author SHA1 Message Date
Dag-Erling Smørgrav c917023380 lib/printf: 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.

Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D41725

FRR changes only include printf(), scanf/strtol are not locally
implemented in FRR.  Also added "(void) 0" to empty "else ..." to
avoid a compiler warning.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
(cherry picked from FreeBSD commit bce0bef3c6abab92c7ac8cc23b7cc632a382721e)
2024-03-10 15:29:17 +01:00
Warner Losh 53df20fa68 lib/printf: Remove $FreeBSD$: two-line .h pattern
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
(cherry picked from FreeBSD commit b3e7694832e81d7a904a10f525f8797b753bf0d3)
2023-09-03 23:32:52 +02:00
David Lamparter 3ea7943059 lib: put printfrr extension args into struct
... for easier extensibility.  Add width, # and - flags while at it.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-30 22:32:55 +02:00
David Lamparter 212e04e5a7 lib: rework printfrr extensions to output directly
Allowing printfrr extensions to directly write to the output buffer has
a few advantages:
- there is no arbitrary length limit imposed (previously 64)
- the output doesn't need to be copied another time
- the extension can directly use bprintfrr() to put together pieces

The downside is that the theoretical length (regardless of available
buffer space) must be computed correctly.

Extended unit tests to test these paths a bit more thoroughly.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-27 16:56:55 +01:00
David Lamparter bf4d3d8021 lib/printf: add extension support
Inspired by the Linux kernel, this allows us to do %pI4 and similar
things.

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-03 16:45:01 +02:00
David Lamparter 5c25bd87b5 lib/printf: integrate
Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-03 16:44:51 +02:00
David Lamparter 8be3678a23 lib/printf: rename & private __find_arguments
These are internal to printf(), and symbols starting with __ are
reserved for the compiler/libc.

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-03 16:44:32 +02:00
David Lamparter e8c672ea81 lib/printf: disable wchar_t support
... we just don't use wchar_t in FRR, no point in having this enabled.

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-03 16:44:29 +02:00
David Lamparter ea0b6afe2b lib: import FreeBSD's printf
... from current SVN HEAD (not that it has been touched in the past 2
years ...)

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-03 16:43:11 +02:00