aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/port/getopt_long.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/port/getopt_long.c b/src/port/getopt_long.c
index ff379db29b0..c9892769883 100644
--- a/src/port/getopt_long.c
+++ b/src/port/getopt_long.c
@@ -79,14 +79,22 @@ getopt_long(int argc, char *const argv[],
place++;
- if (place[0] && place[0] == '-' && place[1] == '\0')
- { /* found "--" */
+ if (!*place)
+ {
+ /* treat "-" as not being an option */
+ place = EMSG;
+ return -1;
+ }
+
+ if (place[0] == '-' && place[1] == '\0')
+ {
+ /* found "--", treat it as end of options */
++optind;
place = EMSG;
return -1;
}
- if (place[0] && place[0] == '-' && place[1])
+ if (place[0] == '-' && place[1])
{
/* long option */
size_t namelen;