diff options
author | Thomas Voss <mail@thomasvoss.com> | 2023-10-04 22:56:06 +0200 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2023-10-04 22:56:06 +0200 |
commit | 0809286db1636b6a981e0b397d6d2bdea2a00e15 (patch) | |
tree | ade62ad34534ea38c8ca12db580d11a6e9a16551 | |
parent | 05939962175d0b89b8955418b4c660d66ada6cb2 (diff) |
Assert that the argument to ‘-p’ isn’t emptyv1.0.2
-rw-r--r-- | main.l | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -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 ',': |