28 #if defined(HAVE_STRCASECMP) || defined (HAVE_STRNCASECMP)
32 #if defined(HAVE_STRICMP) || defined (HAVE_STRNICMP)
44 static bool casecompare(
char c1,
char c2) {
return (tolower(c1)==tolower(c2)); }
47 static bool equal(
const std::string& s1,
const std::string& s2)
49 return s1.size() == s2.size()
50 && std::equal(s1.begin(), s1.end(), s2.begin(), casecompare);
53 static bool equal(
const char* s1,
const char* s2)
56 #if defined(HAVE_STRCASECMP)
57 return strcasecmp(s1, s2) == 0;
58 #elif defined(HAVE_STRICMP)
59 return stricmp(s1, s2) == 0;
64 if (s1 == 0 || s2 == 0)
67 while ((*s1 !=
'\0') || (*s2 !=
'\0'))
69 if (!casecompare(*s1, *s2))
79 static bool equal(
const char* s1,
const char* s2,
size_t n)
82 #if defined(HAVE_STRNCASECMP)
83 return strncasecmp(s1, s2, n) == 0;
84 #elif defined(HAVE_STRNICMP)
85 return strnicmp(s1, s2, n) == 0;
87 if (s1 == s2 || n == 0)
90 if (s1 == 0 || s2 == 0)
93 while (n-- && ((*s1 !=
'\0') || (*s2 !=
'\0')))
95 if (!casecompare(*s1, *s2))
Definition: stringutils.h:41