From 962624e8c343e3968fbb55160b8a14b460400bc0 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Sun, 19 Jun 2011 16:26:10 +0000 Subject: 29491: remove some variables set but not used --- Src/Zle/zle_tricky.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'Src/Zle/zle_tricky.c') diff --git a/Src/Zle/zle_tricky.c b/Src/Zle/zle_tricky.c index 8f7c2aac1..80a495317 100644 --- a/Src/Zle/zle_tricky.c +++ b/Src/Zle/zle_tricky.c @@ -529,7 +529,7 @@ parambeg(char *s) * or $'...'). */ char *b = p + 1, *e = b; - int n = 0, br = 1, nest = 0; + int n = 0, br = 1; if (*b == Inbrace) { char *tb = b; @@ -543,8 +543,6 @@ parambeg(char *s) n = skipparens(Inpar, Outpar, &b); for (tb = p - 1; tb > s && *tb != Outbrace && *tb != Inbrace; tb--); - if (tb > s && *tb == Inbrace && (tb[-1] == String || *tb == Qstring)) - nest = 1; } /* Ignore the stuff before the parameter name. */ -- cgit v1.2.3 From 437d5d98f6d05588e23a6d9fda50184d0b6a80bb Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Sun, 19 Jun 2011 19:42:41 +0000 Subject: unposted: Remove additional for loop noticed by Mikael --- ChangeLog | 5 ++++- Src/Zle/zle_tricky.c | 2 -- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'Src/Zle/zle_tricky.c') diff --git a/ChangeLog b/ChangeLog index 501c64b6e..446bff14b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2011-06-19 Peter Stephenson + * unposted: Src/Zle/zle_refresh.c: remove additional loop + noticed by Mikael. + * 29491: Src/glob.c, Src/lex.c, Src/math.c, Src/params.c, Src/parse.c, Src/utils.c, Src/Modules/db_gdbm.c, Src/Zle/compcore.c, Src/Zle/complist.c, Src/Zle/zle_refresh.c, @@ -15016,5 +15019,5 @@ ***************************************************** * This is used by the shell to define $ZSH_PATCHLEVEL -* $Revision: 1.5374 $ +* $Revision: 1.5375 $ ***************************************************** diff --git a/Src/Zle/zle_tricky.c b/Src/Zle/zle_tricky.c index 80a495317..3b3796dd2 100644 --- a/Src/Zle/zle_tricky.c +++ b/Src/Zle/zle_tricky.c @@ -541,8 +541,6 @@ parambeg(char *s) /* Ignore the possible (...) flags. */ b++, br++; n = skipparens(Inpar, Outpar, &b); - - for (tb = p - 1; tb > s && *tb != Outbrace && *tb != Inbrace; tb--); } /* Ignore the stuff before the parameter name. */ -- cgit v1.2.3 From e1680e68409892a4737243fff9ea9b0043e99ea0 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Thu, 23 Jun 2011 19:29:24 +0000 Subject: 29503: Missing popheap() on failed autoload --- ChangeLog | 6 +++++- Src/Zle/zle_tricky.c | 4 ---- Src/exec.c | 1 + 3 files changed, 6 insertions(+), 5 deletions(-) (limited to 'Src/Zle/zle_tricky.c') diff --git a/ChangeLog b/ChangeLog index 011a8ed7e..4e6c3f115 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-06-23 Peter Stephenson + + * 29503: Src/exec.c: Missing popheap() on failed autoload. + 2011-06-20 Peter Stephenson * unposted: update version to 4.3.12-dev-1 as wordcode @@ -15038,5 +15042,5 @@ ***************************************************** * This is used by the shell to define $ZSH_PATCHLEVEL -* $Revision: 1.5379 $ +* $Revision: 1.5380 $ ***************************************************** diff --git a/Src/Zle/zle_tricky.c b/Src/Zle/zle_tricky.c index 3b3796dd2..19787f9ff 100644 --- a/Src/Zle/zle_tricky.c +++ b/Src/Zle/zle_tricky.c @@ -2146,10 +2146,6 @@ doexpansion(char *s, int lst, int olst, int explincmd) ss = quotename(ss, NULL); untokenize(ss); inststr(ss); -#if 0 - if (olst != COMP_EXPAND_COMPLETE || nonempty(vl) || - (zlemetacs && zlemetaline[zlemetacs-1] != '/')) { -#endif if (nonempty(vl) || !first) { spaceinline(1); zlemetaline[zlemetacs++] = ' '; diff --git a/Src/exec.c b/Src/exec.c index 87a167ba6..644a58367 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -4343,6 +4343,7 @@ loadautofn(Shfunc shf, int fksh, int autol) } if (!prog) { zsfree(fname); + popheap(); return NULL; } if (ksh == 2 || (ksh == 1 && isset(KSHAUTOLOAD))) { -- cgit v1.2.3 From 4a3ce8ab89c73f88559d9c48fdb4ed459a8aceef Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Wed, 3 Aug 2011 20:57:32 +0000 Subject: 29644: work around _describe bug, plus cosmetic tweaks --- ChangeLog | 6 +++++- Functions/Chpwd/zsh_directory_name_cdr | 2 +- Src/Zle/compcore.c | 3 ++- Src/Zle/zle_tricky.c | 13 ++++++++++++- 4 files changed, 20 insertions(+), 4 deletions(-) (limited to 'Src/Zle/zle_tricky.c') diff --git a/ChangeLog b/ChangeLog index c6209fca0..dfc2b987e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2011-08-03 Peter Stephenson + * 29644: Functions/Chpwd/zsh_directory_name_cdr, + Src/Zle/compcore.c, Src/Zle/zle_tricky.c: Work round a bug in + _describe, plus a new comment and some more braces. + * 29633: Doc/Zsh/func.yo, Src/parse.c, Test/C04funcdef.ztst: be more careful that anonymous function syntax doesn't mess up working syntax with other functions. @@ -15195,5 +15199,5 @@ ***************************************************** * This is used by the shell to define $ZSH_PATCHLEVEL -* $Revision: 1.5414 $ +* $Revision: 1.5415 $ ***************************************************** diff --git a/Functions/Chpwd/zsh_directory_name_cdr b/Functions/Chpwd/zsh_directory_name_cdr index 09aa35a93..c9be7db0c 100644 --- a/Functions/Chpwd/zsh_directory_name_cdr +++ b/Functions/Chpwd/zsh_directory_name_cdr @@ -18,7 +18,7 @@ elif [[ $1 = c ]]; then values=(${${(f)"$(cdr -l)"}/ ##/:}) keys=(${values%%:*}) _describe -t dir-index 'recent directory index' \ - values keys -V unsorted -S']' + values -V unsorted -S']' return fi fi diff --git a/Src/Zle/compcore.c b/Src/Zle/compcore.c index 2e2749835..b1de6c6cc 100644 --- a/Src/Zle/compcore.c +++ b/Src/Zle/compcore.c @@ -607,7 +607,7 @@ callcompfunc(char *s, char *fn) if (rdstr) compredirect = rdstr; kset |= CP_REDIRECT; - } else + } else { switch (linwhat) { case IN_ENV: compcontext = (linarr ? "array_value" : "value"); @@ -637,6 +637,7 @@ callcompfunc(char *s, char *fn) aadd = 1; } } + } compcontext = ztrdup(compcontext); if (compwords) freearray(compwords); diff --git a/Src/Zle/zle_tricky.c b/Src/Zle/zle_tricky.c index 19787f9ff..999b2b7be 100644 --- a/Src/Zle/zle_tricky.c +++ b/Src/Zle/zle_tricky.c @@ -398,7 +398,18 @@ mod_export char *cmdstr; /**/ mod_export char *varname; -/* != 0 if we are in a subscript */ +/* + * != 0 if we are in a subscript. + * Of course, this being the completion code, you're expected to guess + * what the different numbers actually mean, but here's a cheat: + * 1: Key of an ordinary array + * 2: Key of a hash + * 3: Ummm.... this appears to be a special case of 2. After a lot + * of uncommented code looking for groups of brackets, we suddenly + * decide to set it to 2. The only upshot seems to be that compctl + * then doesn't add a matching ']' at the end, so I think it means + * there's one there already. + */ /**/ mod_export int insubscr; -- cgit v1.2.3 From 8dc39360c92252207c9287e63d2f7bb457a77aaf Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Fri, 14 Oct 2011 19:01:41 +0000 Subject: 29820: _pick_variant -b to match builtin --- ChangeLog | 8 ++++++- Completion/Base/Utility/_pick_variant | 8 ++++++- Doc/Zsh/compsys.yo | 8 ++++++- Src/Zle/zle_tricky.c | 41 +++++++++++++++++++++++++++++++++++ 4 files changed, 62 insertions(+), 3 deletions(-) (limited to 'Src/Zle/zle_tricky.c') diff --git a/ChangeLog b/ChangeLog index a9b214167..bc4572ad4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-10-14 Peter Stephenson + + * 29820: Doc/Zsh/compsys.yo, + Completion/Base/Utility/_pick_variant: -b option to match + builtins. + 2011-10-12 Mikael Magnusson * 29815: Doc/Makefile.in: include mod_langinfo in documentation. @@ -15455,5 +15461,5 @@ ***************************************************** * This is used by the shell to define $ZSH_PATCHLEVEL -* $Revision: 1.5475 $ +* $Revision: 1.5476 $ ***************************************************** diff --git a/Completion/Base/Utility/_pick_variant b/Completion/Base/Utility/_pick_variant index 01fa2b98f..9099e3599 100644 --- a/Completion/Base/Utility/_pick_variant +++ b/Completion/Base/Utility/_pick_variant @@ -6,7 +6,7 @@ local -A opts (( $+_cmd_variant )) || typeset -gA _cmd_variant -zparseopts -D -A opts c: r: +zparseopts -D -A opts b: c: r: : ${opts[-c]:=$words[1]} while [[ $1 = *=* ]]; do @@ -19,6 +19,12 @@ if (( $+_cmd_variant[$opts[-c]] )); then return 0 fi +if [[ $+opts[-b] -eq 1 && -n $builtins[$opts[-c]] ]]; then + _cmd_variant[$opts[-c]]=$opts[-b] + (( $+opts[-r] )) && eval "${opts[-r]}=${_cmd_variant[$opts[-c]]}" + return 0 +fi + output="$(_call_program variant $opts[-c] "${@[2,-1]}" &1)" for cmd pat in "$var[@]"; do diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo index d3d272c10..e07ac0e9e 100644 --- a/Doc/Zsh/compsys.yo +++ b/Doc/Zsh/compsys.yo @@ -4387,7 +4387,9 @@ tt(ambiguous), tt(special-dirs), tt(list-suffixes) and tt(file-sort) described above. ) findex(_pick_variant) -item(tt(_pick_variant [ tt(-c) var(command) ] [ tt(-r) var(name) ] var(label)tt(=)var(pattern) ... var(label) [ var(args) ... ]))( +xitem(tt(_pick_variant) [ tt(-b) var(builtin-label) ] [ tt(-c) +var(command) ] [ tt(-r) var(name) ]) +item( var(label)tt(=)var(pattern) ... var(label) [ var(args) ... ])( This function is used to resolve situations where a single command name requires more than one type of handling, either because it has more than one variant or because there is a name clash between two @@ -4403,6 +4405,10 @@ tt(...)' contains var(pattern), then tt(label) is selected as the label for the command variant. If none of the patterns match, the final command label is selected and status 1 is returned. +If the `tt(-b) var(builtin-label)' is given, the command is tested to +see if it is provided as a shell builtin, possibly autoloaded; if so, +the label var(builtin-label) is selected as the label for the variant. + If the `tt(-r) var(name)' is given, the var(label) picked is stored in the parameter named var(name). diff --git a/Src/Zle/zle_tricky.c b/Src/Zle/zle_tricky.c index 999b2b7be..6fa887a1e 100644 --- a/Src/Zle/zle_tricky.c +++ b/Src/Zle/zle_tricky.c @@ -1869,6 +1869,10 @@ get_comp_string(void) } } else if (p < curs) { if (*p == Outbrace) { + /* + * HERE: strip and remember code from last + * comma to here. + */ cant = 1; break; } @@ -1876,6 +1880,16 @@ get_comp_string(void) char *tp = p; if (!skipparens(Inbrace, Outbrace, &tp)) { + /* + * Balanced brace: skip. + * We only deal with unfinished braces, so + * something{foobar,morestuff}else + * doesn't work + * + * HERE: instead, continue, look for a comma. + * Stack tp and brace for popping when we + * find a comma at each level. + */ i += tp - p - 1; dp += tp - p - 1; p = tp - 1; @@ -1918,10 +1932,16 @@ get_comp_string(void) hascom = 1; } } else { + /* On or after the cursor position */ if (*p == Inbrace) { char *tp = p; if (!skipparens(Inbrace, Outbrace, &tp)) { + /* + * Balanced braces after the cursor. + * Could do the same with these as + * those before the cursor. + */ i += tp - p - 1; dp += tp - p - 1; p = tp - 1; @@ -1932,6 +1952,14 @@ get_comp_string(void) break; } if (p == curs) { + /* + * We've reached the cursor position. + * If there's a pending open brace at this + * point we need to stack the text. + * We've marked the bit we don't want from + * bbeg to bend, which might be a comma + * between the opening brace and us. + */ if (bbeg) { Brinfo new; int len = bend - bbeg; @@ -1961,10 +1989,23 @@ get_comp_string(void) bbeg = NULL; } if (*p == Comma) { + /* + * Comma on or after cursor. + * We set bbeg to NULL at the cursor; here + * it's being used to find the first comma + * afterwards. + */ if (!bbeg) bbeg = p; hascom = 2; } else if (*p == Outbrace) { + /* + * Closing brace on or after the cursor. + * Not sure how this can be after the cursor; + * if it was matched, wouldn't we have skipped + * over the group, and if it wasn't, surely we're + * not interested in it? + */ Brinfo new; int len; -- cgit v1.2.3