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:
Douglas Clowes
2014-01-30 14:52:28 +11:00
parent 91d0dc86f5
commit 3abc6c9e60
5 changed files with 20 additions and 78 deletions

View File

@ -16,26 +16,6 @@ namespace eval ::scobj::cybaman {
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} {
set my_list [list]
set idx 0

View File

@ -74,25 +74,6 @@ namespace eval ::scobj::[set vendor]_[set device] {
debug_log 1 "Extract channel $result from argument $arg"
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} {
# send a command to set a value

View File

@ -80,25 +80,6 @@ namespace eval ::scobj::[set vendor]_[set device] {
debug_log 1 "Extract channel $result from argument $arg"
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} {
# send a command to set a value

View File

@ -35,26 +35,6 @@ namespace eval ::scobj::[set vendor]_[set device] {
} 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 {} {
return "[namespace current]"
}

View File

@ -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
# running on an external Tcl interpreter.
set errorInfo ""