diff options
author | vda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-11-27 14:44:18 +0000 |
---|---|---|
committer | vda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-11-27 14:44:18 +0000 |
commit | f9cc9081205c29917da34460395b6da2dc4c4567 (patch) | |
tree | 8dd4e8a4db28561fad1dcaeabee936a3aad7187c | |
parent | 278809224505ecc8bbef7b9a86982bf35b46e719 (diff) | |
download | busybox-w32-f9cc9081205c29917da34460395b6da2dc4c4567.tar.gz busybox-w32-f9cc9081205c29917da34460395b6da2dc4c4567.tar.bz2 busybox-w32-f9cc9081205c29917da34460395b6da2dc4c4567.zip |
Provide our own isdigit macro. saves more than 400 bytes.
git-svn-id: svn://busybox.net/trunk/busybox@16685 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r-- | coreutils/head.c | 5 | ||||
-rw-r--r-- | coreutils/od.c | 2 | ||||
-rw-r--r-- | coreutils/tail.c | 9 | ||||
-rw-r--r-- | include/libbb.h | 6 | ||||
-rw-r--r-- | sysklogd/syslogd.c | 2 |
5 files changed, 13 insertions, 11 deletions
diff --git a/coreutils/head.c b/coreutils/head.c index d732461f7..f2c948300 100644 --- a/coreutils/head.c +++ b/coreutils/head.c | |||
@@ -49,9 +49,8 @@ int head_main(int argc, char **argv) | |||
49 | 49 | ||
50 | #if !ENABLE_DEBUG_YANK_SUSv2 || ENABLE_FEATURE_FANCY_HEAD | 50 | #if !ENABLE_DEBUG_YANK_SUSv2 || ENABLE_FEATURE_FANCY_HEAD |
51 | /* Allow legacy syntax of an initial numeric option without -n. */ | 51 | /* Allow legacy syntax of an initial numeric option without -n. */ |
52 | if ((argc > 1) && (argv[1][0] == '-') | 52 | if (argc > 1 && argv[1][0] == '-' |
53 | /* && (isdigit)(argv[1][1]) */ | 53 | && isdigit(argv[1][1]) |
54 | && (((unsigned int)(argv[1][1] - '0')) <= 9) | ||
55 | ) { | 54 | ) { |
56 | --argc; | 55 | --argc; |
57 | ++argv; | 56 | ++argv; |
diff --git a/coreutils/od.c b/coreutils/od.c index 9a2d4c343..8de866281 100644 --- a/coreutils/od.c +++ b/coreutils/od.c | |||
@@ -21,7 +21,7 @@ | |||
21 | #include "busybox.h" | 21 | #include "busybox.h" |
22 | #include "dump.h" | 22 | #include "dump.h" |
23 | 23 | ||
24 | #define isdecdigit(c) (isdigit)(c) | 24 | #define isdecdigit(c) isdigit(c) |
25 | #define ishexdigit(c) (isxdigit)(c) | 25 | #define ishexdigit(c) (isxdigit)(c) |
26 | 26 | ||
27 | static void | 27 | static void |
diff --git a/coreutils/tail.c b/coreutils/tail.c index 82c0d99bc..ed5ea1467 100644 --- a/coreutils/tail.c +++ b/coreutils/tail.c | |||
@@ -93,7 +93,7 @@ static const char header_fmt[] = "\n==> %s <==\n"; | |||
93 | int tail_main(int argc, char **argv) | 93 | int tail_main(int argc, char **argv) |
94 | { | 94 | { |
95 | long count = 10; | 95 | long count = 10; |
96 | unsigned int sleep_period = 1; | 96 | unsigned sleep_period = 1; |
97 | int from_top = 0; | 97 | int from_top = 0; |
98 | int follow = 0; | 98 | int follow = 0; |
99 | int header_threshhold = 1; | 99 | int header_threshhold = 1; |
@@ -110,10 +110,9 @@ int tail_main(int argc, char **argv) | |||
110 | 110 | ||
111 | #if !ENABLE_DEBUG_YANK_SUSv2 || ENABLE_FEATURE_FANCY_TAIL | 111 | #if !ENABLE_DEBUG_YANK_SUSv2 || ENABLE_FEATURE_FANCY_TAIL |
112 | /* Allow legacy syntax of an initial numeric option without -n. */ | 112 | /* Allow legacy syntax of an initial numeric option without -n. */ |
113 | if (argc >=2 && ((argv[1][0] == '+') || ((argv[1][0] == '-') | 113 | if (argc >= 2 && (argv[1][0] == '+' || argv[1][0] == '-') |
114 | /* && (isdigit)(argv[1][1]) */ | 114 | && isdigit(argv[1][1]) |
115 | && (((unsigned int)(argv[1][1] - '0')) <= 9)))) | 115 | ) { |
116 | { | ||
117 | optind = 2; | 116 | optind = 2; |
118 | optarg = argv[1]; | 117 | optarg = argv[1]; |
119 | goto GET_COUNT; | 118 | goto GET_COUNT; |
diff --git a/include/libbb.h b/include/libbb.h index 63748c85d..baab74878 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -666,7 +666,6 @@ extern const char bb_default_login_shell[]; | |||
666 | #undef isascii | 666 | #undef isascii |
667 | #undef isblank | 667 | #undef isblank |
668 | #undef iscntrl | 668 | #undef iscntrl |
669 | #undef isdigit | ||
670 | #undef isgraph | 669 | #undef isgraph |
671 | #undef islower | 670 | #undef islower |
672 | #undef isprint | 671 | #undef isprint |
@@ -675,6 +674,11 @@ extern const char bb_default_login_shell[]; | |||
675 | #undef isupper | 674 | #undef isupper |
676 | #undef isxdigit | 675 | #undef isxdigit |
677 | 676 | ||
677 | /* This one is more efficient - we save ~400 bytes */ | ||
678 | #undef isdigit | ||
679 | #define isdigit(a) ((unsigned)((a) - '0') <= 9) | ||
680 | |||
681 | |||
678 | #ifdef DMALLOC | 682 | #ifdef DMALLOC |
679 | #include <dmalloc.h> | 683 | #include <dmalloc.h> |
680 | #endif | 684 | #endif |
diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c index 9e030bd63..453cbda35 100644 --- a/sysklogd/syslogd.c +++ b/sysklogd/syslogd.c | |||
@@ -468,7 +468,7 @@ static int serveConnection(char *tmpbuf, int n_read) | |||
468 | /* Parse the magic priority number. */ | 468 | /* Parse the magic priority number. */ |
469 | num_lt++; | 469 | num_lt++; |
470 | pri = 0; | 470 | pri = 0; |
471 | while (isdigit(*(++p))) { | 471 | while (isdigit(*++p)) { |
472 | pri = 10 * pri + (*p - '0'); | 472 | pri = 10 * pri + (*p - '0'); |
473 | } | 473 | } |
474 | if (pri & ~(LOG_FACMASK | LOG_PRIMASK)) { | 474 | if (pri & ~(LOG_FACMASK | LOG_PRIMASK)) { |