/usr/share/tau/tools/inc/stack.tcl is in tau-racy 2.16.4-1.5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | #*********************************************************************#
#* TAU/pC++/Sage++ Copyright (C) 1994 *#
#* Jerry Manic Saftware *#
#* Indiana University University of Oregon University of Rennes *#
#*********************************************************************#
# -- generic stack for tcl
#
# -- stacks are implemented by a "struct"
# -- stack(length) contains the number of elements stored in stack
# -- stack(data) is a list of the values
#
# initStack: initialize stack
#
# stack: variable name for new stack
#
proc initStack {stack} {
upvar $stack s
set s(length) 0
set s(data) [list]
}
#
# pushStack: push value onto stack
#
# stack: variable name for stack
# val: value to push
#
proc pushStack {stack val} {
upvar $stack s
incr s(length)
lappend s(data) $val
}
#
# popStack: pop value from stack
#
# stack: variable name for stack
#
proc popStack {stack} {
upvar $stack s
if { $s(length) } {
set i [incr s(length) -1]
set r [lindex $s(data) $i]
set s(data) [lreplace $s(data) $i $i]
return $r
} else {
return ""
}
}
#
# topStack: return top value from stack without popping it
#
# stack: variable name for stack
#
proc topStack {stack} {
upvar $stack s
lindex $s(data) [expr $s(length) - 1]
}
|