git-gui: Don't attempt to inline array reads in methods

If a variable reference to a field is to an array, and it is
the only reference to that field in that method we cannot make
it an inlined [set foo] call as the regexp was converting the
Tcl code wrong.  We were producing "[set foo](x)" for "$foo(x)",
and that isn't valid Tcl when foo is an array.  So we just punt
if the only occurance has a ( after it.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
This commit is contained in:
Shawn O. Pearce 2007-05-08 21:31:31 -04:00
parent c74b6c66f0
commit 28bf928cf8

View File

@ -96,7 +96,8 @@ proc method {name params body {deleted {}} {del_body {}}} {
set n [lindex $n 0]
if {[regexp -- $n\\M $body]} {
if { [regexp -all -- $n\\M $body] == 1
&& [regexp -all -- \\\$$n\\M $body] == 1} {
&& [regexp -all -- \\\$$n\\M $body] == 1
&& [regexp -all -- \\\$$n\\( $body] == 0} {
regsub -all \\\$$n\\M $body "\[set \${this}::$n\]" body
} else {
append decl { ${this}::} $n { } $n