Skip to contentSkip to conversation

index.3, memchr.3, strchr.3, string.3, strpbrk.3, strsep.3, strspn.3, strstr.3, strtok.3: Deprecate index(3) and rindex(3)

PATCH In review Alejandro Colomar 1 participant 2 messages Jan 5, 2023 Man-pages: manual pages for Linux -- Sections 2, 3, 4, 5, and 7

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 index.3, memchr.3, strchr.3, string.3, strpbrk.3, strsep.3, strspn.3, strstr.3, strtok.3: Deprecate index(3) and rindex(3)

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

---

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(-)
man3/index.3 +12 -49
index 24ba04baa..a0aa5b78a 100644
@@ -1,14 +1,8 @@
 '\" t
-.\" Copyright 1993 David Metcalfe ([email protected])
+.\" Copyright 2022 Alejandro Colomar <[email protected]>
 .\"
 .\" 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 ([email protected])
 .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)
man3/memchr.3 +0 -2
index 10bc35b9d..68873964e 100644
@@ -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),
man3/strchr.3 +0 -2
index 6686e6fee..bbdf33a77 100644
@@ -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),
man3/string.3 +4 -10
index 0bd16a0bd..298f57e83 100644
@@ -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),
man3/strpbrk.3 +0 -2
index f459ee1ee..cb84aeca4 100644
@@ -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),
man3/strsep.3 +0 -2
index 0eb95b8a7..c3e584343 100644
@@ -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),
man3/strspn.3 +0 -2
index e584ca257..34d2f1a6a 100644
@@ -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),
man3/strstr.3 +0 -2
index 879e51cef..5e7122390 100644
@@ -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),
man3/strtok.3 +0 -2
index 80c189064..437072563 100644
@@ -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),
Signature · 1 line
2.39.0
#1 lore raw

index(3) Library Functions Manual index(3)

NAME
index, rindex - locate character in string

LIBRARY
Standard C library (libc, -lc)

SYNOPSIS

       #include <strings.h>

       [[deprecated]] char *index(const char *s, int c);
       [[deprecated]] char *rindex(const char *s, int c);

DESCRIPTION
index() is identical to strchr(3).

rindex() is identical to strrchr(3).

Use strchr(3) and strrchr(3) instead of these functions.

STANDARDS
4.3BSD; marked as LEGACY in POSIX.1‐2001. POSIX.1‐2008 removes the specifications of index() and rindex(), recommending strchr(3) and str‐ rchr(3) instead.

SEE ALSO

       strchr(3), strrchr(3)

Linux man‐pages (unreleased) (date) index(3)