[PATCH v2 2/2] Port strnstr.c to newlib.
Sichen Zhao
1473996754@qq.com
Fri Aug 25 06:16:00 GMT 2017
---
newlib/libc/include/string.h | 3 +++
newlib/libc/string/Makefile.am | 1 +
newlib/libc/string/strnstr.c | 13 ++++++-------
3 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/newlib/libc/include/string.h b/newlib/libc/include/string.h
index 7833aa1..304d8a5 100644
--- a/newlib/libc/include/string.h
+++ b/newlib/libc/include/string.h
@@ -121,6 +121,9 @@ size_t _EXFUN(strnlen,(const char *, size_t));
#if __BSD_VISIBLE
char *_EXFUN(strsep,(char **, const char *));
#endif
+#if __BSD_VISIBLE
+char *_EXFUN(strnstr,(const char *, const char *, size_t));
+#endif
#if __MISC_VISIBLE
char *_EXFUN(strlwr,(char *));
diff --git a/newlib/libc/string/Makefile.am b/newlib/libc/string/Makefile.am
index e62f286..f8bd41e 100644
--- a/newlib/libc/string/Makefile.am
+++ b/newlib/libc/string/Makefile.am
@@ -40,6 +40,7 @@ GENERAL_SOURCES = \
strncmp.c \
strncpy.c \
strnlen.c \
+ strnstr.c \
strpbrk.c \
strrchr.c \
strsep.c \
diff --git a/newlib/libc/string/strnstr.c b/newlib/libc/string/strnstr.c
index 4de757d..8903200 100644
--- a/newlib/libc/string/strnstr.c
+++ b/newlib/libc/string/strnstr.c
@@ -31,12 +31,8 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)strstr.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
+#undef __STRICT_ANSI__
+#include <_ansi.h>
#include <string.h>
/*
@@ -44,7 +40,10 @@ __FBSDID("$FreeBSD$");
* first slen characters of s.
*/
char *
-strnstr(const char *s, const char *find, size_t slen)
+_DEFUN (strnstr, (s, find, slen),
+ _CONST char *s _AND
+ _CONST char *find _AND
+ size_t slen)
{
char c, sc;
size_t len;
--
2.7.4
More information about the Newlib
mailing list