comparison dmd2/gnuc.c @ 758:f04dde6e882c

Added initial D2 support, D2 frontend and changes to codegen to make things compile.
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Tue, 11 Nov 2008 01:38:48 +0100
parents
children
comparison
equal deleted inserted replaced
757:2c730d530c98 758:f04dde6e882c
1
2 // Put functions in here missing from gnu C
3
4 #include "gnuc.h"
5
6 int memicmp(const char *s1, const char *s2, int n)
7 {
8 int result = 0;
9
10 for (int i = 0; i < n; i++)
11 { char c1 = s1[i];
12 char c2 = s2[i];
13
14 result = c1 - c2;
15 if (result)
16 {
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;
24 }
25 }
26 return result;
27 }
28
29 int stricmp(const char *s1, const char *s2)
30 {
31 int result = 0;
32
33 for (;;)
34 { char c1 = *s1;
35 char c2 = *s2;
36
37 result = c1 - c2;
38 if (result)
39 {
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;
47 }
48 if (!c1)
49 break;
50 s1++;
51 s2++;
52 }
53 return result;
54 }
55