From nobody Tue Jan 31 00:39:09 2023 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 4P5R4t20j4z3bt4q; Tue, 31 Jan 2023 00:39:10 +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 4P5R4t1HNRz4WGy; Tue, 31 Jan 2023 00:39:10 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675125550; 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=NoGVGNaBW3mn1XbiaCRBLIkGwyp4sJ3u7ZrjDUizHnQ=; b=Z/BWVeriMrXk8X6BTgAMzsFoPr1E6tbG8vt3u38Ioi1TLOXXcv3tEgVsBh6bCJdL1c8zYg wU+TgiFZHsKjumU6m1c3AZEP+290L0zyqnXV4s/72zpELdXzGfaI4el7L923oGhoFTmqy7 n96QNmQcCnA+ebL3AoZLJF6v8Mmz0xhC6Jx8udpt7Dcj6eu2A83elNeUHcn+o1n7UclFAP 1JEfatEbyvLnpPj5lUN9Jb68Wql4ay0kIUIBtlkaG2vsCmzFGDEYwpRqfC16YB6Pasokh8 uQrx3MxSsAHWs3lAAHbm9SsDo1Klk6a6HH7Uf0FcSh4fHOgpJHzydyMeQu7oFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675125550; 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=NoGVGNaBW3mn1XbiaCRBLIkGwyp4sJ3u7ZrjDUizHnQ=; b=ApXEiDBkAHKAEhd5gatliJgRqPUJTyRdeLj3aCIrUrvK5DE1sJ3Yo81/BdDt7wqPYNAUs2 6mN5ZLZ6Cp+x4nP8iTcUYaZLeCTidL0KydoctwxULl3IOhrY5qwmlagfg6fY693wk0dKw8 3vY0rs+H22Pm5HAtvPKgtodkOflO7Ln0bhF/JiGhC0SlDlviR2Tt+7T02lncuEEJ6D1CiS byuettlUm2IdE2n28xbgQZdd4a/8kaRFdysv4VXmYIxobq6UPhGdhLIVFhh6hAFbQpbZuJ 01THsStKM7TxsR3fRLQj0cIlCAnzSoHQEXJmBL9/iMqiRfLHEueRuhxsUACcNA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1675125550; a=rsa-sha256; cv=none; b=kY07l1NcmW67uN2Z6mRvfHF9bC+sqNRQILlIpZTwC218CTAA68SQI3XXL29Q1KGVXP3OP4 s/ig0A2zO0SersikEytFH0o7z7eJ1Hq4JMNOsmQg4YcPCoiFthUVwjKRaXWOkKi+uwXtFD 76shX4NKgAx1J53y3ayPHPBqCwvwCuigJvSKlXk1U1cI0G9PJ8tHGwek0lGJieB7892c2B FKKX72zgrjmGnBqAX+K2z/452vLxFSD44L7/xEtHbXHWf6P2hUavZbSJqEbkualKF5AXmc R836fY8SSVg3U9R39Z0RJelLv4VErz6Jd9rPIETYTNdPkStBwMrleamKmII1fA== 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 4P5R4t0NjDzTy4; Tue, 31 Jan 2023 00:39:10 +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 30V0d96S059574; Tue, 31 Jan 2023 00:39:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30V0d9Qs059573; Tue, 31 Jan 2023 00:39:09 GMT (envelope-from git) Date: Tue, 31 Jan 2023 00:39:09 GMT Message-Id: <202301310039.30V0d9Qs059573@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: 9149830359bf - stable/13 - strfmon(3): Add an EXAMPLES section 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: 9149830359bfc816e916d24fab4acd5c0e70e13d Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=9149830359bfc816e916d24fab4acd5c0e70e13d commit 9149830359bfc816e916d24fab4acd5c0e70e13d Author: Jose Luis Duran AuthorDate: 2022-11-08 20:36:57 +0000 Commit: Konstantin Belousov CommitDate: 2023-01-31 00:38:19 +0000 strfmon(3): Add an EXAMPLES section (cherry picked from commit cdd9d92dade61a6b5c37b758e9533a076bb5a2de) --- lib/libc/stdlib/strfmon.3 | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/lib/libc/stdlib/strfmon.3 b/lib/libc/stdlib/strfmon.3 index 924c82109a68..1ddfb77cb0ac 100644 --- a/lib/libc/stdlib/strfmon.3 +++ b/lib/libc/stdlib/strfmon.3 @@ -149,6 +149,31 @@ The .Fn strfmon_l function returns the same values as .Fn strfmon . +.Sh EXAMPLES +The following example will format the value +.Dq Li 1234567.89 +to the string +.Dq Li $1,234,567.89 : +.Bd -literal -offset indent +#include +#include +#include + +int +main() +{ + char string[100]; + double money = 1234567.89; + + if (setlocale(LC_MONETARY, "en_US.UTF-8") == NULL) { + fprintf(stderr, "Unable to setlocale().\\n"); + return (1); + } + + strfmon(string, sizeof(string) - 1, "%n", money); + printf("%s\\n", string); +} +.Ed .Sh ERRORS The .Fn strfmon