diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/libbb.h | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/include/libbb.h b/include/libbb.h index ad0d59d04..805846391 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -1566,8 +1566,11 @@ extern const char bb_default_login_shell[]; | |||
1566 | #define RB_POWER_OFF 0x4321fedc | 1566 | #define RB_POWER_OFF 0x4321fedc |
1567 | #endif | 1567 | #endif |
1568 | 1568 | ||
1569 | /* Make sure we call functions instead of macros. */ | 1569 | /* Make sure we call functions instead of these macros */ |
1570 | #undef isalnum | 1570 | #undef isalnum |
1571 | #undef ispunct | ||
1572 | #undef isxdigit | ||
1573 | /* and these we'll redefine */ | ||
1571 | #undef isalpha | 1574 | #undef isalpha |
1572 | #undef isascii | 1575 | #undef isascii |
1573 | #undef isblank | 1576 | #undef isblank |
@@ -1575,25 +1578,32 @@ extern const char bb_default_login_shell[]; | |||
1575 | #undef isgraph | 1578 | #undef isgraph |
1576 | #undef islower | 1579 | #undef islower |
1577 | #undef isprint | 1580 | #undef isprint |
1578 | #undef ispunct | ||
1579 | #undef isupper | 1581 | #undef isupper |
1580 | #undef isxdigit | 1582 | #undef isdigit |
1583 | #undef isspace | ||
1581 | 1584 | ||
1582 | /* This one is more efficient - we save ~500 bytes. | 1585 | /* This one is more efficient - we save ~500 bytes. |
1583 | * BTW, x86 likes (unsigned char) cast more than (unsigned). */ | 1586 | * BTW, x86 likes (unsigned char) cast more than (unsigned). */ |
1584 | #undef isdigit | ||
1585 | #define isdigit(a) ((unsigned char)((a) - '0') <= 9) | 1587 | #define isdigit(a) ((unsigned char)((a) - '0') <= 9) |
1586 | 1588 | ||
1587 | /* This one is more efficient too! ~200 bytes */ | 1589 | #define isascii(a) ((unsigned char)(a) <= 0x7f) |
1590 | #define isgraph(a) ((unsigned char)(a) > ' ') | ||
1591 | #define isprint(a) ((unsigned char)(a) >= ' ') | ||
1592 | #define isupper(a) ((unsigned char)((a) - 'A') <= ('Z' - 'A')) | ||
1593 | #define islower(a) ((unsigned char)((a) - 'a') <= ('z' - 'a')) | ||
1594 | #define isalpha(a) ((unsigned char)(((a) | 0x20) - 'a') <= ('z' - 'a')) | ||
1595 | #define isblank(a) ({ unsigned char bb__isblank = (a); bb__isblank == ' ' || bb__isblank == '\t'; }) | ||
1596 | #define iscntrl(a) ({ unsigned char bb__iscntrl = (a); bb__iscntrl < ' ' || bb__iscntrl == 0x7f; }) | ||
1597 | |||
1588 | /* In POSIX/C locale (the only locale we care about: do we REALLY want | 1598 | /* In POSIX/C locale (the only locale we care about: do we REALLY want |
1589 | * to allow Unicode whitespace in, say, .conf files? nuts!) | 1599 | * to allow Unicode whitespace in, say, .conf files? nuts!) |
1590 | * isspace is only these chars: "\t\n\v\f\r" and space. | 1600 | * isspace is only these chars: "\t\n\v\f\r" and space. |
1591 | * "\t\n\v\f\r" happen to have ASCII codes 9,10,11,12,13. | 1601 | * "\t\n\v\f\r" happen to have ASCII codes 9,10,11,12,13. |
1592 | * Use that. | 1602 | * Use that. |
1593 | */ | 1603 | */ |
1594 | #undef isspace | ||
1595 | #define isspace(a) ({ unsigned char bb__isspace = (a) - 9; bb__isspace == (' ' - 9) || bb__isspace <= (13 - 9); }) | 1604 | #define isspace(a) ({ unsigned char bb__isspace = (a) - 9; bb__isspace == (' ' - 9) || bb__isspace <= (13 - 9); }) |
1596 | 1605 | ||
1606 | |||
1597 | #define ARRAY_SIZE(x) ((unsigned)(sizeof(x) / sizeof((x)[0]))) | 1607 | #define ARRAY_SIZE(x) ((unsigned)(sizeof(x) / sizeof((x)[0]))) |
1598 | 1608 | ||
1599 | 1609 | ||