* [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)
@ 2023-01-05 18:44 Alejandro Colomar
2023-01-05 18:47 ` Alejandro Colomar
0 siblings, 1 reply; 2+ messages in thread
From: Alejandro Colomar @ 2023-01-05 18:44 UTC (permalink / raw)
To: G. Branden Robinson, linux-man; +Cc: Alejandro Colomar
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [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)
2023-01-05 18:44 [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
@ 2023-01-05 18:47 ` Alejandro Colomar
0 siblings, 0 replies; 2+ messages in thread
From: Alejandro Colomar @ 2023-01-05 18:47 UTC (permalink / raw)
To: G. Branden Robinson, linux-man; +Cc: Alejandro Colomar
[-- Attachment #1.1: Type: text/plain, Size: 863 bytes --]
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)
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-01-05 18:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-05 18:44 [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
2023-01-05 18:47 ` Alejandro Colomar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).