aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/libc/stdlib/strfmon.c12
-rw-r--r--lib/libc/tests/stdlib/strfmon_test.c4
2 files changed, 12 insertions, 4 deletions
diff --git a/lib/libc/stdlib/strfmon.c b/lib/libc/stdlib/strfmon.c
index a7a48317c97c..80a73ee28916 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;
diff --git a/lib/libc/tests/stdlib/strfmon_test.c b/lib/libc/tests/stdlib/strfmon_test.c
index b5b22f9a483d..d4d1f6a580d9 100644
--- a/lib/libc/tests/stdlib/strfmon_test.c
+++ b/lib/libc/tests/stdlib/strfmon_test.c
@@ -81,8 +81,8 @@ ATF_TC_BODY(strfmon_examples, tc)
{ "%^#5n", "[ $ 123.45] [-$ 123.45] [ $ 3456.78]" },
{ "%^#5.0n", "[ $ 123] [-$ 123] [ $ 3457]" },
{ "%^#5.4n", "[ $ 123.4500] [-$ 123.4500] [ $ 3456.7810]" },
- { "%(#5n", "[$ 123.45] [($ 123.45)] [$ 3,456.78]" }, /* XXX */
- { "%!(#5n", "[ 123.45] [( 123.45)] [ 3,456.78]" }, /* XXX */
+ { "%(#5n", "[ $ 123.45 ] [($ 123.45)] [ $ 3,456.78 ]" },
+ { "%!(#5n", "[ 123.45 ] [( 123.45)] [ 3,456.78 ]" },
{ "%-14#5.4n", "[ $ 123.4500 ] [-$ 123.4500 ] [ $ 3,456.7810 ]" },
{ "%14#5.4n", "[ $ 123.4500] [ -$ 123.4500] [ $ 3,456.7810]" },
};