git: babe20c88c28 - stable/13 - strfmon: Fix an edge case when sep_by_space is 2
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 01 Nov 2022 00:46:33 UTC
The branch stable/13 has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=babe20c88c28ca87c0ab28cc15f1296973a86d1e
commit babe20c88c28ca87c0ab28cc15f1296973a86d1e
Author: Jose Luis Duran <jlduran@gmail.com>
AuthorDate: 2022-10-18 02:24:03 +0000
Commit: Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2022-11-01 00:44:41 +0000
strfmon: Fix an edge case when sep_by_space is 2
(cherry picked from commit 750fe3e6a4619e040c7b0951775698b61290102e)
---
lib/libc/stdlib/strfmon.c | 8 ++++++--
lib/libc/tests/stdlib/strfmon_test.c | 2 +-
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/lib/libc/stdlib/strfmon.c b/lib/libc/stdlib/strfmon.c
index a26521bb694d..d3266fe52ed5 100644
--- a/lib/libc/stdlib/strfmon.c
+++ b/lib/libc/stdlib/strfmon.c
@@ -296,7 +296,8 @@ vstrfmon_l(char * __restrict s, size_t maxsize, locale_t loc,
* non-negative value
* = 1 - space separates the symbol from the value
* = 2 - space separates the symbol and the sign string,
- * if adjacent.
+ * if adjacent; otherwise, a space separates
+ * the sign string from the value
*
* p_sign_posn & n_sign_posn
*
@@ -338,8 +339,11 @@ vstrfmon_l(char * __restrict s, size_t maxsize, locale_t loc,
} else if (sep_by_space == 1)
PRINT(space_char);
}
- } else if (sign_posn == 1)
+ } else if (sign_posn == 1) {
PRINTS(signstr);
+ if (sep_by_space == 2)
+ PRINT(' ');
+ }
PRINTS(asciivalue);
diff --git a/lib/libc/tests/stdlib/strfmon_test.c b/lib/libc/tests/stdlib/strfmon_test.c
index d4d1f6a580d9..664d1811dc46 100644
--- a/lib/libc/tests/stdlib/strfmon_test.c
+++ b/lib/libc/tests/stdlib/strfmon_test.c
@@ -116,7 +116,7 @@ ATF_TC_BODY(strfmon_cs_precedes_0, tc)
/* sep_by_space x sign_posn */
{ "[(123.00$)] [-123.00$] [123.00$-] [123.00-$] [123.00$-]" },
{ "[(123.00 $)] [-123.00 $] [123.00 $-] [123.00 -$] [123.00 $-]" },
- { "[(123.00$)] [-123.00$] [123.00$ -] [123.00- $] [123.00$ -]" }, /* XXX */
+ { "[(123.00$)] [- 123.00$] [123.00$ -] [123.00- $] [123.00$ -]" },
};
size_t i, j;
struct lconv *lc;