zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: "Zsh Hackers' List" <zsh-workers@zsh.org>
Subject: Re: PATCH: completion for parameter flags
Date: Sat, 4 Jun 2011 22:22:57 +0100	[thread overview]
Message-ID: <20110604222257.0d60cccd@pws-pc.ntlworld.com> (raw)
In-Reply-To: <BANLkTinFFgOFVdDT6gCKgX2GPx+kwZcz5A@mail.gmail.com>

On Sat, 4 Jun 2011 14:39:52 +0200
Mikael Magnusson <mikachu@gmail.com> wrote:
> ${(<tab> shows me glob qualifiers.
> foo${(<tab> does nothing at all.

This exposed an existing bug, that "${(stuff) wasn't handled properly.
In a quoted string it needs to scan for untokenized parentheses.

Index: Completion/Zsh/Context/_brace_parameter
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Zsh/Context/_brace_parameter,v
retrieving revision 1.2
diff -p -u -r1.2 _brace_parameter
--- Completion/Zsh/Context/_brace_parameter	3 Jun 2011 22:06:59 -0000	1.2
+++ Completion/Zsh/Context/_brace_parameter	4 Jun 2011 21:19:17 -0000
@@ -4,7 +4,7 @@ local char delim found_percent found_m e
 local -a flags
 integer q_last n_q
 
-if [[ $PREFIX = '${('[^\)]# ]]; then
+if [[ $PREFIX = *'${('[^\)]# ]]; then
   # Parameter flags.
   compset -p 3
 
Index: Src/Zle/compcore.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/compcore.c,v
retrieving revision 1.108
diff -p -u -r1.108 compcore.c
--- Src/Zle/compcore.c	3 Jun 2011 22:07:00 -0000	1.108
+++ Src/Zle/compcore.c	4 Jun 2011 21:19:17 -0000
@@ -1099,7 +1099,7 @@ mod_export char *
 check_param(char *s, int set, int test)
 {
     char *p;
-    int found = 0;
+    int found = 0, qstring = 0;
 
     zsfree(parpre);
     parpre = NULL;
@@ -1126,6 +1126,7 @@ check_param(char *s, int set, int test)
 		!(*p == String && p[1] == Snull) &&
 		!(*p == Qstring && p[1] == '\'')) {
 		found = 1;
+		qstring = (*p == Qstring);
 		break;
 	    }
 	}
@@ -1161,7 +1162,8 @@ check_param(char *s, int set, int test)
 
 	    /* Ignore the possible (...) flags. */
 	    b++, br++;
-	    if (skipparens(Inpar, Outpar, &b) > 0) {
+	    if ((qstring ? skipparens('(', ')', &b) :
+		 skipparens(Inpar, Outpar, &b)) > 0) {
 		/*
 		 * We are still within the parameter flags.  There's no
 		 * point trying to do anything clever here with

-- 
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/


      reply	other threads:[~2011-06-04 21:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-03 20:54 Peter Stephenson
2011-06-04 12:39 ` Mikael Magnusson
2011-06-04 21:22   ` Peter Stephenson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110604222257.0d60cccd@pws-pc.ntlworld.com \
    --to=p.w.stephenson@ntlworld.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).