File: strcasecmp.c

package info (click to toggle)
coda 2.21.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 9,320 kB
  • sloc: ansic: 125,785; javascript: 6,732; java: 2,391; yacc: 1,007; python: 872; makefile: 615; lex: 204; sh: 99; fortran: 60; xml: 5
file content (26 lines) | stat: -rw-r--r-- 435 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <ctype.h>
#include <string.h>

int strcasecmp(const char *s1, const char *s2)
{
    unsigned char us1;
    unsigned char us2;
    size_t index;
    
    us1 = tolower(*s1);
    us2 = tolower(*s2);

    index = 0;
    while (us1 != '\0' && us1 == us2)
    {
        index++;
        us1 = tolower(s1[index]);
        us2 = tolower(s2[index]);
    }
    
    return us1 - us2;
}