From nobody Wed Jan 25 09:03:24 2023 X-Original-To: dev-commits-src-main@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 4P1yYT0WkMz311QW; Wed, 25 Jan 2023 09:03:25 +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 4P1yYS72VSz3krq; Wed, 25 Jan 2023 09:03:24 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674637405; 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=XhRTFy7pHrhaSLOb1xtNOF2zOFImZeFFLBkPcdaZO0Y=; b=Jr6dqoUO3aAuRrMkvxhCQ8HoEDWHEiyqJC8yXqOPQ4A0rBF85jmQH42G6MbUg54EyNktIg myV4jrYeaBk7BK1G/RFXySu6o68nzdJ+Zlvf1nPS7tteo9zz2fz/mFijWfivraDJjjX+Pl 9Mj7wKcNDIKWJ7CXUjSEyVs3oG0jOxAP5+KFEmP+3LshkkP/pD/esQp77Jf8XQvqn5q/wm uG/jS8+JPwooeUVLO530dkmv62kGwcNbqe7rChwuyIIt20Fvm3dP4/LRz9pWBwWcbfwIyn IDJhwCbWfwJeAaI2eTx/V050rVD6wu04+bTfhlpJtAks/fpqKfyZOzdPlg/efA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674637405; 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=XhRTFy7pHrhaSLOb1xtNOF2zOFImZeFFLBkPcdaZO0Y=; b=OUeeeE3qXzn6Pl4pTshFwCDmLogt8QQzrqwhQp0B5LGIO93mpX542QmAJGJ0K/mV7zcMTO PuopWmErHQBR/ltH2jxbNmrK906U+NEzrF5uvXbV6pedWyTi42H3e0VtsX0zl+Iyw46ssc SujcaWvxMfxUnnmwmPhiTcWdIltQLDlYQVltjVsEAfPwpIjx6TCj90Uf4IuzOvAc8BqoRb mDXNpg/D7Hh4NAf0TOKc9C6VzAj8uFXzyHELPwvRvlOKnawTTvEOqQwUfvZl/8Ao7wE+FE Y625T/fckUun6OOIYuX0LDvahgtK0ZT1yPbvcfDY2M+x5BGP1UNQpFdYokarrg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1674637405; a=rsa-sha256; cv=none; b=iPkcglpqZT0ZmRmiwxoj7qFuLLWeO0cspKmc7sCgMKY/0sD5P6lt00lO77jhrV00BbmGp7 gLvPds/C5DFFZfnMN+I+m9KHuphUGcxUt4RsJH7s1uoG2rEIb+QafaOnyhMZXP96voqS7G UzdUp2DH6k87Elv9x+qgpCteaH5LZ8TYG7AYml5bi7BstdM6ge/2Jwes7Kl5elMql0e41l k6TGY+pVS+R/jO0JCZOVIF9TayJbrn1qgwK1levcsKiUz6EX2Sry17hkVPvfjZ2hTouT9k I7P+CafCedpPF4ynEPA67Ek3zXgCOyQ1MfBjk17tkU1fqrd2zeXwRWyHbhsm/w== 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 4P1yYS63yFzjjg; Wed, 25 Jan 2023 09:03:24 +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 30P93OtZ027076; Wed, 25 Jan 2023 09:03:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30P93Obg027075; Wed, 25 Jan 2023 09:03:24 GMT (envelope-from git) Date: Wed, 25 Jan 2023 09:03:24 GMT Message-Id: <202301250903.30P93Obg027075@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: cdd9d92dade6 - main - strfmon(3): Add an EXAMPLES section List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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: cdd9d92dade61a6b5c37b758e9533a076bb5a2de Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=cdd9d92dade61a6b5c37b758e9533a076bb5a2de commit cdd9d92dade61a6b5c37b758e9533a076bb5a2de Author: Jose Luis Duran AuthorDate: 2022-11-08 20:36:57 +0000 Commit: Konstantin Belousov CommitDate: 2023-01-25 09:02:55 +0000 strfmon(3): Add an EXAMPLES section Reviewed by: kib MFC after: 1 week --- 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