aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-01-12 00:22:31 +0100
committerThomas Voss <mail@thomasvoss.com> 2024-01-12 00:22:31 +0100
commitcec79aabe3af8a3719defff31e8674fe712f5144 (patch)
treee6c2580093350808248f8efd95429757776aaa19
parent33cb7d45e9d3a40820237ef5c0ec52d26bbae8a5 (diff)
Add the streq() helper macro
-rw-r--r--grab.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/grab.c b/grab.c
index f42521d..7c8fdc9 100644
--- a/grab.c
+++ b/grab.c
@@ -27,6 +27,7 @@
warn(__VA_ARGS__); \
rv = EXIT_FAILURE; \
} while (0)
+#define streq(a, b) (!strcmp(a, b))
#define EEARLY "Input string terminated prematurely"
@@ -133,7 +134,7 @@ main(int argc, char **argv)
filecnt = argc - 1;
if (isatty(STDOUT_FILENO) == 1 && !env_or_default("NO_COLOR", nullptr))
- color = strcmp(env_or_default("TERM", ""), "dumb");
+ color = !streq(env_or_default("TERM", ""), "dumb");
ops = comppat(argv[0]);
if (argc == 1)
@@ -142,7 +143,7 @@ main(int argc, char **argv)
for (int i = 1; i < argc; i++) {
FILE *fp;
- if (strcmp(argv[i], "-") == 0) {
+ if (streq(argv[i], "-")) {
grab(ops, stdin, "-");
} else if ((fp = fopen(argv[i], "r")) == nullptr) {
warn("fopen: %s", argv[i]);