summaryrefslogtreecommitdiffstats
path: root/Utilities/cmcurl/lib/strequal.c
diff options
context:
space:
mode:
Diffstat (limited to 'Utilities/cmcurl/lib/strequal.c')
-rw-r--r--Utilities/cmcurl/lib/strequal.c52
1 files changed, 15 insertions, 37 deletions
diff --git a/Utilities/cmcurl/lib/strequal.c b/Utilities/cmcurl/lib/strequal.c
index 83796f6..5f2f508 100644
--- a/Utilities/cmcurl/lib/strequal.c
+++ b/Utilities/cmcurl/lib/strequal.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2013, 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
@@ -18,25 +18,19 @@
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
- * $Id$
***************************************************************************/
-#include "setup.h"
+#include "curl_setup.h"
-#include <string.h>
-#include <ctype.h>
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
#include "strequal.h"
-#if defined(HAVE_STRCASECMP) && defined(__STRICT_ANSI__)
-/* 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
-
+/*
+ * @unittest: 1301
+ */
int curl_strequal(const char *first, const char *second)
{
#if defined(HAVE_STRCASECMP)
@@ -46,8 +40,8 @@ int curl_strequal(const char *first, const char *second)
#elif defined(HAVE_STRICMP)
return !(stricmp)(first, second);
#else
- while (*first && *second) {
- if (toupper(*first) != toupper(*second)) {
+ while(*first && *second) {
+ if(toupper(*first) != toupper(*second)) {
break;
}
first++;
@@ -57,17 +51,20 @@ int curl_strequal(const char *first, const char *second)
#endif
}
+/*
+ * @unittest: 1301
+ */
int curl_strnequal(const char *first, const char *second, size_t max)
{
-#if defined(HAVE_STRCASECMP)
+#if defined(HAVE_STRNCASECMP)
return !strncasecmp(first, second, max);
-#elif defined(HAVE_STRCMPI)
+#elif defined(HAVE_STRNCMPI)
return !strncmpi(first, second, max);
-#elif defined(HAVE_STRICMP)
+#elif defined(HAVE_STRNICMP)
return !strnicmp(first, second, max);
#else
- while (*first && *second && max) {
- if (toupper(*first) != toupper(*second)) {
+ while(*first && *second && max) {
+ if(toupper(*first) != toupper(*second)) {
break;
}
max--;
@@ -80,22 +77,3 @@ int curl_strnequal(const char *first, const char *second, size_t max)
return toupper(*first) == toupper(*second);
#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;
-}