blob: 0a070872a49b18a8362bb3839d1f00ab3be57335 (
plain)
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
#// objective: tests processing of commands inside brackets [], only references/referencedby relations are relevant
#// check: 058__bracket__recursion_8tcl.xml
#// config: REFERENCED_BY_RELATION = yes
#// config: REFERENCES_RELATION = yes
#// config: EXTRACT_ALL = yes
#// config: INLINE_SOURCES = yes
##
# \brief should be reference by every proc below
proc Invoked args {
puts "Procedure \"Invoked\" is invoked indeed. Ok."
return $args
}
##
# \brief must not be reference by every proc below
proc NotInvoked args {
puts "Procedure \"NotInvoked\" is invoked. Not Ok!"
return $args
}
#
# check if call references work at all
proc a args {
Invoked NotInvoked
return
}
#
# check brackets with various quoting, bracing
proc b args {
set r [Invoked]
set r [list \[NotInvoked \]]
return
}
proc c args {
set r \{[Invoked]\}
set r {[NotInvoked]}
return
}
proc d args {
set r "[Invoked]"
set r "\[NotInvoked \]"
return
}
proc e args {
set r [list \[NotInvoked [Invoked]\]]
return
}
proc f args {
set r [list [Invoked \[NotInvoked \]]]
return
}
proc g args {
set r "{[Invoked]}"
set r "{\[NotInvoked \]}"
return
}
proc h args {
[Invoked set] r {[NotInvoked]}
return
}
# check brackets in tcl commands containing script arguments
#
# example generated according to
# https://groups.google.com/d/msg/comp.lang.tcl/G5-mc3GiIyY/e-AVD9t7xMkJ
proc i args {
foreach item [Invoked] {
return
}
}
proc j args {
foreach [Invoked item] [list one two three] {
}
return
}
proc k args {
while {[Invoked 0]} {
}
}
proc l args {
for {} {[Invoked 0]} {} {
}
}
proc m args {
if {[Invoked 1]} {
}
}
proc n args {
if [Invoked 1] {
}
}
proc o args {
if {0} {
} elseif {[Invoked 0]} {
}
}
# these are really nasty examples
# they shows, that the condition argument may not be parsed as a script
set NotInvoked \$NotInvoked
proc $NotInvoked args {
puts "Procedure \"\$NotInvoked\" is invoked. Not Ok!"
return $args
}
proc p args {
set NotInvoked \$NotInvoked
if {$NotInvoked eq [Invoked 1]} {
}
return
}
proc q args {
set NotInvoked \$NotInvoked
if {0} {
} elseif {$NotInvoked eq [Invoked 1]} {
}
return
}
proc r args {
set NotInvoked \$NotInvoked
while {$NotInvoked eq [Invoked 1]} {
}
return
}
proc s args {
set NotInvoked \$NotInvoked
for {} {$NotInvoked eq [Invoked 1]} {} {
}
return
}
# dangling open brackets should not confuse the scanner
proc t args {
set foo ]]]][Invoked]
return
}
#
# call all single letter procs
# let tcl check what is called and what is not called
foreach p [info procs ?] {
puts "Check procedure \"$p\""
$p
}
exit
|