svn commit: trunk/busybox/coreutils

vda at busybox.net vda at busybox.net
Thu Dec 21 00:43:06 UTC 2006


Author: vda
Date: 2006-12-20 16:43:06 -0800 (Wed, 20 Dec 2006)
New Revision: 17024

Log:
tail: fix tail +N


Modified:
   trunk/busybox/coreutils/tail.c


Changeset:
Modified: trunk/busybox/coreutils/tail.c
===================================================================
--- trunk/busybox/coreutils/tail.c	2006-12-21 00:22:03 UTC (rev 17023)
+++ trunk/busybox/coreutils/tail.c	2006-12-21 00:43:06 UTC (rev 17024)
@@ -122,15 +122,15 @@
 				/* FALLS THROUGH */
 			case 'n':
 #if !ENABLE_DEBUG_YANK_SUSv2 || ENABLE_FEATURE_FANCY_TAIL
-			GET_COUNT:
+ GET_COUNT:
 #endif
-				count = xatol_sfx(optarg, tail_suffixes);
-				/* Note: Leading whitespace is an error trapped above. */
+				from_top = 0;
 				if (*optarg == '+') {
+					++optarg;
 					from_top = 1;
-				} else {
-					from_top = 0;
 				}
+				count = xatol_sfx(optarg, tail_suffixes);
+				/* Note: Leading whitespace is an error trapped above. */
 				if (count < 0) {
 					count = -count;
 				}
@@ -150,20 +150,18 @@
 				bb_show_usage();
 		}
 	}
+	argc -= optind;
+	argv += optind;
 
 	/* open all the files */
-	fds = xmalloc(sizeof(int) * (argc - optind + 1));
-
-	argv += optind;
+	fds = xmalloc(sizeof(int) * (argc + 1));
 	nfiles = i = 0;
-
-	if ((argc -= optind) == 0) {
+	if (argc == 0) {
 		struct stat statbuf;
 
 		if (!fstat(STDIN_FILENO, &statbuf) && S_ISFIFO(statbuf.st_mode)) {
 			follow = 0;
 		}
-		/* --argv; */
 		*argv = (char *) bb_msg_standard_input;
 		goto DO_STDIN;
 	}




More information about the busybox-cvs mailing list