diff options
| author | David Laight <david.laight.linux@gmail.com> | 2026-03-08 14:37:37 +0300 |
|---|---|---|
| committer | Thomas Weißschuh <linux@weissschuh.net> | 2026-03-20 19:55:52 +0300 |
| commit | a30d20588fb8507540d267505a8876bc37bb3ec7 (patch) | |
| tree | 550616867a7454d4aca1c39db41f2a268349ef54 /tools/include | |
| parent | 8df70ee45b1383114cdcaa9b2fe7449cdf5f46d5 (diff) | |
| download | linux-a30d20588fb8507540d267505a8876bc37bb3ec7.tar.xz | |
tools/nolibc/printf: Add support for conversion flags space and plus
Flags ' ' and '+' are sign characters for positive numbers.
Signed-off-by: David Laight <david.laight.linux@gmail.com>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://patch.msgid.link/20260308113742.12649-13-david.laight.linux@gmail.com
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Diffstat (limited to 'tools/include')
| -rw-r--r-- | tools/include/nolibc/stdio.h | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/tools/include/nolibc/stdio.h b/tools/include/nolibc/stdio.h index 3620aa643c81..65e113f135d4 100644 --- a/tools/include/nolibc/stdio.h +++ b/tools/include/nolibc/stdio.h @@ -296,7 +296,7 @@ int fseek(FILE *stream, long offset, int whence) * - %% generates a single % * - %m outputs strerror(errno). * - %X outputs a..f the same as %x. - * - The modifiers [#-+ 0] are currently ignored. + * - The modifiers [#-0] are currently ignored. * - No support for precision or variable widths. * - No support for floating point or wide characters. * - Invalid formats are copied to the output buffer. @@ -457,6 +457,10 @@ int __nolibc_printf(__nolibc_printf_cb cb, void *state, const char *fmt, va_list sign_prefix = '-'; v = -(signed_v + 1); v++; + } else if (_NOLIBC_PF_FLAGS_CONTAIN(flags, '+')) { + sign_prefix = '+'; + } else if (_NOLIBC_PF_FLAGS_CONTAIN(flags, ' ')) { + sign_prefix = ' '; } } |
