File: strcasecmp.c

package info (click to toggle)
makedepf90 3.0.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 420 kB
  • sloc: ansic: 997; yacc: 356; lex: 224; makefile: 204; sh: 153
file content (23 lines) | stat: -rw-r--r-- 438 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <ctype.h>

int strcasecmp (const char *s1, const char *s2)
/* 
 * Use in case no 'strcasecmp' is found in libc on the system
 */
{
    int diff;

    while (*s1 && *s2) {
        if ((diff = (int) tolower(*s1) - (int) tolower(*s2)) != 0)  
            return diff;
        s1++;
        s2++;
    }

    if (*s1 == '\0' && *s2 == '\0') 
        return 0;
    else if (*s1 == '\0')
        return -1;
    else
        return 1;
}