From aea523c41880b73ea5f3c534e9e3474b8d0022e7 Mon Sep 17 00:00:00 2001 From: Themaister Date: Sat, 4 May 2013 01:03:46 +0200 Subject: [PATCH] Update optind correctly in getopt_long(). --- compat/compat.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/compat/compat.c b/compat/compat.c index 6427f27f36..89b1919309 100644 --- a/compat/compat.c +++ b/compat/compat.c @@ -160,12 +160,13 @@ int getopt_long(int argc, char *argv[], const char *optstring, const struct option *longopts, int *longindex) { (void)longindex; - if (argc == 1) - return -1; if (optind == 0) optind = 1; + if (argc == 1) + return -1; + int short_index = find_short_index(&argv[optind]); int long_index = find_long_index(&argv[optind]);