diff options
author | dim <dim@FreeBSD.org> | 2011-12-16 21:12:23 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2011-12-16 21:12:23 +0000 |
commit | 4e36a16dc88daa10cbae50f682eb574300d62380 (patch) | |
tree | 3ef8493c80aac7980af8dc53abd0bf16e9436e3d /bin | |
parent | c54854914ac3e4a9ea43d7d0311069e7e352386a (diff) | |
download | FreeBSD-src-4e36a16dc88daa10cbae50f682eb574300d62380.zip FreeBSD-src-4e36a16dc88daa10cbae50f682eb574300d62380.tar.gz |
Fix some obtuse fprintf tricks in bin/ed.
MFC after: 1 week
Diffstat (limited to 'bin')
-rw-r--r-- | bin/ed/io.c | 6 | ||||
-rw-r--r-- | bin/ed/main.c | 32 |
2 files changed, 20 insertions, 18 deletions
diff --git a/bin/ed/io.c b/bin/ed/io.c index 85ba0de..63fe10c 100644 --- a/bin/ed/io.c +++ b/bin/ed/io.c @@ -53,7 +53,8 @@ read_file(char *fn, long n) errmsg = "cannot close input file"; return ERR; } - fprintf(stdout, !scripted ? "%lu\n" : "", size); + if (!scripted) + fprintf(stdout, "%lu\n", size); return current_addr - n; } @@ -161,7 +162,8 @@ write_file(char *fn, const char *mode, long n, long m) errmsg = "cannot close output file"; return ERR; } - fprintf(stdout, !scripted ? "%lu\n" : "", size); + if (!scripted) + fprintf(stdout, "%lu\n", size); return n ? m - n + 1 : 0; } diff --git a/bin/ed/main.c b/bin/ed/main.c index fad1866..f414d40 100644 --- a/bin/ed/main.c +++ b/bin/ed/main.c @@ -192,9 +192,10 @@ top: fputs("?\n", stderr); errmsg = "warning: file modified"; if (!isatty(0)) { - fprintf(stderr, garrulous ? - "script, line %d: %s\n" : - "", lineno, errmsg); + if (garrulous) + fprintf(stderr, + "script, line %d: %s\n", + lineno, errmsg); quit(2); } clearerr(stdin); @@ -225,27 +226,26 @@ top: fputs("?\n", stderr); /* give warning */ errmsg = "warning: file modified"; if (!isatty(0)) { - fprintf(stderr, garrulous ? - "script, line %d: %s\n" : - "", lineno, errmsg); + if (garrulous) + fprintf(stderr, "script, line %d: %s\n", + lineno, errmsg); quit(2); } break; case FATAL: - if (!isatty(0)) - fprintf(stderr, garrulous ? - "script, line %d: %s\n" : "", - lineno, errmsg); - else - fprintf(stderr, garrulous ? "%s\n" : "", - errmsg); + if (!isatty(0)) { + if (garrulous) + fprintf(stderr, "script, line %d: %s\n", + lineno, errmsg); + } else if (garrulous) + fprintf(stderr, "%s\n", errmsg); quit(3); default: fputs("?\n", stderr); if (!isatty(0)) { - fprintf(stderr, garrulous ? - "script, line %d: %s\n" : "", - lineno, errmsg); + if (garrulous) + fprintf(stderr, "script, line %d: %s\n", + lineno, errmsg); quit(2); } break; |