svn commit: trunk/busybox: coreutils include

aldot at busybox.net aldot at busybox.net
Wed Nov 12 13:22:25 UTC 2008


Author: aldot
Date: 2008-11-12 05:22:24 -0800 (Wed, 12 Nov 2008)
New Revision: 24017

Log:
- add support for seq -s <separator>


Modified:
   trunk/busybox/coreutils/seq.c
   trunk/busybox/include/usage.h


Changeset:
Modified: trunk/busybox/coreutils/seq.c
===================================================================
--- trunk/busybox/coreutils/seq.c	2008-11-12 12:59:56 UTC (rev 24016)
+++ trunk/busybox/coreutils/seq.c	2008-11-12 13:22:24 UTC (rev 24017)
@@ -16,8 +16,10 @@
 int seq_main(int argc, char **argv)
 {
 	double last, increment, i;
-	enum { OPT_w = 1 };
-	unsigned opt = getopt32(argv, "+w");
+	enum { OPT_w = 1, OPT_s };
+	const char *sep = "\n";
+	bool is_consecutive = 0;
+	unsigned opt = getopt32(argv, "+ws:", &sep);
 	unsigned width = 0;
 
 	argc -= optind;
@@ -39,9 +41,12 @@
 
 	/* You should note that this is pos-5.0.91 semantics, -- FK. */
 	while ((increment > 0 && i <= last) || (increment < 0 && i >= last)) {
-		printf("%0*g\n", width, i);
+		if (is_consecutive++) {
+			printf("%s", sep);
+		}
+		printf("%0*g", width, i);
 		i += increment;
 	}
-
+	bb_putchar('\n');
 	return fflush(stdout);
 }

Modified: trunk/busybox/include/usage.h
===================================================================
--- trunk/busybox/include/usage.h	2008-11-12 12:59:56 UTC (rev 24016)
+++ trunk/busybox/include/usage.h	2008-11-12 13:22:24 UTC (rev 24017)
@@ -3594,12 +3594,13 @@
      "\nOther options are silently ignored; -oi is implied" \
 
 #define seq_trivial_usage \
-       "[-w] [first [increment]] last"
+       "[-w] [-s separator] [first [increment]] last"
 #define seq_full_usage "\n\n" \
        "Print numbers from FIRST to LAST, in steps of INCREMENT.\n" \
        "FIRST, INCREMENT default to 1\n" \
      "\nArguments:" \
-     "\n       -w          Pad to last with leading zeros" \
+     "\n	-w          Pad to last with leading zeros" \
+     "\n	-s <string> Use string separator" \
      "\n	LAST" \
      "\n	FIRST LAST" \
      "\n	FIRST INCREMENT LAST" \




More information about the busybox-cvs mailing list