diff main.c @ 122:64c4de3709de

Complain if -[DIU] is given an empty argument. (Like many compilers over the years, we don't accept the argument appearing in the next argv word.) Warn about this in the man page too.
author David A. Holland
date Tue, 11 Jun 2013 18:32:41 -0400
parents 2b0b61fd1a36
children eaae8014a94a
line wrap: on
line diff
--- a/main.c	Tue Jun 11 18:02:13 2013 -0400
+++ b/main.c	Tue Jun 11 18:32:41 2013 -0400
@@ -134,6 +134,11 @@
 	struct place p2;
 	char *val;
 
+	if (*str == '\0') {
+		warnx("-D: macro name expected");
+		die();
+	}
+
 	val = strchr(str, '=');
 	if (val != NULL) {
 		*val = '\0';
@@ -153,6 +158,10 @@
 void
 commandline_undef(const struct place *p, char *str)
 {
+	if (*str == '\0') {
+		warnx("-D: macro name expected");
+		die();
+	}
 	commandline_macro_add(p, str, p, NULL);
 }
 
@@ -343,6 +352,10 @@
 void
 commandline_addincpath(struct stringarray *arr, char *s)
 {
+	if (*s == '\0') {
+		warnx("Empty include path");
+		die();
+	}
 	stringarray_add(arr, s, NULL);
 }