1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-08 12:01:21 +02:00

33320 (cf. PWS 33311): revert 33069, fix lexing of bangchar during completion

add typtab_flags bits (replaces specialcomma boolean) to record any unusual handling of typtab entries; signal safety; make bangchar non-special during completion lexing of the command line.
This commit is contained in:
Barton E. Schaefer 2014-10-02 08:39:43 -07:00
parent 7adc786b05
commit 57252dc1e0
5 changed files with 56 additions and 9 deletions

View file

@ -1,3 +1,11 @@
2014-10-02 Barton E. Schaefer <schaefer@zsh.org>
* 33320 (cf. PWS 33311): Completion/Base/Completer/_expand_alias,
Src/Zle/compcore.c, Src/utils.c, Src/ztype.h: revert 33069; add
typtab_flags bits (replaces specialcomma boolean) to record any
unusual handling of typtab entries; signal safety; make bangchar
non-special during completion lexing of the command line.
2014-10-02 Peter Stephenson <p.stephenson@samsung.com> 2014-10-02 Peter Stephenson <p.stephenson@samsung.com>
* 33325: Src/exec.c, Test/A05execution.ztst: fix ksh autoloads * 33325: Src/exec.c, Test/A05execution.ztst: fix ksh autoloads

View file

@ -25,8 +25,6 @@ else
pre=(_main_complete - aliases) pre=(_main_complete - aliases)
fi fi
[[ "$compstate[quoting]" = (single|double) ]] || word="${(Q)word}"
zstyle -s ":completion:${curcontext}:" regular tmp || tmp=yes zstyle -s ":completion:${curcontext}:" regular tmp || tmp=yes
case $tmp in case $tmp in
always) sel=r;; always) sel=r;;

View file

@ -702,6 +702,7 @@ callcompfunc(char *s, char *fn)
} }
zsfree(compprefix); zsfree(compprefix);
zsfree(compsuffix); zsfree(compsuffix);
makebangspecial(0);
if (unset(COMPLETEINWORD)) { if (unset(COMPLETEINWORD)) {
tmp = (linwhat == IN_MATH ? dupstring(s) : multiquote(s, 0)); tmp = (linwhat == IN_MATH ? dupstring(s) : multiquote(s, 0));
untokenize(tmp); untokenize(tmp);
@ -722,6 +723,7 @@ callcompfunc(char *s, char *fn)
untokenize(ss); untokenize(ss);
compsuffix = ztrdup(ss); compsuffix = ztrdup(ss);
} }
makebangspecial(1);
zsfree(complastprefix); zsfree(complastprefix);
zsfree(complastsuffix); zsfree(complastsuffix);
complastprefix = ztrdup(compprefix); complastprefix = ztrdup(compprefix);

View file

@ -3424,12 +3424,12 @@ equalsplit(char *s, char **t)
return 0; return 0;
} }
static int specialcomma;
/* the ztypes table */ /* the ztypes table */
/**/ /**/
mod_export short int typtab[256]; mod_export short int typtab[256];
static int typtab_flags = 0;
/* initialize the ztypes table */ /* initialize the ztypes table */
@ -3440,8 +3440,15 @@ inittyptab(void)
int t0; int t0;
char *s; char *s;
for (t0 = 0; t0 != 256; t0++) if (!(typtab_flags & ZTF_INIT)) {
typtab[t0] = 0; typtab_flags = ZTF_INIT;
if (interact && isset(SHINSTDIN))
typtab_flags |= ZTF_INTERACT;
}
queue_signals();
memset(typtab, 0, sizeof(typtab));
for (t0 = 0; t0 != 32; t0++) for (t0 = 0; t0 != 32; t0++)
typtab[t0] = typtab[t0 + 128] = ICNTRL; typtab[t0] = typtab[t0 + 128] = ICNTRL;
typtab[127] = ICNTRL; typtab[127] = ICNTRL;
@ -3514,20 +3521,43 @@ inittyptab(void)
#endif #endif
for (s = SPECCHARS; *s; s++) for (s = SPECCHARS; *s; s++)
typtab[STOUC(*s)] |= ISPECIAL; typtab[STOUC(*s)] |= ISPECIAL;
if (specialcomma) if (typtab_flags & ZTF_SP_COMMA)
typtab[STOUC(',')] |= ISPECIAL; typtab[STOUC(',')] |= ISPECIAL;
if (isset(BANGHIST) && bangchar && interact && isset(SHINSTDIN)) if (isset(BANGHIST) && bangchar && (typtab_flags & ZTF_INTERACT)) {
typtab_flags |= ZTF_BANGCHAR;
typtab[bangchar] |= ISPECIAL; typtab[bangchar] |= ISPECIAL;
} else
typtab_flags &= ~ZTF_BANGCHAR;
unqueue_signals();
} }
/**/ /**/
mod_export void mod_export void
makecommaspecial(int yesno) makecommaspecial(int yesno)
{ {
if ((specialcomma = yesno) != 0) if (yesno != 0) {
typtab_flags |= ZTF_SP_COMMA;
typtab[STOUC(',')] |= ISPECIAL; typtab[STOUC(',')] |= ISPECIAL;
else } else {
typtab_flags &= ~ZTF_SP_COMMA;
typtab[STOUC(',')] &= ~ISPECIAL; typtab[STOUC(',')] &= ~ISPECIAL;
}
}
/**/
mod_export void
makebangspecial(int yesno)
{
/* Name and call signature for congruence with makecommaspecial(),
* but in this case when yesno is nonzero we defer to the state
* saved by inittyptab().
*/
if (yesno == 0) {
typtab[bangchar] &= ~ISPECIAL;
} else if (typtab_flags & ZTF_BANGCHAR) {
typtab[bangchar] |= ISPECIAL;
}
} }

View file

@ -59,6 +59,15 @@
#define iwsep(X) zistype(X,IWSEP) #define iwsep(X) zistype(X,IWSEP)
#define inull(X) zistype(X,INULL) #define inull(X) zistype(X,INULL)
/*
* Bit flags for typtab_flags --- preserved after
* shell initialisation.
*/
#define ZTF_INIT (0x0001) /* One-off initialisation done */
#define ZTF_INTERACT (0x0002) /* Shell interative and reading from stdin */
#define ZTF_SP_COMMA (0x0004) /* Treat comma as a special characters */
#define ZTF_BANGCHAR (0x0008) /* Treat bangchar as a special character */
#ifdef MULTIBYTE_SUPPORT #ifdef MULTIBYTE_SUPPORT
#define WC_ZISTYPE(X,Y) wcsitype((X),(Y)) #define WC_ZISTYPE(X,Y) wcsitype((X),(Y))
#define WC_ISPRINT(X) iswprint(X) #define WC_ISPRINT(X) iswprint(X)