source: trunk/minix/lib/ip/strcasecmp.c@ 20

Last change on this file since 20 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 651 bytes
Line 
1/*
2strcasecmp.c
3
4Created Oct 14, 1991 by Philip Homburg
5*/
6
7#include <ctype.h>
8#include <string.h>
9
10#ifdef __STDC__
11#define _CONST const
12#else
13#define _CONST
14#endif
15
16int
17strcasecmp(s1, s2)
18_CONST char *s1, *s2;
19{
20 int c1, c2;
21 while (c1= toupper(*s1++), c2= toupper(*s2++), c1 == c2 && (c1 & c2))
22 ;
23 if (c1 & c2)
24 return c1 < c2 ? -1 : 1;
25 return c1 ? 1 : (c2 ? -1 : 0);
26}
27
28int
29strncasecmp(s1, s2, len)
30_CONST char *s1, *s2;
31size_t len;
32{
33 int c1, c2;
34 do {
35 if (len == 0)
36 return 0;
37 len--;
38 } while (c1= toupper(*s1++), c2= toupper(*s2++), c1 == c2 && (c1 & c2))
39 ;
40 if (c1 & c2)
41 return c1 < c2 ? -1 : 1;
42 return c1 ? 1 : (c2 ? -1 : 0);
43}
Note: See TracBrowser for help on using the repository browser.