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