From 1d76d014d4278daf128115a72fb2df910b203e6d Mon Sep 17 00:00:00 2001 From: marko Date: Tue, 14 Aug 2007 20:46:47 +0000 Subject: [PATCH] Remove comments embedded in switch construct in popupConfigApply in an attempt to unbreak it -> man n switch says comments may not be embedded in between switch tokens / sections, it seems that my copy of tclsh8.4 becomes really nervous about that (the older versions did not complain as far as I can recall). While here, do some indentation cleanups. Bug found by: Submitted by: Reviewed by: Approved by: Obtained from: --- editor.tcl | 212 +++++++++++++++++++++++++---------------------------- 1 file changed, 99 insertions(+), 113 deletions(-) diff --git a/editor.tcl b/editor.tcl index e8a8f54..f9fdf2c 100755 --- a/editor.tcl +++ b/editor.tcl @@ -1,4 +1,4 @@ -# $Id: editor.tcl,v 1.73 2007/08/10 18:31:52 ana Exp $ +# $Id: editor.tcl,v 1.74 2007/08/14 20:46:47 marko Exp $ # # Copyright 2004, 2005 University of Zagreb, Croatia. All rights reserved. # @@ -2620,9 +2620,6 @@ proc popupConfigApply { wi object_type target phase } { return } switch -exact -- $object_type { - # - # Node - # node { set type [nodeType $target] set model [getNodeModel $target] @@ -2637,9 +2634,6 @@ proc popupConfigApply { wi object_type target phase } { set changed 1 } - # - # Queue config - # foreach ifc [ifcList $target] { if { [nodeType [peerByIfc $target $ifc]] != "rj45" && \ [nodeType $target] != "rj45" } { @@ -2666,127 +2660,117 @@ proc popupConfigApply { wi object_type target phase } { } if {[[typemodel $target].layer] == "NETWORK"} { - foreach ifc [ifcList $target] { - # - # Operational state - # - global [subst ifoper$ifc] - set ifoperstate [subst $[subst ifoper$ifc]] - set oldifoperstate [getIfcOperState $target $ifc] - if { $ifoperstate != $oldifoperstate } { - setIfcOperState $target $ifc $ifoperstate - set changed 1 - } + foreach ifc [ifcList $target] { + global [subst ifoper$ifc] + set ifoperstate [subst $[subst ifoper$ifc]] + set oldifoperstate [getIfcOperState $target $ifc] + if { $ifoperstate != $oldifoperstate } { + setIfcOperState $target $ifc $ifoperstate + set changed 1 + } - # - # IPv4 / IPv6 address & MTU - # - set ipaddr [$wi.if$ifc.cfg.ipv4.addrv get] - set oldipaddr [getIfcIPv4addr $target $ifc] - if { $ipaddr != $oldipaddr } { - setIfcIPv4addr $target $ifc $ipaddr - set changed 1 - } - set ipaddr [$wi.if$ifc.cfg.ipv6.addrv get] - set oldipaddr [getIfcIPv6addr $target $ifc] - if { $ipaddr != $oldipaddr } { - setIfcIPv6addr $target $ifc $ipaddr - set changed 1 - } + set ipaddr [$wi.if$ifc.cfg.ipv4.addrv get] + set oldipaddr [getIfcIPv4addr $target $ifc] + if { $ipaddr != $oldipaddr } { + setIfcIPv4addr $target $ifc $ipaddr + set changed 1 + } + set ipaddr [$wi.if$ifc.cfg.ipv6.addrv get] + set oldipaddr [getIfcIPv6addr $target $ifc] + if { $ipaddr != $oldipaddr } { + setIfcIPv6addr $target $ifc $ipaddr + set changed 1 + } - set mtu [$wi.if$ifc.label.mtuv get] - set oldmtu [getIfcMTU $target $ifc] - if { $mtu != $oldmtu } { - setIfcMTU $target $ifc $mtu - set changed 1 + set mtu [$wi.if$ifc.label.mtuv get] + set oldmtu [getIfcMTU $target $ifc] + if { $mtu != $oldmtu } { + setIfcMTU $target $ifc $mtu + set changed 1 + } } - } - - set oldIPv4statrtes [lsort [getStatIPv4routes $target]] - set oldIPv6statrtes [lsort [getStatIPv6routes $target]] - set newIPv4statrtes {} - set newIPv6statrtes {} - set i 1 - while { 1 } { - set text [$wi.statrt.cfg.text get $i.0 $i.end] - set rtentry [lrange [split [string trim $text]] 0 2] - if { $rtentry == "" } { - break - } - set dst [lindex $rtentry 0] - set gw [lindex $rtentry 1] - set metric [lindex $rtentry 2] - if { [string is integer $metric] != 1 || $metric > 65535 } { - break - } - if { [checkIPv4Net $dst] == 1 } { - if { [checkIPv4Addr $gw] == 1 } { - lappend newIPv4statrtes [string trim "$dst $gw $metric"] - } else { + set oldIPv4statrtes [lsort [getStatIPv4routes $target]] + set oldIPv6statrtes [lsort [getStatIPv6routes $target]] + set newIPv4statrtes {} + set newIPv6statrtes {} + set i 1 + while { 1 } { + set text [$wi.statrt.cfg.text get $i.0 $i.end] + set rtentry [lrange [split [string trim $text]] 0 2] + if { $rtentry == "" } { + break + } + set dst [lindex $rtentry 0] + set gw [lindex $rtentry 1] + set metric [lindex $rtentry 2] + if { [string is integer $metric] != 1 || $metric > 65535 } { break } - } elseif { [checkIPv6Net $dst] == 1 } { - if { [checkIPv6Addr $gw] == 1 } { - lappend newIPv6statrtes [string trim "$dst $gw $metric"] + if { [checkIPv4Net $dst] == 1 } { + if { [checkIPv4Addr $gw] == 1 } { + lappend newIPv4statrtes [string trim "$dst $gw $metric"] + } else { + break + } + } elseif { [checkIPv6Net $dst] == 1 } { + if { [checkIPv6Addr $gw] == 1 } { + lappend newIPv6statrtes [string trim "$dst $gw $metric"] + } else { + break + } } else { break } - } else { - break + incr i + } + set newIPv4statrtes [lsort $newIPv4statrtes] + if { $oldIPv4statrtes != $newIPv4statrtes } { + setStatIPv4routes $target $newIPv4statrtes + set changed 1 + } + set newIPv6statrtes [lsort $newIPv6statrtes] + if { $oldIPv6statrtes != $newIPv6statrtes } { + setStatIPv6routes $target $newIPv6statrtes + set changed 1 } - incr i - } - set newIPv4statrtes [lsort $newIPv4statrtes] - if { $oldIPv4statrtes != $newIPv4statrtes } { - setStatIPv4routes $target $newIPv4statrtes - set changed 1 - } - set newIPv6statrtes [lsort $newIPv6statrtes] - if { $oldIPv6statrtes != $newIPv6statrtes } { - setStatIPv6routes $target $newIPv6statrtes - set changed 1 - } - set oldcustomenabled [getCustomEnabled $target] - if {$oldcustomenabled != $customEnabled} { - setCustomEnabled $target $customEnabled - set changed 1 - } + set oldcustomenabled [getCustomEnabled $target] + if {$oldcustomenabled != $customEnabled} { + setCustomEnabled $target $customEnabled + set changed 1 + } - if { $showIPsecConfig == 0 } { - set ipsecEnabled 0 - } - set oldipsecenabled [getIpsecEnabled $target] - if {$oldipsecenabled != $ipsecEnabled} { - setIpsecEnabled $target $ipsecEnabled - set changed 1 - } + if { $showIPsecConfig == 0 } { + set ipsecEnabled 0 + } + set oldipsecenabled [getIpsecEnabled $target] + if {$oldipsecenabled != $ipsecEnabled} { + setIpsecEnabled $target $ipsecEnabled + set changed 1 + } - set oldcpuconf [getNodeCPUConf $target] - set newcpuconf {} - set cpumin [$wi.cpu.mine get] - set cpumax [$wi.cpu.maxe get] - set cpuweight [$wi.cpu.weighte get] - if { $cpumin != "" } { - lappend newcpuconf "min $cpumin" - } - if { $cpumax != "" } { - lappend newcpuconf "max $cpumax" - } - if { $cpuweight != "" } { - lappend newcpuconf "weight $cpuweight" - } - if { $oldcpuconf != $newcpuconf } { - setNodeCPUConf $target [list $newcpuconf] - set changed 1 + set oldcpuconf [getNodeCPUConf $target] + set newcpuconf {} + set cpumin [$wi.cpu.mine get] + set cpumax [$wi.cpu.maxe get] + set cpuweight [$wi.cpu.weighte get] + if { $cpumin != "" } { + lappend newcpuconf "min $cpumin" + } + if { $cpumax != "" } { + lappend newcpuconf "max $cpumax" + } + if { $cpuweight != "" } { + lappend newcpuconf "weight $cpuweight" + } + if { $oldcpuconf != $newcpuconf } { + setNodeCPUConf $target [list $newcpuconf] + set changed 1 + } } - } # XXX node } - # - # Link - # link { set mirror [getLinkMirror $target] set bw [$wi.bandwidth.value get] @@ -2839,8 +2823,10 @@ proc popupConfigApply { wi object_type target phase } { if { $changed == 1 && $oper_mode == "exec" } { execSetLinkParams $eid $target } - } # XXX link } + + } + if { $changed == 1 } { redrawAll updateUndoLog -- 2.39.5