Avoid side effects in putc(), which may be implemented as a macro

Signed-off-by: Dan Fandrich <dan@coneharvesters.com>
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
This commit is contained in:
Dan Fandrich 2010-09-07 23:38:28 -07:00 committed by Denys Vlasenko
parent 95d48f2598
commit 77d4872691
3 changed files with 12 additions and 8 deletions

View File

@ -573,7 +573,8 @@ static unsigned print_name(const char *name)
putchar('\\'); putchar('\\');
len++; len++;
} }
putchar(*name++); putchar(*name);
name++;
} }
putchar('"'); putchar('"');
return len; return len;

View File

@ -70,8 +70,8 @@ int tee_main(int argc, char **argv)
while ((c = safe_read(STDIN_FILENO, buf, sizeof(buf))) > 0) { while ((c = safe_read(STDIN_FILENO, buf, sizeof(buf))) > 0) {
fp = files; fp = files;
do do
fwrite(buf, 1, c, *fp++); fwrite(buf, 1, c, *fp);
while (*fp); while (*++fp);
} }
if (c < 0) { /* Make sure read errors are signaled. */ if (c < 0) { /* Make sure read errors are signaled. */
retval = EXIT_FAILURE; retval = EXIT_FAILURE;
@ -81,8 +81,8 @@ int tee_main(int argc, char **argv)
while ((c = getchar()) != EOF) { while ((c = getchar()) != EOF) {
fp = files; fp = files;
do do
putc(c, *fp++); putc(c, *fp);
while (*fp); while (*++fp);
} }
#endif #endif

View File

@ -953,7 +953,8 @@ sharg(union node *arg, FILE *fp)
for (p = arg->narg.text; *p; p++) { for (p = arg->narg.text; *p; p++) {
switch ((unsigned char)*p) { switch ((unsigned char)*p) {
case CTLESC: case CTLESC:
putc(*++p, fp); p++;
putc(*p, fp);
break; break;
case CTLVAR: case CTLVAR:
putc('$', fp); putc('$', fp);
@ -962,8 +963,10 @@ sharg(union node *arg, FILE *fp)
if (subtype == VSLENGTH) if (subtype == VSLENGTH)
putc('#', fp); putc('#', fp);
while (*p != '=') while (*p != '=') {
putc(*p++, fp); putc(*p, fp);
p++;
}
if (subtype & VSNUL) if (subtype & VSNUL)
putc(':', fp); putc(':', fp);