]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[libc] Fix isdigit(), islower() and isupper().
authorMichael Brown <mcb30@etherboot.org>
Mon, 19 May 2008 15:34:17 +0000 (16:34 +0100)
committerMichael Brown <mcb30@etherboot.org>
Mon, 19 May 2008 15:34:17 +0000 (16:34 +0100)
From: Stefan Hajnoczi <stefanha@gmail.com>

src/drivers/net/mlx_ipoib/mt23108.c
src/drivers/net/mlx_ipoib/mt25218.c
src/include/ctype.h

index 492bc901fae47114d9e990ff45201f610815a080..e1f61db6be12c6eeb095e3fac9ba7995e1a0b5ef 100644 (file)
@@ -10,6 +10,8 @@ Skeleton NIC driver for Etherboot
  * your option) any later version.
  */
 
+/* to get toupper() */
+#include <ctype.h>
 /* to get some global routines like printf */
 #include "etherboot.h"
 /* to get the interface to the body of the program */
@@ -31,12 +33,7 @@ int prompt_key(int secs, unsigned char *ch_p)
 
        for (tmo = currticks() + secs * TICKS_PER_SEC; currticks() < tmo;) {
                if (iskey()) {
-                       ch = getchar();
-                       /* toupper does not work ... */
-                       if (ch == 'v')
-                               ch = 'V';
-                       if (ch == 'i')
-                               ch = 'I';
+                       ch = toupper(getchar());
                        if ((ch=='V') || (ch=='I')) {
                                *ch_p = ch;
                                return 1;
index a603cdeb5dc851dcdb06dad166879fc12dcd22ac..8a252eaefb959a3aeac2c7735ae884daf1d7c104 100644 (file)
@@ -10,6 +10,8 @@ Skeleton NIC driver for Etherboot
  * your option) any later version.
  */
 
+/* to get toupper() */
+#include <ctype.h>
 /* to get some global routines like printf */
 #include "etherboot.h"
 /* to get the interface to the body of the program */
@@ -31,12 +33,7 @@ int prompt_key(int secs, unsigned char *ch_p)
 
        for (tmo = currticks() + secs * TICKS_PER_SEC; currticks() < tmo;) {
                if (iskey()) {
-                       ch = getchar();
-                       /* toupper does not work ... */
-                       if (ch == 'v')
-                               ch = 'V';
-                       if (ch == 'i')
-                               ch = 'I';
+                       ch = toupper(getchar());
                        if ((ch=='V') || (ch=='I')) {
                                *ch_p = ch;
                                return 1;
index a79395d2a3bd61066c975c7478a0493a53ff7e8b..7740443d98884e38bc6e171552774da633829790 100644 (file)
@@ -6,10 +6,9 @@
  * Character types
  */
 
-#define isdigit(c)     ((c & 0x04) != 0)
-#define islower(c)     ((c & 0x02) != 0)
-//#define isspace(c)   ((c & 0x20) != 0)
-#define isupper(c)     ((c & 0x01) != 0)
+#define isdigit(c)     ((c) >= '0' && (c) <= '9')
+#define islower(c)     ((c) >= 'a' && (c) <= 'z')
+#define isupper(c)     ((c) >= 'A' && (c) <= 'Z')
 
 static inline unsigned char tolower(unsigned char c)
 {