* Proposed patches for make completion bugs
@ 2015-04-28 0:45 Jared Ahern
2015-04-28 8:34 ` Peter Stephenson
0 siblings, 1 reply; 2+ messages in thread
From: Jared Ahern @ 2015-04-28 0:45 UTC (permalink / raw)
To: zsh-workers
[-- Attachment #1: Type: text/plain, Size: 3590 bytes --]
Hello,
I've been using zsh for years and it is excellent. One thing that I
realized recently was that it was not completing the "make" command
correctly, so I investigated, using version 5.0.7 as a base. As far as I
can tell, my problems resulted from two issues. The first was that zsh did
not recognize the ?= or ::= forms of variable assignment in at least GNU
make. This should be corrected with this patch:
diff -rup a/Completion/Unix/Command/_make b/Completion/Unix/Command/_make
--- a/Completion/Unix/Command/_make 2013-11-27 14:00:19.000000000 -0500
+++ b/Completion/Unix/Command/_make 2015-04-27 20:17:05.000000000 -0400
@@ -64,18 +64,18 @@ _make-parseMakefile () {
while read input
do
case "$input " in
- # VARIABLE = value
- ([[:alnum:]][[:alnum:]_]#[ $TAB]#=*)
- var=${input%%[ $TAB]#=*}
+ # VARIABLE = value OR VARIABLE ?= value
+ ([[:alnum:]][[:alnum:]_]#[ $TAB]#(\?|)=*)
+ var=${input%%[ $TAB]#(\?|)=*}
val=${input#*=}
val=${val##[ $TAB]#}
VARIABLES[$var]=$val
;;
- # VARIABLE := value
+ # VARIABLE := value OR VARIABLE ::= value
# Evaluated immediately
- ([[:alnum:]][[:alnum:]_]#[ $TAB]#:=*)
- var=${input%%[ $TAB]#:=*}
+ ([[:alnum:]][[:alnum:]_]#[ $TAB]#:(:|)=*)
+ var=${input%%[ $TAB]#:(:|)=*}
val=${input#*=}
val=${val##[ $TAB]#}
val=$(_make-expandVars $val)
The second issue is that as far as I can tell, expansion of "make"
variables was not happening at all. This should be addressed by this
separate second patch, although I may have induced regressions of which I
am unaware. I wasn't 100% sure what the original intent was for the
_make-expandVars function, but my cases appear to be fixed.
diff -rup a/Completion/Unix/Command/_make c/Completion/Unix/Command/_make
--- a/Completion/Unix/Command/_make 2013-11-27 14:00:19.000000000 -0500
+++ c/Completion/Unix/Command/_make 2015-04-27 20:17:17.000000000 -0400
@@ -7,51 +7,52 @@ _make-expandVars() {
local open close var val front ret tmp=$1
front=${tmp%%\$*}
+ tmp=${tmp#$front}
case $tmp in
- (\(*) # Variable of the form $(foobar)
+ (\$\(*) # Variable of the form $(foobar)
open='('
close=')'
;;
- ({*) # ${foobar}
+ (\${*) # ${foobar}
open='{'
close='}'
;;
- ([[:alpha:]]*) # $foobar. This is exactly $(f)oobar.
+ (\$[[:alpha:]]*) # $foobar. This is exactly $(f)oobar.
open=''
close=''
- var=${(s::)var[1]}
+ var=${(s::)tmp[2]}
;;
- (\$*) # Escaped $.
+ (\$\$*) # Escaped $.
print -- "${front}\$$(_make-expandVars ${tmp#\$})"
return
;;
(*) # Nothing left to substitute.
- print -- $tmp
+ print -- ${front}${tmp}
return
;;
esac
if [[ -n $open ]]
then
- var=${tmp#$open}
+ var=${tmp#\$$open}
var=${var%%$close*}
fi
case $var in
([[:alnum:]_]#)
val=${VARIABLES[$var]}
- ret=${ret//\$$open$var$close/$val}
+ ret=${tmp//\$$open$var$close/$val}
;;
(*)
# Improper variable name. No replacement.
# I'm not sure if this is desired behavior.
front+="\$$open$var$close"
- ret=${ret/\$$open$var$close/}
+ ret=${tmp/\$$open$var$close/}
;;
esac
The sourceforge site for zsh indicated that proposed patches should be sent
to this email address, but please email me if I should do anything
different, or if you need more info. Hopefully I've included all the
correct patch text. With luck, these two changes will make it into a future
version of zsh!
Thanks,
Jared
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Proposed patches for make completion bugs
2015-04-28 0:45 Proposed patches for make completion bugs Jared Ahern
@ 2015-04-28 8:34 ` Peter Stephenson
0 siblings, 0 replies; 2+ messages in thread
From: Peter Stephenson @ 2015-04-28 8:34 UTC (permalink / raw)
To: zsh-workers; +Cc: Jared Ahern
On Mon, 27 Apr 2015 20:45:55 -0400
Jared Ahern <jared.ahern@gmail.com> wrote:
> The second issue is that as far as I can tell, expansion of "make"
> variables was not happening at all. This should be addressed by this
> separate second patch, although I may have induced regressions of which I
> am unaware. I wasn't 100% sure what the original intent was for the
> _make-expandVars function, but my cases appear to be fixed.
It's certainly hard to see how the old code could work...
local open close var val front ret tmp=$1
front=${tmp%%\$*}
case $tmp in
(\(*) # Variable of the form $(foobar)
... if tmp still has a $, how can matching it without a $ at the start
of the case be useful? I'll assume this is an improvement and apply
both patches until someone comes up with a counterexample.
Thanks
pws
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-04-28 8:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-28 0:45 Proposed patches for make completion bugs Jared Ahern
2015-04-28 8:34 ` Peter Stephenson
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).