Subversion Repositories freemyipod

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
72 theseven 1
#include "global.h"
111 theseven 2
#include "string.h"
3
#include "libc/include/ctype.h"
72 theseven 4
 
5
int strcasecmp(const char *s1, const char *s2)
6
{
7
    while (*s1 != '\0' && tolower(*s1) == tolower(*s2)) {
8
        s1++;
9
        s2++;
10
    }
11
 
12
    return tolower(*(unsigned char *) s1) - tolower(*(unsigned char *) s2);
13
}
14
 
15
int strncasecmp(const char *s1, const char *s2, size_t n)
16
{
17
    int d = 0;
18
 
19
    for(; n != 0; n--)
20
    {
21
        int c1 = tolower(*s1++);
22
        int c2 = tolower(*s2++);
23
        if((d = c1 - c2) != 0 || c2 == '\0')
24
            break;
25
    }
26
 
27
    return d;
28
}