From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/12427 Path: news.gmane.org!.POSTED!not-for-mail From: Samuel Holland Newsgroups: gmane.linux.lib.musl.general Subject: [PATCH 2/2] support long options containing equals signs Date: Mon, 29 Jan 2018 20:36:42 -0600 Message-ID: <20180130023642.2363-2-samuel@sholland.org> References: <20180130023642.2363-1-samuel@sholland.org> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1517279709 16898 195.159.176.226 (30 Jan 2018 02:35:09 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 30 Jan 2018 02:35:09 +0000 (UTC) Cc: Samuel Holland To: musl@lists.openwall.com Original-X-From: musl-return-12443-gllmg-musl=m.gmane.org@lists.openwall.com Tue Jan 30 03:35:05 2018 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1egLlB-0003ek-It for gllmg-musl@m.gmane.org; Tue, 30 Jan 2018 03:34:57 +0100 Original-Received: (qmail 20035 invoked by uid 550); 30 Jan 2018 02:36:57 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 19962 invoked from network); 30 Jan 2018 02:36:56 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= cc:date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=xtTy4TmPGi1evEBlF TbDPajrlODvY0r++yMOIHKHEGg=; b=i1I7GK80izZnW85TLSwEtxlrxvsSlqvHw deMQ4QHMzkjr5WdcvjHMtbfq0NuUqvDbzpRHy2+1CZ5tpilzLgE8PnH5iDsIEwLZ rvqBLzc/91TkBR7mcCKJ985i3LYa2tqm6cuSJAtbIlacaxsJQUkc0o/QDv2UZ5BY Mc/Scf5PcnD7hvqGPNf4sEGWa3TFe/sAqCvjW1KfFOPa/J+yXqgTsEJao134ydsv qBFpEMaSKXDzGEYoSmHpN0ga0Zi9Kd3GmlO+iY/c6ajBkXIcp3+CcreTV8RpHSAP o4NcG3sasUnaT8YKj2GWWIXYP2zy7mVHuiH7B588cV3EhZeHVxnjw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=xtTy4TmPGi1evEBlFTbDPajrlODvY0r++yMOIHKHEGg=; b=Q/zKPSGZ Z2WYFOWsZItur9BSXTGJvLKQLXyQ4NgQe5RCnCSUEcAodm/GbkN95rOnma+OjIp4 rMvSxp/kMpBVyjIK6OUuOd+KIXNt1E4nObQzOvMQVobZRJ3HK5VURMsZnx6a2hzP Aswdqiv2pyDicYF94xjZsugCEWVORp0An9sITdDL8FQXWxzsmdqTuue3oZjZDzvR hXUkmZ7QDWQ/lHGRC/YcG9eC9gebnPIBWq7FRs1Vih6Nw0uSs5bl020OiVxdri7A j1Hg6mjSlpEN7IsqmWmPX86fqUTjiw/0r0WsFVuT1xu0nUj2tpwlcUzL2gmx0WSz LjsOphd00+Af7Q== X-ME-Sender: X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180130023642.2363-1-samuel@sholland.org> Xref: news.gmane.org gmane.linux.lib.musl.general:12427 Archived-At: 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