blob: 0df094001784f9e87b6a6134aa7ab48d6039b690 [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 *
Rob Landley73a20f32006-02-23 19:54:48 +00005 * Copyright (C) 2004, Glenn McGrath
Glenn L McGrath82364bb2004-01-27 09:22:20 +00006 *
Rob Landley73a20f32006-02-23 19:54:48 +00007 * Licensed under the GPL v2, see the file LICENSE in this tarball.
Glenn L McGrath82364bb2004-01-27 09:22:20 +00008 */
9
10#include <stdio.h>
11#include <stdlib.h>
12#include "busybox.h"
13
Rob Landleydfba7412006-03-06 20:47:33 +000014int seq_main(int argc, char **argv)
Glenn L McGrath82364bb2004-01-27 09:22:20 +000015{
Rob Landley73a20f32006-02-23 19:54:48 +000016 double last, first, increment, i;
17
18 first = increment = 1;
19 switch (argc) {
20 case 4:
21 increment=atof(argv[2]);
22 case 3:
23 first=atof(argv[1]);
24 case 2:
25 last=atof(argv[argc -1]);
26 break;
27 default:
28 bb_show_usage();
Glenn L McGrath82364bb2004-01-27 09:22:20 +000029 }
Glenn L McGrath82364bb2004-01-27 09:22:20 +000030
Glenn L McGrathefc6bf62004-07-23 06:43:29 +000031 /* You should note that this is pos-5.0.91 semantics, -- FK. */
Rob Landleyd5b94282006-04-27 22:36:32 +000032 for (i = first;
33 (increment > 0 && i <= last) || (increment < 0 && i >=last);
34 i += increment)
35 {
36 printf("%g\n", i);
Glenn L McGrath82364bb2004-01-27 09:22:20 +000037 }
38
Glenn L McGrathefc6bf62004-07-23 06:43:29 +000039 return EXIT_SUCCESS;
Glenn L McGrath82364bb2004-01-27 09:22:20 +000040}