1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-06-17 09:08:04 +02:00

zsh-workers:6194

This commit is contained in:
Tanaka Akira 1999-05-04 21:21:26 +00:00
parent d14a9044cf
commit 742502db62

View file

@ -578,6 +578,10 @@ static char *varname;
static int insubscr;
/* Parameter pointer for completing keys of an assoc array. */
static Param keypm;
/* 1 if we are completing in a quoted string (or inside `...`) */
/**/
@ -1364,9 +1368,15 @@ get_comp_string(void)
zsfree(varname);
varname = ztrdup(tt);
*s = sav;
if (skipparens(Inbrack, Outbrack, &s) > 0 || s > tt + cs - wb)
s = NULL, inwhat = IN_MATH, insubscr = 1;
else if (*s == '=' && cs > wb + (s - tt)) {
if (skipparens(Inbrack, Outbrack, &s) > 0 || s > tt + cs - wb) {
s = NULL;
inwhat = IN_MATH;
if ((keypm = (Param) paramtab->getnode(paramtab, varname)) &&
(keypm->flags & PM_HASHED))
insubscr = 2;
else
insubscr = 1;
} else if (*s == '=' && cs > wb + (s - tt)) {
s++;
wb += s - tt;
t0 = STRING;
@ -1424,11 +1434,15 @@ get_comp_string(void)
zsfree(varname);
varname = ztrdup(nb);
*ne = sav;
if ((keypm = (Param) paramtab->getnode(paramtab,
varname)) &&
(keypm->flags & PM_HASHED))
insubscr = 2;
}
}
}
if (inwhat == IN_MATH) {
if (compfunc) {
if (compfunc || insubscr == 2) {
int lev;
char *p;
@ -1472,7 +1486,11 @@ get_comp_string(void)
zsfree(varname);
varname = ztrdup((char *) line + i + 1);
line[wb - 1] = sav;
insubscr = 1;
if ((keypm = (Param) paramtab->getnode(paramtab, varname)) &&
(keypm->flags & PM_HASHED))
insubscr = 2;
else
insubscr = 1;
}
}
/* This variable will hold the current word in quoted form. */
@ -4280,14 +4298,22 @@ callcompfunc(char *s, char *fn)
if ((list = getshfunc(fn)) != &dummy_list) {
char **p, *tmp;
int set, aadd = 0, usea = 1, icf = incompfunc, osc = sfcontext;
int aadd = 0, usea = 1, icf = incompfunc, osc = sfcontext;
unsigned int set;
Param *ocpms = comppms;
comppms = (Param *) zalloc(CP_NUM * sizeof(Param));
set = -1 & ~(CP_PARAMETER | CP_REDIRECT | CP_QUOTE | CP_QUOTING |
CP_EXACTSTR | CP_FORCELIST | CP_OLDLIST | CP_OLDINS |
(useglob ? 0 : CP_PATMATCH));
set = CP_ALLMASK &
~(CP_PARAMETER | CP_REDIRECT | CP_QUOTE | CP_QUOTING |
CP_EXACTSTR | CP_FORCELIST | CP_OLDLIST | CP_OLDINS |
(useglob ? 0 : CP_PATMATCH));
zsfree(compvared);
if (varedarg) {
compvared = ztrdup(varedarg);
set |= CP_VARED;
} else
compvared = ztrdup("");
if (!*complastprompt)
set &= ~CP_LASTPROMPT;
zsfree(compcontext);
@ -4821,13 +4847,22 @@ makecomplistglobal(char *os, int incmd, int lst, int flags)
char *s;
ccont = CC_CCCONT;
cc_dummy.suffix = NULL;
if (linwhat == IN_ENV) {
/* Default completion for parameter values. */
cc = &cc_default;
keypm = NULL;
} else if (linwhat == IN_MATH) {
/* Parameter names inside mathematical expression. */
cc_dummy.mask = CC_PARAMS;
if (insubscr == 2) {
/* Inside subscript of assoc array, complete keys. */
cc_dummy.mask = 0;
cc_dummy.suffix = "]";
} else {
/* Other math environment, complete paramete names. */
keypm = NULL;
cc_dummy.mask = CC_PARAMS;
}
cc = &cc_dummy;
cc_dummy.refc = 10000;
} else if (linwhat == IN_COND) {
@ -4843,13 +4878,16 @@ makecomplistglobal(char *os, int incmd, int lst, int flags)
(CC_FILES | CC_PARAMS);
cc = &cc_dummy;
cc_dummy.refc = 10000;
} else if (linredir)
keypm = NULL;
} else if (linredir) {
/* In redirections use default completion. */
cc = &cc_default;
else
keypm = NULL;
} else {
/* Otherwise get the matches for the command. */
keypm = NULL;
return makecomplistcmd(os, incmd, flags);
}
if (cc) {
/* First, use the -T compctl. */
if (!(flags & CFN_FIRST)) {
@ -5963,7 +6001,12 @@ makecomplistflags(Compctl cc, char *s, int incmd, int compadd)
if ((t = cc->mask & (CC_ALREG | CC_ALGLOB)))
/* Add the two types of aliases. */
dumphashtable(aliastab, t | (cc->mask & (CC_DISCMDS|CC_EXCMDS)));
if (keypm && cc == &cc_dummy) {
/* Add the keys of the parameter in keypm. */
scanhashtable(keypm->gets.hfn(keypm), 0, 0, PM_UNSET, addhnmatch, 0);
keypm = NULL;
cc_dummy.suffix = NULL;
}
if (!errflag && cc->ylist) {
/* generate the user-defined display list: if anything fails, *
* we silently allow the normal completion list to be used. */
@ -7562,10 +7605,12 @@ listlist(LinkList l)
struct cmgroup dg;
Cmgroup am = amatches;
int vl = validlist, sm = smatches;
char *oclp = complastprompt;
if (listshown)
showagain = 1;
complastprompt = ((zmult == 1) == !!isset(ALWAYSLASTPROMPT) ? "yes" : NULL);
smatches = 1;
validlist = 1;
amatches = &dg;
@ -7576,6 +7621,7 @@ listlist(LinkList l)
amatches = am;
validlist = vl;
smatches = sm;
complastprompt = oclp;
}
/* Expand the history references. */