File: strcasecmp.c

package info (click to toggle)
fetchmail 6.3.6-1
  • links: PTS
  • area: main
  • in suites: etch-m68k
  • size: 6,336 kB
  • ctags: 3,609
  • sloc: ansic: 26,407; sh: 4,967; perl: 3,180; python: 1,920; yacc: 448; makefile: 331; lex: 277; awk: 124; lisp: 84; sed: 16
file content (23 lines) | stat: -rw-r--r-- 662 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/* 
 * scratch implementation of strcasecmp(), 
 * in case your C library doesn't have it 
 *
 * For license terms, see the file COPYING in this directory.
 */
#include <ctype.h>

int strcasecmp(char *s1, char *s2)
{
    while (toupper((unsigned char)*s1) == toupper((unsigned char)*s2++))
	if (*s1++ == '\0')
	    return 0;
    return(toupper((unsigned char)*s1) - toupper((unsigned char)*--s2));
}

int strncasecmp(char *s1, char *s2, register int n)
{
    while (--n >= 0 && toupper((unsigned char)*s1) == toupper((unsigned char)*s2++))
	if (*s1++ == '\0')
	    return 0;
    return(n < 0 ? 0 : toupper((unsigned char)*s1) - toupper((unsigned char)*--s2));
}