forked from totalspectrum/spin2cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstrcasecmp.c
More file actions
42 lines (36 loc) · 824 Bytes
/
Copy pathstrcasecmp.c
File metadata and controls
42 lines (36 loc) · 824 Bytes
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/* from Henry Spencer's stringlib */
/* modified by ERS */
#include <string.h>
#include <ctype.h>
#include <compiler.h>
/*
* strcasecmp - compare string s1 to s2, ignoring case
*/
int /* <0 for <, 0 for ==, >0 for > */
strcasecmp(const char *scan1, const char *scan2)
{
register int c1, c2;
if (!scan1)
return scan2 ? -1 : 0;
if (!scan2) return 1;
do {
c1 = toupper(*scan1++);
c2 = toupper(*scan2++);
} while (c1 && c1 == c2);
/*
* The following case analysis is necessary so that characters
* which look negative collate low against normal characters but
* high against the end-of-string NUL.
*/
// W21: only if char is signed (in flexspin it isn't)
#if 0
if (c1 == c2)
return(0);
else if (c1 == '\0')
return(-1);
else if (c2 == '\0')
return(1);
else
#endif
return(c1 - c2);
}