* as/link/hc08/lkihx.c (newArea),
[fw/sdcc] / as / strcmpi.c
1 /* strcmpi.c */
2
3 /*
4  * Compare two strings ignoring case.
5  *
6  * Taken from GLIBC 2.2.5. Original code is copyrighted "Free
7  * Software Foundation" and published under the GNU Lesser General
8  * Public License.
9  * 
10  */
11
12 #include <ctype.h>
13
14 int as_strcmpi (const char *s1, const char *s2)
15 {
16   const unsigned char *p1 = (const unsigned char *) s1;
17   const unsigned char *p2 = (const unsigned char *) s2;
18   unsigned char c1, c2;
19
20   if (p1 == p2)
21     return 0;
22
23   do
24     {
25       c1 = tolower (*p1++);
26       c2 = tolower (*p2++);
27       if (c1 == '\0')
28         break;
29     }
30   while (c1 == c2);
31   
32   return c1 - c2;
33 }
34