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.
This commit is contained in:
parent
7571593864
commit
6fb374754d
|
@ -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
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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 \
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
|
@ -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
|
||||
|
@ -83,6 +84,9 @@ managing areas of memory. The corresponding declarations are in
|
|||
@page
|
||||
@include string/strcasecmp.def
|
||||
|
||||
@page
|
||||
@include string/strcasestr.def
|
||||
|
||||
@page
|
||||
@include string/strcat.def
|
||||
|
||||
|
|
Loading…
Reference in New Issue