diff options
author | Jose Luis Duran <jlduran@gmail.com> | 2022-10-14 23:26:32 +0000 |
---|---|---|
committer | Konstantin Belousov <kib@FreeBSD.org> | 2022-11-01 00:44:41 +0000 |
commit | 8e5a2135210d2c53ef8bdcbb1b268d4bb5081f04 (patch) | |
tree | e26b6355a7e9c2b39ec4af11829cf92b90cd7e2c /lib/libc/stdlib/strfmon.c | |
parent | 56462db9422c785534a5bbcf8812ec9dc7160270 (diff) |
strfmon: Fix alignment when enclosed by parentheses
(cherry picked from commit 947efadc3d6e778a824618d82f53f061bec69b77)
Diffstat (limited to 'lib/libc/stdlib/strfmon.c')
-rw-r--r-- | lib/libc/stdlib/strfmon.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/libc/stdlib/strfmon.c b/lib/libc/stdlib/strfmon.c index d6619f4d7d54..a26521bb694d 100644 --- a/lib/libc/stdlib/strfmon.c +++ b/lib/libc/stdlib/strfmon.c @@ -373,8 +373,12 @@ vstrfmon_l(char * __restrict s, size_t maxsize, locale_t loc, PRINTS(signstr); } - if (sign_posn == 0 && (flags & IS_NEGATIVE)) - PRINT(')'); + if (sign_posn == 0) { + if (flags & IS_NEGATIVE) + PRINT(')'); + else if (left_prec >= 0) + PRINT(' '); + } if (dst - tmpptr < width) { if (flags & LEFT_JUSTIFY) { @@ -466,6 +470,10 @@ __calc_left_pad(int flags, char *cur_symb) } switch (sign_posn) { + case 0: + if (flags & IS_NEGATIVE) + left_chars++; + break; case 1: left_chars += strlen(signstr); break; |