Move pathname and basename utility functions to extra_utility
This makes them generally available to SICS (and it's early)
This commit is contained in:
@ -16,26 +16,6 @@ namespace eval ::scobj::cybaman {
|
|||||||
close $fd
|
close $fd
|
||||||
}
|
}
|
||||||
|
|
||||||
proc basename {node} {
|
|
||||||
set point [string last "/" $node]
|
|
||||||
if { $point < 0 } {
|
|
||||||
return $node
|
|
||||||
} else {
|
|
||||||
incr point
|
|
||||||
return "[string range $node $point end]"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
proc pathname {node} {
|
|
||||||
set point [string last "/" $node]
|
|
||||||
if { $point < 0 } {
|
|
||||||
return ""
|
|
||||||
} else {
|
|
||||||
incr point -1
|
|
||||||
return "[string range $node 0 $point]"
|
|
||||||
}
|
|
||||||
return "[join [lrange [split $node '/'] 0 end-1] '/']"
|
|
||||||
}
|
|
||||||
|
|
||||||
proc splitxml {str} {
|
proc splitxml {str} {
|
||||||
set my_list [list]
|
set my_list [list]
|
||||||
set idx 0
|
set idx 0
|
||||||
|
@ -74,25 +74,6 @@ namespace eval ::scobj::[set vendor]_[set device] {
|
|||||||
debug_log 1 "Extract channel $result from argument $arg"
|
debug_log 1 "Extract channel $result from argument $arg"
|
||||||
return $result
|
return $result
|
||||||
}
|
}
|
||||||
proc basename {node} {
|
|
||||||
set point [string last "/" $node]
|
|
||||||
if { $point < 0 } {
|
|
||||||
return $node
|
|
||||||
} else {
|
|
||||||
incr point
|
|
||||||
return "[string range $node $point end]"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
proc pathname {node} {
|
|
||||||
set point [string last "/" $node]
|
|
||||||
if { $point < 0 } {
|
|
||||||
return ""
|
|
||||||
} else {
|
|
||||||
incr point -1
|
|
||||||
return "[string range $node 0 $point]"
|
|
||||||
}
|
|
||||||
return "[join [lrange [split $node '/'] 0 end-1] '/']"
|
|
||||||
}
|
|
||||||
|
|
||||||
proc setValue {tc_root nextState cmd} {
|
proc setValue {tc_root nextState cmd} {
|
||||||
# send a command to set a value
|
# send a command to set a value
|
||||||
|
@ -80,25 +80,6 @@ namespace eval ::scobj::[set vendor]_[set device] {
|
|||||||
debug_log 1 "Extract channel $result from argument $arg"
|
debug_log 1 "Extract channel $result from argument $arg"
|
||||||
return $result
|
return $result
|
||||||
}
|
}
|
||||||
proc basename {node} {
|
|
||||||
set point [string last "/" $node]
|
|
||||||
if { $point < 0 } {
|
|
||||||
return $node
|
|
||||||
} else {
|
|
||||||
incr point
|
|
||||||
return "[string range $node $point end]"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
proc pathname {node} {
|
|
||||||
set point [string last "/" $node]
|
|
||||||
if { $point < 0 } {
|
|
||||||
return ""
|
|
||||||
} else {
|
|
||||||
incr point -1
|
|
||||||
return "[string range $node 0 $point]"
|
|
||||||
}
|
|
||||||
return "[join [lrange [split $node '/'] 0 end-1] '/']"
|
|
||||||
}
|
|
||||||
|
|
||||||
proc setPoint {tc_root nextState cmd} {
|
proc setPoint {tc_root nextState cmd} {
|
||||||
# send a command to set a value
|
# send a command to set a value
|
||||||
|
@ -35,26 +35,6 @@ namespace eval ::scobj::[set vendor]_[set device] {
|
|||||||
} catch_message ]
|
} catch_message ]
|
||||||
}
|
}
|
||||||
|
|
||||||
proc basename {node} {
|
|
||||||
set point [string last "/" $node]
|
|
||||||
if { $point < 0 } {
|
|
||||||
return $node
|
|
||||||
} else {
|
|
||||||
incr point
|
|
||||||
return "[string range $node $point end]"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
proc pathname {node} {
|
|
||||||
set point [string last "/" $node]
|
|
||||||
if { $point < 0 } {
|
|
||||||
return ""
|
|
||||||
} else {
|
|
||||||
incr point -1
|
|
||||||
return "[string range $node 0 $point]"
|
|
||||||
}
|
|
||||||
return "[join [lrange [split $node '/'] 0 end-1] '/']"
|
|
||||||
}
|
|
||||||
|
|
||||||
proc ns {} {
|
proc ns {} {
|
||||||
return "[namespace current]"
|
return "[namespace current]"
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,23 @@
|
|||||||
|
# utility functions like basename/dirname in bash (dcl)
|
||||||
|
proc basename {node} {
|
||||||
|
set point [string last "/" $node]
|
||||||
|
if { $point < 0 } {
|
||||||
|
return $node
|
||||||
|
} else {
|
||||||
|
incr point
|
||||||
|
return "[string range $node $point end]"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
proc pathname {node} {
|
||||||
|
set point [string last "/" $node]
|
||||||
|
if { $point < 0 } {
|
||||||
|
return ""
|
||||||
|
} else {
|
||||||
|
incr point -1
|
||||||
|
return "[string range $node 0 $point]"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# Many of these functions are also useful in test and debug code
|
# Many of these functions are also useful in test and debug code
|
||||||
# running on an external Tcl interpreter.
|
# running on an external Tcl interpreter.
|
||||||
set errorInfo ""
|
set errorInfo ""
|
||||||
|
Reference in New Issue
Block a user