public inbox for linux-man@vger.kernel.org
 help / color / mirror / Atom feed
From: Alejandro Colomar <alx.manpages@gmail.com>
To: "G. Branden Robinson" <g.branden.robinson@gmail.com>,
	linux-man@vger.kernel.org
Cc: Alejandro Colomar <alx@kernel.org>
Subject: [PATCH] index.3, memchr.3, strchr.3, string.3, strpbrk.3, strsep.3, strspn.3, strstr.3, strtok.3: Deprecate index(3) and rindex(3)
Date: Thu,  5 Jan 2023 19:44:47 +0100	[thread overview]
Message-ID: <20230105184446.10141-1-alx@kernel.org> (raw)

They are identical to strchr(3) and strrchr(3).  Use those.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
---

Hi Branden,

I prepared this in response to your messages regarding index(3) and
rindex(3).  These functions are wasting manual page real estate, and are
just confusing users.  Be concise in that these are just aliases for
str[r]chr(3), and let readers open strchr(3) for the details.

Cheers,

Alex

 man3/index.3   | 61 ++++++++++----------------------------------------
 man3/memchr.3  |  2 --
 man3/strchr.3  |  2 --
 man3/string.3  | 14 ++++--------
 man3/strpbrk.3 |  2 --
 man3/strsep.3  |  2 --
 man3/strspn.3  |  2 --
 man3/strstr.3  |  2 --
 man3/strtok.3  |  2 --
 9 files changed, 16 insertions(+), 73 deletions(-)

diff --git a/man3/index.3 b/man3/index.3
index 24ba04baa..a0aa5b78a 100644
--- a/man3/index.3
+++ b/man3/index.3
@@ -1,14 +1,8 @@
 '\" t
-.\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
+.\" Copyright 2022 Alejandro Colomar <alx@kernel.org>
 .\"
 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
 .\"
-.\" References consulted:
-.\"     Linux libc source code
-.\"     Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
-.\"     386BSD man pages
-.\" Modified Mon Apr 12 12:54:34 1993, David Metcalfe
-.\" Modified Sat Jul 24 19:13:52 1993, Rik Faith (faith@cs.unc.edu)
 .TH index 3 (date) "Linux man-pages (unreleased)"
 .SH NAME
 index, rindex \- locate character in string
@@ -19,47 +13,23 @@ .SH SYNOPSIS
 .nf
 .B #include <strings.h>
 .PP
-.BI "char *index(const char *" s ", int " c );
-.BI "char *rindex(const char *" s ", int " c );
+.BI "[[deprecated]] char *index(const char *" s ", int " c );
+.BI "[[deprecated]] char *rindex(const char *" s ", int " c );
 .fi
 .SH DESCRIPTION
-The
 .BR index ()
-function returns a pointer to the first occurrence
-of the character \fIc\fP in the string \fIs\fP.
+is identical to
+.BR strchr (3).
 .PP
-The
 .BR rindex ()
-function returns a pointer to the last occurrence
-of the character \fIc\fP in the string \fIs\fP.
+is identical to
+.BR strrchr (3).
 .PP
-The terminating null byte (\(aq\e0\(aq) is considered to be a part of the
-strings.
-.SH RETURN VALUE
-The
-.BR index ()
+Use
+.BR strchr (3)
 and
-.BR rindex ()
-functions return a pointer to
-the matched character or NULL if the character is not found.
-.SH ATTRIBUTES
-For an explanation of the terms used in this section, see
-.BR attributes (7).
-.ad l
-.nh
-.TS
-allbox;
-lbx lb lb
-l l l.
-Interface	Attribute	Value
-T{
-.BR index (),
-.BR rindex ()
-T}	Thread safety	MT-Safe
-.TE
-.hy
-.ad
-.sp 1
+.BR strrchr (3)
+instead of these functions.
 .SH STANDARDS
 4.3BSD; marked as LEGACY in POSIX.1-2001.
 POSIX.1-2008 removes the specifications of
@@ -72,12 +42,5 @@ .SH STANDARDS
 .BR strrchr (3)
 instead.
 .SH SEE ALSO
-.BR memchr (3),
 .BR strchr (3),
-.BR string (3),
-.BR strpbrk (3),
-.BR strrchr (3),
-.BR strsep (3),
-.BR strspn (3),
-.BR strstr (3),
-.BR strtok (3)
+.BR strrchr (3)
diff --git a/man3/memchr.3 b/man3/memchr.3
index 10bc35b9d..68873964e 100644
--- a/man3/memchr.3
+++ b/man3/memchr.3
@@ -137,9 +137,7 @@ .SH STANDARDS
 .SH SEE ALSO
 .BR bstring (3),
 .BR ffs (3),
-.BR index (3),
 .BR memmem (3),
-.BR rindex (3),
 .BR strchr (3),
 .BR strpbrk (3),
 .BR strrchr (3),
diff --git a/man3/strchr.3 b/man3/strchr.3
index 6686e6fee..bbdf33a77 100644
--- a/man3/strchr.3
+++ b/man3/strchr.3
@@ -112,9 +112,7 @@ .SH STANDARDS
 .BR strchrnul ()
 is a GNU extension.
 .SH SEE ALSO
-.BR index (3),
 .BR memchr (3),
-.BR rindex (3),
 .BR string (3),
 .BR strlen (3),
 .BR strpbrk (3),
diff --git a/man3/string.3 b/man3/string.3
index 0bd16a0bd..298f57e83 100644
--- a/man3/string.3
+++ b/man3/string.3
@@ -37,16 +37,12 @@ .SH SYNOPSIS
 ignoring case.
 .TP
 .BI "char *index(const char *" s ", int " c );
-Return a pointer to the first occurrence of the character
-.I c
-in the string
-.IR s .
+Alias for
+.BR strchr (3).
 .TP
 .BI "char *rindex(const char *" s ", int " c );
