Cope with Main not being a class.
[delight/core.git] / dmd2 / gnuc.c
blob849d1e4df602dd4fed4135b7ae895b2edb168327
2 // Put functions in here missing from gnu C
4 #include "gnuc.h"
6 int memicmp(const char *s1, const char *s2, int n)
8 int result = 0;
10 for (int i = 0; i < n; i++)
11 { char c1 = s1[i];
12 char c2 = s2[i];
14 result = c1 - c2;
15 if (result)
17 if ('A' <= c1 && c1 <= 'Z')
18 c1 += 'a' - 'A';
19 if ('A' <= c2 && c2 <= 'Z')
20 c2 += 'a' - 'A';
21 result = c1 - c2;
22 if (result)
23 break;
26 return result;
29 int stricmp(const char *s1, const char *s2)
31 int result = 0;
33 for (;;)
34 { char c1 = *s1;
35 char c2 = *s2;
37 result = c1 - c2;
38 if (result)
40 if ('A' <= c1 && c1 <= 'Z')
41 c1 += 'a' - 'A';
42 if ('A' <= c2 && c2 <= 'Z')
43 c2 += 'a' - 'A';
44 result = c1 - c2;
45 if (result)
46 break;
48 if (!c1)
49 break;
50 s1++;
51 s2++;
53 return result;