aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2006-11-27 14:44:18 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2006-11-27 14:44:18 +0000
commit459903bd4e270ab4884ba9577516f9b2753898b0 (patch)
tree8dd4e8a4db28561fad1dcaeabee936a3aad7187c
parentd686a045c8134d3a42fa5cc6b2e09118e08d603f (diff)
downloadbusybox-459903bd4e270ab4884ba9577516f9b2753898b0.tar.gz
Provide our own isdigit macro. saves more than 400 bytes.
-rw-r--r--coreutils/head.c5
-rw-r--r--coreutils/od.c2
-rw-r--r--coreutils/tail.c9
-rw-r--r--include/libbb.h6
-rw-r--r--sysklogd/syslogd.c2
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)
#if !ENABLE_DEBUG_YANK_SUSv2 || ENABLE_FEATURE_FANCY_HEAD
/* Allow legacy syntax of an initial numeric option without -n. */
- if ((argc > 1) && (argv[1][0] == '-')
- /* && (isdigit)(argv[1][1]) */
- && (((unsigned int)(argv[1][1] - '0')) <= 9)
+ if (argc > 1 && argv[1][0] == '-'
+ && isdigit(argv[1][1])
) {
--argc;
++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 @@
#include "busybox.h"
#include "dump.h"
-#define isdecdigit(c) (isdigit)(c)
+#define isdecdigit(c) isdigit(c)
#define ishexdigit(c) (isxdigit)(c)
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";
int tail_main(int argc, char **argv)
{
long count = 10;
- unsigned int sleep_period = 1;
+ unsigned sleep_period = 1;
int from_top = 0;
int follow = 0;
int header_threshhold = 1;
@@ -110,10 +110,9 @@ int tail_main(int argc, char **argv)
#if !ENABLE_DEBUG_YANK_SUSv2 || ENABLE_FEATURE_FANCY_TAIL
/* Allow legacy syntax of an initial numeric option without -n. */
- if (argc >=2 && ((argv[1][0] == '+') || ((argv[1][0] == '-')
- /* && (isdigit)(argv[1][1]) */
- && (((unsigned int)(argv[1][1] - '0')) <= 9))))
- {
+ if (argc >= 2 && (argv[1][0] == '+' || argv[1][0] == '-')
+ && isdigit(argv[1][1])
+ ) {
optind = 2;
optarg = argv[1];
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[];
#undef isascii
#undef isblank
#undef iscntrl
-#undef isdigit
#undef isgraph
#undef islower
#undef isprint
@@ -675,6 +674,11 @@ extern const char bb_default_login_shell[];
#undef isupper
#undef isxdigit
+/* This one is more efficient - we save ~400 bytes */
+#undef isdigit
+#define isdigit(a) ((unsigned)((a) - '0') <= 9)
+
+
#ifdef DMALLOC
#include <dmalloc.h>
#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)
/* Parse the magic priority number. */
num_lt++;
pri = 0;
- while (isdigit(*(++p))) {
+ while (isdigit(*++p)) {
pri = 10 * pri + (*p - '0');
}
if (pri & ~(LOG_FACMASK | LOG_PRIMASK)) {