From nobody Wed Dec 3 02:38:51 2025 X-Original-To: dev-commits-src-branches@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 4dLhfM6c0kz6Jfnl for ; Wed, 03 Dec 2025 02:38:51 +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 "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4dLhfM5Nzgz3tJL for ; Wed, 03 Dec 2025 02:38:51 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1764729531; 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=bwvpmyA6Qs7MUHyVjKxu5Fw2T7Y+2OIn/sItq7+hQ+Y=; b=UoYVTl54hScZe1r6soWZ9JGgOB7TqKJMFSLa0eiI0e5Heayw/glukm2ciMTjwcfOTe1vIb qjH2hoL9iCNYHbTN+0GUlI0c6f2aEN5OV6fnJvC5JoM4S1sG9edi48NWBub/bW01yPJ9xN +9A9BQqmEcyMM0R1s3qUrELsWi7zMcYV4y6Vt0YZuN3WhqWTzaswgH1ILik+zDjA2ywOUE HzwbKSRNPSt2AYMYkFEkI3s7k+6JXilHtA8qnkBlmGZ21D5+1vn9WE99oS+IkENo5znz08 +HYISoxhNSjDsrMO6XNdC8ZNzQwwbywPMlpskXmh7CIueTV/2Vbr9+WfThD7Cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1764729531; 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=bwvpmyA6Qs7MUHyVjKxu5Fw2T7Y+2OIn/sItq7+hQ+Y=; b=Dg9Qbe3KMHvVwyCr58LQIxrdm4ga6Z8+pYcRf9Q79QNuljBM/hk57zI5JTuMq6oZFJEKwL FfobQ002A0Zn/kZqc6IYyMHDa59rygjKQJpFpYTSVre2ndzkyEMwEUuCgJHAmDZKB6tF6/ vTTntNoMCoMZOeEk1fak5HcetGriIRTjD882LqPZvoDMxZxzxn8Rmh8ixSpCd36LxE9N3d 7OMW8N6sENbyPJ7wfyLMzjAekIKH3C9ttJs1sk+2s2cFlulVp8XRO6NVUMpmFZ5KmrC+rf sRvi1jAfDk9zdfECzLVtzGJ/W1qKsstwD+XlBGgvveIN1HFxCfQkLAQnFSEq5A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1764729531; a=rsa-sha256; cv=none; b=oEUAeEoMH/QNegb730LnuyEXpZJnegl3ENkW8uiaeBdIs9QgtIDdTfvqp3HP2js/zHsAL5 c/yZ6UeCJvILAynEjDZvPeesnJS2eTt2o0ilX4d/WVsJuCuf/JOacTuy68/ASsZBgkSGum 2hgPnU0MTvWayRuCQpkAdKaTXsYLgMqj4LpYzKR0mWLjhpA5ldTx+y72H67klUjuyTkAzh fJ+d+MT+ajl4u9HF9UzxtoPawCihvbpt3hDYhichEYrcLm9Fq2pB1fK5iA3fBdWwTHpXcZ aKlzODVnFrusaOUzlmH8JGS/p1iWWqf7sG6a71nLo+h4PvtzvKqlISBcwXKYmw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4dLhfM4x4Pz39C for ; Wed, 03 Dec 2025 02:38:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 30892 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 03 Dec 2025 02:38:51 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Jose Luis Duran Subject: git: 33189f868ab9 - stable/13 - strfmon: Add tests for Austin Group Defect 1199 List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jlduran X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 33189f868ab9d2c672413916b6510c856db3dd4c Auto-Submitted: auto-generated Date: Wed, 03 Dec 2025 02:38:51 +0000 Message-Id: <692fa2bb.30892.22fe3109@gitrepo.freebsd.org> The branch stable/13 has been updated by jlduran: URL: https://cgit.FreeBSD.org/src/commit/?id=33189f868ab9d2c672413916b6510c856db3dd4c commit 33189f868ab9d2c672413916b6510c856db3dd4c Author: Jose Luis Duran AuthorDate: 2025-11-26 20:34:55 +0000 Commit: Jose Luis Duran CommitDate: 2025-12-03 02:35:23 +0000 strfmon: Add tests for Austin Group Defect 1199 Add tests for The Open Group Base Specifications Issue 8[1], Austin Group Defect 1199[2]. Items marked with XXX represent an invalid output. These items will be fixed in subsequent commits. Notice that an existing test is now considered invalid. Our locale definitions do not include int_p_sep_by_space nor int_n_sep_by_space[3]. Those will be addressed in a subsequent commit. However, the CLDR project defines them as "0", which causes the output to appear as "USD123.45". If our locale definitions were to set the international {n,p}_sep_by_space to "1", the output would display as the expected "USD 123.45". While here, use the SPDX license identifier and add my name to the file. [1]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/strfmon.html [2]: https://www.austingroupbugs.net/view.php?id=1199 [3]: https://unicode-org.atlassian.net/browse/CLDR-237 Reviewed by: kib MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D53911 (cherry picked from commit 19e153004fb63c32eba0ef40249f5ede61a93170) --- lib/libc/tests/stdlib/strfmon_test.c | 80 +++++++++++++++++++++++++----------- 1 file changed, 57 insertions(+), 23 deletions(-) diff --git a/lib/libc/tests/stdlib/strfmon_test.c b/lib/libc/tests/stdlib/strfmon_test.c index f092c071724a..0126c2f3f8a8 100644 --- a/lib/libc/tests/stdlib/strfmon_test.c +++ b/lib/libc/tests/stdlib/strfmon_test.c @@ -1,32 +1,15 @@ -/*- - * Copyright (C) 2018 Conrad Meyer +/* + * Copyright (c) 2018 Conrad Meyer * All rights reserved. + * Copyright (c) 2022-2025 Jose Luis Duran * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. + * SPDX-License-Identifier: BSD-2-Clause */ #include #include +#include #include #include #include @@ -209,6 +192,56 @@ ATF_TC_BODY(strfmon_international_currency_code, tc) } } +ATF_TC_WITHOUT_HEAD(strfmon_plus_or_parenthesis); +ATF_TC_BODY(strfmon_plus_or_parenthesis, tc) +{ + const struct { + const char *format; + const char *locale; + const char *expected; + } tests[] = { + { "%+n", "en_US.UTF-8", "[$123.45] [-$123.45]" }, + { "%+i", "en_US.UTF-8", "[USD123.45] [-USD123.45]" }, + { "%(n", "C", "[123.45] [(123.45)]" }, + { "%(i", "C", "[123.45] [(123.45)]" }, + { "%(n", "en_US.UTF-8", "[$123.45] [($123.45)]" }, + { "%(i", "en_US.UTF-8", "[USD123.45] [(USD123.45)]" }, + { "%n", "C", "[123.45] [(123.45)]" }, /* XXX */ + { "%i", "C", "[123.45] [(123.45)]" }, /* XXX */ + { "%n", "en_US.UTF-8", "[$123.45] [-$123.45]" }, + { "%i", "en_US.UTF-8", "[USD123.45] [-USD123.45]" }, + }; + size_t i; + char actual[100], format[50]; + + for (i = 0; i < nitems(tests); ++i) { + if (setlocale(LC_MONETARY, tests[i].locale) == NULL) + atf_tc_skip("unable to setlocale(): %s", + tests[i].locale); + + snprintf(format, sizeof(format), "[%s] [%s]", + tests[i].format, tests[i].format); + strfmon(actual, sizeof(actual) - 1, format, + 123.45, -123.45); + ATF_CHECK_STREQ_MSG(tests[i].expected, actual, + "[%s] %s", tests[i].format, tests[i].locale); + } + + /* + * The '+' flag was included in a conversion specification and + * the locale's positive_sign and negative_sign values would + * both be returned by localeconv() as empty strings. + */ + if (setlocale(LC_MONETARY, "C") == NULL) + atf_tc_skip("unable to setlocale(): %s", tests[i].locale); + + /* ATF_CHECK_ERRNO(EINVAL, strfmon(actual, sizeof(actual) - 1, + "[%+n] [%+n]", 123.45, -123.45)); XXX */ + + /* ATF_CHECK_ERRNO(EINVAL, strfmon(actual, sizeof(actual) - 1, + "[%+i] [%+i]", 123.45, -123.45)); XXX */ +} + ATF_TC(strfmon_l); ATF_TC_HEAD(strfmon_l, tc) { @@ -221,7 +254,7 @@ ATF_TC_BODY(strfmon_l, tc) const char *locale; const char *expected; } tests[] = { - { "C", "[ **1234.57 ] [ **1234.57 ]" }, + { "C", "[ **1234.57 ] [ **1234.57 ]" }, /* XXX */ { "de_DE.UTF-8", "[ **1234,57 €] [ **1.234,57 EUR]" }, { "en_GB.UTF-8", "[ £**1234.57] [ GBP**1,234.57]" }, }; @@ -248,6 +281,7 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, strfmon_cs_precedes_0); ATF_TP_ADD_TC(tp, strfmon_cs_precedes_1); ATF_TP_ADD_TC(tp, strfmon_international_currency_code); + ATF_TP_ADD_TC(tp, strfmon_plus_or_parenthesis); ATF_TP_ADD_TC(tp, strfmon_l); return (atf_no_error()); }