summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2016-09-15 23:05:57 -0400
committerJune McEnroe <june@causal.agency>2016-09-15 23:05:57 -0400
commit2c268e502b56c7593d9d2d2bf5f63cc2d0852ffc (patch)
treee80d8f7ecae82305aef885c29b65b7a291fd239a
parentUse strtoul in xx (diff)
downloadsrc-2c268e502b56c7593d9d2d2bf5f63cc2d0852ffc.tar.gz
src-2c268e502b56c7593d9d2d2bf5f63cc2d0852ffc.zip
Use sysexits.h in xx
-rwxr-xr-x.bin/xx.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/.bin/xx.c b/.bin/xx.c
index 5ee22f6f..9b8f5d0f 100755
--- a/.bin/xx.c
+++ b/.bin/xx.c
@@ -7,6 +7,7 @@ exec clang -Weverything -Wno-vla $@ -o $(dirname $0)/xx $0
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <sysexits.h>
 #include <unistd.h>
 
 static bool zero(const uint8_t *buf, size_t len) {
@@ -41,17 +42,17 @@ int main(int argc, char **argv) {
             flags ^= FLAG_SKIP;
         else {
             fprintf(stderr, "usage: xx [-afk] [-c N] [-g N] [FILE]\n");
-            return (opt == 'h') ? EXIT_SUCCESS : EXIT_FAILURE;
+            return (opt == 'h') ? EX_OK : EX_USAGE;
         }
     }
-    if (!cols) return EXIT_FAILURE;
+    if (!cols) return EX_USAGE;
     if (argc > optind)
         path = argv[optind];
 
     FILE *file = path ? fopen(path, "r") : stdin;
     if (!file) {
         perror(path);
-        return EXIT_FAILURE;
+        return EX_NOINPUT;
     }
 
     uint8_t buf[cols];
@@ -93,7 +94,7 @@ int main(int argc, char **argv) {
 
     if (ferror(file)) {
         perror(path);
-        return EXIT_FAILURE;
+        return EX_IOERR;
     }
-    return EXIT_SUCCESS;
+    return EX_OK;
 }