-Return a pointer to the last occurrence of the character
-.I c
-in the string
-.IR s .
+Alias for
+.BR strrchr (3).
 .TP
 .B #include <string.h>
 .TP
@@ -204,8 +200,6 @@ .SH DESCRIPTION
 See the individual man pages for descriptions of each function.
 .SH SEE ALSO
 .BR bstring (3),
-.BR index (3),
-.BR rindex (3),
 .BR stpcpy (3),
 .BR strcasecmp (3),
 .BR strcat (3),
diff --git a/man3/strpbrk.3 b/man3/strpbrk.3
index f459ee1ee..cb84aeca4 100644
--- a/man3/strpbrk.3
+++ b/man3/strpbrk.3
@@ -57,9 +57,7 @@ .SH ATTRIBUTES
 .SH STANDARDS
 POSIX.1-2001, POSIX.1-2008, C99, SVr4, 4.3BSD.
 .SH SEE ALSO
-.BR index (3),
 .BR memchr (3),
-.BR rindex (3),
 .BR strchr (3),
 .BR string (3),
 .BR strsep (3),
diff --git a/man3/strsep.3 b/man3/strsep.3
index 0eb95b8a7..c3e584343 100644
--- a/man3/strsep.3
+++ b/man3/strsep.3
@@ -154,9 +154,7 @@ .SS Program source
 .EE
 .\" SRC END
 .SH SEE ALSO
-.BR index (3),
 .BR memchr (3),
-.BR rindex (3),
 .BR strchr (3),
 .BR string (3),
 .BR strpbrk (3),
diff --git a/man3/strspn.3 b/man3/strspn.3
index e584ca257..34d2f1a6a 100644
--- a/man3/strspn.3
+++ b/man3/strspn.3
@@ -75,9 +75,7 @@ .SH ATTRIBUTES
 .SH STANDARDS
 POSIX.1-2001, POSIX.1-2008, C99, SVr4, 4.3BSD.
 .SH SEE ALSO
-.BR index (3),
 .BR memchr (3),
-.BR rindex (3),
 .BR strchr (3),
 .BR string (3),
 .BR strpbrk (3),
diff --git a/man3/strstr.3 b/man3/strstr.3
index 879e51cef..5e7122390 100644
--- a/man3/strstr.3
+++ b/man3/strstr.3
@@ -80,10 +80,8 @@ .SH STANDARDS
 .BR strcasestr ()
 function is a nonstandard extension.
 .SH SEE ALSO
-.BR index (3),
 .BR memchr (3),
 .BR memmem (3),
-.BR rindex (3),
 .BR strcasecmp (3),
 .BR strchr (3),
 .BR string (3),
diff --git a/man3/strtok.3 b/man3/strtok.3
index 80c189064..437072563 100644
--- a/man3/strtok.3
+++ b/man3/strtok.3
@@ -272,9 +272,7 @@ .SS Program source
 can be found in
 .BR getaddrinfo_a (3).
 .SH SEE ALSO
-.BR index (3),
 .BR memchr (3),
-.BR rindex (3),
 .BR strchr (3),
 .BR string (3),
 .BR strpbrk (3),
-- 
2.39.0


             reply	other threads:[~2023-01-05 18:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-05 18:44 Alejandro Colomar [this message]
2023-01-05 18:47 ` [PATCH] index.3, memchr.3, strchr.3, string.3, strpbrk.3, strsep.3, strspn.3, strstr.3, strtok.3: Deprecate index(3) and rindex(3) Alejandro Colomar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230105184446.10141-1-alx@kernel.org \
    --to=alx.manpages@gmail.com \
    --cc=alx@kernel.org \
    --cc=g.branden.robinson@gmail.com \
    --cc=linux-man@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox