git: 56462db9422c - stable/13 - strfmon: Trim the SPACE from international currency symbol

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Tue, 01 Nov 2022 00:46:31 UTC
The branch stable/13 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=56462db9422c785534a5bbcf8812ec9dc7160270

commit 56462db9422c785534a5bbcf8812ec9dc7160270
Author:     Jose Luis Duran <jlduran@gmail.com>
AuthorDate: 2022-10-21 16:13:27 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2022-11-01 00:44:41 +0000

    strfmon: Trim the SPACE from international currency symbol
    
    (cherry picked from commit 6da51e19e347c13e133bcba68cc6100c16320a01)
---
 lib/libc/stdlib/strfmon.c            | 4 +++-
 lib/libc/tests/stdlib/strfmon_test.c | 4 ++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/lib/libc/stdlib/strfmon.c b/lib/libc/stdlib/strfmon.c
index 0f327585f5a2..d6619f4d7d54 100644
--- a/lib/libc/stdlib/strfmon.c
+++ b/lib/libc/stdlib/strfmon.c
@@ -240,8 +240,10 @@ vstrfmon_l(char * __restrict s, size_t maxsize, locale_t loc,
 		if (flags & USE_INTL_CURRENCY) {
 			currency_symbol = strdup(lc->int_curr_symbol);
 			if (currency_symbol != NULL &&
-			    strlen(currency_symbol) > 3)
+			    strlen(currency_symbol) > 3) {
 				space_char = currency_symbol[3];
+				currency_symbol[3] = '\0';
+			}
 		} else
 			currency_symbol = strdup(lc->currency_symbol);
 
diff --git a/lib/libc/tests/stdlib/strfmon_test.c b/lib/libc/tests/stdlib/strfmon_test.c
index dc328e974bb8..b5b22f9a483d 100644
--- a/lib/libc/tests/stdlib/strfmon_test.c
+++ b/lib/libc/tests/stdlib/strfmon_test.c
@@ -195,8 +195,8 @@ ATF_TC_BODY(strfmon_international_currency_code, tc)
 		const char *locale;
 		const char *expected;
 	} tests[] = {
-	    { "en_US.UTF-8", "[USD 123.45]" }, /* XXX */
-	    { "de_DE.UTF-8", "[123,45 EUR ]" }, /* XXX */
+	    { "en_US.UTF-8", "[USD123.45]" },
+	    { "de_DE.UTF-8", "[123,45 EUR]" },
 	    { "C", "[123.45]" },
 	};
 	size_t i;