From nobody Tue Nov 01 00:46:33 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 4N1WYQ1gHfz4gy1F; Tue, 1 Nov 2022 00:46:34 +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 4N1WYQ12vFz3R8b; Tue, 1 Nov 2022 00:46:34 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1667263594; 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=gRkVNhnpUDWLC7F1F9B+osATqy+RTpy85flALT+KQG4=; b=RsiVPd/fxTIASChuX+0wpk+VtdvJR6GSzAKG7dhPVqHirg9jEqq+0xKFAP5GZVESKF+UrN dq7Dmkst/0ctiZcurX4jfPaCP/nCiNDzXyBlpD2eYxWQhnJzwiyiDhI1er+XmHOAniVoEo CmTvcCGsZ68E+5lzgHAmBPp/1UaPSvp8KXl0L4D5HGfQVhIPDET+dLsRWsIhHDHOMEAVQi M5yecMGJXZFo2Ml412gfmqcvSnfpjjF8YvObyjiDea/oUT/XmW5rPICZ3XEwdiP61puQPS f2cYb6b7Kmok43kxkmQ1Et0ntoCpPCHEC6fG8vr8E1S0Vmlud7rIo/AZjCJmJA== 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 4N1WYQ08Rxzwmd; Tue, 1 Nov 2022 00:46:34 +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 2A10kXTW042090; Tue, 1 Nov 2022 00:46:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2A10kXed042089; Tue, 1 Nov 2022 00:46:33 GMT (envelope-from git) Date: Tue, 1 Nov 2022 00:46:33 GMT Message-Id: <202211010046.2A10kXed042089@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: babe20c88c28 - stable/13 - strfmon: Fix an edge case when sep_by_space is 2 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/stable/13 X-Git-Reftype: branch X-Git-Commit: babe20c88c28ca87c0ab28cc15f1296973a86d1e Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1667263594; 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=gRkVNhnpUDWLC7F1F9B+osATqy+RTpy85flALT+KQG4=; b=DLxL3TACzPDLbR5X4S5O0UkbzjwZ1j4assQPQq9YRbOD6dQ3ePqBrPABGtzJb+qvgGgzKd UugSi9AICwOUUorDF6cJJRoLl16ME1VWeGd1UsMP/ADUHy7rcKfS3WnnmFxjOcbk2kgy76 252X0jqL2XPfNKoMS9925yKULRs9q8bLOBnDCqOMIhB+sWMYCloH3mITz41Anbay0tEpas JO8W/B8KsVH73vV5TqkMRfW8YJP9sonQTh4sbSEYauo4Hv6gmALQTS0SdDCtOI86KxhKiS 4RXfUsfUTp066UH/DoDL2jdc3d4hoPtuoXiHBm+KElQeg8uT2DNYKQaXdWMdAA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1667263594; a=rsa-sha256; cv=none; b=L8rFmeaYJ6QF67ND1/y5uiNgDIMjyQ48d6+u7ThRn0FYU96CmpfLuMDY8Hh8C/sQfTuI/H Jy+rT6isvZs6GoHcTOvNotux/KK4EL8eCt/fXaHXxUrGrQADlJwZgKJdeEXS1fJojys5lU YSMLePIZpJvgiKVM0pRZR//F7+XE3TLRaLaeINvsC6tI5geKqoOpKCTyid43tREE+QwueH BlhEO9iMB/YV3mCE5oxisr+3SHq1/bddb09BqEDsho6Xs5N4FNWU2y92O2guOKmbkYGk/3 SlkUi/tpkwwmBccOin/RziDzBm/5fiDTNtnn+RfFD5ED/MrDM6uODoXnmRAtxg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=babe20c88c28ca87c0ab28cc15f1296973a86d1e commit babe20c88c28ca87c0ab28cc15f1296973a86d1e Author: Jose Luis Duran AuthorDate: 2022-10-18 02:24:03 +0000 Commit: Konstantin Belousov 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;