X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=coreutils%2Fseq.c;h=e81a4660ad5e8d47750248761d1d3f02e12b9b70;hb=bb5b01c7c711dd9ffc2abf23a05ccdfbf7fc0325;hp=66141c4e2c16cd10164ebed7dcf7f22b8d15f772;hpb=dfba741457cc81eb2ed3a9d4c074fbad74aa3249;p=oweals%2Fbusybox.git diff --git a/coreutils/seq.c b/coreutils/seq.c index 66141c4e2..e81a4660a 100644 --- a/coreutils/seq.c +++ b/coreutils/seq.c @@ -11,31 +11,30 @@ #include #include "busybox.h" +int seq_main(int argc, char **argv); int seq_main(int argc, char **argv) { double last, first, increment, i; - + first = increment = 1; switch (argc) { case 4: - increment=atof(argv[2]); + increment = atof(argv[2]); case 3: - first=atof(argv[1]); + first = atof(argv[1]); case 2: - last=atof(argv[argc -1]); + last = atof(argv[argc-1]); break; default: bb_show_usage(); } /* You should note that this is pos-5.0.91 semantics, -- FK. */ - if (first < last ? increment > 0 : increment < 0) { - for (i = first; - (first < last) ? (i <= last) : (i >= last); - i += increment) - { - printf("%g\n", i); - } + for (i = first; + (increment > 0 && i <= last) || (increment < 0 && i >=last); + i += increment) + { + printf("%g\n", i); } return EXIT_SUCCESS;