root/branches/dmdfe-2.0/gnuc.c

Revision 360, 0.8 kB (checked in by Gregor, 2 years ago)

Initial import.

Line 
1 // Put functions in here missing from gnu C
2
3 #include "gnuc.h"
4
5 int memicmp(const char *s1, const char *s2, int n)
6 {
7     int result = 0;
8
9     for (int i = 0; i < n; i++)
10     {   char c1 = s1[i];
11     char c2 = s2[i];
12
13     result = c1 - c2;
14     if (result)
15     {
16         if ('A' <= c1 && c1 <= 'Z')
17         c1 += 'a' - 'A';
18         if ('A' <= c2 && c2 <= 'Z')
19         c2 += 'a' - 'A';
20         result = c1 - c2;
21         if (result)
22         break;
23     }
24     }
25     return result;
26 }
27
28 int stricmp(const char *s1, const char *s2)
29 {
30     int result = 0;
31
32     for (;;)
33     {   char c1 = *s1;
34     char c2 = *s2;
35
36     result = c1 - c2;
37     if (result)
38     {
39         if ('A' <= c1 && c1 <= 'Z')
40         c1 += 'a' - 'A';
41         if ('A' <= c2 && c2 <= 'Z')
42         c2 += 'a' - 'A';
43         result = c1 - c2;
44         if (result)
45         break;
46     }
47     if (!c1)
48         break;
49     s1++;
50     s2++;
51     }
52     return result;
53 }
Note: See TracBrowser for help on using the browser.