david/ipxe
david
/
ipxe
Archived
1
0
Fork 0

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

From: Stefan Hajnoczi <stefanha@gmail.com>
This commit is contained in:
Michael Brown 2008-05-19 16:34:17 +01:00
parent 78281b09e6
commit 7d01bf663e
3 changed files with 9 additions and 16 deletions

View File

@ -10,6 +10,8 @@ Skeleton NIC driver for Etherboot
* your option) any later version. * your option) any later version.
*/ */
/* to get toupper() */
#include <ctype.h>
/* to get some global routines like printf */ /* to get some global routines like printf */
#include "etherboot.h" #include "etherboot.h"
/* to get the interface to the body of the program */ /* 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;) { for (tmo = currticks() + secs * TICKS_PER_SEC; currticks() < tmo;) {
if (iskey()) { if (iskey()) {
ch = getchar(); ch = toupper(getchar());
/* toupper does not work ... */
if (ch == 'v')
ch = 'V';
if (ch == 'i')
ch = 'I';
if ((ch=='V') || (ch=='I')) { if ((ch=='V') || (ch=='I')) {
*ch_p = ch; *ch_p = ch;
return 1; return 1;

View File

@ -10,6 +10,8 @@ Skeleton NIC driver for Etherboot
* your option) any later version. * your option) any later version.
*/ */
/* to get toupper() */
#include <ctype.h>
/* to get some global routines like printf */ /* to get some global routines like printf */
#include "etherboot.h" #include "etherboot.h"
/* to get the interface to the body of the program */ /* 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;) { for (tmo = currticks() + secs * TICKS_PER_SEC; currticks() < tmo;) {
if (iskey()) { if (iskey()) {
ch = getchar(); ch = toupper(getchar());
/* toupper does not work ... */
if (ch == 'v')
ch = 'V';
if (ch == 'i')
ch = 'I';
if ((ch=='V') || (ch=='I')) { if ((ch=='V') || (ch=='I')) {
*ch_p = ch; *ch_p = ch;
return 1; return 1;

View File

@ -6,10 +6,9 @@
* Character types * Character types
*/ */
#define isdigit(c) ((c & 0x04) != 0) #define isdigit(c) ((c) >= '0' && (c) <= '9')
#define islower(c) ((c & 0x02) != 0) #define islower(c) ((c) >= 'a' && (c) <= 'z')
//#define isspace(c) ((c & 0x20) != 0) #define isupper(c) ((c) >= 'A' && (c) <= 'Z')
#define isupper(c) ((c & 0x01) != 0)
static inline unsigned char tolower(unsigned char c) static inline unsigned char tolower(unsigned char c)
{ {