limit the number of looked-at tokens to 32

pull/436/head
romkatv 5 years ago
parent 2db236fc69
commit 251ec93396

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

Loading…
Cancel
Save