summaryrefslogtreecommitdiff
path: root/coreutils/seq.c
diff options
context:
space:
mode:
authorDenis Vlasenko2007-04-10 15:43:37 +0000
committerDenis Vlasenko2007-04-10 15:43:37 +0000
commit99912ca733dd960f5589227fd999c86e73c8e894 (patch)
tree9df947fc08884d498cf76a02204d74b121064134 /coreutils/seq.c
parentff131b980d524a33d8a43cefe65e14f64a43f2da (diff)
downloadbusybox-99912ca733dd960f5589227fd999c86e73c8e894.zip
busybox-99912ca733dd960f5589227fd999c86e73c8e894.tar.gz
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 e81a466..ef884d6 100644
--- a/coreutils/seq.c
+++ b/coreutils/seq.c
@@ -7,21 +7,22 @@
* Licensed under the GPL v2, see the file LICENSE in this tarball.
*/
-#include <stdio.h>
-#include <stdlib.h>
#include "busybox.h"
+/* This is a NOFORK applet. Be very careful! */
+
+
int seq_main(int argc, char **argv);
int seq_main(int argc, char **argv)
{
- double last, first, increment, i;
+ double last, increment, i;
- first = increment = 1;
+ i = increment = 1;
switch (argc) {
case 4:
increment = atof(argv[2]);
case 3:
- first = atof(argv[1]);
+ i = atof(argv[1]);
case 2:
last = atof(argv[argc-1]);
break;
@@ -30,12 +31,10 @@ int seq_main(int argc, char **argv)
}
/* You should note that this is pos-5.0.91 semantics, -- FK. */
- for (i = first;
- (increment > 0 && i <= last) || (increment < 0 && i >=last);
- i += increment)
- {
+ while ((increment > 0 && i <= last) || (increment < 0 && i >= last)) {
printf("%g\n", i);
+ i += increment;
}
- return EXIT_SUCCESS;
+ return fflush(stdout);
}