Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 1 Nov 2022 00:46:35 GMT
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 81e14c8f16bb - stable/13 - strfmon: Fix formatting of a second fixed-width value
Message-ID:  <202211010046.2A10kZNV042113@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=81e14c8f16bb4545a5fc0549b05d9325010dbddd

commit 81e14c8f16bb4545a5fc0549b05d9325010dbddd
Author:     Jose Luis Duran <jlduran@gmail.com>
AuthorDate: 2022-10-21 19:34:09 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2022-11-01 00:44:41 +0000

    strfmon: Fix formatting of a second fixed-width value
    
    (cherry picked from commit 34f88528edba44b2703ba8c772bef077eca33dab)
---
 lib/libc/stdlib/strfmon.c            | 2 +-
 lib/libc/tests/stdlib/strfmon_test.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/libc/stdlib/strfmon.c b/lib/libc/stdlib/strfmon.c
index d3266fe52ed5..5436bd6ec78e 100644
--- a/lib/libc/stdlib/strfmon.c
+++ b/lib/libc/stdlib/strfmon.c
@@ -135,7 +135,6 @@ vstrfmon_l(char * __restrict s, size_t maxsize, locale_t loc,
 	fmt = format;
 	asciivalue = NULL;
 	currency_symbol = NULL;
-	pad_size = 0;
 
 	while (*fmt) {
 		/* pass nonformating characters AS IS */
@@ -155,6 +154,7 @@ vstrfmon_l(char * __restrict s, size_t maxsize, locale_t loc,
 		/* set up initial values */
 		flags = (NEED_GROUPING|LOCALE_POSN);
 		pad_char = ' ';		/* padding character is "space" */
+		pad_size = 0;		/* no padding initially */
 		left_prec = -1;		/* no left precision specified */
 		right_prec = -1;	/* no right precision specified */
 		width = -1;		/* no width specified */
diff --git a/lib/libc/tests/stdlib/strfmon_test.c b/lib/libc/tests/stdlib/strfmon_test.c
index 664d1811dc46..d8e4f478547a 100644
--- a/lib/libc/tests/stdlib/strfmon_test.c
+++ b/lib/libc/tests/stdlib/strfmon_test.c
@@ -74,7 +74,7 @@ ATF_TC_BODY(strfmon_examples, tc)
 		const char *expected;
 	} tests[] = {
 	    { "%n", "[$123.45] [-$123.45] [$3,456.78]" },
-	    { "%11n", "[    $123.45] [       -$123.45] [  $3,456.78]" }, /* XXX */
+	    { "%11n", "[    $123.45] [   -$123.45] [  $3,456.78]" },
 	    { "%#5n", "[ $   123.45] [-$   123.45] [ $ 3,456.78]" },
 	    { "%=*#5n", "[ $***123.45] [-$***123.45] [ $*3,456.78]" },
 	    { "%=0#5n", "[ $000123.45] [-$000123.45] [ $03,456.78]" },



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202211010046.2A10kZNV042113>