comparison dmd2/root/gnuc.c @ 1452:638d16625da2

LDC 2 compiles again.
author Robert Clipsham <robert@octarineparrot.com>
date Sat, 30 May 2009 17:23:32 +0100
parents
children
comparison
equal deleted inserted replaced
1423:42bd767ec5a4 1452:638d16625da2
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