diff options
author | Andy Cedilnik <andy.cedilnik@kitware.com> | 2004-10-05 13:34:20 (GMT) |
---|---|---|
committer | Andy Cedilnik <andy.cedilnik@kitware.com> | 2004-10-05 13:34:20 (GMT) |
commit | 609801fe67c95f9959468df8316a8f4a26943842 (patch) | |
tree | be2cf804edae61b76806c95bf0965985e4f45aed /Source/CTest/Curl/strequal.c | |
parent | 50da0328472ad0f318f64a20876c474ad968fef3 (diff) | |
download | CMake-609801fe67c95f9959468df8316a8f4a26943842.zip CMake-609801fe67c95f9959468df8316a8f4a26943842.tar.gz CMake-609801fe67c95f9959468df8316a8f4a26943842.tar.bz2 |
ENH: Update Curl to 7.12.1
Diffstat (limited to 'Source/CTest/Curl/strequal.c')
-rw-r--r-- | Source/CTest/Curl/strequal.c | 57 |
1 files changed, 38 insertions, 19 deletions
diff --git a/Source/CTest/Curl/strequal.c b/Source/CTest/Curl/strequal.c index 0cc22ea..f993e38 100644 --- a/Source/CTest/Curl/strequal.c +++ b/Source/CTest/Curl/strequal.c @@ -1,16 +1,16 @@ /*************************************************************************** - * _ _ ____ _ - * Project ___| | | | _ \| | - * / __| | | | |_) | | - * | (__| |_| | _ <| |___ + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2002, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2004, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms * are also available at http://curl.haxx.se/docs/copyright.html. - * + * * You may opt to use, copy, modify, merge, publish, distribute and/or sell * copies of the Software, and permit persons to whom the Software is * furnished to do so, under the terms of the COPYING file. @@ -26,14 +26,22 @@ #include <string.h> #include <ctype.h> +#include "strequal.h" + +#ifdef HAVE_STRCASECMP +/* this is for "-ansi -Wall -pedantic" to stop complaining! */ +extern int (strcasecmp)(const char *s1, const char *s2); +extern int (strncasecmp)(const char *s1, const char *s2, size_t n); +#endif + int curl_strequal(const char *first, const char *second) { #if defined(HAVE_STRCASECMP) return !(strcasecmp)(first, second); -#elif defined(HAVE_STRICMP) - return !(stricmp)(first, second); #elif defined(HAVE_STRCMPI) return !(strcmpi)(first, second); +#elif defined(HAVE_STRICMP) + return !(stricmp)(first, second); #else while (*first && *second) { if (toupper(*first) != toupper(*second)) { @@ -50,10 +58,10 @@ int curl_strnequal(const char *first, const char *second, size_t max) { #if defined(HAVE_STRCASECMP) return !strncasecmp(first, second, max); -#elif defined(HAVE_STRICMP) - return !strnicmp(first, second, max); #elif defined(HAVE_STRCMPI) return !strncmpi(first, second, max); +#elif defined(HAVE_STRICMP) + return !strnicmp(first, second, max); #else while (*first && *second && max) { if (toupper(*first) != toupper(*second)) { @@ -70,6 +78,25 @@ int curl_strnequal(const char *first, const char *second, size_t max) #endif } +/* + * Curl_strcasestr() finds the first occurrence of the substring needle in the + * string haystack. The terminating `\0' characters are not compared. The + * matching is done CASE INSENSITIVE, which thus is the difference between + * this and strstr(). + */ +char *Curl_strcasestr(const char *haystack, const char *needle) +{ + size_t nlen = strlen(needle); + size_t hlen = strlen(haystack); + + while(hlen-- >= nlen) { + if(curl_strnequal(haystack, needle, nlen)) + return (char *)haystack; + haystack++; + } + return NULL; +} + #ifndef HAVE_STRLCAT /* * The strlcat() function appends the NUL-terminated string src to the end @@ -82,7 +109,7 @@ int curl_strnequal(const char *first, const char *second, size_t max) * src. While this may seem somewhat confusing it was done to make trunca- * tion detection simple. * - * + * */ size_t Curl_strlcat(char *dst, const char *src, size_t siz) { @@ -111,11 +138,3 @@ size_t Curl_strlcat(char *dst, const char *src, size_t siz) return(dlen + (s - src)); /* count does not include NUL */ } #endif - -/* - * local variables: - * eval: (load-file "../curl-mode.el") - * end: - * vim600: fdm=marker - * vim: et sw=2 ts=2 sts=2 tw=78 - */ |