diff options
author | nobody <nobody@localhost> | 2004-10-13 09:42:10 +0000 |
---|---|---|
committer | nobody <nobody@localhost> | 2004-10-13 09:42:10 +0000 |
commit | 8c59a0bf0e9e2d87b0ff273ea3f0bf05bbbf6373 (patch) | |
tree | 1826706cd4fd009fcd14f4f8021005ec8ec0fa59 /busybox/coreutils/seq.c | |
download | busybox-w32-8c59a0bf0e9e2d87b0ff273ea3f0bf05bbbf6373.tar.gz busybox-w32-8c59a0bf0e9e2d87b0ff273ea3f0bf05bbbf6373.tar.bz2 busybox-w32-8c59a0bf0e9e2d87b0ff273ea3f0bf05bbbf6373.zip |
This commit was manufactured by cvs2svn to create tag 'busybox_1_00'.
Diffstat (limited to 'busybox/coreutils/seq.c')
-rw-r--r-- | busybox/coreutils/seq.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/busybox/coreutils/seq.c b/busybox/coreutils/seq.c new file mode 100644 index 000000000..8006be83d --- /dev/null +++ b/busybox/coreutils/seq.c | |||
@@ -0,0 +1,51 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | ||
2 | /* | ||
3 | * seq implementation for busybox | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify | ||
6 | * it under the terms of version 2 of the GNU General Public License as | ||
7 | * published by the Free Software Foundation. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
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 | */ | ||
18 | |||
19 | #include <stdio.h> | ||
20 | #include <stdlib.h> | ||
21 | #include "busybox.h" | ||
22 | |||
23 | extern int seq_main(int argc, char **argv) | ||
24 | { | ||
25 | double last; | ||
26 | double first = 1; | ||
27 | double increment = 1; | ||
28 | double i; | ||
29 | |||
30 | if (argc == 4) { | ||
31 | first = atof(argv[1]); | ||
32 | increment = atof(argv[2]); | ||
33 | } else if (argc == 3) { | ||
34 | first = atof(argv[1]); | ||
35 | } else if (argc != 2) { | ||
36 | bb_show_usage(); | ||
37 | } | ||
38 | last = atof(argv[argc - 1]); | ||
39 | |||
40 | /* You should note that this is pos-5.0.91 semantics, -- FK. */ | ||
41 | if ((first > last) && (increment > 0)) { | ||
42 | return EXIT_SUCCESS; | ||
43 | } | ||
44 | |||
45 | for (i = first; ((first <= last) ? (i <= last) : (i >= last)); | ||
46 | i += increment) { | ||
47 | printf("%g\n", i); | ||
48 | } | ||
49 | |||
50 | return EXIT_SUCCESS; | ||
51 | } | ||