svn commit: branches/busybox_scratch/coreutils

aldot at busybox.net aldot at busybox.net
Sun Jul 2 18:27:27 UTC 2006


Author: aldot
Date: 2006-07-02 11:27:23 -0700 (Sun, 02 Jul 2006)
New Revision: 15579

Log:
- improve readability and reduce the size a tiny bit.
   text	   data	    bss	    dec	    hex	filename
   1045	      0	      0	   1045	    415	coreutils/od.o.gcc-3.4.orig
   1040	      0	      0	   1040	    410	coreutils/od.o.gcc-3.4
   1020	      0	      0	   1020	    3fc	coreutils/od.o.gcc-4.0.orig
   1018	      0	      0	   1018	    3fa	coreutils/od.o.gcc-4.0
   1009	      0	      0	   1009	    3f1	coreutils/od.o.gcc-4.1.orig
   1008	      0	      0	   1008	    3f0	coreutils/od.o.gcc-4.1


Modified:
   branches/busybox_scratch/coreutils/od.c


Changeset:
Modified: branches/busybox_scratch/coreutils/od.c
===================================================================
--- branches/busybox_scratch/coreutils/od.c	2006-07-02 15:07:32 UTC (rev 15578)
+++ branches/busybox_scratch/coreutils/od.c	2006-07-02 18:27:23 UTC (rev 15579)
@@ -1,3 +1,4 @@
+/* vi: set sw=4 ts=4: */
 /*
  * od implementation for busybox
  * Based on code from util-linux v 2.11l
@@ -5,20 +6,8 @@
  * Copyright (c) 1990
  *	The Regents of the University of California.  All rights reserved.
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
  *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
  * Original copyright notice is retained at the end of this file.
  */
 
@@ -29,13 +18,10 @@
 #include "busybox.h"
 #include "dump.h"
 
-#define isdecdigit(c) (isdigit)(c)
-#define ishexdigit(c) (isxdigit)(c)
-
 static void
 odoffset(int argc, char ***argvp)
 {
-	register char *num, *p;
+	char *num, *p;
 	int base;
 	char *end;
 
@@ -58,32 +44,32 @@
 		return;
 	}
 
-	if ((*p != '+')
-		&& (argc < 2
-			|| (!isdecdigit(p[0])
-				&& ((p[0] != 'x') || !ishexdigit(p[1])))))
+	if ((*p != '+')) {
+		if (argc < 2
+			|| (!(isdigit)(p[0])
+				&& ((p[0] != 'x') || !(isxdigit)(p[1]))))
 		return;
+	} else /* p[0] == '+' */
+		++p;
 
-	base = 0;
 	/*
 	 * bb_dump_skip over leading '+', 'x[0-9a-fA-f]' or '0x', and
 	 * set base.
 	 */
-	if (p[0] == '+')
+	if (p[0] == 'x' && (isxdigit)(p[1])) {
 		++p;
-	if (p[0] == 'x' && ishexdigit(p[1])) {
-		++p;
 		base = 16;
 	} else if (p[0] == '0' && p[1] == 'x') {
 		p += 2;
 		base = 16;
-	}
+	} else
+		base = 0;
 
 	/* bb_dump_skip over the number */
 	if (base == 16)
-		for (num = p; ishexdigit(*p); ++p);
+		for (num = p; (isxdigit)(*p); ++p);
 	else
-		for (num = p; isdecdigit(*p); ++p);
+		for (num = p; (isdigit)(*p); ++p);
 
 	/* check for no number */
 	if (num == p)
@@ -114,27 +100,22 @@
 		if (*p)
 			bb_dump_skip = 0;
 		else {
-			++*argvp;
 			/*
 			 * If the offset uses a non-octal base, the base of
 			 * the offset is changed as well.  This isn't pretty,
 			 * but it's easy.
 			 */
 #define	TYPE_OFFSET	7
-			{
-				char x_or_d;
-				if (base == 16) {
+				char x_or_d = '\0';
+				++*argvp;
+				if (base == 16)
 					x_or_d = 'x';
-					goto DO_X_OR_D;
-				}
-				if (base == 10) {
+				if (base == 10)
 					x_or_d = 'd';
-				DO_X_OR_D:
+				if (x_or_d)
 					bb_dump_fshead->nextfu->fmt[TYPE_OFFSET]
 						= bb_dump_fshead->nextfs->nextfu->fmt[TYPE_OFFSET]
 						= x_or_d;
-				}
-			}
 		}
 	}
 }
@@ -167,7 +148,7 @@
 int od_main(int argc, char **argv)
 {
 	int ch;
-	int first = 1;
+	int first = 0;
 	char *p;
 	bb_dump_vflag = FIRST;
 	bb_dump_length = -1;
@@ -176,8 +157,8 @@
 		if (ch == 'v') {
 			bb_dump_vflag = ALL;
 		} else if (((p = strchr(od_opts, ch)) != NULL) && (*p != '\0')) {
-			if (first) {
-				first = 0;
+			if (first == 0) {
+				first++;
 				bb_dump_add("\"%07.7_Ao\n\"");
 				bb_dump_add("\"%07.7_ao  \"");
 			} else {




More information about the busybox-cvs mailing list