|
Message-Id: <20180130023642.2363-2-samuel@sholland.org> Date: Mon, 29 Jan 2018 20:36:42 -0600 From: Samuel Holland <samuel@...lland.org> To: musl@...ts.openwall.com Cc: Samuel Holland <samuel@...lland.org> Subject: [PATCH 2/2] support long options containing equals signs Consider the first equals sign found in the option to be the delimiter between it and its argument, even if it matches an equals sign in the option name. This avoids consuming the equals sign, which would prevent finding the argument. Instead, it forces a partial match of the part of the option name before the equals sign. --- src/misc/getopt_long.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/misc/getopt_long.c b/src/misc/getopt_long.c index 0d1501d4..008b747c 100644 --- a/src/misc/getopt_long.c +++ b/src/misc/getopt_long.c @@ -63,7 +63,8 @@ static int __getopt_long_core(int argc, char *const *argv, const char *optstring const char *name = longopts[i].name; opt = argv[optind]+1; if (*opt == '-') opt++; - for (; *name && *name == *opt; name++, opt++); + while (*opt && *opt != '=' && *opt == *name) + name++, opt++; if (*opt && *opt != '=') continue; arg = opt; match = i; -- 2.13.6
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.