zsh-workers
 help / color / mirror / code / Atom feed
From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: zsh-workers@zsh.org
Subject: [PATCH 4/4] internal: Document some compadd internals.
Date: Tue,  1 Nov 2016 17:26:11 +0000	[thread overview]
Message-ID: <1478021171-22495-4-git-send-email-danielsh@fujitsu.shahaf.local2> (raw)
In-Reply-To: <1478021171-22495-1-git-send-email-danielsh@fujitsu.shahaf.local2>

---
 Src/Zle/comp.h     | 19 +++++++++----------
 Src/Zle/compcore.c | 12 ++++++++++--
 2 files changed, 19 insertions(+), 12 deletions(-)

diff --git a/Src/Zle/comp.h b/Src/Zle/comp.h
index 14af617..3711fde 100644
--- a/Src/Zle/comp.h
+++ b/Src/Zle/comp.h
@@ -125,7 +125,7 @@ struct cmatch {
 #define CMF_REMOVE   (1<< 1)	/* remove the suffix */
 #define CMF_ISPAR    (1<< 2)	/* is paramter expansion */
 #define CMF_PARBR    (1<< 3)	/* paramter expansion with a brace */
-#define CMF_PARNEST  (1<< 4)	/* nested paramter expansion */
+#define CMF_PARNEST  (1<< 4)	/* nested parameter expansion */
 #define CMF_NOLIST   (1<< 5)	/* should not be listed */
 #define CMF_DISPLINE (1<< 6)	/* display strings one per line */
 #define CMF_HIDE     (1<< 7)	/* temporarily hide this one */
@@ -235,7 +235,6 @@ struct cpattern {
  * the anchor. */
 
 typedef struct cline *Cline;
-typedef struct clsub Clsub;
 
 struct cline {
     Cline next;
@@ -291,14 +290,14 @@ struct menuinfo {
 
 /* Flags for compadd and addmatches(). */
 
-#define CAF_QUOTE    1
-#define CAF_NOSORT   2
-#define CAF_MATCH    4
-#define CAF_UNIQCON  8
-#define CAF_UNIQALL 16
-#define CAF_ARRAYS  32
-#define CAF_KEYS    64
-#define CAF_ALL    128
+#define CAF_QUOTE    1    /* compadd -Q: positional arguments already quoted */
+#define CAF_NOSORT   2    /* compadd -V: don't sort */
+#define CAF_MATCH    4    /* compadd without -U: do matching */
+#define CAF_UNIQCON  8    /* compadd -2: don't deduplicate */
+#define CAF_UNIQALL 16    /* compadd -1: deduplicate */
+#define CAF_ARRAYS  32    /* compadd -a or -k: array/assoc parameter names */
+#define CAF_KEYS    64    /* compadd -k: assoc parameter names */
+#define CAF_ALL    128    /* compadd -C: _all_matches */
 
 /* Data for compadd and addmatches() */
 
diff --git a/Src/Zle/compcore.c b/Src/Zle/compcore.c
index f69f680..fe16c13 100644
--- a/Src/Zle/compcore.c
+++ b/Src/Zle/compcore.c
@@ -1976,6 +1976,11 @@ get_user_var(char *nam)
     }
 }
 
+/*
+ * If KEYS, then NAME is an associative array; return its keys.
+ * Else, NAME is a plain array; return its elements.
+ */
+
 static char **
 get_data_arr(char *name, int keys)
 {
@@ -2037,16 +2042,17 @@ addmatch(char *str, int flags, char ***dispp, int line)
 int
 addmatches(Cadata dat, char **argv)
 {
+    /* ms: "match string" - string to use as completion.
+     * Overloaded at one place as a temporary. */
     char *s, *ms, *lipre = NULL, *lisuf = NULL, *lpre = NULL, *lsuf = NULL;
     char **aign = NULL, **dparr = NULL, *oaq = autoq, *oppre = dat->ppre;
     char *oqp = qipre, *oqs = qisuf, qc, **disp = NULL, *ibuf = NULL;
     char **arrays = NULL;
-    int lpl, lsl, sl, bcp = 0, bcs = 0, bpadd = 0, bsadd = 0;
+    int lpl, lsl, bcp = 0, bcs = 0, bpadd = 0, bsadd = 0;
     int ppl = 0, psl = 0, ilen = 0;
     int llpl = 0, llsl = 0, nm = mnum, gflags = 0, ohp = haspattern;
     int isexact, doadd, ois = instring, oib = inbackt;
     Cline lc = NULL, pline = NULL, sline = NULL;
-    Cmatch cm;
     struct cmlist mst;
     Cmlist oms = mstack;
     Patprog cp = NULL, *pign = NULL;
@@ -2424,6 +2430,7 @@ addmatches(Cadata dat, char **argv)
 	if (dat->psuf)
 	    psl = strlen(dat->psuf);
 	for (; (s = *argv); argv++) {
+	    int sl;
 	    bpl = obpl;
 	    bsl = obsl;
 	    if (disp) {
@@ -2484,6 +2491,7 @@ addmatches(Cadata dat, char **argv)
 		goto next_array;
 	    }
 	    if (doadd) {
+		Cmatch cm;
 		Brinfo bp;
 
 		for (bp = obpl; bp; bp = bp->next)


      parent reply	other threads:[~2016-11-01 17:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-01 17:26 [PATCH 1/4] internal: Document and simplify multiquote() Daniel Shahaf
2016-11-01 17:26 ` [PATCH 2/4] internal: Document bin_compadd() Daniel Shahaf
2016-11-01 17:26 ` [PATCH 3/4] internal: Document matchspec flags Daniel Shahaf
2016-11-01 17:26 ` Daniel Shahaf [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=1478021171-22495-4-git-send-email-danielsh@fujitsu.shahaf.local2 \
    --to=d.s@daniel.shahaf.name \
    --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).