mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 08:18:11 +00:00
Compat work towards porting vim.
This commit is contained in:
parent
2e5b9d318f
commit
a356746d04
17 changed files with 200 additions and 77 deletions
|
@ -1,16 +1,36 @@
|
|||
#include <strings.h>
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
|
||||
extern "C" {
|
||||
|
||||
int strcasecmp(const char*, const char*)
|
||||
static char foldcase(char ch)
|
||||
{
|
||||
assert(false);
|
||||
if (isalpha(ch))
|
||||
return tolower(ch);
|
||||
return ch;
|
||||
}
|
||||
|
||||
int strncasecmp(const char*, const char*, size_t)
|
||||
int strcasecmp(const char* s1, const char* s2)
|
||||
{
|
||||
assert(false);
|
||||
for (; foldcase(*s1) == foldcase(*s2); ++s1, ++s2) {
|
||||
if (*s1 == 0)
|
||||
return 0;
|
||||
}
|
||||
return foldcase(*(const unsigned char*)s1) < foldcase(*(const unsigned char*)s2) ? -1 : 1;
|
||||
}
|
||||
|
||||
int strncasecmp(const char* s1, const char* s2, size_t n)
|
||||
{
|
||||
if (!n)
|
||||
return 0;
|
||||
do {
|
||||
if (foldcase(*s1) != foldcase(*s2++))
|
||||
return foldcase(*(const unsigned char*)s1) - foldcase(*(const unsigned char*)--s2);
|
||||
if (*s1++ == 0)
|
||||
break;
|
||||
} while (--n);
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue