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 | |||||
Denis Vlasenko | b6adbf1 | 2007-05-26 19:00:18 +0000 | [diff] [blame] | 10 | #include "libbb.h" |
Glenn L McGrath | 82364bb | 2004-01-27 09:22:20 +0000 | [diff] [blame] | 11 | |
Denis Vlasenko | 99912ca | 2007-04-10 15:43:37 +0000 | [diff] [blame] | 12 | /* This is a NOFORK applet. Be very careful! */ |
13 | |||||
14 | |||||
Denis Vlasenko | 9b49a5e | 2007-10-11 10:05:36 +0000 | [diff] [blame] | 15 | int seq_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
Rob Landley | dfba741 | 2006-03-06 20:47:33 +0000 | [diff] [blame] | 16 | int seq_main(int argc, char **argv) |
Glenn L McGrath | 82364bb | 2004-01-27 09:22:20 +0000 | [diff] [blame] | 17 | { |
Denis Vlasenko | 99912ca | 2007-04-10 15:43:37 +0000 | [diff] [blame] | 18 | double last, increment, i; |
Denis Vlasenko | 9213a9e | 2006-09-17 16:28:10 +0000 | [diff] [blame] | 19 | |
Denis Vlasenko | 99912ca | 2007-04-10 15:43:37 +0000 | [diff] [blame] | 20 | i = increment = 1; |
Rob Landley | 73a20f3 | 2006-02-23 19:54:48 +0000 | [diff] [blame] | 21 | switch (argc) { |
22 | case 4: | ||||
Denis Vlasenko | ce97960 | 2006-09-27 23:31:08 +0000 | [diff] [blame] | 23 | increment = atof(argv[2]); |
Rob Landley | 73a20f3 | 2006-02-23 19:54:48 +0000 | [diff] [blame] | 24 | case 3: |
Denis Vlasenko | 99912ca | 2007-04-10 15:43:37 +0000 | [diff] [blame] | 25 | i = atof(argv[1]); |
Rob Landley | 73a20f3 | 2006-02-23 19:54:48 +0000 | [diff] [blame] | 26 | case 2: |
Denis Vlasenko | ce97960 | 2006-09-27 23:31:08 +0000 | [diff] [blame] | 27 | last = atof(argv[argc-1]); |
Rob Landley | 73a20f3 | 2006-02-23 19:54:48 +0000 | [diff] [blame] | 28 | break; |
29 | default: | ||||
30 | bb_show_usage(); | ||||
Glenn L McGrath | 82364bb | 2004-01-27 09:22:20 +0000 | [diff] [blame] | 31 | } |
Glenn L McGrath | 82364bb | 2004-01-27 09:22:20 +0000 | [diff] [blame] | 32 | |
Glenn L McGrath | efc6bf6 | 2004-07-23 06:43:29 +0000 | [diff] [blame] | 33 | /* You should note that this is pos-5.0.91 semantics, -- FK. */ |
Denis Vlasenko | 99912ca | 2007-04-10 15:43:37 +0000 | [diff] [blame] | 34 | while ((increment > 0 && i <= last) || (increment < 0 && i >= last)) { |
Rob Landley | d5b9428 | 2006-04-27 22:36:32 +0000 | [diff] [blame] | 35 | printf("%g\n", i); |
Denis Vlasenko | 99912ca | 2007-04-10 15:43:37 +0000 | [diff] [blame] | 36 | i += increment; |
Glenn L McGrath | 82364bb | 2004-01-27 09:22:20 +0000 | [diff] [blame] | 37 | } |
38 | |||||
Denis Vlasenko | 99912ca | 2007-04-10 15:43:37 +0000 | [diff] [blame] | 39 | return fflush(stdout); |
Glenn L McGrath | 82364bb | 2004-01-27 09:22:20 +0000 | [diff] [blame] | 40 | } |