From nobody Tue Nov 18 13:38:25 2025 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 4d9m0K2fXDz6H98L for ; Tue, 18 Nov 2025 13:38: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 "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4d9m0K20gLz3nq8 for ; Tue, 18 Nov 2025 13:38:25 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1763473105; 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=v4ZJk7f1X3tgZupVlPciUf9GRhkni8WRYRMnIiNKEiA=; b=fmrMvNaayYlgxR///bhsfJasP0KUPZ2uFLJMVeq+G+MhGIzMOZeASLgsGBL7leyluwB9/M wphwLHKHTW+aEY/4LkJ3AZF0364SHo3r95twTdAR3M8EngCe+KSOZiQM83FMHyv7ahTGqS 0i2vepyUVQw/z2hlcAuwR3vZbHyou0PZzB/Adzv0lwtG3gOwhhACYh9Z4c+xpBVo3shfO8 cGS4GSoeJB5tVH5cJ3x1hLhDH07INhEHn+ee6tzmfbBcLsXGobfeF9u6dpAYJYBD1GAAiY ai9uLT3BYpdRQjGAG5YYThZns10022YiMpW5h2sLA66If8Zt3KR28MOisgJ11g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1763473105; 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=v4ZJk7f1X3tgZupVlPciUf9GRhkni8WRYRMnIiNKEiA=; b=hTzt+QlNlpT+GkC3QtFkyw30uOp114RPmptjrzJoUrIYyapiPhmxLntsDZAC8EVylQAVcY IegKOK5tpdorNT2tEcV908zQmuNAkjCiBzt96eyanKL3N2isQCM3dp9lku3KHK0hirhKhw AS03ZbEIKXrM1Jyz6MUYFlgNiIZHlNWqnBhmWf4Yc6KPUVpJYpes9Q57dWBs7u46QRS2nv u9Iw6CX60VMNiLPbzLS74iDXCZf2q7P79LXQxNja89tt8gI/6P3kOuEzgZBhJao458gVN+ Tj1KCkqDlYEy0X9P2usBgCaT9ekLXGoAaSWfo7IQ0eCKyYoNSduorOfkwimCcg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1763473105; a=rsa-sha256; cv=none; b=pTG68fA3lCeI87jkeYttNVf12hjEVA/vileDAuP7bAq7EpSZWBNQqxdLYQBuWa7CbNZKvA fwGqcU+nDWEABa/TSGUzXcHpsTLJjVseo057fJogxasSzTFbySC/s+1+Og/X8B1x/IYa+U +/6G5XwtBpEAknkFnhOjQ+0bCZnIq73BrcmsfxQfd5IntIirhxor48n9o+Pc/Bc50dUxQ1 Bi//5tUpKouHTH/xKL7dLApDprOSPz97TtTMq/LZAiOvz1ujKyngmgsey0Y8E+WoKAyMiB B7urKuA8qWqM9ky11dlh4SVytk6oeX5A87FtfPnlgN1JRdfQSvHE/t1oC74+sg== 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 4d9m0K1ZYczx52 for ; Tue, 18 Nov 2025 13:38:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 2e437 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 18 Nov 2025 13:38:25 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mateusz Piotrowski <0mp@FreeBSD.org> Subject: git: d086bf34b56f - stable/15 - d.7: Document strchr, strjoin, strrchr, strstr, strtok, strlen, and substr 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: 0mp X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: d086bf34b56f1a9bb75cdceabec02cc39703fe66 Auto-Submitted: auto-generated Date: Tue, 18 Nov 2025 13:38:25 +0000 Message-Id: <691c76d1.2e437.2a4eeeb4@gitrepo.freebsd.org> The branch stable/15 has been updated by 0mp: URL: https://cgit.FreeBSD.org/src/commit/?id=d086bf34b56f1a9bb75cdceabec02cc39703fe66 commit d086bf34b56f1a9bb75cdceabec02cc39703fe66 Author: Mateusz Piotrowski <0mp@FreeBSD.org> AuthorDate: 2025-10-28 20:06:53 +0000 Commit: Mateusz Piotrowski <0mp@FreeBSD.org> CommitDate: 2025-11-18 13:38:14 +0000 d.7: Document strchr, strjoin, strrchr, strstr, strtok, strlen, and substr Reviewed by: markj MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D53417 (cherry picked from commit af99c4c1d03c742faf8bd4c62fbbb664c5f7fc18) --- share/man/man7/d.7 | 124 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) diff --git a/share/man/man7/d.7 b/share/man/man7/d.7 index 4b00d3d71c79..59b3389b121b 100644 --- a/share/man/man7/d.7 +++ b/share/man/man7/d.7 @@ -198,6 +198,130 @@ The number of nanoseconds since the Epoch Suitable for timestamping logs. .El .Sh BUILT-IN FUNCTIONS +.\" Keep the indentation wide enough for the reader to be able to skim through +.\" function names quickly. +.Bl -tag -width "size_t strlen" +.It Ft string Fn strchr "string s" "char c" +Return a substring of +.Fa s +starting at the first occurance of +.Fa c +in +.Fa s . +Return +.Dv NULL +if +.Fa c +does not occur in +.Fa s . +.Pp +For example, +.Bd -literal -compact -offset indent +strchr("abc", 'b'); +.Ed +returns +.Ql "bc" +and +.Bd -literal -compact -offset indent +strchr("abc", 'd'); +.Ed +returns +.Dv NULL . +.It Ft string Fn strjoin "string s1" "string s2" +Return a string resulting from concatenating +.Fa s1 +and +.Fa s2 . +.Pp +For example, +.Bd -literal -compact -offset indent +strjoin("abc", "def") +.Ed +returns +.Ql abcdef . +.It Ft string Fn strrchr "string s" "char c" +Return a substring of +.Fa s +starting at the last occurance of +.Fa c +in +.Fa s . +Similar to +.Fn strchr . +.It Ft string Fn strstr "string haystack" "string needle" +Return a substring of +.Fa haystack +starting at the first occurrence of +.Fa needle . +Return +.Dv NULL +if +.Fa needle +is not a substring of +.Fa haystack . +.Pp +For example, +.Bd -literal -compact -offset indent +strstr("abc1bc2", "bc") +.Ed +returns +.Ql bc1bc2 +and +.Bd -literal -compact -offset indent +strstr("abc", "xy") +.Ed +returns +.Dv NULL . +.It Ft string Fn strtok "string s" "string separators" +Tokenize +.Fa s +with +.Fa separators . +.Pp +For example, +.Bd -literal -compact -offset indent +strtok("abcdefg", "xyzd") +.Ed +returns +.Ql abc . +.It Ft size_t Fn strlen "string s" +Return the length of string +.Fa s . +.It Ft string Fn substr "string s" "int position" "[int length]" +Return a +substring of string +.Fa s +starting at +.Fa position . +The substring will be at most +.Fa length Ns -long . +If +.Fa length +is not specified, use the rest of the string. +If +.Fa position +is greater than +the size of +.Fa s , +return an empty string. +.Pp +For example, +.Bd -literal -compact -offset indent +substr("abcd", 2) +.Ed +returns +.Ql cd , +.Bd -literal -compact -offset indent +substr("abcd", 2, 1) +.Ed +returns +.Ql c , +and +.Bd -literal -compact -offset indent +substr("abcd", 99) +.Ed +returns an empty string. +.El .Ss Aggregation Functions .Bl -tag -compact -width "llquantize(value, factor, low, high, nsteps)" .It Fn avg value