From 770bf934442b1e2cefc9ce65e3da204b5ec0d170 Mon Sep 17 00:00:00 2001 From: romkatv Date: Sun, 12 Jan 2020 09:43:42 +0100 Subject: [PATCH] get rid of captures --- internal/parse.zsh | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/internal/parse.zsh b/internal/parse.zsh index 2c0e8cf7..0a4a5027 100644 --- a/internal/parse.zsh +++ b/internal/parse.zsh @@ -145,11 +145,16 @@ function _parse_buffer() { local -r id='(<->|[[:alpha:]_][[:IDENT:]]#)' local -r var="\$$id|\${$id}|\"\$$id\"|\"\${$id}\"" - local -i e c=32 + local -i e ic c=1024 local skip n s r state - local -a aln alp alf v commands match mbegin mend + local -a aln alp alf v commands - [[ -o interactive_comments ]] && local tokens=(${(Z+C+)1}) || local tokens=(${(z)1}) + if [[ -o interactive_comments ]]; then + ic=1 + local tokens=(${(Z+C+)1}) + else + local tokens=(${(z)1}) + fi () { while (( $#tokens )); do @@ -171,25 +176,26 @@ function _parse_buffer() { tokens[1]=() if (( $+galiases[$token] )); then (( $aln[(eI)p$token] )) && break - n=p$token s=$galiases[$token] + n=p$token elif (( e )); then break elif (( $+aliases[$token] )); then (( $aln[(eI)p$token] )) && break - n=p$token s=$aliases[$token] - elif [[ $token == (#b)?*.(?*) ]] && (( $+saliases[$match[1]] )); then - (( $aln[(eI)s$match[1]] )) && break - n=s$match[1] - s=${saliases[$match[1]]%% #} + n=p$token + elif [[ $token == ?*.?* ]] && (( $+saliases[${token##*.}] )); then + r=${token##*.} + (( $aln[(eI)s$r] )) && break + s=${saliases[$r]%% #} + n=s$r else break fi aln+=$n alp+=$#tokens [[ $s == *' ' ]] && alf+=$#tokens - [[ -o interactive_comments ]] && tokens[1,0]=(${(Z+C+)s}) || tokens[1,0]=(${(z)s}) + (( ic )) && tokens[1,0]=(${(Z+C+)s}) || tokens[1,0]=(${(z)s}) done case $state in