From c2a262226e5a5e8aa45fa8899a4cefcb780f14aa Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Wed, 21 Jun 2023 18:33:43 -0500 Subject: [PATCH] Convert to FLAG() macros, minor cleanups. --- toys/other/bzcat.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/toys/other/bzcat.c b/toys/other/bzcat.c index f7453441..ebe93298 100644 --- a/toys/other/bzcat.c +++ b/toys/other/bzcat.c @@ -684,29 +684,24 @@ static void do_bunzip2(int fd, char *name) dotbz = 0; // For - no replace - if (toys.optflags&FLAG_t) outfd = xopen("/dev/null", O_WRONLY); - else if ((fd || strcmp(name, "-")) && !(toys.optflags&FLAG_c)) { - if (toys.optflags&FLAG_k) { - if (!dotbz || !access(name, X_OK)) { - error_msg("%s exists", name); - - return; - } - } + if (FLAG(t)) outfd = xopen("/dev/null", O_WRONLY); + else if ((fd || strcmp(name, "-")) && !FLAG(c)) { + if (FLAG(k) && (!dotbz || !access(name, X_OK))) + return error_msg("%s exists", name); outfd = copy_tempfile(fd, name, &tmp); rename++; } - if (toys.optflags&FLAG_v) printf("%s:", name); + if (FLAG(v)) printf("%s:", name); err = bunzipStream(fd, outfd); - if (toys.optflags&FLAG_v) { + if (FLAG(v)) { printf("%s\n", err ? err : "ok"); toys.exitval |= !!err; } else if (err) error_msg_raw(err); // can't test outfd==1 because may have been called with stdin+stdout closed if (rename) { - if (toys.optflags&FLAG_k) { + if (FLAG(k)) { free(tmp); tmp = 0; } else { -- 2.39.2