* 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.
*/
return cur_size;
}
-static void rewrite(priv_dumper_t *dumper, FS *fs)
+static NOINLINE void rewrite(priv_dumper_t *dumper, FS *fs)
{
enum { NOTOKAY, USEBCNT, USEPREC } sokay;
PR *pr, **nextpr = NULL;
* if, rep count is greater than 1, no trailing whitespace
* gets output from the last iteration of the format unit.
*/
- for (fu = fs->nextfu;; fu = fu->nextfu) {
+ for (fu = fs->nextfu; fu; fu = fu->nextfu) {
if (!fu->nextfu && fs->bcnt < dumper->blocksize
&& !(fu->flags & F_SETREP) && fu->bcnt
) {
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
) {
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;
}
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);
}
} 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 {
switch (pr->bcnt) {
case 4:
- memmove(&fval, bp, sizeof(fval));
+ memcpy(&fval, bp, sizeof(fval));
printf(pr->fmt, fval);
break;
case 8:
- memmove(&dval, bp, sizeof(dval));
+ memcpy(&dval, bp, sizeof(dval));
printf(pr->fmt, dval);
break;
}
printf(pr->fmt, (int) *bp);
break;
case 2:
- memmove(&sval, bp, sizeof(sval));
+ memcpy(&sval, bp, sizeof(sval));
printf(pr->fmt, (int) sval);
break;
case 4:
- memmove(&ival, bp, sizeof(ival));
+ memcpy(&ival, bp, sizeof(ival));
printf(pr->fmt, ival);
break;
}
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);
printf(pr->fmt, (unsigned) *bp);
break;
case 2:
- memmove(&sval, bp, sizeof(sval));
+ memcpy(&sval, bp, sizeof(sval));
printf(pr->fmt, (unsigned) sval);
break;
case 4:
- memmove(&ival, bp, sizeof(ival));
+ memcpy(&ival, bp, sizeof(ival));
printf(pr->fmt, ival);
break;
}
nextfupp = &tfs->nextfu;
/* take the format string and break it up into format units */
- for (p = fmt;;) {
+ p = fmt;
+ for (;;) {
p = skip_whitespace(p);
if (!*p) {
break;