blob: 8006be83dc5227481906dd08ce75ac4ef9bab194 [file] [log] [blame]
Glenn L McGrathefc6bf62004-07-23 06:43:29 +00001/* vi: set sw=4 ts=4: */
Glenn L McGrath82364bb2004-01-27 09:22:20 +00002/*
Glenn L McGrathefc6bf62004-07-23 06:43:29 +00003 * seq implementation for busybox
4 *
Glenn L McGrath82364bb2004-01-27 09:22:20 +00005 * 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
23extern 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]);
Glenn L McGrathefc6bf62004-07-23 06:43:29 +000033 } else if (argc == 3) {
Glenn L McGrath82364bb2004-01-27 09:22:20 +000034 first = atof(argv[1]);
Glenn L McGrathefc6bf62004-07-23 06:43:29 +000035 } else if (argc != 2) {
Glenn L McGrath82364bb2004-01-27 09:22:20 +000036 bb_show_usage();
37 }
38 last = atof(argv[argc - 1]);
39
Glenn L McGrathefc6bf62004-07-23 06:43:29 +000040 /* 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) {
Glenn L McGrath82364bb2004-01-27 09:22:20 +000047 printf("%g\n", i);
48 }
49
Glenn L McGrathefc6bf62004-07-23 06:43:29 +000050 return EXIT_SUCCESS;
Glenn L McGrath82364bb2004-01-27 09:22:20 +000051}