summary refs log tree commit diff
path: root/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main.c')
-rw-r--r--main.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/main.c b/main.c
index 56edb04..395f7f1 100644
--- a/main.c
+++ b/main.c
@@ -257,9 +257,11 @@ uint64_t str_hash(Str s) {
 /* --hvar bgcolor:'#fcc,#cfc,#ccf,#cff,#ffc,#fcf' */
 int hvar_calc(Str param, Str *name, Str *val, Str filename) {
 	Cut c = str_cut(param, ':');
+	if (!c.head.n || !c.tail.n) return -1;
 	*name = c.head;
 	usize n = 0;
 	for (Str h = c.tail; h.n > 0; h = str_cut(h, ',').tail) n++;
+	if (!n) return -1;
 	srand(str_hash(filename));
 	usize j = rand() % n;
 	usize i = 0;
@@ -270,7 +272,7 @@ int hvar_calc(Str param, Str *name, Str *val, Str filename) {
 		}
 		i++;
 	}
-	return 1;
+	return -1;
 }
 
 void usage(const char *cmd) {
@@ -409,7 +411,7 @@ int main(int argc, const char **argv) {
 				for (int i = 0; i < opts.hvarc; i++) {
 					Str name, val;
 					if (hvar_calc(opts.hvarv[i], &name, &val, title)) {
-						fprintf(stderr, "failed to caluclate hashvar!\n");
+						fprintf(stderr, "invalid argument given to --hvar\n");
 						return 1;
 					}
 					str_cat(&thtml, S("--"), &scratch);