lineedit: do not hang on error, but return error indicator.
[oweals/busybox.git] / libbb / dump.c
index 49e5e26f81e52fc68a2cbcd01623a82e7cfa6da5..4db3f06f0935f99e277ee3b5f5fdada67c9bd97f 100644 (file)
@@ -6,7 +6,7 @@
  * Copyright (c) 1989
  *     The Regents of the University of California.  All rights reserved.
  *
- * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
+ * Licensed under GPLv2 or later, see file LICENSE in this source tree.
  *
  * Original copyright notice is retained at the end of this file.
  */
@@ -323,9 +323,7 @@ static void do_skip(priv_dumper_t *dumper, const char *fname, int statok)
        struct stat sbuf;
 
        if (statok) {
-               if (fstat(STDIN_FILENO, &sbuf)) {
-                       bb_simple_perror_msg_and_die(fname);
-               }
+               xfstat(STDIN_FILENO, &sbuf, fname);
                if (!(S_ISCHR(sbuf.st_mode) || S_ISBLK(sbuf.st_mode) || S_ISFIFO(sbuf.st_mode))
                 && dumper->pub.dump_skip >= sbuf.st_size
                ) {
@@ -349,16 +347,16 @@ static NOINLINE int next(priv_dumper_t *dumper)
 
        for (;;) {
                if (*dumper->argv) {
+                       dumper->next__done = statok = 1;
                        if (!(freopen(*dumper->argv, "r", stdin))) {
                                bb_simple_perror_msg(*dumper->argv);
                                dumper->exitval = 1;
                                ++dumper->argv;
                                continue;
                        }
-                       dumper->next__done = statok = 1;
                } else {
                        if (dumper->next__done)
-                               return 0;
+                               return 0; /* no next file */
                        dumper->next__done = 1;
                        statok = 0;
                }