Bladeren bron

Move tolower() etc to ctype.h as per ISO C

tags/v0.9.3
Michael Brown 17 jaren geleden
bovenliggende
commit
afe4e011ac
3 gewijzigde bestanden met toevoegingen van 31 en 27 verwijderingen
  1. 1
    0
      src/core/string.c
  2. 28
    0
      src/include/ctype.h
  3. 2
    27
      src/include/string.h

+ 1
- 0
src/core/string.c Bestand weergeven

@@ -24,6 +24,7 @@
24 24
 #include <stdint.h>
25 25
 #include <stdlib.h>
26 26
 #include <string.h>
27
+#include <ctype.h>
27 28
 
28 29
 /* *** FROM string.c *** */
29 30
 

+ 28
- 0
src/include/ctype.h Bestand weergeven

@@ -0,0 +1,28 @@
1
+#ifndef _CTYPE_H
2
+#define _CTYPE_H
3
+
4
+/** @file
5
+ *
6
+ * Character types
7
+ */
8
+
9
+#define isdigit(c)	((c & 0x04) != 0)
10
+#define islower(c)	((c & 0x02) != 0)
11
+//#define isspace(c)	((c & 0x20) != 0)
12
+#define isupper(c)	((c & 0x01) != 0)
13
+
14
+static inline unsigned char tolower(unsigned char c)
15
+{
16
+	if (isupper(c))
17
+		c -= 'A'-'a';
18
+	return c;
19
+}
20
+
21
+static inline unsigned char toupper(unsigned char c)
22
+{
23
+	if (islower(c))
24
+		c -= 'a'-'A';
25
+	return c;
26
+}
27
+
28
+#endif /* _CTYPE_H */

+ 2
- 27
src/include/string.h Bestand weergeven

@@ -14,33 +14,8 @@
14 14
 #ifndef ETHERBOOT_STRING_H
15 15
 #define ETHERBOOT_STRING_H
16 16
 
17
-#include "stddef.h"
18
-#include "bits/string.h"
19
-
20
-
21
-/* *** FROM ctype.h *** */
22
-
23
-#define isdigit(c)	((c & 0x04) != 0)
24
-#define islower(c)	((c & 0x02) != 0)
25
-//#define isspace(c)	((c & 0x20) != 0)
26
-#define isupper(c)	((c & 0x01) != 0)
27
-
28
-static inline unsigned char tolower(unsigned char c)
29
-{
30
-	if (isupper(c))
31
-		c -= 'A'-'a';
32
-	return c;
33
-}
34
-
35
-static inline unsigned char toupper(unsigned char c)
36
-{
37
-	if (islower(c))
38
-		c -= 'a'-'A';
39
-	return c;
40
-}
41
-
42
-
43
-/* *** FROM string.h *** */
17
+#include <stddef.h>
18
+#include <bits/string.h>
44 19
 
45 20
 int strnicmp(const char *s1, const char *s2, size_t len);
46 21
 char * strcpy(char * dest,const char *src);

Laden…
Annuleren
Opslaan