Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/newlib
diff options
context:
space:
mode:
authorJeff Johnston <jjohnstn@redhat.com>2007-06-08 22:38:51 +0400
committerJeff Johnston <jjohnstn@redhat.com>2007-06-08 22:38:51 +0400
commit6fb374754dff1fbbe28b513b57caedc62e9a7cee (patch)
tree1fb6bb0f26b02fcf53c2d5736343d49ffe7ddc50 /newlib
parent75715938641f75ab4e715fb7310683628097fd44 (diff)
2007-06-08 Jeff Johnston <jjohnstn@redhat.com>
* libc/string/strcasestr.c: New file. * libc/include/string.h: Add strcasestr. * libc/string/strings.tex: Add strcasestr. * libc/string/Makefile.am: Ditto. * libc/string/Makefile.in: Regenerated.
Diffstat (limited to 'newlib')
-rw-r--r--newlib/ChangeLog8
-rw-r--r--newlib/libc/include/string.h1
-rw-r--r--newlib/libc/string/Makefile.am5
-rw-r--r--newlib/libc/string/Makefile.in14
-rw-r--r--newlib/libc/string/strcasestr.c99
-rw-r--r--newlib/libc/string/strings.tex4
6 files changed, 126 insertions, 5 deletions
diff --git a/newlib/ChangeLog b/newlib/ChangeLog
index ee4ce26c1..c6f2de8eb 100644
--- a/newlib/ChangeLog
+++ b/newlib/ChangeLog
@@ -1,3 +1,11 @@
+2007-06-08 Jeff Johnston <jjohnstn@redhat.com>
+
+ * libc/string/strcasestr.c: New file.
+ * libc/include/string.h: Add strcasestr.
+ * libc/string/strings.tex: Add strcasestr.
+ * libc/string/Makefile.am: Ditto.
+ * libc/string/Makefile.in: Regenerated.
+
2007-06-06 Christian Groessler <chris@groessler.org>
* libc/stdlib/ldtoa (_ldcheck): Make sure the setting of
diff --git a/newlib/libc/include/string.h b/newlib/libc/include/string.h
index 55a86b374..c677f6f7b 100644
--- a/newlib/libc/include/string.h
+++ b/newlib/libc/include/string.h
@@ -61,6 +61,7 @@ extern void *memmem (__const void *, size_t, __const void *, size_t);
#endif
char *_EXFUN(rindex,(const char *, int));
int _EXFUN(strcasecmp,(const char *, const char *));
+char *_EXFUN(strcasestr,(const char *, const char *));
char *_EXFUN(strdup,(const char *));
char *_EXFUN(_strdup_r,(struct _reent *, const char *));
char *_EXFUN(strndup,(const char *, size_t));
diff --git a/newlib/libc/string/Makefile.am b/newlib/libc/string/Makefile.am
index dbe603628..e0482d82e 100644
--- a/newlib/libc/string/Makefile.am
+++ b/newlib/libc/string/Makefile.am
@@ -78,6 +78,7 @@ ELIX_SOURCES = \
memccpy.c \
mempcpy.c \
strndup.c \
+ strcasestr.c \
strndup_r.c
endif
@@ -103,8 +104,8 @@ bzero.def memset.def strcpy.def strncpy.def strxfrm.def \
index.def rindex.def strcspn.def strpbrk.def swab.def \
memchr.def strcat.def strerror.def strerror_r.def strrchr.def \
memcmp.def strchr.def strlen.def strnlen.def strspn.def \
-strcasecmp.def strncasecmp.def strlwr.def strupr.def memccpy.def \
-mempcpy.def \
+strcasecmp.def strncasecmp.def strcasestr.def strlwr.def strupr.def \
+memccpy.def mempcpy.def \
wcscat.def wcschr.def wcscmp.def wcscoll.def \
wcscpy.def wcscspn.def \
wcslcat.def wcslcpy.def wcslen.def wcsncat.def \
diff --git a/newlib/libc/string/Makefile.in b/newlib/libc/string/Makefile.in
index adeb7c446..f5c5bdbe6 100644
--- a/newlib/libc/string/Makefile.in
+++ b/newlib/libc/string/Makefile.in
@@ -91,6 +91,7 @@ am__objects_1 = lib_a-bcopy.$(OBJEXT) lib_a-bzero.$(OBJEXT) \
@ELIX_LEVEL_1_FALSE@ lib_a-memccpy.$(OBJEXT) \
@ELIX_LEVEL_1_FALSE@ lib_a-mempcpy.$(OBJEXT) \
@ELIX_LEVEL_1_FALSE@ lib_a-strndup.$(OBJEXT) \
+@ELIX_LEVEL_1_FALSE@ lib_a-strcasestr.$(OBJEXT) \
@ELIX_LEVEL_1_FALSE@ lib_a-strndup_r.$(OBJEXT)
@USE_LIBTOOL_FALSE@am_lib_a_OBJECTS = $(am__objects_1) \
@USE_LIBTOOL_FALSE@ $(am__objects_2)
@@ -111,7 +112,7 @@ am__objects_3 = bcopy.lo bzero.lo index.lo memchr.lo memcmp.lo \
wcwidth.lo wmemchr.lo wmemcmp.lo wmemcpy.lo wmemmove.lo \
wmemset.lo
@ELIX_LEVEL_1_FALSE@am__objects_4 = bcmp.lo memccpy.lo mempcpy.lo \
-@ELIX_LEVEL_1_FALSE@ strndup.lo strndup_r.lo
+@ELIX_LEVEL_1_FALSE@ strndup.lo strcasestr.lo strndup_r.lo
@USE_LIBTOOL_TRUE@am_libstring_la_OBJECTS = $(am__objects_3) \
@USE_LIBTOOL_TRUE@ $(am__objects_4)
libstring_la_OBJECTS = $(am_libstring_la_OBJECTS)
@@ -362,6 +363,7 @@ GENERAL_SOURCES = \
@ELIX_LEVEL_1_FALSE@ memccpy.c \
@ELIX_LEVEL_1_FALSE@ mempcpy.c \
@ELIX_LEVEL_1_FALSE@ strndup.c \
+@ELIX_LEVEL_1_FALSE@ strcasestr.c \
@ELIX_LEVEL_1_FALSE@ strndup_r.c
@ELIX_LEVEL_1_TRUE@ELIX_SOURCES =
@@ -380,8 +382,8 @@ bzero.def memset.def strcpy.def strncpy.def strxfrm.def \
index.def rindex.def strcspn.def strpbrk.def swab.def \
memchr.def strcat.def strerror.def strerror_r.def strrchr.def \
memcmp.def strchr.def strlen.def strnlen.def strspn.def \
-strcasecmp.def strncasecmp.def strlwr.def strupr.def memccpy.def \
-mempcpy.def \
+strcasecmp.def strncasecmp.def strcasestr.def strlwr.def strupr.def \
+memccpy.def mempcpy.def \
wcscat.def wcschr.def wcscmp.def wcscoll.def \
wcscpy.def wcscspn.def \
wcslcat.def wcslcpy.def wcslen.def wcsncat.def \
@@ -869,6 +871,12 @@ lib_a-strndup.o: strndup.c
lib_a-strndup.obj: strndup.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-strndup.obj `if test -f 'strndup.c'; then $(CYGPATH_W) 'strndup.c'; else $(CYGPATH_W) '$(srcdir)/strndup.c'; fi`
+lib_a-strcasestr.o: strcasestr.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-strcasestr.o `test -f 'strcasestr.c' || echo '$(srcdir)/'`strcasestr.c
+
+lib_a-strcasestr.obj: strcasestr.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-strcasestr.obj `if test -f 'strcasestr.c'; then $(CYGPATH_W) 'strcasestr.c'; else $(CYGPATH_W) '$(srcdir)/strcasestr.c'; fi`
+
lib_a-strndup_r.o: strndup_r.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-strndup_r.o `test -f 'strndup_r.c' || echo '$(srcdir)/'`strndup_r.c
diff --git a/newlib/libc/string/strcasestr.c b/newlib/libc/string/strcasestr.c
new file mode 100644
index 000000000..f1c14a08b
--- /dev/null
+++ b/newlib/libc/string/strcasestr.c
@@ -0,0 +1,99 @@
+/*
+FUNCTION
+ <<strcasestr>>---case-insensitive character string search
+
+INDEX
+ strcasestr
+
+ANSI_SYNOPSIS
+ #include <string.h>
+ char *strcasestr(const char *<[s]>, const char *<[find]>);
+
+TRAD_SYNOPSIS
+ #include <string.h>
+ int strcasecmp(<[s]>, <[find]>)
+ char *<[s]>;
+ char *<[find]>;
+
+DESCRIPTION
+ <<strcasestr>> searchs the string <[s]> for
+ the first occurrence of the sequence <[find]>. <<strcasestr>>
+ is identical to <<strstr>> except the search is
+ case-insensitive.
+
+RETURNS
+
+ A pointer to the first case-insensitive occurrence of the sequence
+ <[find]> or <<NULL>> if no match was found.
+
+PORTABILITY
+<<strcasestr>> is in the Berkeley Software Distribution.
+
+<<strcasestr>> requires no supporting OS subroutines. It uses
+tolower() from elsewhere in this library.
+
+QUICKREF
+ strcasestr
+*/
+
+/*-
+ * Copyright (c) 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: /repoman/r/ncvs/src/lib/libc/string/strcasestr.c,v 1.4 2007/01/09 00:28:12 imp Exp $");
+
+#include <ctype.h>
+#include <string.h>
+
+/*
+ * Find the first occurrence of find in s, ignore case.
+ */
+char *
+strcasestr(s, find)
+ const char *s, *find;
+{
+ char c, sc;
+ size_t len;
+
+ if ((c = *find++) != 0) {
+ c = tolower((unsigned char)c);
+ len = strlen(find);
+ do {
+ do {
+ if ((sc = *s++) == 0)
+ return (NULL);
+ } while ((char)tolower((unsigned char)sc) != c);
+ } while (strncasecmp(s, find, len) != 0);
+ s--;
+ }
+ return ((char *)s);
+}
diff --git a/newlib/libc/string/strings.tex b/newlib/libc/string/strings.tex
index 3ca732f79..5d43fd56b 100644
--- a/newlib/libc/string/strings.tex
+++ b/newlib/libc/string/strings.tex
@@ -19,6 +19,7 @@ managing areas of memory. The corresponding declarations are in
* memset:: Set an area of memory
* rindex:: Reverse search for character in string
* strcasecmp:: Compare strings ignoring case
+* strcasestr:: Find string segment ignoring case
* strcat:: Concatenate strings
* strchr:: Search for character in string
* strcmp:: Character string compare
@@ -84,6 +85,9 @@ managing areas of memory. The corresponding declarations are in
@include string/strcasecmp.def
@page
+@include string/strcasestr.def
+
+@page
@include string/strcat.def
@page