summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2011-04-18 21:42:51 (GMT)
committerdgp <dgp@users.sourceforge.net>2011-04-18 21:42:51 (GMT)
commitcf9cbf06ede2587aad27b49a23c04c5fd3a46940 (patch)
treee842cb86065dd668b96d29fb3f1378a9e07696f4
parent66a254dddfb0c618ee609c6bfab4a6549e098772 (diff)
parent34bda55e3628476458e63d4495350e14672d01af (diff)
downloadtcl-cf9cbf06ede2587aad27b49a23c04c5fd3a46940.zip
tcl-cf9cbf06ede2587aad27b49a23c04c5fd3a46940.tar.gz
tcl-cf9cbf06ede2587aad27b49a23c04c5fd3a46940.tar.bz2
Use ListRepPtr(.) and other cleanup.
-rw-r--r--ChangeLog4
-rw-r--r--generic/tclCmdIL.c31
-rw-r--r--generic/tclConfig.c3
-rw-r--r--generic/tclListObj.c18
4 files changed, 24 insertions, 32 deletions
diff --git a/ChangeLog b/ChangeLog
index 312010c..1c3abf8 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 0a2784d..b6e9f21 100644
--- a/generic/tclCmdIL.c
+++ b/generic/tclCmdIL.c
@@ -1666,7 +1666,6 @@ InfoLoadedCmd(
Tcl_Obj *const objv[]) /* Argument objects. */
{
const char *interpName;
- int result;
if ((objc != 1) && (objc != 2)) {
Tcl_WrongNumArgs(interp, 1, objv, "?interp?");
@@ -1678,8 +1677,7 @@ InfoLoadedCmd(
} else { /* Get pkgs just in specified interp. */
interpName = TclGetString(objv[1]);
}
- result = TclGetLoadedPackages(interp, interpName);
- return result;
+ return TclGetLoadedPackages(interp, interpName);
}
/*
@@ -2502,7 +2500,7 @@ Tcl_LrangeObjCmd(
}
if (Tcl_IsShared(objv[1]) ||
- (((List *) objv[1]->internalRep.twoPtrValue.ptr1)->refCount > 1)) {
+ ((ListRepPtr(objv[1])->refCount > 1))) {
Tcl_SetObjResult(interp, Tcl_NewListObj(last - first + 1,
&elemPtrs[first]));
} else {
@@ -2607,7 +2605,7 @@ Tcl_LrepeatObjCmd(
listPtr = Tcl_NewListObj(totalElems, NULL);
if (totalElems) {
- List *listRepPtr = listPtr->internalRep.twoPtrValue.ptr1;
+ List *listRepPtr = ListRepPtr(listPtr);
listRepPtr->elemCount = elementCount*objc;
dataArray = &listRepPtr->elements;
@@ -2796,15 +2794,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 = 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];
@@ -2813,15 +2811,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
@@ -4006,7 +3995,7 @@ Tcl_LsortObjCmd(
Tcl_Obj **newArray, *objPtr;
resultPtr = Tcl_NewListObj(sortInfo.numElements * groupSize, NULL);
- listRepPtr = resultPtr->internalRep.twoPtrValue.ptr1;
+ listRepPtr = ListRepPtr(resultPtr);
newArray = &listRepPtr->elements;
if (group) {
for (i=0; elementPtr!=NULL ; elementPtr=elementPtr->nextPtr) {
diff --git a/generic/tclConfig.c b/generic/tclConfig.c
index 3ad5dfd..8f60b02 100644
--- a/generic/tclConfig.c
+++ b/generic/tclConfig.c
@@ -277,8 +277,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 9128333..8a0f89a 100644
--- a/generic/tclListObj.c
+++ b/generic/tclListObj.c
@@ -446,7 +446,7 @@ Tcl_ListObjGetElements(
return result;
}
}
- listRepPtr = listPtr->internalRep.twoPtrValue.ptr1;
+ listRepPtr = ListRepPtr(listPtr);
*objcPtr = listRepPtr->elemCount;
*objvPtr = &listRepPtr->elements;
return TCL_OK;
@@ -564,7 +564,7 @@ Tcl_ListObjAppendElement(
}
}
- listRepPtr = listPtr->internalRep.twoPtrValue.ptr1;
+ listRepPtr = ListRepPtr(listPtr);
numElems = listRepPtr->elemCount;
numRequired = numElems + 1 ;
@@ -674,7 +674,7 @@ Tcl_ListObjIndex(
}
}
- listRepPtr = listPtr->internalRep.twoPtrValue.ptr1;
+ listRepPtr = ListRepPtr(listPtr);
if ((index < 0) || (index >= listRepPtr->elemCount)) {
*objPtrPtr = NULL;
} else {
@@ -729,7 +729,7 @@ Tcl_ListObjLength(
}
}
- listRepPtr = listPtr->internalRep.twoPtrValue.ptr1;
+ listRepPtr = ListRepPtr(listPtr);
*intPtr = listRepPtr->elemCount;
return TCL_OK;
}
@@ -816,7 +816,7 @@ Tcl_ListObjReplace(
* Resist any temptation to optimize this case.
*/
- listRepPtr = listPtr->internalRep.twoPtrValue.ptr1;
+ listRepPtr = ListRepPtr(listPtr);
elemPtrs = &listRepPtr->elements;
numElems = listRepPtr->elemCount;
@@ -1523,7 +1523,7 @@ TclListObjSetElement(
}
}
- listRepPtr = listPtr->internalRep.twoPtrValue.ptr1;
+ listRepPtr = ListRepPtr(listPtr);
elemCount = listRepPtr->elemCount;
elemPtrs = &listRepPtr->elements;
@@ -1610,7 +1610,7 @@ static void
FreeListInternalRep(
Tcl_Obj *listPtr) /* List object with internal rep to free. */
{
- register List *listRepPtr = listPtr->internalRep.twoPtrValue.ptr1;
+ register List *listRepPtr = ListRepPtr(listPtr);
register Tcl_Obj **elemPtrs = &listRepPtr->elements;
register Tcl_Obj *objPtr;
int numElems = listRepPtr->elemCount;
@@ -1651,7 +1651,7 @@ DupListInternalRep(
Tcl_Obj *srcPtr, /* Object with internal rep to copy. */
Tcl_Obj *copyPtr) /* Object with internal rep to set. */
{
- List *listRepPtr = srcPtr->internalRep.twoPtrValue.ptr1;
+ List *listRepPtr = ListRepPtr(srcPtr);
listRepPtr->refCount++;
copyPtr->internalRep.twoPtrValue.ptr1 = listRepPtr;
@@ -1873,7 +1873,7 @@ UpdateStringOfList(
{
# define LOCAL_SIZE 20
int localFlags[LOCAL_SIZE], *flagPtr;
- List *listRepPtr = listPtr->internalRep.twoPtrValue.ptr1;
+ List *listRepPtr = ListRepPtr(listPtr);
int numElems = listRepPtr->elemCount;
register int i;
const char *elem;