summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--generic/tclCmdIL.c34
-rw-r--r--generic/tclConfig.c3
-rw-r--r--generic/tclListObj.c18
4 files changed, 25 insertions, 34 deletions
diff --git a/ChangeLog b/ChangeLog
index d9e54e2..d55c35e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2011-04-18 Don Porter <dgp@users.sourceforge.net>
+ * generic/tclCmdIL.c: Use ListRepPtr(.) and other cleanup.
+ * generic/tclConfig.c:
+ * generic/tclListObj.c:
+
* generic/tclInt.h: Define and use macros that test whether
* generic/tclBasic.c: a Tcl list value is canonical.
* generic/tclUtil.c:
diff --git a/generic/tclCmdIL.c b/generic/tclCmdIL.c
index 87c5435..25fd078 100644
--- a/generic/tclCmdIL.c
+++ b/generic/tclCmdIL.c
@@ -1540,7 +1540,6 @@ InfoLoadedCmd(
Tcl_Obj *CONST objv[]) /* Argument objects. */
{
char *interpName;
- int result;
if ((objc != 1) && (objc != 2)) {
Tcl_WrongNumArgs(interp, 1, objv, "?interp?");
@@ -1552,8 +1551,7 @@ InfoLoadedCmd(
} else { /* Get pkgs just in specified interp. */
interpName = TclGetString(objv[1]);
}
- result = TclGetLoadedPackages(interp, interpName);
- return result;
+ return TclGetLoadedPackages(interp, interpName);
}
/*
@@ -2403,7 +2401,7 @@ Tcl_LrepeatObjCmd(
register Tcl_Obj *CONST objv[])
/* The argument objects. */
{
- int elementCount, i, result, totalElems;
+ int elementCount, i, totalElems;
Tcl_Obj *listPtr, **dataArray;
List *listRepPtr;
@@ -2416,8 +2414,7 @@ Tcl_LrepeatObjCmd(
Tcl_WrongNumArgs(interp, 1, objv, "positiveCount value ?value ...?");
return TCL_ERROR;
}
- result = TclGetIntFromObj(interp, objv[1], &elementCount);
- if (result == TCL_ERROR) {
+ if (TCL_ERROR == TclGetIntFromObj(interp, objv[1], &elementCount)) {
return TCL_ERROR;
}
if (elementCount < 1) {
@@ -2454,7 +2451,7 @@ Tcl_LrepeatObjCmd(
*/
listPtr = Tcl_NewListObj(totalElems, NULL);
- listRepPtr = (List *) listPtr->internalRep.twoPtrValue.ptr1;
+ listRepPtr = ListRepPtr(listPtr);
listRepPtr->elemCount = elementCount*objc;
dataArray = &listRepPtr->elements;
@@ -2639,15 +2636,15 @@ Tcl_LreverseObjCmd(
return TCL_OK;
}
- if (Tcl_IsShared(objv[1])) {
+ if (Tcl_IsShared(objv[1])
+ || (ListRepPtr(objv[1])->refCount > 1)) { /* Bug 1675044 */
Tcl_Obj *resultObj, **dataArray;
- List *listPtr;
+ List *listRepPtr;
- makeNewReversedList:
resultObj = Tcl_NewListObj(elemc, NULL);
- listPtr = (List *) resultObj->internalRep.twoPtrValue.ptr1;
- listPtr->elemCount = elemc;
- dataArray = &listPtr->elements;
+ listRepPtr = ListRepPtr(resultObj);
+ listRepPtr->elemCount = elemc;
+ dataArray = &listRepPtr->elements;
for (i=0,j=elemc-1 ; i<elemc ; i++,j--) {
dataArray[j] = elemv[i];
@@ -2656,15 +2653,6 @@ Tcl_LreverseObjCmd(
Tcl_SetObjResult(interp, resultObj);
} else {
- /*
- * It is theoretically possible for a list object to have a shared
- * internal representation, but be an unshared object. Check for this
- * and use the "shared" code if we have that problem. [Bug 1675044]
- */
-
- if (((List *) objv[1]->internalRep.twoPtrValue.ptr1)->refCount > 1) {
- goto makeNewReversedList;
- }
/*
* Not shared, so swap "in place". This relies on Tcl_LOGE above
@@ -3763,7 +3751,7 @@ Tcl_LsortObjCmd(
int i;
resultPtr = Tcl_NewListObj(sortInfo.numElements, NULL);
- listRepPtr = (List *) resultPtr->internalRep.twoPtrValue.ptr1;
+ listRepPtr = ListRepPtr(resultPtr);
newArray = &listRepPtr->elements;
if (indices) {
for (i = 0; elementPtr != NULL ; elementPtr = elementPtr->nextPtr){
diff --git a/generic/tclConfig.c b/generic/tclConfig.c
index c91ee64..2ba1bd2 100644
--- a/generic/tclConfig.c
+++ b/generic/tclConfig.c
@@ -273,8 +273,7 @@ QueryConfigObjCmd(
}
if (n) {
- List *listRepPtr = (List *)
- listPtr->internalRep.twoPtrValue.ptr1;
+ List *listRepPtr = ListRepPtr(listPtr);
Tcl_DictSearch s;
Tcl_Obj *key, **vals;
int done, i = 0;
diff --git a/generic/tclListObj.c b/generic/tclListObj.c
index b2a951e..9544337 100644
--- a/generic/tclListObj.c
+++ b/generic/tclListObj.c
@@ -447,7 +447,7 @@ Tcl_ListObjGetElements(
return result;
}
}
- listRepPtr = (List *) listPtr->internalRep.twoPtrValue.ptr1;
+ listRepPtr = ListRepPtr(listPtr);
*objcPtr = listRepPtr->elemCount;
*objvPtr = &listRepPtr->elements;
return TCL_OK;
@@ -565,7 +565,7 @@ Tcl_ListObjAppendElement(
}
}
- listRepPtr = (List *) listPtr->internalRep.twoPtrValue.ptr1;
+ listRepPtr = ListRepPtr(listPtr);
numElems = listRepPtr->elemCount;
numRequired = numElems + 1 ;
@@ -676,7 +676,7 @@ Tcl_ListObjIndex(
}
}
- listRepPtr = (List *) listPtr->internalRep.twoPtrValue.ptr1;
+ listRepPtr = ListRepPtr(listPtr);
if ((index < 0) || (index >= listRepPtr->elemCount)) {
*objPtrPtr = NULL;
} else {
@@ -731,7 +731,7 @@ Tcl_ListObjLength(
}
}
- listRepPtr = (List *) listPtr->internalRep.twoPtrValue.ptr1;
+ listRepPtr = ListRepPtr(listPtr);
*intPtr = listRepPtr->elemCount;
return TCL_OK;
}
@@ -818,7 +818,7 @@ Tcl_ListObjReplace(
* Resist any temptation to optimize this case.
*/
- listRepPtr = (List *) listPtr->internalRep.twoPtrValue.ptr1;
+ listRepPtr = ListRepPtr(listPtr);
elemPtrs = &listRepPtr->elements;
numElems = listRepPtr->elemCount;
@@ -1502,7 +1502,7 @@ TclListObjSetElement(
}
}
- listRepPtr = (List *) listPtr->internalRep.twoPtrValue.ptr1;
+ listRepPtr = ListRepPtr(listPtr);
elemCount = listRepPtr->elemCount;
elemPtrs = &listRepPtr->elements;
@@ -1587,7 +1587,7 @@ static void
FreeListInternalRep(
Tcl_Obj *listPtr) /* List object with internal rep to free. */
{
- register List *listRepPtr = (List *) listPtr->internalRep.twoPtrValue.ptr1;
+ register List *listRepPtr = ListRepPtr(listPtr);
register Tcl_Obj **elemPtrs = &listRepPtr->elements;
register Tcl_Obj *objPtr;
int numElems = listRepPtr->elemCount;
@@ -1627,7 +1627,7 @@ DupListInternalRep(
Tcl_Obj *srcPtr, /* Object with internal rep to copy. */
Tcl_Obj *copyPtr) /* Object with internal rep to set. */
{
- List *listRepPtr = (List *) srcPtr->internalRep.twoPtrValue.ptr1;
+ List *listRepPtr = ListRepPtr(srcPtr);
listRepPtr->refCount++;
copyPtr->internalRep.twoPtrValue.ptr1 = (void *) listRepPtr;
@@ -1843,7 +1843,7 @@ UpdateStringOfList(
{
# define LOCAL_SIZE 20
int localFlags[LOCAL_SIZE], *flagPtr;
- List *listRepPtr = (List *) listPtr->internalRep.twoPtrValue.ptr1;
+ List *listRepPtr = ListRepPtr(listPtr);
int numElems = listRepPtr->elemCount;
register int i;
char *elem, *dst;