From nobody Wed Dec 3 02:38:27 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 4dLhdv6FR1z6JflG for ; Wed, 03 Dec 2025 02:38:27 +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 4dLhdv2R1vz3sNC for ; Wed, 03 Dec 2025 02:38:27 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1764729507; 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=uUd3ABTFDoR5ec5eDsw4A+GFvinlaap+L2KdIbLjZ3o=; b=cxTpoR3AShr1LABTiwL1JYPnJz3155ga04C0GsxPh++UelLbb3HaUysByhfz5VQ7WI6Zv0 Be+hVWSAx5vUW390Rek2kczaWWJBTigun+gVQMiFOom5LTpmhkj84zak5yTKcCDFoB1dGF wTOR5a4zGa8zfgwLlhMeSv5l+aaopfxe/3lrS2Id82iQRhM2eq5vm03iE2AxEKNFQpM+Vr 2GJHMkGcMKtc7yBQJkPNkOz8SpcQxU61ziDDBC0FJg65ykAs6lMU0VNmYoPjmWWGFjSlu5 PBFGmxj4sJyGeYwnW66Zzx/OeM1sD9/OSGenox25DQmYmdSSJTA3b9rJU1+zCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1764729507; 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=uUd3ABTFDoR5ec5eDsw4A+GFvinlaap+L2KdIbLjZ3o=; b=x36Q/ZXW1f3Uvsv78wVntdDkYeO7cnsxpa3HfWXkbty4xS0A2XBnbyew8OVG+oQ19+H6TU en8pT6hYBqpbVFY6Yq2Mp8NtZAk0/O4OZGMEn8kEJkCmbm0PCYES3hfmfoKAslzYqlc8r+ ccDCx6UDW4l0//M8FL/aPRpV8jWIkO91/02VMmFIJ8w2cR1LFmed4gUWIgNUOMWw+Attm9 qoGhB+urLdi4/NVtwUdu351QFW8RxR62QM+spgeFtgyYeu3ebdpMiGtH0Gjs7E5n1Nij6B HbSAq9ELrFQMi2Z7NtxcDruzl9tfpsOevYzLRLw5Pa/W/I/pX28MLyM1TgDGFw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1764729507; a=rsa-sha256; cv=none; b=dhUSH55lgUEaQthRvUlH02Wgybh1wFpp1/M/jnE8YoG0B3gIHBU8ewM+m7atDQin4w7U2O OeFMqZYUZcd8kRjgbpu5xqMH8959FwmVuWavOISHJig57QxNBY1OjZbFcf03yH9Ie5+b6/ bHwdc/cKuNPmTJlpkbG9gh40vYK0dJkTigj69lriPdiJYu23qMXZe29kwFvxs+OELCng+Y Nk6ZzzZmEh/QvQxpW5qa2nRu0/RBy2LcF08mc8NZzTBLxloOomfmqahkgcI0+QY8XCQP+Z 6u95HlEwcyDtifecV7wk3f/ERFpUNDR09iz9ycId6088E2rieddx5q6YT6znfg== 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 4dLhdv20nnz399 for ; Wed, 03 Dec 2025 02:38:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 2f7b7 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 03 Dec 2025 02:38:27 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Jose Luis Duran Subject: git: 7745ece2819e - stable/14 - 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/14 X-Git-Reftype: branch X-Git-Commit: 7745ece2819e3613308974c5c547b7d1218b3856 Auto-Submitted: auto-generated Date: Wed, 03 Dec 2025 02:38:27 +0000 Message-Id: <692fa2a3.2f7b7.5cbb4679@gitrepo.freebsd.org> The branch stable/14 has been updated by jlduran: URL: https://cgit.FreeBSD.org/src/commit/?id=7745ece2819e3613308974c5c547b7d1218b3856 commit 7745ece2819e3613308974c5c547b7d1218b3856 Author: Jose Luis Duran AuthorDate: 2025-11-26 20:34:55 +0000 Commit: Jose Luis Duran CommitDate: 2025-12-03 02:34:09 +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 86f6256dba0b..3c97d61ba82c 100644 --- a/lib/libc/tests/stdlib/strfmon_test.c +++ b/lib/libc/tests/stdlib/strfmon_test.c @@ -1,31 +1,14 @@ -/*- - * 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 @@ -208,6 +191,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) { @@ -220,7 +253,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]" }, }; @@ -247,6 +280,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()); }