diff options
| author | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2008-11-12 13:22:24 +0000 |
|---|---|---|
| committer | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2008-11-12 13:22:24 +0000 |
| commit | c021cb08b58dee7480fe6035d8ac00f0dbe83188 (patch) | |
| tree | 818cd62174f60f4a4647b6bbcea27a1ca1029031 /coreutils | |
| parent | 2598f761bb526afd8ec0de06071fcd6f1a897cd5 (diff) | |
| download | busybox-w32-c021cb08b58dee7480fe6035d8ac00f0dbe83188.tar.gz busybox-w32-c021cb08b58dee7480fe6035d8ac00f0dbe83188.tar.bz2 busybox-w32-c021cb08b58dee7480fe6035d8ac00f0dbe83188.zip | |
- add support for seq -s <separator>
Diffstat (limited to 'coreutils')
| -rw-r--r-- | coreutils/seq.c | 13 |
1 files changed, 9 insertions, 4 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; | |||
| 16 | int seq_main(int argc, char **argv) | 16 | int 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 | } |
