source: MondoRescue/branches/2.2.9/mindi-busybox/coreutils/seq.c@ 2142

Last change on this file since 2142 was 1765, checked in by Bruno Cornec, 16 years ago

Update to busybox 1.7.2

File size: 752 bytes
Line 
1/* vi: set sw=4 ts=4: */
2/*
3 * seq implementation for busybox
4 *
5 * Copyright (C) 2004, Glenn McGrath
6 *
7 * Licensed under the GPL v2, see the file LICENSE in this tarball.
8 */
9
10#include "libbb.h"
11
12/* This is a NOFORK applet. Be very careful! */
13
14
15int seq_main(int argc, char **argv);
16int seq_main(int argc, char **argv)
17{
18 double last, increment, i;
19
20 i = increment = 1;
21 switch (argc) {
22 case 4:
23 increment = atof(argv[2]);
24 case 3:
25 i = atof(argv[1]);
26 case 2:
27 last = atof(argv[argc-1]);
28 break;
29 default:
30 bb_show_usage();
31 }
32
33 /* You should note that this is pos-5.0.91 semantics, -- FK. */
34 while ((increment > 0 && i <= last) || (increment < 0 && i >= last)) {
35 printf("%g\n", i);
36 i += increment;
37 }
38
39 return fflush(stdout);
40}
Note: See TracBrowser for help on using the repository browser.