summaryrefslogtreecommitdiff
path: root/Src/Zle/complete.c
diff options
context:
space:
mode:
authorDaniel Shahaf <d.s@daniel.shahaf.name>2016-11-01 17:26:09 +0000
committerDaniel Shahaf <d.s@daniel.shahaf.name>2016-11-03 16:44:14 +0000
commit952e607395ffd7e7592227344139e611854cf2c8 (patch)
treeb57547c8ecdc4ddedf3cc8b81b6cced70ae91e1e /Src/Zle/complete.c
parent36b290814f5c2176f67f10746d5e899ccc260a67 (diff)
downloadzsh-952e607395ffd7e7592227344139e611854cf2c8.tar.gz
zsh-952e607395ffd7e7592227344139e611854cf2c8.zip
39803: internal: Document bin_compadd().
Diffstat (limited to 'Src/Zle/complete.c')
-rw-r--r--Src/Zle/complete.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/Src/Zle/complete.c b/Src/Zle/complete.c
index 73619347c..484754bee 100644
--- a/Src/Zle/complete.c
+++ b/Src/Zle/complete.c
@@ -555,8 +555,8 @@ static int
bin_compadd(char *name, char **argv, UNUSED(Options ops), UNUSED(int func))
{
struct cadata dat;
- char *p, **sp, *e, *m = NULL, *mstr = NULL;
- int dm;
+ char *mstr = NULL; /* argument of -M options, accumulated */
+ int added; /* return value */
Cmatcher match = NULL;
if (incompfunc != 1) {
@@ -572,14 +572,16 @@ bin_compadd(char *name, char **argv, UNUSED(Options ops), UNUSED(int func))
dat.dummies = -1;
for (; *argv && **argv == '-'; argv++) {
+ char *p; /* loop variable, points into argv */
if (!(*argv)[1]) {
argv++;
break;
}
for (p = *argv + 1; *p; p++) {
- sp = NULL;
- e = NULL;
- dm = 0;
+ char *m = NULL; /* argument of -M option (this one only) */
+ char **sp = NULL; /* the argument to an option should be copied
+ to *sp. */
+ const char *e; /* error message */
switch (*p) {
case 'q':
dat.flags |= CMF_REMOVE;
@@ -661,7 +663,6 @@ bin_compadd(char *name, char **argv, UNUSED(Options ops), UNUSED(int func))
case 'M':
sp = &m;
e = "matching specification expected after -%c";
- dm = 1;
break;
case 'X':
sp = &(dat.exp);
@@ -748,14 +749,13 @@ bin_compadd(char *name, char **argv, UNUSED(Options ops), UNUSED(int func))
zsfree(mstr);
return 1;
}
- if (dm) {
+ if (m) {
if (mstr) {
char *tmp = tricat(mstr, " ", m);
zsfree(mstr);
mstr = tmp;
} else
mstr = ztrdup(m);
- m = NULL;
}
}
}
@@ -774,10 +774,10 @@ bin_compadd(char *name, char **argv, UNUSED(Options ops), UNUSED(int func))
return 1;
dat.match = match = cpcmatcher(match);
- dm = addmatches(&dat, argv);
+ added = addmatches(&dat, argv);
freecmatcher(match);
- return dm;
+ return added;
}
#define CVT_RANGENUM 0