limit the number of looked-at tokens to 32

This commit is contained in:
romkatv 2020-01-11 15:47:59 +01:00
parent 2db236fc69
commit 251ec93396

View file

@ -97,6 +97,7 @@ typeset -gA _p9k_skip_arg=(
)
function _p9k_next_token() {
if (( $#tokens )); then
if (( $#tokens == aln[-1] )); then
aln[-1]=()
alp[-1]=()
@ -110,9 +111,9 @@ function _p9k_next_token() {
(( e = 1 ))
fi
while (( $#tokens )); do
while (( c-- > 0 )); do
token=$tokens[1]
shift 1 tokens
tokens[1]=()
if (( $+galiases[$token] )); then
(( $aln[(eI)p$token] )) && return
n=p$token
@ -135,6 +136,7 @@ function _p9k_next_token() {
[[ $s == *' ' ]] && alf+=$#tokens
[[ -o interactive_comments ]] && tokens[1,0]=(${(Z+C+)s}) || tokens[1,0]=(${(z)s})
done
fi
token=
return 1
@ -182,12 +184,13 @@ function _p9k_extract_commands() {
local -r id='$(<->|[[:alpha:]_][[:IDENT:]]#)'
local -r var="\$$id|\${$id}|\"\$$id\"|\"\${$id}\""
local -i e
local -i e c=32
local skip n s r
local -a aln alp alf v commands match mbegin mend
[[ -o interactive_comments ]] && local tokens=(${(Z+C+)1}) || local tokens=(${(z)1})
() {
while (( $#tokens )); do
if (( $#tokens == aln[-1] )); then
aln[-1]=()
@ -202,9 +205,9 @@ function _p9k_extract_commands() {
(( e = $#skip ))
fi
while (( $#tokens )) || break; do
while (( c-- > 0 )) || return; do
token=$tokens[1]
shift 1 tokens
tokens[1]=()
if (( $+galiases[$token] )); then
(( $aln[(eI)p$token] )) && break
n=p$token
@ -229,7 +232,7 @@ function _p9k_extract_commands() {
done
if [[ $token == '<<'(|-) ]]; then
_p9k_next_token || break
_p9k_next_token || return
r=$token
while true; do
while _p9k_next_token && [[ $token != ';' ]]; do done
@ -284,6 +287,7 @@ function _p9k_extract_commands() {
commands+=${:-${(Q)${~token}}}
skip=']'
done
}
_p9k_commands+=($commands)
_p9k_commands=(${(u)_p9k_commands:#('(('*'))'|'`'*'`'|'$'*)})