Subject: Simplify AuxData access with a macro.

From: dgp <[email-masked]>
Date: Sat, 27 Jul 2013 20:29:42 +0000

---
 generic/tclAssembly.c | 2 +-
 generic/tclCompile.c  | 1 +
 generic/tclCompile.h  | 9 +++++++++
 tests/subst.test      | 4 ++++
 4 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/generic/tclAssembly.c b/generic/tclAssembly.c
index 6bf2fa8..100e9ef 100644
--- a/generic/tclAssembly.c
+++ b/generic/tclAssembly.c
@@ -3047,7 +3047,7 @@ ResolveJumpTableTargets(
     auxDataIndex = TclGetInt4AtPtr(envPtr->codeStart + bbPtr->jumpOffset + 1);
     DEBUG_PRINT("bbPtr = %p jumpOffset = %d auxDataIndex = %d\n",
 	    bbPtr, bbPtr->jumpOffset, auxDataIndex);
-    realJumpTablePtr = envPtr->auxDataArrayPtr[auxDataIndex].clientData;
+    realJumpTablePtr = TclFetchAuxData(envPtr, auxDataIndex);
     realJumpHashPtr = &realJumpTablePtr->hashTable;
 
     /*
diff --git a/generic/tclCompile.c b/generic/tclCompile.c
index e4da2ba..772ce22 100644
--- a/generic/tclCompile.c
+++ b/generic/tclCompile.c
@@ -2055,6 +2055,7 @@ TclCompileScript(
 #ifdef TCL_COMPILE_DEBUG
 	/*
 	 * If tracing, print a line for each top level command compiled.
+	 * TODO: Suppress when numWords == 0 ?
 	 */
 
 	if ((tclTraceCompile >= 1) && (envPtr->procPtr == NULL)) {
diff --git a/generic/tclCompile.h b/generic/tclCompile.h
index 56315db..beb28fd 100644
--- a/generic/tclCompile.h
+++ b/generic/tclCompile.h
@@ -1113,6 +1113,15 @@ MODULE_SCOPE Tcl_Obj	*TclNewInstNameObj(unsigned char inst);
  *----------------------------------------------------------------
  */
 
+/*
+ * Simplified form to access AuxData.
+ *
+ * ClientData TclFetchAuxData(CompileEng *envPtr, int index);
+ */
+
+#define TclFetchAuxData(envPtr, index) \
+    (envPtr)->auxDataArrayPtr[(index)].clientData
+
 #define LITERAL_ON_HEAP		0x01
 #define LITERAL_CMD_NAME	0x02
 
diff --git a/tests/subst.test b/tests/subst.test
index 4be4798..7466895 100644
--- a/tests/subst.test
+++ b/tests/subst.test
@@ -293,6 +293,10 @@ test subst-13.1 {Bug 3081065} -setup {
 } -cleanup {
     removeFile subst13.tcl
 }
+test subst-13.2 {Test for segfault} -body {
+    subst {[}
+} -returnCodes error -result * -match glob
+
 
 # cleanup
 ::tcltest::cleanupTests
-- 
cgit v0.12