Glenn L McGrath | efc6bf6 | 2004-07-23 06:43:29 +0000 | [diff] [blame] | 1 | /* vi: set sw=4 ts=4: */ |
Glenn L McGrath | 82364bb | 2004-01-27 09:22:20 +0000 | [diff] [blame] | 2 | /* |
Glenn L McGrath | efc6bf6 | 2004-07-23 06:43:29 +0000 | [diff] [blame] | 3 | * seq implementation for busybox |
4 | * | ||||
Rob Landley | 73a20f3 | 2006-02-23 19:54:48 +0000 | [diff] [blame] | 5 | * Copyright (C) 2004, Glenn McGrath |
Glenn L McGrath | 82364bb | 2004-01-27 09:22:20 +0000 | [diff] [blame] | 6 | * |
Rob Landley | 73a20f3 | 2006-02-23 19:54:48 +0000 | [diff] [blame] | 7 | * Licensed under the GPL v2, see the file LICENSE in this tarball. |
Glenn L McGrath | 82364bb | 2004-01-27 09:22:20 +0000 | [diff] [blame] | 8 | */ |
9 | |||||
10 | #include <stdio.h> | ||||
11 | #include <stdlib.h> | ||||
12 | #include "busybox.h" | ||||
13 | |||||
Denis Vlasenko | 06af216 | 2007-02-03 17:28:39 +0000 | [diff] [blame] | 14 | int seq_main(int argc, char **argv); |
Rob Landley | dfba741 | 2006-03-06 20:47:33 +0000 | [diff] [blame] | 15 | int seq_main(int argc, char **argv) |
Glenn L McGrath | 82364bb | 2004-01-27 09:22:20 +0000 | [diff] [blame] | 16 | { |
Rob Landley | 73a20f3 | 2006-02-23 19:54:48 +0000 | [diff] [blame] | 17 | double last, first, increment, i; |
Denis Vlasenko | 9213a9e | 2006-09-17 16:28:10 +0000 | [diff] [blame] | 18 | |
Rob Landley | 73a20f3 | 2006-02-23 19:54:48 +0000 | [diff] [blame] | 19 | first = increment = 1; |
20 | switch (argc) { | ||||
21 | case 4: | ||||
Denis Vlasenko | ce97960 | 2006-09-27 23:31:08 +0000 | [diff] [blame] | 22 | increment = atof(argv[2]); |
Rob Landley | 73a20f3 | 2006-02-23 19:54:48 +0000 | [diff] [blame] | 23 | case 3: |
Denis Vlasenko | ce97960 | 2006-09-27 23:31:08 +0000 | [diff] [blame] | 24 | first = atof(argv[1]); |
Rob Landley | 73a20f3 | 2006-02-23 19:54:48 +0000 | [diff] [blame] | 25 | case 2: |
Denis Vlasenko | ce97960 | 2006-09-27 23:31:08 +0000 | [diff] [blame] | 26 | last = atof(argv[argc-1]); |
Rob Landley | 73a20f3 | 2006-02-23 19:54:48 +0000 | [diff] [blame] | 27 | break; |
28 | default: | ||||
29 | bb_show_usage(); | ||||
Glenn L McGrath | 82364bb | 2004-01-27 09:22:20 +0000 | [diff] [blame] | 30 | } |
Glenn L McGrath | 82364bb | 2004-01-27 09:22:20 +0000 | [diff] [blame] | 31 | |
Glenn L McGrath | efc6bf6 | 2004-07-23 06:43:29 +0000 | [diff] [blame] | 32 | /* You should note that this is pos-5.0.91 semantics, -- FK. */ |
Rob Landley | d5b9428 | 2006-04-27 22:36:32 +0000 | [diff] [blame] | 33 | for (i = first; |
Denis Vlasenko | ce97960 | 2006-09-27 23:31:08 +0000 | [diff] [blame] | 34 | (increment > 0 && i <= last) || (increment < 0 && i >=last); |
35 | i += increment) | ||||
Rob Landley | d5b9428 | 2006-04-27 22:36:32 +0000 | [diff] [blame] | 36 | { |
37 | printf("%g\n", i); | ||||
Glenn L McGrath | 82364bb | 2004-01-27 09:22:20 +0000 | [diff] [blame] | 38 | } |
39 | |||||
Glenn L McGrath | efc6bf6 | 2004-07-23 06:43:29 +0000 | [diff] [blame] | 40 | return EXIT_SUCCESS; |
Glenn L McGrath | 82364bb | 2004-01-27 09:22:20 +0000 | [diff] [blame] | 41 | } |