From nobody Tue Oct 25 21:51:30 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4MxlyB2pP0z4g5jC; Tue, 25 Oct 2022 21:51:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4MxlyB2N7Wz3gYf; Tue, 25 Oct 2022 21:51:30 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1666734690; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=7t6AH8M+6jH+j9WswU8gGHcPoDzs220SX01DVfiviyA=; b=KX53Ahxgw4vgjROuOQe4eIQXuFpWchtDIKE5rJojJjsPJhfHh0hf9jIllqFjBSF0Rk4sIa 7HSjHa12OUbKGxZBG2RPnCr6RXzJ5aFoIaSitvkWMKJP+QXZdo/kQR+Gg3ZzbUtr+ETEFt iiB8eaPquedoff6HcKabWEy0p4b2FRVPu/8oIfdaGq63HOlUUFTYVKgIRGePafFItDh+Ok C3I3ZshtNh/xLQsL8NUM+MtmaSyU0JgJLUgqqcd5uVTHTiKDl7l+alv2sCh3jOixqY9+IX aH//M6MobECn+v3Us1DSCP8AUCV1Lj3YzglMoKoYOyKWzlhEz5hshtQTzA1GnA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4MxlyB160gztMb; Tue, 25 Oct 2022 21:51:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 29PLpU3R088515; Tue, 25 Oct 2022 21:51:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 29PLpUhW088514; Tue, 25 Oct 2022 21:51:30 GMT (envelope-from git) Date: Tue, 25 Oct 2022 21:51:30 GMT Message-Id: <202210252151.29PLpUhW088514@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 34f88528edba - main - strfmon: Fix formatting of a second fixed-width value List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 34f88528edba44b2703ba8c772bef077eca33dab Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1666734690; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=7t6AH8M+6jH+j9WswU8gGHcPoDzs220SX01DVfiviyA=; b=ZXperr/PiLyqHe2XqbRmbH6UbURTkjljmJKAoTI4g8m453653ge9bYq7LulFB62n0DA1Zv t5wRtTYVwEk3z6cseQjSZFfWzp1Dk8yUoSBgXy1BVlZa5N5zbAKKwgolHbrZybbPtHJAyK SsOmdBVonqPeO8vmfiUHUbEnM6rYjKqfhH5p2EclPW0PaM0fdkvZdZcCJzek8YPdghQ5ZL eUgd5HCLI3YMt/egYKgnxkLXMSgzk/lVrDPVaKLuAYCDTpMSj2QZBvIlVCT4MlGixR4lkN A011sXg68cTiSKTXTp70dZyZ/y5akH3zrMUflwGaf4lCAG8nThzUPUOosowm6Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1666734690; a=rsa-sha256; cv=none; b=Cj3Qq0s/1cISGDOcq+Pg9NEpL8GgJ3YpazHeql/C23ZIArNDAHZvEvou3n64iDfDVqkpem PIoF99tAmBCy6y4zKTEWW3dtWBW8xuuzzPUrl7VEbUA2DfG7aY73z5Wi4lIXHhe4h6CwjF rxvX1xTWrN6Mjqmw4m/0c2ohvh1hpmXjDZ6OtNCL7HwEzozROTJaby12gXAqgNfGDHN24D qcsfXu1g/3BXh64vGSQw8l3180sXjq8a63MfzxxWmcA4iQnSE79rM+O0+i8gufp/M0NvBQ jqf7q0eBCd62MaB2aVh7AccwCwb1FmTr2d+8uW+4T1HQwVv+JpIrQpB9OjIBqw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=34f88528edba44b2703ba8c772bef077eca33dab commit 34f88528edba44b2703ba8c772bef077eca33dab Author: Jose Luis Duran AuthorDate: 2022-10-21 19:34:09 +0000 Commit: Konstantin Belousov CommitDate: 2022-10-25 21:40:17 +0000 strfmon: Fix formatting of a second fixed-width value There is a bug when formatting two consecutive values using fixed-widths and the values need padding. This was because the value of pad_size was zeroed only every other time. Format Before After [%8n] [%8n] [ $123.45] [ $123.45] [ $123.45] [ $123.45] Reviewed by: kib PR: 267282 Github PR: #619 MFC after: 1 week --- 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 d453b7a3943b..c0579f31e821 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]" },