svn commit: trunk/busybox: coreutils include sysklogd

vda at busybox.net vda at busybox.net
Mon Nov 27 14:44:19 UTC 2006


Author: vda
Date: 2006-11-27 06:44:18 -0800 (Mon, 27 Nov 2006)
New Revision: 16685

Log:
Provide our own isdigit macro. saves more than 400 bytes.


Modified:
   trunk/busybox/coreutils/head.c
   trunk/busybox/coreutils/od.c
   trunk/busybox/coreutils/tail.c
   trunk/busybox/include/libbb.h
   trunk/busybox/sysklogd/syslogd.c


Changeset:
Modified: trunk/busybox/coreutils/head.c
===================================================================
--- trunk/busybox/coreutils/head.c	2006-11-27 14:43:21 UTC (rev 16684)
+++ trunk/busybox/coreutils/head.c	2006-11-27 14:44:18 UTC (rev 16685)
@@ -49,9 +49,8 @@
 
 #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;

Modified: trunk/busybox/coreutils/od.c
===================================================================
--- trunk/busybox/coreutils/od.c	2006-11-27 14:43:21 UTC (rev 16684)
+++ trunk/busybox/coreutils/od.c	2006-11-27 14:44:18 UTC (rev 16685)
@@ -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

Modified: trunk/busybox/coreutils/tail.c
===================================================================
--- trunk/busybox/coreutils/tail.c	2006-11-27 14:43:21 UTC (rev 16684)
+++ trunk/busybox/coreutils/tail.c	2006-11-27 14:44:18 UTC (rev 16685)
@@ -93,7 +93,7 @@
 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 @@
 
 #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;

Modified: trunk/busybox/include/libbb.h
===================================================================
--- trunk/busybox/include/libbb.h	2006-11-27 14:43:21 UTC (rev 16684)
+++ trunk/busybox/include/libbb.h	2006-11-27 14:44:18 UTC (rev 16685)
@@ -666,7 +666,6 @@
 #undef isascii
 #undef isblank
 #undef iscntrl
-#undef isdigit
 #undef isgraph
 #undef islower
 #undef isprint
@@ -675,6 +674,11 @@
 #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

Modified: trunk/busybox/sysklogd/syslogd.c
===================================================================
--- trunk/busybox/sysklogd/syslogd.c	2006-11-27 14:43:21 UTC (rev 16684)
+++ trunk/busybox/sysklogd/syslogd.c	2006-11-27 14:44:18 UTC (rev 16685)
@@ -468,7 +468,7 @@
 				/* 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)) {




More information about the busybox-cvs mailing list