From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28858 invoked by alias); 21 Oct 2015 17:44:29 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 36908 Received: (qmail 23540 invoked from network); 21 Oct 2015 17:44:28 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.0 X-Biglobe-Sender: Content-Type: text/plain; charset=iso-8859-1 Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) Subject: Re: configure --with- completion From: "Jun T." In-Reply-To: <20151020130008.GA20896@zira.vinc17.org> Date: Thu, 22 Oct 2015 01:11:55 +0900 Content-Transfer-Encoding: quoted-printable Message-Id: References: <20150904084027.GA15509@zira.vinc17.org> <20151020130008.GA20896@zira.vinc17.org> To: zsh-workers@zsh.org X-Mailer: Apple Mail (2.1878.6) X-Biglobe-Spnum: 63730 2015/10/20 22:00, Vincent Lefevre wrote: > The problem seems to come to the fact that >=20 > --with-gmp-build=3DDIR GMP build directory (please read INSTALL = file) >=20 > is listed after >=20 > --with-gmp=3DDIR GMP install directory Yes. For example,=20 % _foo() {=20 _arguments : '-x=3D:switch:(on off)' '-xy=3D:answer:(yes no)' = '*:file:_files' } % compdef _foo foo % foo -xy=3D this completes nothing. If -x and -xy are exchanged, it works as = expected. In ca_get_opt() (computil.c:1167), the current word seems to be compared with optspecs in the order they are passed to _arguments. In the = example above, the current word "-xy=3D" is first compared with '-x', and since '-x' matches with the beginning of "-xy=3D" (strpfx() at line 1695), it is considered as the option -x followed by 'y=3D'. So the next = (correct) optspec '-xy' is not tried. Probably we need to look at the next character after the option '-x' ('y' in the above example), and if the type of the option is CAO_OEQUAL and the next character is not '=3D' (or NULL), then reject '-x' and=20 go to the next possible option '-xy'. But I rather hesitate to modify functions which I don't understand well yet. A workaround (for '_arguments --') would be to modify _arguments as in the patch below. It sorts the optspecs generated by '_arguments --' so that --with-gmp-build comes before --with-gmp. But this patch has effect only with '_arguments --', and does not fix the example above (-x and -xy). Patching computil.c would be better ... diff --git a/Completion/Base/Utility/_arguments = b/Completion/Base/Utility/_arguments index 87fb20e..fa9750e 100644 --- a/Completion/Base/Utility/_arguments +++ b/Completion/Base/Utility/_arguments @@ -303,7 +303,13 @@ if (( long )); then fi fi done - set -A "$name" "${(@)cache:# #}" + # Sort the optspecs in $cache so that -xy comes before -x (this + # seems to be required by a restriction (or bug) of comparguments). + # We do this by the following steps: + # add '~' at the end of option name, sort, and remove '~'. + # ('~'=3D0x7e comes after any other printable ASCII characters) + tmp=3D( ${${(o)${${cache:# = #}/(#b)([a-zA-Z0-9_-]#)/$match[1]~}}/\~/} ) + set -A "$name" "$tmp[@]" fi set -- "$tmpargv[@]" "${(@P)name}" fi