summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/string.h1
-rw-r--r--lib/libc/string/Makefile.inc3
-rw-r--r--lib/libc/string/Symbol.map4
-rw-r--r--lib/libc/string/memchr.331
-rw-r--r--sys/sys/param.h2
5 files changed, 36 insertions, 5 deletions
diff --git a/include/string.h b/include/string.h
index f0dc21814897..1b6e1849de43 100644
--- a/include/string.h
+++ b/include/string.h
@@ -59,6 +59,7 @@ __BEGIN_DECLS
void *memccpy(void * __restrict, const void * __restrict, int, size_t);
#endif
void *memchr(const void *, int, size_t) __pure;
+void *memrchr(const void *, int, size_t) __pure;
int memcmp(const void *, const void *, size_t) __pure;
void *memcpy(void * __restrict, const void * __restrict, size_t);
#if __BSD_VISIBLE
diff --git a/lib/libc/string/Makefile.inc b/lib/libc/string/Makefile.inc
index 6d64ea5a08c9..9e5f0dab9b3b 100644
--- a/lib/libc/string/Makefile.inc
+++ b/lib/libc/string/Makefile.inc
@@ -7,7 +7,7 @@ CFLAGS+= -I${.CURDIR}/locale
# machine-independent string sources
MISRCS+=bcmp.c bcopy.c bzero.c ffs.c ffsl.c fls.c flsl.c index.c memccpy.c \
- memchr.c memcmp.c \
+ memchr.c memrchr.c memcmp.c \
memcpy.c memmem.c memmove.c memset.c rindex.c stpcpy.c strcasecmp.c \
strcat.c strchr.c strcmp.c strcoll.c strcpy.c strcspn.c strdup.c \
strerror.c strlcat.c strlcpy.c strlen.c strmode.c strncat.c strncmp.c \
@@ -39,6 +39,7 @@ MLINKS+=ffs.3 ffsl.3
MLINKS+=ffs.3 fls.3
MLINKS+=ffs.3 flsl.3
MLINKS+=index.3 rindex.3
+MLINKS+=memchr.3 memrchr.3
MLINKS+=strcasecmp.3 strncasecmp.3
MLINKS+=strcat.3 strncat.3
MLINKS+=strchr.3 strrchr.3
diff --git a/lib/libc/string/Symbol.map b/lib/libc/string/Symbol.map
index ad9f74327f13..d034ecce718b 100644
--- a/lib/libc/string/Symbol.map
+++ b/lib/libc/string/Symbol.map
@@ -77,6 +77,10 @@ FBSD_1.0 {
wmemset;
};
+FBSD_1.1 {
+ memrchr;
+};
+
FBSDprivate_1.0 {
__strtok_r;
};
diff --git a/lib/libc/string/memchr.3 b/lib/libc/string/memchr.3
index d82d859dd0f1..5cbaf6cc1779 100644
--- a/lib/libc/string/memchr.3
+++ b/lib/libc/string/memchr.3
@@ -32,7 +32,7 @@
.\" @(#)memchr.3 8.1 (Berkeley) 6/4/93
.\" $FreeBSD$
.\"
-.Dd June 4, 1993
+.Dd April 9, 2008
.Dt MEMCHR 3
.Os
.Sh NAME
@@ -44,6 +44,8 @@
.In string.h
.Ft void *
.Fn memchr "const void *b" "int c" "size_t len"
+.Ft void *
+.Fn memrchr "const void *b" "int c" "size_t len"
.Sh DESCRIPTION
The
.Fn memchr
@@ -53,11 +55,22 @@ locates the first occurrence of
(converted to an unsigned char)
in string
.Fa b .
+.Pp
+The
+.Fn memrchr
+function behaves like
+.Fn memchr ,
+except that it locates the last occurrence of
+.Fa c
+in string
+.Fa b .
.Sh RETURN VALUES
The
.Fn memchr
-function
-returns a pointer to the byte located,
+and
+.Fn memrchr
+functions
+return a pointer to the byte located,
or NULL if no such byte exists within
.Fa len
bytes.
@@ -77,3 +90,15 @@ The
function
conforms to
.St -isoC .
+.Pp
+The
+.Fn memrchr
+function is a GNU extension and conforms to no standard.
+.Sh HISTORY
+The
+.Fn memrchr
+function first appeared in GNU libc 2.1.91, this implementation
+first appeared in
+.Fx 8.0 ,
+coming from
+.Ox 4.3 .
diff --git a/sys/sys/param.h b/sys/sys/param.h
index ae675062282e..5ff7b9d9223f 100644
--- a/sys/sys/param.h
+++ b/sys/sys/param.h
@@ -57,7 +57,7 @@
* is created, otherwise 1.
*/
#undef __FreeBSD_version
-#define __FreeBSD_version 700108 /* Master, propagated to newvers */
+#define __FreeBSD_version 700109 /* Master, propagated to newvers */
#ifndef LOCORE
#include <sys/types.h>