aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2023-10-04 22:56:06 +0200
committerThomas Voss <mail@thomasvoss.com> 2023-10-04 22:56:06 +0200
commit0809286db1636b6a981e0b397d6d2bdea2a00e15 (patch)
treeade62ad34534ea38c8ca12db580d11a6e9a16551
parent05939962175d0b89b8955418b4c660d66ada6cb2 (diff)
Assert that the argument to ‘-p’ isn’t emptyv1.0.2
-rw-r--r--main.l7
1 files changed, 7 insertions, 0 deletions
diff --git a/main.l b/main.l
index 3ccae4a..2d26cd0 100644
--- a/main.l
+++ b/main.l
@@ -12,6 +12,8 @@ const char empty_field[] = "argument to the -p option contains an empty field";
const char invalid_char[] = "argument to the -p option must be a "
"comma-seperated list of positive integers";
const char final_comma[] = "argument to the -p option contains trailing comma";
+const char empty_string[] = "argument to the -p option cannot be "
+ "the empty string";
const char *argv0;
unsigned pos;
@@ -102,6 +104,11 @@ append_positions(char *raw)
usage();
}
+ if (*raw == '\0') {
+ warnx(empty_string);
+ usage();
+ }
+
for (s = raw, positions.len++; *s; s++) {
switch (*s) {
case ',':