summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2012-12-18 10:21:34 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2012-12-18 10:21:34 (GMT)
commitee58f2d325a281f03cf6669e8d7ae2c377a5af2d (patch)
treea3ef61d217fa5bb2731a2bda48fb8c7c5a9a5086
parent71500874b393cf7e4a8528218307492dd88d18b7 (diff)
downloadtcl-ee58f2d325a281f03cf6669e8d7ae2c377a5af2d.zip
tcl-ee58f2d325a281f03cf6669e8d7ae2c377a5af2d.tar.gz
tcl-ee58f2d325a281f03cf6669e8d7ae2c377a5af2d.tar.bz2
Better version that can handle simple composite array keys as well. As long as
they are free of command substitutions, we can still safely omit the exception processor code.
-rw-r--r--generic/tclCompCmdsSZ.c33
1 files changed, 23 insertions, 10 deletions
diff --git a/generic/tclCompCmdsSZ.c b/generic/tclCompCmdsSZ.c
index 71a1dfc..7bead0d 100644
--- a/generic/tclCompCmdsSZ.c
+++ b/generic/tclCompCmdsSZ.c
@@ -838,19 +838,32 @@ TclSubstCompile(
continue;
case TCL_TOKEN_VARIABLE:
/*
- * Simple variable access; can only generate TCL_OK or TCL_ERROR
- * so no need to generate elaborate exception-management code.
+ * Check for simple variable access; see if we can only generate
+ * TCL_OK or TCL_ERROR from the substituted variable read; if so,
+ * there is no need to generate elaborate exception-management
+ * code. Note that the first component of TCL_TOKEN_VARIABLE is
+ * always TCL_TOKEN_TEXT...
*/
- if (tokenPtr->numComponents == 1 || (tokenPtr->numComponents == 2
- && tokenPtr[2].type == TCL_TOKEN_TEXT)) {
- envPtr->line = bline;
- TclCompileVarSubst(interp, tokenPtr, envPtr);
- bline = envPtr->line;
- count++;
- continue;
+ if (tokenPtr->numComponents > 1) {
+ int i, foundCommand = 0;
+
+ for (i=2 ; i<=tokenPtr->numComponents ; i++) {
+ if (tokenPtr[i].type == TCL_TOKEN_COMMAND) {
+ foundCommand = 1;
+ break;
+ }
+ }
+ if (foundCommand) {
+ break;
+ }
}
- break;
+
+ envPtr->line = bline;
+ TclCompileVarSubst(interp, tokenPtr, envPtr);
+ bline = envPtr->line;
+ count++;
+ continue;
}
while (count > 255) {