mirror of
git://git.code.sf.net/p/zsh/code
synced 2024-09-28 15:01:21 +02:00
Split tokenize() into shtokenize() and zshtokenize()
to improve SH_GLOB handling, particularly in completion
This commit is contained in:
parent
b7aa69cb7d
commit
cefd2de2e1
@ -2797,7 +2797,7 @@ readoutput(int in, int qt)
|
||||
|
||||
while (*words) {
|
||||
if (isset(GLOBSUBST))
|
||||
tokenize(*words);
|
||||
shtokenize(*words);
|
||||
addlinknode(ret, *words++);
|
||||
}
|
||||
}
|
||||
|
18
Src/glob.c
18
Src/glob.c
@ -2447,6 +2447,20 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr)
|
||||
/**/
|
||||
mod_export void
|
||||
tokenize(char *s)
|
||||
{
|
||||
zshtokenize(s, 0);
|
||||
}
|
||||
|
||||
/**/
|
||||
mod_export void
|
||||
shtokenize(char *s)
|
||||
{
|
||||
zshtokenize(s, isset(SHGLOB));
|
||||
}
|
||||
|
||||
/**/
|
||||
static void
|
||||
zshtokenize(char *s, int shglob)
|
||||
{
|
||||
char *t;
|
||||
int bslash = 0;
|
||||
@ -2463,7 +2477,7 @@ tokenize(char *s)
|
||||
bslash = 1;
|
||||
continue;
|
||||
case '<':
|
||||
if (isset(SHGLOB))
|
||||
if (shglob)
|
||||
break;
|
||||
if (bslash) {
|
||||
s[-1] = Bnull;
|
||||
@ -2482,7 +2496,7 @@ tokenize(char *s)
|
||||
case '(':
|
||||
case '|':
|
||||
case ')':
|
||||
if (isset(SHGLOB))
|
||||
if (shglob)
|
||||
break;
|
||||
case '>':
|
||||
case '^':
|
||||
|
10
Src/subst.c
10
Src/subst.c
@ -197,7 +197,7 @@ stringsubst(LinkList list, LinkNode node, int ssub, int asssub)
|
||||
continue;
|
||||
}
|
||||
if (!qt && ssub && isset(GLOBSUBST))
|
||||
tokenize(s);
|
||||
shtokenize(s);
|
||||
l1 = str2 - str3;
|
||||
l2 = strlen(s);
|
||||
if (nonempty(pl)) {
|
||||
@ -450,14 +450,14 @@ strcatsub(char **d, char *pb, char *pe, char *src, int l, char *s, int glbsub,
|
||||
if (!pl && (!s || !*s)) {
|
||||
*d = dest = (copied ? src : dupstring(src));
|
||||
if (glbsub)
|
||||
tokenize(dest);
|
||||
shtokenize(dest);
|
||||
} else {
|
||||
*d = dest = hcalloc(pl + l + (s ? strlen(s) : 0) + 1);
|
||||
strncpy(dest, pb, pl);
|
||||
dest += pl;
|
||||
strcpy(dest, src);
|
||||
if (glbsub)
|
||||
tokenize(dest);
|
||||
shtokenize(dest);
|
||||
dest += l;
|
||||
if (s)
|
||||
strcpy(dest, s);
|
||||
@ -1595,7 +1595,7 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub)
|
||||
if (!quoteerr) {
|
||||
errflag = oef;
|
||||
if (haserr)
|
||||
tokenize(s);
|
||||
shtokenize(s);
|
||||
} else if (haserr || errflag) {
|
||||
zerr("parse error in ${...%c...} substitution",
|
||||
NULL, s[-1]);
|
||||
@ -2063,7 +2063,7 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub)
|
||||
else {
|
||||
y = dupstring(x);
|
||||
if (globsubst)
|
||||
tokenize(y);
|
||||
shtokenize(y);
|
||||
}
|
||||
insertlinknode(l, n, (void *) y), incnode(n);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user