Provide our own isdigit macro. saves more than 400 bytes.
authorDenis Vlasenko <vda.linux@googlemail.com>
Mon, 27 Nov 2006 14:44:18 +0000 (14:44 -0000)
committerDenis Vlasenko <vda.linux@googlemail.com>
Mon, 27 Nov 2006 14:44:18 +0000 (14:44 -0000)
coreutils/head.c
coreutils/od.c
coreutils/tail.c
include/libbb.h
sysklogd/syslogd.c

index d732461f772eb5111469d5cbe7cf37522de50262..f2c948300308cd0601b46c7c0d1d43b2d080c887 100644 (file)
@@ -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;
index 9a2d4c3432ed80dbb486932a064300b1c215141c..8de86628140414af6484e30d5e4144c3ed973ff1 100644 (file)
@@ -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
index 82c0d99bcc929d21b69ef58b188dbeedfa5e418c..ed5ea14671d80cf9d5b0cceed2c1636c5028db0f 100644 (file)
@@ -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;
index 63748c85df0a5f7df6e2a8cf1fddbe9a4cc0b5f7..baab74878e23f444395f68513778ebb1073c8b1f 100644 (file)
@@ -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
index 9e030bd63dd957a66acdbae4ef57e1bf6d1aa51a..453cbda35d68355f3664cfdc38ee290b03486c39 100644 (file)
@@ -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)) {