diff options
| author | David Laight <david.laight.linux@gmail.com> | 2026-03-08 14:37:39 +0300 |
|---|---|---|
| committer | Thomas Weißschuh <linux@weissschuh.net> | 2026-03-20 19:57:21 +0300 |
| commit | b5f3f59cf4384a8c9e60fa4bb1a8f4ad71126a90 (patch) | |
| tree | da6de1da2149dec95ed6e5db75fb935d6e283bc5 /tools/include | |
| parent | 5eae5f1a01aff6f9773547265167d7a680c6fbc3 (diff) | |
| download | linux-b5f3f59cf4384a8c9e60fa4bb1a8f4ad71126a90.tar.xz | |
tools/nolibc/printf: Add support for left aligning fields
Output the characters before or after the pad - writing the pad takes more code.
Include additional/changed tests
Signed-off-by: David Laight <david.laight.linux@gmail.com>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://patch.msgid.link/20260308113742.12649-15-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 db714b1ce274..c8a463ed73c7 100644 --- a/tools/include/nolibc/stdio.h +++ b/tools/include/nolibc/stdio.h @@ -545,7 +545,11 @@ do_output: /* Stop gcc back-merging this code into one of the conditionals above. */ _NOLIBC_OPTIMIZER_HIDE_VAR(len); + /* Output the characters on the required side of any padding. */ width -= len; + flags = _NOLIBC_PF_FLAGS_CONTAIN(flags, '-'); + if (flags && cb(state, outstr, len) != 0) + return -1; while (width > 0) { /* Output pad in 16 byte blocks with the small block first. */ int pad_len = ((width - 1) & 15) + 1; @@ -554,7 +558,7 @@ do_output: if (cb(state, " ", pad_len) != 0) return -1; } - if (cb(state, outstr, len) != 0) + if (!flags && cb(state, outstr, len) != 0) return -1; } |
