lineedit: do not hang on error, but return error indicator.
[oweals/busybox.git] / libbb / dump.c
index bef485eff3491dda8c4599eb04c5eddaf130f6c3..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;
                }
@@ -492,13 +490,13 @@ static void conv_c(PR *pr, unsigned char *p)
                str += 4;
        } while (*str);
 
-       if (isprint(*p)) {
+       if (isprint_asciionly(*p)) {
                *pr->cchar = 'c';
                printf(pr->fmt, *p);
        } else {
                sprintf(buf, "%03o", (int) *p);
                str = buf;
        strpr:
+ strpr:
                *pr->cchar = 's';
                printf(pr->fmt, str);
        }
@@ -519,7 +517,7 @@ static void conv_u(PR *pr, unsigned char *p)
        } else if (*p == 0x7f) {
                *pr->cchar = 's';
                printf(pr->fmt, "del");
-       } else if (isprint(*p)) {
+       } else if (*p < 0x7f) { /* isprint() */
                *pr->cchar = 'c';
                printf(pr->fmt, *p);
        } else {
@@ -609,7 +607,7 @@ static void display(priv_dumper_t* dumper)
                                                        break;
                                                }
                                                case F_P:
-                                                       printf(pr->fmt, isprint(*bp) ? *bp : '.');
+                                                       printf(pr->fmt, isprint_asciionly(*bp) ? *bp : '.');
                                                        break;
                                                case F_STR:
                                                        printf(pr->fmt, (char *) bp);