Browse Source

[libc] Fix isdigit(), islower() and isupper().

From: Stefan Hajnoczi <stefanha@gmail.com>
tags/v0.9.4
Michael Brown 16 years ago
parent
commit
7d01bf663e

+ 3
- 6
src/drivers/net/mlx_ipoib/mt23108.c View File

10
  * your option) any later version.
10
  * your option) any later version.
11
  */
11
  */
12
 
12
 
13
+/* to get toupper() */
14
+#include <ctype.h>
13
 /* to get some global routines like printf */
15
 /* to get some global routines like printf */
14
 #include "etherboot.h"
16
 #include "etherboot.h"
15
 /* to get the interface to the body of the program */
17
 /* to get the interface to the body of the program */
31
 
33
 
32
 	for (tmo = currticks() + secs * TICKS_PER_SEC; currticks() < tmo;) {
34
 	for (tmo = currticks() + secs * TICKS_PER_SEC; currticks() < tmo;) {
33
 		if (iskey()) {
35
 		if (iskey()) {
34
-			ch = getchar();
35
-			/* toupper does not work ... */
36
-			if (ch == 'v')
37
-				ch = 'V';
38
-			if (ch == 'i')
39
-				ch = 'I';
36
+			ch = toupper(getchar());
40
 			if ((ch=='V') || (ch=='I')) {
37
 			if ((ch=='V') || (ch=='I')) {
41
 				*ch_p = ch;
38
 				*ch_p = ch;
42
 				return 1;
39
 				return 1;

+ 3
- 6
src/drivers/net/mlx_ipoib/mt25218.c View File

10
  * your option) any later version.
10
  * your option) any later version.
11
  */
11
  */
12
 
12
 
13
+/* to get toupper() */
14
+#include <ctype.h>
13
 /* to get some global routines like printf */
15
 /* to get some global routines like printf */
14
 #include "etherboot.h"
16
 #include "etherboot.h"
15
 /* to get the interface to the body of the program */
17
 /* to get the interface to the body of the program */
31
 
33
 
32
 	for (tmo = currticks() + secs * TICKS_PER_SEC; currticks() < tmo;) {
34
 	for (tmo = currticks() + secs * TICKS_PER_SEC; currticks() < tmo;) {
33
 		if (iskey()) {
35
 		if (iskey()) {
34
-			ch = getchar();
35
-			/* toupper does not work ... */
36
-			if (ch == 'v')
37
-				ch = 'V';
38
-			if (ch == 'i')
39
-				ch = 'I';
36
+			ch = toupper(getchar());
40
 			if ((ch=='V') || (ch=='I')) {
37
 			if ((ch=='V') || (ch=='I')) {
41
 				*ch_p = ch;
38
 				*ch_p = ch;
42
 				return 1;
39
 				return 1;

+ 3
- 4
src/include/ctype.h View File

6
  * Character types
6
  * Character types
7
  */
7
  */
8
 
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)
9
+#define isdigit(c)	((c) >= '0' && (c) <= '9')
10
+#define islower(c)	((c) >= 'a' && (c) <= 'z')
11
+#define isupper(c)	((c) >= 'A' && (c) <= 'Z')
13
 
12
 
14
 static inline unsigned char tolower(unsigned char c)
13
 static inline unsigned char tolower(unsigned char c)
15
 {
14
 {

Loading…
Cancel
Save