1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-01-01 05:16:05 +01:00

31465: fix basic completion and globbing uses of disabled patterns

This commit is contained in:
Peter Stephenson 2013-06-13 18:40:36 +01:00
parent fdf2867e5f
commit 347a63da0c
4 changed files with 87 additions and 36 deletions

View file

@ -1,3 +1,13 @@
2013-06-13 Peter Stephenson <p.w.stephenson@ntlworld.com>
* 31465: Completion/compinit, Src/glob.c, Src/pattern.c: fix
basic completion and globbing use of pattern disables.
* 31444: Doc/Zsh/builtins.yo, Doc/Zsh/options.yo,
Doc/zmacros.yo, Src/builtin.c, Src/exec.c, Src/options.c,
Src/pattern.c, Src/zsh.h: Basic (not fully functional) code for
enable/disable -p.
2013-06-13 Barton E. Schaefer <schaefer@zsh.org>
* 31474: Makefile.in, Src/zsh.mdd: create patchlevel.h correctly

View file

@ -163,8 +163,9 @@ _comp_options=(
typeset -g _comp_setup='local -A _comp_caller_options;
_comp_caller_options=(${(kv)options[@]});
setopt localoptions localtraps ${_comp_options[@]};
setopt localoptions localtraps localpatterns ${_comp_options[@]};
local IFS=$'\'\ \\t\\r\\n\\0\''
enable -p \| \~ \( \? \* \[ \< \^ \#
exec </dev/null;
trap - ZERR
local -a reply

View file

@ -445,41 +445,6 @@ insert(char *s, int checked)
unqueue_signals();
}
/* Check to see if str is eligible for filename generation. */
/**/
mod_export int
haswilds(char *str)
{
/* `[' and `]' are legal even if bad patterns are usually not. */
if ((*str == Inbrack || *str == Outbrack) && !str[1])
return 0;
/* If % is immediately followed by ?, then that ? is *
* not treated as a wildcard. This is so you don't have *
* to escape job references such as %?foo. */
if (str[0] == '%' && str[1] == Quest)
str[1] = '?';
for (; *str; str++) {
switch (*str) {
case Inpar:
case Bar:
case Star:
case Inbrack:
case Inang:
case Quest:
return 1;
case Pound:
case Hat:
if (isset(EXTENDEDGLOB))
return 1;
break;
}
}
return 0;
}
/* Do the globbing: scanner is called recursively *
* with successive bits of the path until we've *
* tried all of it. */

View file

@ -3966,3 +3966,78 @@ clearpatterndisables(void)
{
memset(zpc_disables, 0, ZPC_COUNT);
}
/* Check to see if str is eligible for filename generation. */
/**/
mod_export int
haswilds(char *str)
{
char *start;
/* `[' and `]' are legal even if bad patterns are usually not. */
if ((*str == Inbrack || *str == Outbrack) && !str[1])
return 0;
/* If % is immediately followed by ?, then that ? is *
* not treated as a wildcard. This is so you don't have *
* to escape job references such as %?foo. */
if (str[0] == '%' && str[1] == Quest)
str[1] = '?';
/*
* Note that at this point zpc_special has not been set up.
*/
start = str;
for (; *str; str++) {
switch (*str) {
case Inpar:
if ((!isset(SHGLOB) && !zpc_disables[ZPC_INPAR]) ||
(str > start && isset(KSHGLOB) &&
((str[-1] == Quest && !zpc_disables[ZPC_KSH_QUEST]) ||
(str[-1] == Star && !zpc_disables[ZPC_KSH_STAR]) ||
(str[-1] == '+' && !zpc_disables[ZPC_KSH_PLUS]) ||
(str[-1] == '!' && !zpc_disables[ZPC_KSH_BANG]) ||
(str[-1] == '@' && !zpc_disables[ZPC_KSH_AT]))))
return 1;
break;
case Bar:
if (!zpc_disables[ZPC_BAR])
return 1;
break;
case Star:
if (!zpc_disables[ZPC_STAR])
return 1;
break;
case Inbrack:
if (!zpc_disables[ZPC_INBRACK])
return 1;
break;
case Inang:
if (!zpc_disables[ZPC_INANG])
return 1;
break;
case Quest:
if (!zpc_disables[ZPC_QUEST])
return 1;
break;
case Pound:
if (isset(EXTENDEDGLOB) && !zpc_disables[ZPC_HASH])
return 1;
break;
case Hat:
if (isset(EXTENDEDGLOB) && !zpc_disables[ZPC_HAT])
return 1;
break;
}
}
return 0;
}