mirror of
https://git.planet-casio.com/Vhex-Kernel-Core/fxlibc.git
synced 2024-12-29 13:03:38 +01:00
ctype: test and fix character class functions (DONE)
This commit is contained in:
parent
d70a2c671c
commit
50629bf479
3 changed files with 9 additions and 8 deletions
2
STATUS
2
STATUS
|
@ -31,7 +31,7 @@ DONE: Function/symbol/macro is defined, builds, links, and is tested
|
||||||
TODO: Check standard compliance
|
TODO: Check standard compliance
|
||||||
|
|
||||||
7.4 <ctype.h>
|
7.4 <ctype.h>
|
||||||
7.4.1 is*: TEST
|
7.4.1 is*: DONE
|
||||||
7.4.2 to*: TEST
|
7.4.2 to*: TEST
|
||||||
|
|
||||||
7.5 <errno.h>
|
7.5 <errno.h>
|
||||||
|
|
|
@ -4,8 +4,9 @@
|
||||||
/*
|
/*
|
||||||
** Character classification functions. These are all implemented as sets of
|
** Character classification functions. These are all implemented as sets of
|
||||||
** comparisons. There is an approach with a 128-byte table, but it takes more
|
** comparisons. There is an approach with a 128-byte table, but it takes more
|
||||||
** space; every function but isalnum, ispunct and isxdigit needs less code to
|
** space; in fact, every function but isalnum, ispunct and isxdigit needs less
|
||||||
** compare than lookup, and using just one won't pull the whole table.
|
** code to compare than to perform the lookup. Additionally, users won't need
|
||||||
|
** the whole table for a single call to isspace().
|
||||||
*/
|
*/
|
||||||
extern int isalnum(int c);
|
extern int isalnum(int c);
|
||||||
extern int isalpha(int c);
|
extern int isalpha(int c);
|
||||||
|
@ -31,8 +32,8 @@ extern int toupper(int c);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define isalnum(c) ({ \
|
#define isalnum(c) ({ \
|
||||||
int __c = (c); \
|
int __c0 = (c); \
|
||||||
isalpha(c) || isdigit(c); \
|
isalpha(__c0) || isdigit(__c0); \
|
||||||
})
|
})
|
||||||
|
|
||||||
#define isalpha(c) ({ \
|
#define isalpha(c) ({ \
|
||||||
|
@ -67,7 +68,7 @@ extern int toupper(int c);
|
||||||
|
|
||||||
#define isprint(c) ({ \
|
#define isprint(c) ({ \
|
||||||
int __c = (c); \
|
int __c = (c); \
|
||||||
(__c >= 32) || (__c < 0x7f); \
|
(__c >= 32) && (__c < 0x7f); \
|
||||||
})
|
})
|
||||||
|
|
||||||
#define ispunct(c) ({ \
|
#define ispunct(c) ({ \
|
||||||
|
@ -89,7 +90,7 @@ extern int toupper(int c);
|
||||||
#define isxdigit(c) ({ \
|
#define isxdigit(c) ({ \
|
||||||
int __c = (c); \
|
int __c = (c); \
|
||||||
int __c20 = __c | 0x20; \
|
int __c20 = __c | 0x20; \
|
||||||
(__c >= '0' && __c <= '9') || (__c20 >= 'a' && __c20 <= 'z'); \
|
(__c >= '0' && __c <= '9') || (__c20 >= 'a' && __c20 <= 'f'); \
|
||||||
})
|
})
|
||||||
|
|
||||||
#define tolower(c) ({ \
|
#define tolower(c) ({ \
|
||||||
|
|
|
@ -4,5 +4,5 @@
|
||||||
int isxdigit(int c)
|
int isxdigit(int c)
|
||||||
{
|
{
|
||||||
int c20 = c | 0x20;
|
int c20 = c | 0x20;
|
||||||
return (c >= '0' && c <= '9') || (c20 >= 'a' && c20 <= 'z');
|
return (c >= '0' && c <= '9') || (c20 >= 'a' && c20 <= 'f');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue