diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2021-12-21 16:18:53 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2021-12-21 16:18:53 (GMT) |
commit | e3c67e088158312bf1d91f23ff22d9f67f87c016 (patch) | |
tree | 76b2e5daefcb9c4700e7f399df406157e37e38ca /generic/tclCmdIL.c | |
parent | ead6c0d0543e7a3ccb5a45d79554f7852d70a1df (diff) | |
parent | fc5ef30f8cb501a35c696d8356e1e89e3004efaa (diff) | |
download | tcl-e3c67e088158312bf1d91f23ff22d9f67f87c016.zip tcl-e3c67e088158312bf1d91f23ff22d9f67f87c016.tar.gz tcl-e3c67e088158312bf1d91f23ff22d9f67f87c016.tar.bz2 |
New macro TclNewIndexObj(). For Tcl 8.7 it's the same as TclNewIntObj(), but in Tcl 9.0 not any more.
Merge 8.6
Diffstat (limited to 'generic/tclCmdIL.c')
-rw-r--r-- | generic/tclCmdIL.c | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/generic/tclCmdIL.c b/generic/tclCmdIL.c index b9fc84a..986dd49 100644 --- a/generic/tclCmdIL.c +++ b/generic/tclCmdIL.c @@ -2731,8 +2731,8 @@ Tcl_LremoveObjCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - int i, idxc; - int listLen, *idxv, prevIdx, first, num; + int i, idxc, listLen, prevIdx, first, num; + int *idxv; Tcl_Obj *listObj; /* @@ -2960,7 +2960,8 @@ Tcl_LreplaceObjCmd( Tcl_Obj *const objv[]) /* Argument objects. */ { Tcl_Obj *listPtr; - int first, last, listLen, numToDelete, result; + int first, last; + int listLen, numToDelete, result; if (objc < 4) { Tcl_WrongNumArgs(interp, 1, objv, @@ -2991,8 +2992,7 @@ Tcl_LreplaceObjCmd( if (first == TCL_INDEX_NONE) { first = 0; - } - if (first > listLen) { + } else if (first > listLen) { first = listLen; } @@ -3140,9 +3140,10 @@ Tcl_LsearchObjCmd( Tcl_Obj *const objv[]) /* Argument values. */ { const char *bytes, *patternBytes; - int i, match, index, result=TCL_OK, listc, length, elemLen, bisect; + int i, match, index, result=TCL_OK, listc, bisect; + int length, elemLen, start, groupSize, groupOffset, lower, upper; int allocatedIndexVector = 0; - int dataType, isIncreasing, lower, upper, start, groupSize, groupOffset; + int dataType, isIncreasing; Tcl_WideInt patWide, objWide; int allMatches, inlineReturn, negatedMatch, returnSubindices, noCase; double patDouble, objDouble; @@ -3514,7 +3515,7 @@ Tcl_LsearchObjCmd( if (allMatches || inlineReturn) { Tcl_ResetResult(interp); } else { - TclNewIntObj(itemPtr, TCL_INDEX_NONE); + TclNewIndexObj(itemPtr, TCL_INDEX_NONE); Tcl_SetObjResult(interp, itemPtr); } goto done; @@ -3645,7 +3646,7 @@ Tcl_LsearchObjCmd( * our first match might not be the first occurrence. * Consider: 0 0 0 1 1 1 2 2 2 * - * To maintain consistancy with standard lsearch semantics, we + * To maintain consistency with standard lsearch semantics, we * must find the leftmost occurrence of the pattern in the * list. Thus we don't just stop searching here. This * variation means that a search always makes log n @@ -3719,8 +3720,7 @@ Tcl_LsearchObjCmd( if (noCase) { match = (TclUtfCasecmp(bytes, patternBytes) == 0); } else { - match = (memcmp(bytes, patternBytes, - (size_t) length) == 0); + match = (memcmp(bytes, patternBytes, length) == 0); } } break; @@ -3804,10 +3804,10 @@ Tcl_LsearchObjCmd( } else if (returnSubindices) { int j; - TclNewIntObj(itemPtr, i+groupOffset); + TclNewIndexObj(itemPtr, i+groupOffset); for (j=0 ; j<sortInfo.indexc ; j++) { Tcl_Obj *elObj; - TclNewIntObj(elObj, TclIndexDecode(sortInfo.indexv[j], listc)); + TclNewIndexObj(elObj, TclIndexDecode(sortInfo.indexv[j], listc)); Tcl_ListObjAppendElement(interp, itemPtr, elObj); } Tcl_ListObjAppendElement(interp, listPtr, itemPtr); @@ -3827,16 +3827,16 @@ Tcl_LsearchObjCmd( if (returnSubindices) { int j; - TclNewIntObj(itemPtr, index+groupOffset); + TclNewIndexObj(itemPtr, index+groupOffset); for (j=0 ; j<sortInfo.indexc ; j++) { Tcl_Obj *elObj; - TclNewIntObj(elObj, TclIndexDecode(sortInfo.indexv[j], listc)); + TclNewIndexObj(elObj, TclIndexDecode(sortInfo.indexv[j], listc)); Tcl_ListObjAppendElement(interp, itemPtr, elObj); } Tcl_SetObjResult(interp, itemPtr); } else { Tcl_Obj *elObj; - TclNewIntObj(elObj, index); + TclNewIndexObj(elObj, index); Tcl_SetObjResult(interp, elObj); } } else if (index < 0) { @@ -4420,7 +4420,7 @@ Tcl_LsortObjCmd( idx = elementPtr->payload.index; for (j = 0; j < groupSize; j++) { if (indices) { - TclNewIntObj(objPtr, idx + j - groupOffset); + TclNewIndexObj(objPtr, idx + j - groupOffset); newArray[i++] = objPtr; Tcl_IncrRefCount(objPtr); } else { @@ -4432,7 +4432,7 @@ Tcl_LsortObjCmd( } } else if (indices) { for (i=0; elementPtr != NULL ; elementPtr = elementPtr->nextPtr) { - TclNewIntObj(objPtr, elementPtr->payload.index); + TclNewIndexObj(objPtr, elementPtr->payload.index); newArray[i++] = objPtr; Tcl_IncrRefCount(objPtr); } |