diff --git a/doc/binary.n b/doc/binary.n index 9ab694eb794b..70f569b02b68 100644 --- a/doc/binary.n +++ b/doc/binary.n @@ -82,6 +82,8 @@ RFC 2045 calls for base64 decoders to be non-strict. . The \fBhex\fR binary encoding converts each byte to a pair of hexadecimal digits that represent the byte value as a hexadecimal integer. +When encoding, lower characters are used. +When decoding, upper and lower characters are accepted. .RS .PP No options are supported during encoding. During decoding, the following diff --git a/generic/tclCmdIL.c b/generic/tclCmdIL.c index b9fc84a72c2e..986dd4973334 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 ; jpayload.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); } diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c index f8f0004b377c..bd689a685121 100644 --- a/generic/tclCmdMZ.c +++ b/generic/tclCmdMZ.c @@ -385,12 +385,12 @@ Tcl_RegexpObjCmd( end--; } } else { - start = -1; - end = -1; + start = TCL_INDEX_NONE; + end = TCL_INDEX_NONE; } - TclNewIntObj(objs[0], start); - TclNewIntObj(objs[1], end); + TclNewIndexObj(objs[0], start); + TclNewIndexObj(objs[1], end); newPtr = Tcl_NewListObj(2, objs); } else { @@ -1910,7 +1910,7 @@ StringIsCmd( str_is_done: if ((result == 0) && (failVarObj != NULL)) { - TclNewIntObj(objPtr, failat); + TclNewIndexObj(objPtr, failat); if (Tcl_ObjSetVar2(interp, failVarObj, NULL, objPtr, TCL_LEAVE_ERR_MSG) == NULL) { return TCL_ERROR; } @@ -2543,7 +2543,7 @@ StringStartCmd( cur += 1; } } - TclNewIntObj(obj, cur); + TclNewIndexObj(obj, cur); Tcl_SetObjResult(interp, obj); return TCL_OK; } @@ -2604,7 +2604,7 @@ StringEndCmd( } else { cur = length; } - TclNewIntObj(obj, cur); + TclNewIndexObj(obj, cur); Tcl_SetObjResult(interp, obj); return TCL_OK; } @@ -3778,10 +3778,10 @@ TclNRSwitchObjCmd( Tcl_Obj *rangeObjAry[2]; if (info.matches[j].end > 0) { - TclNewIntObj(rangeObjAry[0], info.matches[j].start); - TclNewIntObj(rangeObjAry[1], info.matches[j].end-1); + TclNewIndexObj(rangeObjAry[0], info.matches[j].start); + TclNewIndexObj(rangeObjAry[1], info.matches[j].end-1); } else { - TclNewIntObj(rangeObjAry[1], TCL_INDEX_NONE); + TclNewIndexObj(rangeObjAry[1], TCL_INDEX_NONE); rangeObjAry[0] = rangeObjAry[1]; } diff --git a/generic/tclInt.h b/generic/tclInt.h index 4e26bf3900d0..ea8305563c4c 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -4326,7 +4326,7 @@ TclScaleTime( /* * Invalidate the string rep first so we can use the bytes value for our * pointer chain, and signal an obj deletion (as opposed to shimmering) with - * 'length == -1'. + * 'length == TCL_INDEX_NONE'. * Use empty 'if ; else' to handle use in unbraced outer if/else conditions. */ @@ -4338,7 +4338,7 @@ TclScaleTime( && ((objPtr)->bytes != &tclEmptyString)) { \ ckfree((objPtr)->bytes); \ } \ - (objPtr)->length = -1; \ + (objPtr)->length = TCL_INDEX_NONE; \ TclFreeObjStorage(objPtr); \ TclIncrObjsFreed(); \ } else { \ @@ -4360,7 +4360,7 @@ TclScaleTime( */ # define TclAllocObjStorageEx(interp, objPtr) \ - (objPtr) = (Tcl_Obj *) ckalloc(sizeof(Tcl_Obj)) + (objPtr) = (Tcl_Obj *)ckalloc(sizeof(Tcl_Obj)) # define TclFreeObjStorageEx(interp, objPtr) \ ckfree(objPtr) @@ -4510,7 +4510,7 @@ MODULE_SCOPE void TclDbInitNewObj(Tcl_Obj *objPtr, const char *file, (objPtr)->bytes = &tclEmptyString; \ (objPtr)->length = 0; \ } else { \ - (objPtr)->bytes = (char *) ckalloc((len) + 1); \ + (objPtr)->bytes = (char *)ckalloc((len) + 1); \ memcpy((objPtr)->bytes, (bytePtr) ? (bytePtr) : &tclEmptyString, (len)); \ (objPtr)->bytes[len] = '\0'; \ (objPtr)->length = (len); \ @@ -4902,6 +4902,9 @@ MODULE_SCOPE Tcl_LibraryInitProc Procbodytest_SafeInit; TCL_DTRACE_OBJ_CREATE(objPtr); \ } while (0) +#define TclNewIndexObj(objPtr, w) \ + TclNewIntObj(objPtr, w) + #define TclNewDoubleObj(objPtr, d) \ do { \ TclIncrObjsAllocated(); \ @@ -4927,6 +4930,9 @@ MODULE_SCOPE Tcl_LibraryInitProc Procbodytest_SafeInit; #define TclNewIntObj(objPtr, w) \ (objPtr) = Tcl_NewWideIntObj(w) +#define TclNewIndexObj(objPtr, w) \ + TclNewIntObj(objPtr, w) + #define TclNewDoubleObj(objPtr, d) \ (objPtr) = Tcl_NewDoubleObj(d) @@ -4939,7 +4945,7 @@ MODULE_SCOPE Tcl_LibraryInitProc Procbodytest_SafeInit; * sizeof(sLiteral "") will fail to compile otherwise. */ #define TclNewLiteralStringObj(objPtr, sLiteral) \ - TclNewStringObj((objPtr), (sLiteral), (int) (sizeof(sLiteral "") - 1)) + TclNewStringObj((objPtr), (sLiteral), sizeof(sLiteral "") - 1) /* *---------------------------------------------------------------- @@ -4952,7 +4958,7 @@ MODULE_SCOPE Tcl_LibraryInitProc Procbodytest_SafeInit; */ #define TclDStringAppendLiteral(dsPtr, sLiteral) \ - Tcl_DStringAppend((dsPtr), (sLiteral), (int) (sizeof(sLiteral "") - 1)) + Tcl_DStringAppend((dsPtr), (sLiteral), sizeof(sLiteral "") - 1) #define TclDStringClear(dsPtr) \ Tcl_DStringSetLength((dsPtr), 0) @@ -5093,12 +5099,12 @@ MODULE_SCOPE Tcl_LibraryInitProc Procbodytest_SafeInit; TCL_CT_ASSERT((nbytes)<=sizeof(Tcl_Obj)); \ TclIncrObjsAllocated(); \ TclAllocObjStorageEx((interp), (_objPtr)); \ - *(void **)&memPtr = (void *) (_objPtr); \ + *(void **)&(memPtr) = (void *) (_objPtr); \ } while (0) #define TclSmallFreeEx(interp, memPtr) \ do { \ - TclFreeObjStorageEx((interp), (Tcl_Obj *) (memPtr)); \ + TclFreeObjStorageEx((interp), (Tcl_Obj *)(memPtr)); \ TclIncrObjsFreed(); \ } while (0) @@ -5108,12 +5114,12 @@ MODULE_SCOPE Tcl_LibraryInitProc Procbodytest_SafeInit; Tcl_Obj *_objPtr; \ TCL_CT_ASSERT((nbytes)<=sizeof(Tcl_Obj)); \ TclNewObj(_objPtr); \ - *(void **)&memPtr = (void *) _objPtr; \ + *(void **)&(memPtr) = (void *)_objPtr; \ } while (0) #define TclSmallFreeEx(interp, memPtr) \ do { \ - Tcl_Obj *_objPtr = (Tcl_Obj *) memPtr; \ + Tcl_Obj *_objPtr = (Tcl_Obj *)(memPtr); \ _objPtr->bytes = NULL; \ _objPtr->typePtr = NULL; \ _objPtr->refCount = 1; \ diff --git a/generic/tclRegexp.c b/generic/tclRegexp.c index b7fbb816d275..8e588ac1cc13 100644 --- a/generic/tclRegexp.c +++ b/generic/tclRegexp.c @@ -677,7 +677,7 @@ TclRegAbout( */ TclNewObj(resultObj); - TclNewIntObj(infoObj, regexpPtr->re.re_nsub); + TclNewIndexObj(infoObj, regexpPtr->re.re_nsub); Tcl_ListObjAppendElement(NULL, resultObj, infoObj); /* diff --git a/generic/tclScan.c b/generic/tclScan.c index 55685294279a..134f60db72c7 100644 --- a/generic/tclScan.c +++ b/generic/tclScan.c @@ -34,7 +34,7 @@ typedef struct { Tcl_UniChar end; } Range; -typedef struct CharSet { +typedef struct { int exclude; /* 1 if this is an exclusion set. */ int nchars; Tcl_UniChar *chars; @@ -1089,7 +1089,7 @@ Tcl_ScanObjCmd( if (code == TCL_OK) { if (underflow && (nconversions == 0)) { if (numVars) { - TclNewIntObj(objPtr, TCL_INDEX_NONE); + TclNewIndexObj(objPtr, TCL_INDEX_NONE); } else { if (objPtr) { Tcl_SetListObj(objPtr, 0, NULL); diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c index 428f75878636..5b8f3a6d45f9 100644 --- a/generic/tclStringObj.c +++ b/generic/tclStringObj.c @@ -3688,7 +3688,7 @@ TclStringFirst( } } firstEnd: - TclNewIntObj(result, value); + TclNewIndexObj(result, value); return result; } @@ -3775,7 +3775,7 @@ TclStringLast( checkStr--; } lastEnd: - TclNewIntObj(result, value); + TclNewIndexObj(result, value); return result; }