lineedit: do not hang on error, but return error indicator.
[oweals/busybox.git] / coreutils / seq.c
index bb39a5b54ad3a52a7e8804a651cabac30aa615fb..8be25360ffd21a2c9a510dd426d648d04d74b872 100644 (file)
@@ -4,7 +4,7 @@
  *
  * Copyright (C) 2004, Glenn McGrath
  *
- * Licensed under the GPL v2, see the file LICENSE in this tarball.
+ * Licensed under GPLv2, see file LICENSE in this source tree.
  */
 #include "libbb.h"
 
@@ -22,8 +22,15 @@ int seq_main(int argc, char **argv)
        unsigned width;
        unsigned frac_part;
        const char *sep, *opt_s = "\n";
-       unsigned opt = getopt32(argv, "+ws:", &opt_s);
+       unsigned opt;
 
+#if ENABLE_LOCALE_SUPPORT
+       /* Undo busybox.c: on input, we want to use dot
+        * as fractional separator, regardless of current locale */
+       setlocale(LC_NUMERIC, "C");
+#endif
+
+       opt = getopt32(argv, "+ws:", &opt_s);
        argc -= optind;
        argv += optind;
        first = increment = 1;
@@ -44,6 +51,10 @@ int seq_main(int argc, char **argv)
                        bb_show_usage();
        }
 
+#if ENABLE_LOCALE_SUPPORT
+       setlocale(LC_NUMERIC, "");
+#endif
+
        /* Last checked to be compatible with: coreutils-6.10 */
        width = 0;
        frac_part = 0;
@@ -84,5 +95,5 @@ int seq_main(int argc, char **argv)
        if (n) /* if while loop executed at least once */
                bb_putchar('\n');
 
-       return fflush(stdout);
+       return fflush_all();
 }