diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2022-12-21 21:43:59 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2022-12-21 21:43:59 (GMT) |
commit | 6a1c2d8f5236854b048c1e4f5a24a64a55c7037e (patch) | |
tree | deaec6f41a4ebe9768b1c6b99797b4bc6f2e6922 /generic | |
parent | 1faa0cca77b8a8f9b6e17acf768afaf71d6eb95d (diff) | |
parent | ecaf98ffad23b0a547d0cedb852e0186d5c0c0af (diff) | |
download | tcl-6a1c2d8f5236854b048c1e4f5a24a64a55c7037e.zip tcl-6a1c2d8f5236854b048c1e4f5a24a64a55c7037e.tar.gz tcl-6a1c2d8f5236854b048c1e4f5a24a64a55c7037e.tar.bz2 |
Merge 8.7
Diffstat (limited to 'generic')
-rwxr-xr-x | generic/tclArithSeries.c | 220 | ||||
-rw-r--r-- | generic/tclArithSeries.h | 9 | ||||
-rw-r--r-- | generic/tclCmdAH.c | 3 | ||||
-rw-r--r-- | generic/tclCmdIL.c | 7 | ||||
-rw-r--r-- | generic/tclExecute.c | 8 | ||||
-rw-r--r-- | generic/tclListObj.c | 5 |
6 files changed, 123 insertions, 129 deletions
diff --git a/generic/tclArithSeries.c b/generic/tclArithSeries.c index ab4258a..48efa8c 100755 --- a/generic/tclArithSeries.c +++ b/generic/tclArithSeries.c @@ -41,7 +41,8 @@ static void DupArithSeriesInternalRep (Tcl_Obj *srcPtr, Tcl_Obj *copyPtr); static void FreeArithSeriesInternalRep (Tcl_Obj *listPtr); static int SetArithSeriesFromAny (Tcl_Interp *interp, Tcl_Obj *objPtr); -static void UpdateStringOfArithSeries (Tcl_Obj *listPtr); +static void UpdateStringOfArithSeries (Tcl_Obj *arithSeriesObj); +static Tcl_Obj *ArithSeriesObjStep(Tcl_Obj *arithSeriesPtr); static Tcl_Size ArithSeriesObjLength(Tcl_Obj *arithSeriesPtr); /* @@ -65,7 +66,7 @@ static Tcl_Size ArithSeriesObjLength(Tcl_Obj *arithSeriesPtr); * And where the equivalent's list I-th element is calculated * as: * - * LIST[i] = START+(STEP*i) + * LIST[i] = START + (STEP * i) * * Zero elements ranges, like in the case of START=10 END=10 STEP=1 * are valid and will be equivalent to the empty list. @@ -120,7 +121,7 @@ ArithSeriesLen(Tcl_WideInt start, Tcl_WideInt end, Tcl_WideInt step) /* *---------------------------------------------------------------------- * - * TclNewArithSeriesInt -- + * NewArithSeriesInt -- * * Creates a new ArithSeries object. The returned object has * refcount = 0. @@ -135,17 +136,18 @@ ArithSeriesLen(Tcl_WideInt start, Tcl_WideInt end, Tcl_WideInt step) * None. *---------------------------------------------------------------------- */ +static Tcl_Obj * -TclNewArithSeriesInt(Tcl_WideInt start, Tcl_WideInt end, Tcl_WideInt step, Tcl_WideInt len) +NewArithSeriesInt(Tcl_WideInt start, Tcl_WideInt end, Tcl_WideInt step, Tcl_WideInt len) { Tcl_WideInt length = (len>=0 ? len : ArithSeriesLen(start, end, step)); - Tcl_Obj *arithSeriesPtr; + Tcl_Obj *arithSeriesObj; ArithSeries *arithSeriesRepPtr; - TclNewObj(arithSeriesPtr); + TclNewObj(arithSeriesObj); if (length <= 0) { - return arithSeriesPtr; + return arithSeriesObj; } arithSeriesRepPtr = (ArithSeries*) Tcl_Alloc(sizeof (ArithSeries)); @@ -155,19 +157,19 @@ TclNewArithSeriesInt(Tcl_WideInt start, Tcl_WideInt end, Tcl_WideInt step, Tcl_W arithSeriesRepPtr->step = step; arithSeriesRepPtr->len = length; arithSeriesRepPtr->elements = NULL; - arithSeriesPtr->internalRep.twoPtrValue.ptr1 = arithSeriesRepPtr; - arithSeriesPtr->internalRep.twoPtrValue.ptr2 = NULL; - arithSeriesPtr->typePtr = &tclArithSeriesType.objType; + arithSeriesObj->internalRep.twoPtrValue.ptr1 = arithSeriesRepPtr; + arithSeriesObj->internalRep.twoPtrValue.ptr2 = NULL; + arithSeriesObj->typePtr = &tclArithSeriesType.objType; if (length > 0) - Tcl_InvalidateStringRep(arithSeriesPtr); + Tcl_InvalidateStringRep(arithSeriesObj); - return arithSeriesPtr; + return arithSeriesObj; } /* *---------------------------------------------------------------------- * - * TclNewArithSeriesDbl -- + * NewArithSeriesDbl -- * * Creates a new ArithSeries object with doubles. The returned object has * refcount = 0. @@ -182,17 +184,18 @@ TclNewArithSeriesInt(Tcl_WideInt start, Tcl_WideInt end, Tcl_WideInt step, Tcl_W * None. *---------------------------------------------------------------------- */ +static Tcl_Obj * -TclNewArithSeriesDbl(double start, double end, double step, Tcl_WideInt len) +NewArithSeriesDbl(double start, double end, double step, Tcl_WideInt len) { Tcl_WideInt length = (len>=0 ? len : ArithSeriesLen(start, end, step)); - Tcl_Obj *arithSeriesPtr; + Tcl_Obj *arithSeriesObj; ArithSeriesDbl *arithSeriesRepPtr; - TclNewObj(arithSeriesPtr); + TclNewObj(arithSeriesObj); if (length <= 0) { - return arithSeriesPtr; + return arithSeriesObj; } arithSeriesRepPtr = (ArithSeriesDbl*) Tcl_Alloc(sizeof (ArithSeriesDbl)); @@ -202,13 +205,13 @@ TclNewArithSeriesDbl(double start, double end, double step, Tcl_WideInt len) arithSeriesRepPtr->step = step; arithSeriesRepPtr->len = length; arithSeriesRepPtr->elements = NULL; - arithSeriesPtr->internalRep.twoPtrValue.ptr1 = arithSeriesRepPtr; - arithSeriesPtr->internalRep.twoPtrValue.ptr2 = NULL; - arithSeriesPtr->typePtr = &tclArithSeriesType.objType; + arithSeriesObj->internalRep.twoPtrValue.ptr1 = arithSeriesRepPtr; + arithSeriesObj->internalRep.twoPtrValue.ptr2 = NULL; + arithSeriesObj->typePtr = &tclArithSeriesType.objType; if (length > 0) - Tcl_InvalidateStringRep(arithSeriesPtr); + Tcl_InvalidateStringRep(arithSeriesObj); - return arithSeriesPtr; + return arithSeriesObj; } /* @@ -231,7 +234,11 @@ TclNewArithSeriesDbl(double start, double end, double step, Tcl_WideInt len) *---------------------------------------------------------------------- */ static void -assignNumber(int useDoubles, Tcl_WideInt *intNumberPtr, double *dblNumberPtr, Tcl_Obj *numberObj) +assignNumber( + int useDoubles, + Tcl_WideInt *intNumberPtr, + double *dblNumberPtr, + Tcl_Obj *numberObj) { void *clientData; int tcl_number_type; @@ -274,6 +281,7 @@ assignNumber(int useDoubles, Tcl_WideInt *intNumberPtr, double *dblNumberPtr, Tc * None. *---------------------------------------------------------------------- */ + int TclNewArithSeriesObj( Tcl_Interp *interp, /* For error reporting */ @@ -356,8 +364,8 @@ TclNewArithSeriesObj( if (arithSeriesObj) { *arithSeriesObj = (useDoubles) - ? TclNewArithSeriesDbl(dstart, dend, dstep, len) - : TclNewArithSeriesInt(start, end, step, len); + ? NewArithSeriesDbl(dstart, dend, dstep, len) + : NewArithSeriesInt(start, end, step, len); } return TCL_OK; } @@ -380,26 +388,23 @@ TclNewArithSeriesObj( * None. *---------------------------------------------------------------------- */ -/* - * ArithSeriesObjStep -- - */ -static int +Tcl_Obj * ArithSeriesObjStep( - Tcl_Obj *arithSeriesPtr, - Tcl_Obj **stepObj) + Tcl_Obj *arithSeriesObj) { ArithSeries *arithSeriesRepPtr; + Tcl_Obj *stepObj; - if (arithSeriesPtr->typePtr != &tclArithSeriesType.objType) { - Tcl_Panic("TclArithSeriesObjIndex called with a not ArithSeries Obj."); + if (arithSeriesObj->typePtr != &tclArithSeriesType.objType) { + Tcl_Panic("ArithSeriesObjStep called with a not ArithSeries Obj."); } - arithSeriesRepPtr = ArithSeriesRepPtr(arithSeriesPtr); + arithSeriesRepPtr = ArithSeriesRepPtr(arithSeriesObj); if (arithSeriesRepPtr->isDouble) { - TclNewDoubleObj(*stepObj, ((ArithSeriesDbl*)(arithSeriesRepPtr))->step); + TclNewDoubleObj(stepObj, ((ArithSeriesDbl*)(arithSeriesRepPtr))->step); } else { - TclNewIntObj(*stepObj, arithSeriesRepPtr->step); + TclNewIntObj(stepObj, arithSeriesRepPtr->step); } - return TCL_OK; + return stepObj; } @@ -410,13 +415,11 @@ ArithSeriesObjStep( * * Returns the element with the specified index in the list * represented by the specified Arithmetic Sequence object. - * If the index is out of range, TCL_ERROR is returned, - * otherwise TCL_OK is returned and the integer value of the - * element is stored in *element. + * If the index is out of range, NULL is returned. * * Results: * - * TCL_OK on success, TCL_ERROR on index out of range. + * The element on success, NULL on index out of range. * * Side Effects: * @@ -425,27 +428,35 @@ ArithSeriesObjStep( *---------------------------------------------------------------------- */ -int -TclArithSeriesObjIndex(Tcl_Obj *arithSeriesPtr, Tcl_WideInt index, Tcl_Obj **elementObj) +Tcl_Obj * +TclArithSeriesObjIndex( + Tcl_Interp *interp, + Tcl_Obj *arithSeriesObj, + Tcl_WideInt index) { ArithSeries *arithSeriesRepPtr; - if (arithSeriesPtr->typePtr != &tclArithSeriesType.objType) { + if (arithSeriesObj->typePtr != &tclArithSeriesType.objType) { Tcl_Panic("TclArithSeriesObjIndex called with a not ArithSeries Obj."); } - arithSeriesRepPtr = ArithSeriesRepPtr(arithSeriesPtr); + arithSeriesRepPtr = ArithSeriesRepPtr(arithSeriesObj); if (index < 0 || (Tcl_Size)index >= arithSeriesRepPtr->len) { - return TCL_ERROR; + if (interp) { + Tcl_SetObjResult(interp, + Tcl_ObjPrintf("index %" TCL_LL_MODIFIER "d is out of bounds 0 to %" + TCL_Z_MODIFIER "d", index, (arithSeriesRepPtr->len-1))); + Tcl_SetErrorCode(interp, "TCL", "MEMORY", NULL); + } + return NULL; } /* List[i] = Start + (Step * index) */ if (arithSeriesRepPtr->isDouble) { - *elementObj = Tcl_NewDoubleObj(ArithSeriesIndexM(arithSeriesRepPtr, index)); + return Tcl_NewDoubleObj(ArithSeriesIndexM(arithSeriesRepPtr, index)); } else { - *elementObj = Tcl_NewWideIntObj(ArithSeriesIndexM(arithSeriesRepPtr, index)); + return Tcl_NewWideIntObj(ArithSeriesIndexM(arithSeriesRepPtr, index)); } - return TCL_OK; } - + /* *---------------------------------------------------------------------- * @@ -463,10 +474,10 @@ TclArithSeriesObjIndex(Tcl_Obj *arithSeriesPtr, Tcl_WideInt index, Tcl_Obj **ele * *---------------------------------------------------------------------- */ -Tcl_Size ArithSeriesObjLength(Tcl_Obj *arithSeriesPtr) +Tcl_Size ArithSeriesObjLength(Tcl_Obj *arithSeriesObj) { ArithSeries *arithSeriesRepPtr = (ArithSeries*) - arithSeriesPtr->internalRep.twoPtrValue.ptr1; + arithSeriesObj->internalRep.twoPtrValue.ptr1; return arithSeriesRepPtr->len; } @@ -482,17 +493,17 @@ Tcl_Size ArithSeriesObjLength(Tcl_Obj *arithSeriesPtr) * None. * * Side effects: - * Frees arithSeriesPtr's ArithSeries* internal representation and + * Frees arithSeriesObj's ArithSeries* internal representation and * sets listPtr's internalRep.twoPtrValue.ptr1 to NULL. * *---------------------------------------------------------------------- */ static void -FreeArithSeriesInternalRep(Tcl_Obj *arithSeriesPtr) +FreeArithSeriesInternalRep(Tcl_Obj *arithSeriesObj) { ArithSeries *arithSeriesRepPtr = - (ArithSeries *) arithSeriesPtr->internalRep.twoPtrValue.ptr1; + (ArithSeries *) arithSeriesObj->internalRep.twoPtrValue.ptr1; if (arithSeriesRepPtr->elements) { Tcl_Size i; Tcl_Obj**elmts = arithSeriesRepPtr->elements; @@ -504,7 +515,7 @@ FreeArithSeriesInternalRep(Tcl_Obj *arithSeriesPtr) Tcl_Free((char *) arithSeriesRepPtr->elements); } Tcl_Free((char *) arithSeriesRepPtr); - arithSeriesPtr->internalRep.twoPtrValue.ptr1 = NULL; + arithSeriesObj->internalRep.twoPtrValue.ptr1 = NULL; } /* @@ -573,10 +584,10 @@ DupArithSeriesInternalRep( */ static void -UpdateStringOfArithSeries(Tcl_Obj *arithSeriesPtr) +UpdateStringOfArithSeries(Tcl_Obj *arithSeriesObj) { ArithSeries *arithSeriesRepPtr = - (ArithSeries*) arithSeriesPtr->internalRep.twoPtrValue.ptr1; + (ArithSeries*) arithSeriesObj->internalRep.twoPtrValue.ptr1; char *elem, *p; Tcl_Obj *elemObj; Tcl_Size i; @@ -587,7 +598,7 @@ UpdateStringOfArithSeries(Tcl_Obj *arithSeriesPtr) * Pass 1: estimate space. */ for (i = 0; i < arithSeriesRepPtr->len; i++) { - TclArithSeriesObjIndex(arithSeriesPtr, i, &elemObj); + elemObj = TclArithSeriesObjIndex(NULL, arithSeriesObj, i); elem = Tcl_GetStringFromObj(elemObj, &slen); Tcl_DecrRefCount(elemObj); slen += 1; /* + 1 is for the space or the nul-term */ @@ -598,17 +609,17 @@ UpdateStringOfArithSeries(Tcl_Obj *arithSeriesPtr) * Pass 2: generate the string repr. */ - p = Tcl_InitStringRep(arithSeriesPtr, NULL, length); + p = Tcl_InitStringRep(arithSeriesObj, NULL, length); for (i = 0; i < arithSeriesRepPtr->len; i++) { - TclArithSeriesObjIndex(arithSeriesPtr, i, &elemObj); + elemObj = TclArithSeriesObjIndex(NULL, arithSeriesObj, i); elem = Tcl_GetStringFromObj(elemObj, &slen); strcpy(p, elem); p[slen] = ' '; p += slen+1; Tcl_DecrRefCount(elemObj); } - if (length > 0) arithSeriesPtr->bytes[length-1] = '\0'; - arithSeriesPtr->length = length-1; + if (length > 0) arithSeriesObj->bytes[length-1] = '\0'; + arithSeriesObj->length = length-1; } /* @@ -654,8 +665,8 @@ SetArithSeriesFromAny( * Results: * * Normally returns a pointer to a new Tcl_Obj, that contains the same - * arithSeries value as *arithSeriesPtr does. The returned Tcl_Obj has a - * refCount of zero. If *arithSeriesPtr does not hold an arithSeries, + * arithSeries value as *arithSeriesObj does. The returned Tcl_Obj has a + * refCount of zero. If *arithSeriesObj does not hold an arithSeries, * NULL is returned, and if interp is non-NULL, an error message is * recorded there. * @@ -668,15 +679,15 @@ SetArithSeriesFromAny( Tcl_Obj * TclArithSeriesObjCopy( Tcl_Interp *interp, /* Used to report errors if not NULL. */ - Tcl_Obj *arithSeriesPtr) /* List object for which an element array is + Tcl_Obj *arithSeriesObj) /* List object for which an element array is * to be returned. */ { Tcl_Obj *copyPtr; ArithSeries *arithSeriesRepPtr; - ArithSeriesGetInternalRep(arithSeriesPtr, arithSeriesRepPtr); + ArithSeriesGetInternalRep(arithSeriesObj, arithSeriesRepPtr); if (NULL == arithSeriesRepPtr) { - if (SetArithSeriesFromAny(interp, arithSeriesPtr) != TCL_OK) { + if (SetArithSeriesFromAny(interp, arithSeriesObj) != TCL_OK) { /* We know this is going to panic, but it's the message we want */ return NULL; } @@ -684,7 +695,7 @@ TclArithSeriesObjCopy( TclNewObj(copyPtr); TclInvalidateStringRep(copyPtr); - DupArithSeriesInternalRep(arithSeriesPtr, copyPtr); + DupArithSeriesInternalRep(arithSeriesObj, copyPtr); return copyPtr; } @@ -694,7 +705,7 @@ TclArithSeriesObjCopy( * TclArithSeriesObjRange -- * * Makes a slice of an ArithSeries value. - * *arithSeriesPtr must be known to be a valid list. + * *arithSeriesObj must be known to be a valid list. * * Results: * Returns a pointer to the sliced series. @@ -710,14 +721,14 @@ TclArithSeriesObjCopy( Tcl_Obj * TclArithSeriesObjRange( Tcl_Interp *interp, /* For error message(s) */ - Tcl_Obj *arithSeriesPtr, /* List object to take a range from. */ + Tcl_Obj *arithSeriesObj, /* List object to take a range from. */ Tcl_Size fromIdx, /* Index of first element to include. */ - Tcl_Size toIdx) /* Index of last element to include. */ + Tcl_Size toIdx) /* Index of last element to include. */ { ArithSeries *arithSeriesRepPtr; Tcl_Obj *startObj, *endObj, *stepObj; - ArithSeriesGetInternalRep(arithSeriesPtr, arithSeriesRepPtr); + ArithSeriesGetInternalRep(arithSeriesObj, arithSeriesRepPtr); if (fromIdx == TCL_INDEX_NONE) { fromIdx = 0; @@ -728,33 +739,21 @@ TclArithSeriesObjRange( return obj; } - if (TclArithSeriesObjIndex(arithSeriesPtr, fromIdx, &startObj) != TCL_OK) { - if (interp) { - Tcl_SetObjResult( - interp, - Tcl_ObjPrintf("index %" TCL_Z_MODIFIER "u is out of bounds 0 to %" - TCL_Z_MODIFIER "u", fromIdx, (arithSeriesRepPtr->len-1))); - Tcl_SetErrorCode(interp, "TCL", "MEMORY", NULL); - } + startObj = TclArithSeriesObjIndex(interp, arithSeriesObj, fromIdx); + if (startObj == NULL) { return NULL; } Tcl_IncrRefCount(startObj); - if (TclArithSeriesObjIndex(arithSeriesPtr, toIdx, &endObj) != TCL_OK) { - if (interp) { - Tcl_SetObjResult( - interp, - Tcl_ObjPrintf("index %" TCL_Z_MODIFIER "u is out of bounds 0 to %" - TCL_Z_MODIFIER "d", fromIdx, (arithSeriesRepPtr->len-1))); - Tcl_SetErrorCode(interp, "TCL", "MEMORY", NULL); - } + endObj = TclArithSeriesObjIndex(interp, arithSeriesObj, toIdx); + if (endObj == NULL) { return NULL; } Tcl_IncrRefCount(endObj); - ArithSeriesObjStep(arithSeriesPtr, &stepObj); + stepObj = ArithSeriesObjStep(arithSeriesObj); Tcl_IncrRefCount(stepObj); - if (Tcl_IsShared(arithSeriesPtr) || - ((arithSeriesPtr->refCount > 1))) { + if (Tcl_IsShared(arithSeriesObj) || + ((arithSeriesObj->refCount > 1))) { Tcl_Obj *newSlicePtr; if (TclNewArithSeriesObj(interp, &newSlicePtr, arithSeriesRepPtr->isDouble, startObj, endObj, @@ -776,10 +775,10 @@ TclArithSeriesObjRange( * string-canonizing effect of [lrange 0 end]. */ - TclInvalidateStringRep(arithSeriesPtr); + TclInvalidateStringRep(arithSeriesObj); if (arithSeriesRepPtr->isDouble) { - ArithSeriesDbl *arithSeriesDblRepPtr = (ArithSeriesDbl*)arithSeriesPtr; + ArithSeriesDbl *arithSeriesDblRepPtr = (ArithSeriesDbl*)arithSeriesObj; double start, end, step; Tcl_GetDoubleFromObj(NULL, startObj, &start); Tcl_GetDoubleFromObj(NULL, endObj, &end); @@ -806,7 +805,7 @@ TclArithSeriesObjRange( Tcl_DecrRefCount(endObj); Tcl_DecrRefCount(stepObj); - return arithSeriesPtr; + return arithSeriesObj; } /* @@ -841,7 +840,7 @@ TclArithSeriesObjRange( int TclArithSeriesGetElements( Tcl_Interp *interp, /* Used to report errors if not NULL. */ - Tcl_Obj *objPtr, /* AbstractList object for which an element + Tcl_Obj *objPtr, /* ArithSeries object for which an element * array is to be returned. */ Tcl_Size *objcPtr, /* Where to store the count of objects * referenced by objv. */ @@ -873,13 +872,8 @@ TclArithSeriesGetElements( } arithSeriesRepPtr->elements = objv; for (i = 0; i < objc; i++) { - if (TclArithSeriesObjIndex(objPtr, i, &objv[i]) != TCL_OK) { - if (interp) { - Tcl_SetObjResult( - interp, - Tcl_NewStringObj("indexing error", -1)); - Tcl_SetErrorCode(interp, "TCL", "MEMORY", NULL); - } + objv[i] = TclArithSeriesObjIndex(interp, objPtr, i); + if (objv[i] == NULL) { return TCL_ERROR; } Tcl_IncrRefCount(objv[i]); @@ -908,7 +902,7 @@ TclArithSeriesGetElements( * TclArithSeriesObjReverse -- * * Reverse the order of the ArithSeries value. - * *arithSeriesPtr must be known to be a valid list. + * *arithSeriesObj must be known to be a valid list. * * Results: * Returns a pointer to the reordered series. @@ -924,7 +918,7 @@ TclArithSeriesGetElements( Tcl_Obj * TclArithSeriesObjReverse( Tcl_Interp *interp, /* For error message(s) */ - Tcl_Obj *arithSeriesPtr) /* List object to reverse. */ + Tcl_Obj *arithSeriesObj) /* List object to reverse. */ { ArithSeries *arithSeriesRepPtr; Tcl_Obj *startObj, *endObj, *stepObj; @@ -933,16 +927,16 @@ TclArithSeriesObjReverse( double dstart, dend, dstep; int isDouble; - ArithSeriesGetInternalRep(arithSeriesPtr, arithSeriesRepPtr); + ArithSeriesGetInternalRep(arithSeriesObj, arithSeriesRepPtr); isDouble = arithSeriesRepPtr->isDouble; len = arithSeriesRepPtr->len; - TclArithSeriesObjIndex(arithSeriesPtr, (len-1), &startObj); + startObj = TclArithSeriesObjIndex(NULL, arithSeriesObj, (len-1)); Tcl_IncrRefCount(startObj); - TclArithSeriesObjIndex(arithSeriesPtr, 0, &endObj); + endObj = TclArithSeriesObjIndex(NULL, arithSeriesObj, 0); Tcl_IncrRefCount(endObj); - ArithSeriesObjStep(arithSeriesPtr, &stepObj); + stepObj = ArithSeriesObjStep(arithSeriesObj); Tcl_IncrRefCount(stepObj); if (isDouble) { @@ -959,8 +953,8 @@ TclArithSeriesObjReverse( TclSetIntObj(stepObj, step); } - if (Tcl_IsShared(arithSeriesPtr) || - ((arithSeriesPtr->refCount > 1))) { + if (Tcl_IsShared(arithSeriesObj) || + ((arithSeriesObj->refCount > 1))) { Tcl_Obj *lenObj; TclNewIntObj(lenObj, len); if (TclNewArithSeriesObj(interp, &resultObj, @@ -974,7 +968,7 @@ TclArithSeriesObjReverse( * In-place is possible. */ - TclInvalidateStringRep(arithSeriesPtr); + TclInvalidateStringRep(arithSeriesObj); if (isDouble) { ArithSeriesDbl *arithSeriesDblRepPtr = @@ -996,7 +990,7 @@ TclArithSeriesObjReverse( } arithSeriesRepPtr->elements = NULL; - resultObj = arithSeriesPtr; + resultObj = arithSeriesObj; } Tcl_DecrRefCount(startObj); diff --git a/generic/tclArithSeries.h b/generic/tclArithSeries.h index 91243db..f59720c 100644 --- a/generic/tclArithSeries.h +++ b/generic/tclArithSeries.h @@ -35,19 +35,14 @@ typedef struct { MODULE_SCOPE Tcl_Obj * TclArithSeriesObjCopy(Tcl_Interp *interp, Tcl_Obj *arithSeriesPtr); -MODULE_SCOPE int TclArithSeriesObjIndex(Tcl_Obj *arithSeriesPtr, - Tcl_WideInt index, Tcl_Obj **elementObj); +MODULE_SCOPE Tcl_Obj *TclArithSeriesObjIndex(Tcl_Interp *, Tcl_Obj *, + Tcl_WideInt index); MODULE_SCOPE Tcl_Obj * TclArithSeriesObjRange(Tcl_Interp *interp, Tcl_Obj *arithSeriesPtr, Tcl_Size fromIdx, Tcl_Size toIdx); MODULE_SCOPE Tcl_Obj * TclArithSeriesObjReverse(Tcl_Interp *interp, Tcl_Obj *arithSeriesPtr); MODULE_SCOPE int TclArithSeriesGetElements(Tcl_Interp *interp, Tcl_Obj *objPtr, Tcl_Size *objcPtr, Tcl_Obj ***objvPtr); -MODULE_SCOPE Tcl_Obj * TclNewArithSeriesInt(Tcl_WideInt start, - Tcl_WideInt end, Tcl_WideInt step, - Tcl_WideInt len); -MODULE_SCOPE Tcl_Obj * TclNewArithSeriesDbl(double start, double end, - double step, Tcl_WideInt len); MODULE_SCOPE int TclNewArithSeriesObj(Tcl_Interp *interp, Tcl_Obj **arithSeriesObj, int useDoubles, Tcl_Obj *startObj, Tcl_Obj *endObj, diff --git a/generic/tclCmdAH.c b/generic/tclCmdAH.c index 875bbdd..3651451 100644 --- a/generic/tclCmdAH.c +++ b/generic/tclCmdAH.c @@ -2875,7 +2875,8 @@ ForeachAssignments( k = statePtr->index[i]++; if (k < statePtr->argcList[i]) { if (isarithseries) { - if (TclArithSeriesObjIndex(statePtr->aCopyList[i], k, &valuePtr) != TCL_OK) { + valuePtr = TclArithSeriesObjIndex(interp, statePtr->aCopyList[i], k); + if (valuePtr == NULL) { Tcl_AppendObjToErrorInfo(interp, Tcl_ObjPrintf( "\n (setting %s loop variable \"%s\")", (statePtr->resultList != NULL ? "lmap" : "foreach"), diff --git a/generic/tclCmdIL.c b/generic/tclCmdIL.c index fbc4995..69d4484 100644 --- a/generic/tclCmdIL.c +++ b/generic/tclCmdIL.c @@ -2232,8 +2232,8 @@ Tcl_JoinObjCmd( if (listLen == 1) { /* One element; return it */ if (isArithSeries) { - Tcl_Obj *valueObj; - if (TclArithSeriesObjIndex(objv[1], 0, &valueObj) != TCL_OK) { + Tcl_Obj *valueObj = TclArithSeriesObjIndex(interp, objv[1], 0); + if (valueObj == NULL) { return TCL_ERROR; } Tcl_SetObjResult(interp, valueObj); @@ -2267,7 +2267,8 @@ Tcl_JoinObjCmd( Tcl_AppendObjToObj(resObjPtr, joinObjPtr); } - if (TclArithSeriesObjIndex(objv[1], i, &valueObj) != TCL_OK) { + valueObj = TclArithSeriesObjIndex(interp, objv[1], i); + if (valueObj == NULL) { return TCL_ERROR; } Tcl_AppendObjToObj(resObjPtr, valueObj); diff --git a/generic/tclExecute.c b/generic/tclExecute.c index d1d7df1..ee9a4ce 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -4667,7 +4667,8 @@ TEBCresume( TRACE_ERROR(interp); goto gotError; } - if (TclArithSeriesObjIndex(valuePtr, index, &objResultPtr) != TCL_OK) { + objResultPtr = TclArithSeriesObjIndex(interp, valuePtr, index); + if (objResultPtr == NULL) { CACHE_STACK_INFO(); TRACE_ERROR(interp); goto gotError; @@ -4732,7 +4733,8 @@ TEBCresume( /* Compute value @ index */ if (index < length) { - if (TclArithSeriesObjIndex(valuePtr, index, &objResultPtr) != TCL_OK) { + objResultPtr = TclArithSeriesObjIndex(interp, valuePtr, index); + if (objResultPtr == NULL) { CACHE_STACK_INFO(); TRACE_ERROR(interp); goto gotError; @@ -4978,7 +4980,7 @@ TEBCresume( do { if (isArithSeries) { - TclArithSeriesObjIndex(value2Ptr, i, &o); + o = TclArithSeriesObjIndex(NULL, value2Ptr, i); } else { Tcl_ListObjIndex(NULL, value2Ptr, i, &o); } diff --git a/generic/tclListObj.c b/generic/tclListObj.c index 8583bad..9102af0 100644 --- a/generic/tclListObj.c +++ b/generic/tclListObj.c @@ -2649,7 +2649,7 @@ TclLindexFlat( &index) == TCL_OK) { } if (i==0) { - TclArithSeriesObjIndex(listObj, index, &elemObj); + elemObj = TclArithSeriesObjIndex(NULL, listObj, index); } else if (index > 0) { /* ArithSeries cannot be a list of lists */ Tcl_DecrRefCount(elemObj); @@ -3310,7 +3310,8 @@ SetListFromAny( listRep.storePtr->numUsed = size; elemPtrs = listRep.storePtr->slots; for (j = 0; j < size; j++) { - if (TclArithSeriesObjIndex(objPtr, j, &elemPtrs[j]) != TCL_OK) { + elemPtrs[j] = TclArithSeriesObjIndex(interp, objPtr, j); + if (elemPtrs[j] == NULL) { return TCL_ERROR; } } |