Tcl Source Code

Artifact [a0194db1e3]
Login

Artifact a0194db1e3073dc3a44451c10ffe5303b81fc19830d942a93ce765e38d5272db:

Attachment "patch-a09031e288-quickfix.diff.1" to ticket [a09031e288] added by leon 2018-12-02 19:30:09. (unpublished)
Index: generic/tclObj.c
==================================================================
--- generic/tclObj.c
+++ generic/tclObj.c
@@ -96,11 +96,11 @@
 } ThreadSpecificData;
 
 static Tcl_ThreadDataKey dataKey;
 
 static void             TclThreadFinalizeContLines(ClientData clientData);
-static ThreadSpecificData *TclGetContLineTable(void);
+static Tcl_HashTable    *TclGetContLineTable(void);
 
 /*
  * Nested Tcl_Obj deletion management support
  *
  * All context references used in the object freeing code are pointers to this
@@ -496,13 +496,14 @@
  *
  * TIP #280
  *----------------------------------------------------------------------
  */
 
-static ThreadSpecificData *
+static Tcl_HashTable *
 TclGetContLineTable(void)
 {
+    return NULL;
     /*
      * Initialize the hashtable tracking invisible continuation lines.  For
      * the release we use a thread exit handler to ensure that this is done
      * before TSD blocks are made invalid. The TclFinalizeObjects() which
      * would be the natural place for this is invoked afterwards, meaning that
@@ -514,11 +515,11 @@
     if (!tsdPtr->lineCLPtr) {
 	tsdPtr->lineCLPtr = Tcl_Alloc(sizeof(Tcl_HashTable));
 	Tcl_InitHashTable(tsdPtr->lineCLPtr, TCL_ONE_WORD_KEYS);
 	Tcl_CreateThreadExitHandler(TclThreadFinalizeContLines,NULL);
     }
-    return tsdPtr;
+    return tsdPtr->lineCLPtr;
 }
 
 /*
  *----------------------------------------------------------------------
  *
@@ -542,13 +543,16 @@
     Tcl_Obj *objPtr,
     int num,
     int *loc)
 {
     int newEntry;
-    ThreadSpecificData *tsdPtr = TclGetContLineTable();
+    Tcl_HashTable *contLineTable = TclGetContLineTable();
+    if ( ! contLineTable )
+        return NULL;
+
     Tcl_HashEntry *hPtr =
-	    Tcl_CreateHashEntry(tsdPtr->lineCLPtr, objPtr, &newEntry);
+	    Tcl_CreateHashEntry(contLineTable, objPtr, &newEntry);
     ContLineLoc *clLocPtr = Tcl_Alloc(sizeof(ContLineLoc) + num*sizeof(int));
 
     if (!newEntry) {
 	/*
 	 * We're entering ContLineLoc data for the same value more than one
@@ -698,13 +702,16 @@
 void
 TclContinuationsCopy(
     Tcl_Obj *objPtr,
     Tcl_Obj *originObjPtr)
 {
-    ThreadSpecificData *tsdPtr = TclGetContLineTable();
+    Tcl_HashTable *contLineTable = TclGetContLineTable();
+    if ( ! contLineTable )
+        return;
+
     Tcl_HashEntry *hPtr =
-            Tcl_FindHashEntry(tsdPtr->lineCLPtr, originObjPtr);
+            Tcl_FindHashEntry(contLineTable, originObjPtr);
 
     if (hPtr) {
 	ContLineLoc *clLocPtr = Tcl_GetHashValue(hPtr);
 
 	TclContinuationsEnter(objPtr, clLocPtr->num, clLocPtr->loc);
@@ -732,13 +739,16 @@
 
 ContLineLoc *
 TclContinuationsGet(
     Tcl_Obj *objPtr)
 {
-    ThreadSpecificData *tsdPtr = TclGetContLineTable();
+    Tcl_HashTable *contLineTable = TclGetContLineTable();
+    if ( ! contLineTable )
+        return NULL;
+
     Tcl_HashEntry *hPtr =
-            Tcl_FindHashEntry(tsdPtr->lineCLPtr, objPtr);
+            Tcl_FindHashEntry(contLineTable, objPtr);
 
     if (!hPtr) {
         return NULL;
     }
     return Tcl_GetHashValue(hPtr);
@@ -768,22 +778,28 @@
 {
     /*
      * Release the hashtable tracking invisible continuation lines.
      */
 
-    ThreadSpecificData *tsdPtr = TclGetContLineTable();
+    Tcl_HashTable *contLineTable = TclGetContLineTable();
+    if ( ! contLineTable )
+        return;
+
     Tcl_HashEntry *hPtr;
     Tcl_HashSearch hSearch;
 
-    for (hPtr = Tcl_FirstHashEntry(tsdPtr->lineCLPtr, &hSearch);
+    for (hPtr = Tcl_FirstHashEntry(contLineTable, &hSearch);
 	    hPtr != NULL; hPtr = Tcl_NextHashEntry(&hSearch)) {
 	Tcl_Free(Tcl_GetHashValue(hPtr));
 	Tcl_DeleteHashEntry(hPtr);
     }
-    Tcl_DeleteHashTable(tsdPtr->lineCLPtr);
-    Tcl_Free(tsdPtr->lineCLPtr);
+    Tcl_DeleteHashTable(contLineTable);
+    Tcl_Free(contLineTable);
+    {
+    ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
     tsdPtr->lineCLPtr = NULL;
+    }
 }
 
 /*
  *--------------------------------------------------------------
  *
@@ -1695,19 +1711,19 @@
  * Tcl_InitStringRep --
  *
  *	This function is called in several configurations to provide all
  *	the tools needed to set an object's string representation. The
  *	function is determined by the arguments.
- *	
+ *
  *	(objPtr->bytes != NULL && bytes != NULL) || (numBytes == -1)
  *	    Invalid call -- panic!
- *	
+ *
  *	objPtr->bytes == NULL && bytes == NULL && numBytes >= 0
  *	    Allocation only - allocate space for (numBytes+1) chars.
  *	    store in objPtr->bytes and return. Also sets
  *	    objPtr->length to 0 and objPtr->bytes[0] to NUL.
- *	
+ *
  *	objPtr->bytes == NULL && bytes != NULL && numBytes >= 0
  *	    Allocate and copy. bytes is assumed to point to chars to
  *	    copy into the string rep. objPtr->length = numBytes. Allocate
  *	    array of (numBytes + 1) chars. store in objPtr->bytes. Copy
  *	    numBytes chars from bytes to objPtr->bytes; Set