[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 Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Signed-off-by: Alejandro Colomar <alx@xxxxxxxxxx>
---

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@xxxxxxxxxxxxxxxxx)
+.\" Copyright 2022 Alejandro Colomar <alx@xxxxxxxxxx>
 .\"
 .\" 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@xxxxxxxxxx)
 .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




[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux