1 /* vi: set sw=4 ts=4: */
3 * seq implementation for busybox
5 * Copyright (C) 2004, Glenn McGrath
7 * Licensed under the GPL v2, see the file LICENSE in this tarball.
12 /* This is a NOFORK applet. Be very careful! */
15 int seq_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
16 int seq_main(int argc, char **argv)
22 double last, increment, i;
23 const char *sep, *opt_s = "\n";
24 unsigned opt = getopt32(argv, "+ws:", &opt_s);
32 increment = atof(argv[1]);
36 last = atof(argv[argc-1]);
41 if (opt & OPT_w) /* Pad to length of start or last */
42 width = MAX(strlen(*argv), strlen(argv[argc-1]));
44 /* You should note that this is pos-5.0.91 semantics, -- FK. */
46 while ((increment > 0 && i <= last) || (increment < 0 && i >= last)) {
47 printf("%s%0*g", sep, width, i);
52 return fflush(stdout);