summary refs log tree commit diff
path: root/bin/when.y
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2024-05-22 12:16:41 -0400
committerJune McEnroe <june@causal.agency>2024-05-22 12:16:41 -0400
commit625662a5c1cbb71cf37653df1f31cd60c48b18ae (patch)
tree7a04a48f7007b30f086b353c0c03002c861383b9 /bin/when.y
parentAdd photo descriptions from 05-03 and 05-06 (diff)
downloadsrc-625662a5c1cbb71cf37653df1f31cd60c48b18ae.tar.gz
src-625662a5c1cbb71cf37653df1f31cd60c48b18ae.zip
Remove use of sysexits.h
Diffstat (limited to '')
-rw-r--r--bin/when.y15
1 files changed, 7 insertions, 8 deletions
diff --git a/bin/when.y b/bin/when.y
index bbc86084..1d3795ad 100644
--- a/bin/when.y
+++ b/bin/when.y
@@ -24,7 +24,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <strings.h>
-#include <sysexits.h>
 #include <time.h>
 
 static void yyerror(const char *str);
@@ -47,14 +46,14 @@ static const struct tm Week = { .tm_mday = 7 };
 static struct tm normalize(struct tm date) {
 	time_t time = timegm(&date);
 	struct tm *norm = gmtime(&time);
-	if (!norm) err(EX_OSERR, "gmtime");
+	if (!norm) err(1, "gmtime");
 	return *norm;
 }
 
 static struct tm today(void) {
 	time_t now = time(NULL);
 	struct tm *local = localtime(&now);
-	if (!local) err(EX_OSERR, "localtime");
+	if (!local) err(1, "localtime");
 	struct tm date = {
 		.tm_year = local->tm_year,
 		.tm_mon = local->tm_mon,
@@ -160,11 +159,11 @@ static void setDate(const char *name, struct tm date) {
 	if (dates.len == dates.cap) {
 		dates.cap = (dates.cap ? dates.cap * 2 : 8);
 		dates.ptr = realloc(dates.ptr, sizeof(*dates.ptr) * dates.cap);
-		if (!dates.ptr) err(EX_OSERR, "realloc");
+		if (!dates.ptr) err(1, "realloc");
 	}
 	dates.ptr[dates.len] = date;
 	dates.ptr[dates.len].tm_zone = strdup(name);
-	if (!dates.ptr[dates.len].tm_zone) err(EX_OSERR, "strdup");
+	if (!dates.ptr[dates.len].tm_zone) err(1, "strdup");
 	dates.len++;
 }
 
@@ -289,7 +288,7 @@ static int yylex(void) {
 
 	if (len && (len != 1 || !strchr("dwmy", *input))) {
 		yylval.tm_zone = strndup(input, len);
-		if (!yylval.tm_zone) err(EX_OSERR, "strndup");
+		if (!yylval.tm_zone) err(1, "strndup");
 		input += len;
 		return Name;
 	}
@@ -319,7 +318,7 @@ int main(int argc, char *argv[]) {
 		fclose(file);
 		silent = false;
 	} else if (errno != ENOENT) {
-		err(EX_CONFIG, "%s", path);
+		err(1, "%s", path);
 	}
 
 	if (argc > 1) {
@@ -331,7 +330,7 @@ int main(int argc, char *argv[]) {
 				printf("%s: ", dates.ptr[i].tm_zone);
 				printScalar(dateDiff(today(), dates.ptr[i]));
 			}
-			return EX_OK;
+			return 0;
 		}
 	}