aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2008-11-12 13:22:24 +0000
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2008-11-12 13:22:24 +0000
commitc021cb08b58dee7480fe6035d8ac00f0dbe83188 (patch)
tree818cd62174f60f4a4647b6bbcea27a1ca1029031
parent2598f761bb526afd8ec0de06071fcd6f1a897cd5 (diff)
downloadbusybox-w32-c021cb08b58dee7480fe6035d8ac00f0dbe83188.tar.gz
busybox-w32-c021cb08b58dee7480fe6035d8ac00f0dbe83188.tar.bz2
busybox-w32-c021cb08b58dee7480fe6035d8ac00f0dbe83188.zip
- add support for seq -s <separator>
-rw-r--r--coreutils/seq.c13
-rw-r--r--include/usage.h5
2 files changed, 12 insertions, 6 deletions
diff --git a/coreutils/seq.c b/coreutils/seq.c
index 899cd696b..cf856bf04 100644
--- a/coreutils/seq.c
+++ b/coreutils/seq.c
@@ -16,8 +16,10 @@ int seq_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
16int seq_main(int argc, char **argv) 16int seq_main(int argc, char **argv)
17{ 17{
18 double last, increment, i; 18 double last, increment, i;
19 enum { OPT_w = 1 }; 19 enum { OPT_w = 1, OPT_s };
20 unsigned opt = getopt32(argv, "+w"); 20 const char *sep = "\n";
21 bool is_consecutive = 0;
22 unsigned opt = getopt32(argv, "+ws:", &sep);
21 unsigned width = 0; 23 unsigned width = 0;
22 24
23 argc -= optind; 25 argc -= optind;
@@ -39,9 +41,12 @@ int seq_main(int argc, char **argv)
39 41
40 /* You should note that this is pos-5.0.91 semantics, -- FK. */ 42 /* You should note that this is pos-5.0.91 semantics, -- FK. */
41 while ((increment > 0 && i <= last) || (increment < 0 && i >= last)) { 43 while ((increment > 0 && i <= last) || (increment < 0 && i >= last)) {
42 printf("%0*g\n", width, i); 44 if (is_consecutive++) {
45 printf("%s", sep);
46 }
47 printf("%0*g", width, i);
43 i += increment; 48 i += increment;
44 } 49 }
45 50 bb_putchar('\n');
46 return fflush(stdout); 51 return fflush(stdout);
47} 52}
diff --git a/include/usage.h b/include/usage.h
index 4360edba6..f9b6aca1b 100644
--- a/include/usage.h
+++ b/include/usage.h
@@ -3594,12 +3594,13 @@
3594 "\nOther options are silently ignored; -oi is implied" \ 3594 "\nOther options are silently ignored; -oi is implied" \
3595 3595
3596#define seq_trivial_usage \ 3596#define seq_trivial_usage \
3597 "[-w] [first [increment]] last" 3597 "[-w] [-s separator] [first [increment]] last"
3598#define seq_full_usage "\n\n" \ 3598#define seq_full_usage "\n\n" \
3599 "Print numbers from FIRST to LAST, in steps of INCREMENT.\n" \ 3599 "Print numbers from FIRST to LAST, in steps of INCREMENT.\n" \
3600 "FIRST, INCREMENT default to 1\n" \ 3600 "FIRST, INCREMENT default to 1\n" \
3601 "\nArguments:" \ 3601 "\nArguments:" \
3602 "\n -w Pad to last with leading zeros" \ 3602 "\n -w Pad to last with leading zeros" \
3603 "\n -s <string> Use string separator" \
3603 "\n LAST" \ 3604 "\n LAST" \
3604 "\n FIRST LAST" \ 3605 "\n FIRST LAST" \
3605 "\n FIRST INCREMENT LAST" \ 3606 "\n FIRST INCREMENT LAST" \