summaryrefslogtreecommitdiffstats
path: root/generic/tclCmdIL.c
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 /generic/tclCmdIL.c
parent66a254dddfb0c618ee609c6bfab4a6549e098772 (diff)
parent34bda55e3628476458e63d4495350e14672d01af (diff)
downloadtcl-cf9cbf06ede2587aad27b49a23c04c5fd3a46940.zip
tcl-cf9cbf06ede2587aad27b49a23c04c5fd3a46940.tar.gz
tcl-cf9cbf06ede2587aad27b49a23c04c5fd3a46940.tar.bz2
Use ListRepPtr(.) and other cleanup.
Diffstat (limited to 'generic/tclCmdIL.c')
-rw-r--r--generic/tclCmdIL.c31
1 files changed, 10 insertions, 21 deletions
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) {