1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-06-22 22:58:03 +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; 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 `...`) */ /* 1 if we are completing in a quoted string (or inside `...`) */
/**/ /**/
@ -1364,9 +1368,15 @@ get_comp_string(void)
zsfree(varname); zsfree(varname);
varname = ztrdup(tt); varname = ztrdup(tt);
*s = sav; *s = sav;
if (skipparens(Inbrack, Outbrack, &s) > 0 || s > tt + cs - wb) if (skipparens(Inbrack, Outbrack, &s) > 0 || s > tt + cs - wb) {
s = NULL, inwhat = IN_MATH, insubscr = 1; s = NULL;
else if (*s == '=' && cs > wb + (s - tt)) { 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++; s++;
wb += s - tt; wb += s - tt;
t0 = STRING; t0 = STRING;
@ -1424,11 +1434,15 @@ get_comp_string(void)
zsfree(varname); zsfree(varname);
varname = ztrdup(nb); varname = ztrdup(nb);
*ne = sav; *ne = sav;
if ((keypm = (Param) paramtab->getnode(paramtab,
varname)) &&
(keypm->flags & PM_HASHED))
insubscr = 2;
} }
} }
} }
if (inwhat == IN_MATH) { if (inwhat == IN_MATH) {
if (compfunc) { if (compfunc || insubscr == 2) {
int lev; int lev;
char *p; char *p;
@ -1472,7 +1486,11 @@ get_comp_string(void)
zsfree(varname); zsfree(varname);
varname = ztrdup((char *) line + i + 1); varname = ztrdup((char *) line + i + 1);
line[wb - 1] = sav; 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. */ /* 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) { if ((list = getshfunc(fn)) != &dummy_list) {
char **p, *tmp; 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; Param *ocpms = comppms;
comppms = (Param *) zalloc(CP_NUM * sizeof(Param)); comppms = (Param *) zalloc(CP_NUM * sizeof(Param));
set = -1 & ~(CP_PARAMETER | CP_REDIRECT | CP_QUOTE | CP_QUOTING | set = CP_ALLMASK &
CP_EXACTSTR | CP_FORCELIST | CP_OLDLIST | CP_OLDINS | ~(CP_PARAMETER | CP_REDIRECT | CP_QUOTE | CP_QUOTING |
(useglob ? 0 : CP_PATMATCH)); 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) if (!*complastprompt)
set &= ~CP_LASTPROMPT; set &= ~CP_LASTPROMPT;
zsfree(compcontext); zsfree(compcontext);
@ -4821,13 +4847,22 @@ makecomplistglobal(char *os, int incmd, int lst, int flags)
char *s; char *s;
ccont = CC_CCCONT; ccont = CC_CCCONT;
cc_dummy.suffix = NULL;
if (linwhat == IN_ENV) { if (linwhat == IN_ENV) {
/* Default completion for parameter values. */ /* Default completion for parameter values. */
cc = &cc_default; cc = &cc_default;
keypm = NULL;
} else if (linwhat == IN_MATH) { } else if (linwhat == IN_MATH) {
/* Parameter names inside mathematical expression. */ if (insubscr == 2) {
cc_dummy.mask = CC_PARAMS; /* 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 = &cc_dummy;
cc_dummy.refc = 10000; cc_dummy.refc = 10000;
} else if (linwhat == IN_COND) { } else if (linwhat == IN_COND) {
@ -4843,13 +4878,16 @@ makecomplistglobal(char *os, int incmd, int lst, int flags)
(CC_FILES | CC_PARAMS); (CC_FILES | CC_PARAMS);
cc = &cc_dummy; cc = &cc_dummy;
cc_dummy.refc = 10000; cc_dummy.refc = 10000;
} else if (linredir) keypm = NULL;
} else if (linredir) {
/* In redirections use default completion. */ /* In redirections use default completion. */
cc = &cc_default; cc = &cc_default;
else keypm = NULL;
} else {
/* Otherwise get the matches for the command. */ /* Otherwise get the matches for the command. */
keypm = NULL;
return makecomplistcmd(os, incmd, flags); return makecomplistcmd(os, incmd, flags);
}
if (cc) { if (cc) {
/* First, use the -T compctl. */ /* First, use the -T compctl. */
if (!(flags & CFN_FIRST)) { 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))) if ((t = cc->mask & (CC_ALREG | CC_ALGLOB)))
/* Add the two types of aliases. */ /* Add the two types of aliases. */
dumphashtable(aliastab, t | (cc->mask & (CC_DISCMDS|CC_EXCMDS))); 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) { if (!errflag && cc->ylist) {
/* generate the user-defined display list: if anything fails, * /* generate the user-defined display list: if anything fails, *
* we silently allow the normal completion list to be used. */ * we silently allow the normal completion list to be used. */
@ -7562,10 +7605,12 @@ listlist(LinkList l)
struct cmgroup dg; struct cmgroup dg;
Cmgroup am = amatches; Cmgroup am = amatches;
int vl = validlist, sm = smatches; int vl = validlist, sm = smatches;
char *oclp = complastprompt;
if (listshown) if (listshown)
showagain = 1; showagain = 1;
complastprompt = ((zmult == 1) == !!isset(ALWAYSLASTPROMPT) ? "yes" : NULL);
smatches = 1; smatches = 1;
validlist = 1; validlist = 1;
amatches = &dg; amatches = &dg;
@ -7576,6 +7621,7 @@ listlist(LinkList l)
amatches = am; amatches = am;
validlist = vl; validlist = vl;
smatches = sm; smatches = sm;
complastprompt = oclp;
} }
/* Expand the history references. */ /* Expand the history references. */