mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-31 13:00:49 +00:00
Get rid of ctype dependencies
This commit is contained in:
1 parent
113abc71d4
commit
393dad97e0
6 files changed
+57
-30
No files matched your search
@@ -1212,6 +1212,17 @@ static bool sn(const char *fmt, ...) {
|
||||
return result;
|
||||
}
|
||||
|
||||
static bool sccmp(const char *s1, const char *s2) {
|
||||
int n1 = mg_casecmp(s1, s2);
|
||||
#if MG_ARCH == MG_ARCH_UNIX
|
||||
int n2 = strcasecmp(s1, s2);
|
||||
#else
|
||||
int n2 = mg_casecmp(s1, s2); // On MSVC98, _stricmp() is buggy
|
||||
#endif
|
||||
MG_INFO(("[%s] [%s] %d %d", s1, s2, n1, n2));
|
||||
return n1 == n2;
|
||||
}
|
||||
|
||||
static void test_str(void) {
|
||||
struct mg_str s = mg_strdup(mg_str("a"));
|
||||
ASSERT(mg_strcmp(s, mg_str("a")) == 0);
|
||||
@@ -1223,6 +1234,12 @@ static void test_str(void) {
|
||||
ASSERT(mg_strstr(mg_str("abc"), mg_str("b")) != NULL);
|
||||
ASSERT(mg_strcmp(mg_str("hi"), mg_strstrip(mg_str(" \thi\r\n"))) == 0);
|
||||
|
||||
ASSERT(sccmp("", ""));
|
||||
ASSERT(sccmp("", "1"));
|
||||
ASSERT(sccmp("a", "A"));
|
||||
ASSERT(sccmp("a1", "A"));
|
||||
ASSERT(sccmp("a", "A1"));
|
||||
|
||||
ASSERT(sn("%d", 0));
|
||||
ASSERT(sn("%d", 1));
|
||||
ASSERT(sn("%d", -1));
|
||||
|
||||
Reference in new issue
Block a user