aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2006-02-23 19:54:48 +0000
committerRob Landley <rob@landley.net>2006-02-23 19:54:48 +0000
commit73a20f355102b715e1ce5f5d268539ee932de708 (patch)
treee625ff3271b08be3b88d47e98a501fc9f4488abf
parented7bb6278da100e46f6286096b47aa0a356a76d8 (diff)
downloadbusybox-w32-73a20f355102b715e1ce5f5d268539ee932de708.tar.gz
busybox-w32-73a20f355102b715e1ce5f5d268539ee932de708.tar.bz2
busybox-w32-73a20f355102b715e1ce5f5d268539ee932de708.zip
"sed 2 -2 10" was very unhappy. Made the thing bigger fixing it,
fiddled a bit to get the size back down as much as I could...
-rw-r--r--coreutils/seq.c53
1 files changed, 22 insertions, 31 deletions
diff --git a/coreutils/seq.c b/coreutils/seq.c
index 8006be83d..51e3add81 100644
--- a/coreutils/seq.c
+++ b/coreutils/seq.c
@@ -2,18 +2,9 @@
2/* 2/*
3 * seq implementation for busybox 3 * seq implementation for busybox
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * Copyright (C) 2004, Glenn McGrath
6 * it under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
8 * 6 *
9 * This program is distributed in the hope that it will be useful, 7 * Licensed under the GPL v2, see the file LICENSE in this tarball.
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */ 8 */
18 9
19#include <stdio.h> 10#include <stdio.h>
@@ -22,29 +13,29 @@
22 13
23extern int seq_main(int argc, char **argv) 14extern int seq_main(int argc, char **argv)
24{ 15{
25 double last; 16 double last, first, increment, i;
26 double first = 1; 17
27 double increment = 1; 18 first = increment = 1;
28 double i; 19 switch (argc) {
29 20 case 4:
30 if (argc == 4) { 21 increment=atof(argv[2]);
31 first = atof(argv[1]); 22 case 3:
32 increment = atof(argv[2]); 23 first=atof(argv[1]);
33 } else if (argc == 3) { 24 case 2:
34 first = atof(argv[1]); 25 last=atof(argv[argc -1]);
35 } else if (argc != 2) { 26 break;
36 bb_show_usage(); 27 default:
28 bb_show_usage();
37 } 29 }
38 last = atof(argv[argc - 1]);
39 30
40 /* You should note that this is pos-5.0.91 semantics, -- FK. */ 31 /* You should note that this is pos-5.0.91 semantics, -- FK. */
41 if ((first > last) && (increment > 0)) { 32 if (first < last ? increment > 0 : increment < 0) {
42 return EXIT_SUCCESS; 33 for (i = first;
43 } 34 (first < last) ? (i <= last) : (i >= last);
44 35 i += increment)
45 for (i = first; ((first <= last) ? (i <= last) : (i >= last)); 36 {
46 i += increment) { 37 printf("%g\n", i);
47 printf("%g\n", i); 38 }
48 } 39 }
49 40
50 return EXIT_SUCCESS; 41 return EXIT_SUCCESS;