aboutsummaryrefslogtreecommitdiff
path: root/coreutils/seq.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-04-10 15:43:37 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-04-10 15:43:37 +0000
commit99912ca733dd960f5589227fd999c86e73c8e894 (patch)
tree9df947fc08884d498cf76a02204d74b121064134 /coreutils/seq.c
parentff131b980d524a33d8a43cefe65e14f64a43f2da (diff)
downloadbusybox-w32-99912ca733dd960f5589227fd999c86e73c8e894.tar.gz
busybox-w32-99912ca733dd960f5589227fd999c86e73c8e894.tar.bz2
busybox-w32-99912ca733dd960f5589227fd999c86e73c8e894.zip
audit small applets and mark some of them as NOFORK.
Put big scary warnings in relevant places.
Diffstat (limited to 'coreutils/seq.c')
-rw-r--r--coreutils/seq.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/coreutils/seq.c b/coreutils/seq.c
index e81a4660a..ef884d6ae 100644
--- a/coreutils/seq.c
+++ b/coreutils/seq.c
@@ -7,21 +7,22 @@
7 * Licensed under the GPL v2, see the file LICENSE in this tarball. 7 * Licensed under the GPL v2, see the file LICENSE in this tarball.
8 */ 8 */
9 9
10#include <stdio.h>
11#include <stdlib.h>
12#include "busybox.h" 10#include "busybox.h"
13 11
12/* This is a NOFORK applet. Be very careful! */
13
14
14int seq_main(int argc, char **argv); 15int seq_main(int argc, char **argv);
15int seq_main(int argc, char **argv) 16int seq_main(int argc, char **argv)
16{ 17{
17 double last, first, increment, i; 18 double last, increment, i;
18 19
19 first = increment = 1; 20 i = increment = 1;
20 switch (argc) { 21 switch (argc) {
21 case 4: 22 case 4:
22 increment = atof(argv[2]); 23 increment = atof(argv[2]);
23 case 3: 24 case 3:
24 first = atof(argv[1]); 25 i = atof(argv[1]);
25 case 2: 26 case 2:
26 last = atof(argv[argc-1]); 27 last = atof(argv[argc-1]);
27 break; 28 break;
@@ -30,12 +31,10 @@ int seq_main(int argc, char **argv)
30 } 31 }
31 32
32 /* You should note that this is pos-5.0.91 semantics, -- FK. */ 33 /* You should note that this is pos-5.0.91 semantics, -- FK. */
33 for (i = first; 34 while ((increment > 0 && i <= last) || (increment < 0 && i >= last)) {
34 (increment > 0 && i <= last) || (increment < 0 && i >=last);
35 i += increment)
36 {
37 printf("%g\n", i); 35 printf("%g\n", i);
36 i += increment;
38 } 37 }
39 38
40 return EXIT_SUCCESS; 39 return fflush(stdout);
41} 40}