diff options
-rw-r--r-- | doc/AddErrInfo.3 | 2 | ||||
-rw-r--r-- | doc/DString.3 | 2 | ||||
-rw-r--r-- | doc/StringObj.3 | 6 | ||||
-rw-r--r-- | doc/TclZlib.3 | 2 | ||||
-rw-r--r-- | generic/tclBasic.c | 2 | ||||
-rw-r--r-- | generic/tclBinary.c | 2 | ||||
-rw-r--r-- | generic/tclCompExpr.c | 2 | ||||
-rw-r--r-- | generic/tclEncoding.c | 8 | ||||
-rw-r--r-- | generic/tclIO.c | 8 | ||||
-rw-r--r-- | generic/tclIORChan.c | 2 | ||||
-rw-r--r-- | generic/tclIORTrans.c | 8 | ||||
-rw-r--r-- | generic/tclInt.h | 6 | ||||
-rw-r--r-- | generic/tclLiteral.c | 12 | ||||
-rw-r--r-- | generic/tclMain.c | 4 | ||||
-rw-r--r-- | generic/tclNamesp.c | 2 | ||||
-rw-r--r-- | generic/tclObj.c | 14 | ||||
-rw-r--r-- | generic/tclParse.c | 35 | ||||
-rw-r--r-- | generic/tclStrToD.c | 4 | ||||
-rw-r--r-- | generic/tclStringObj.c | 54 | ||||
-rw-r--r-- | generic/tclUtf.c | 12 | ||||
-rw-r--r-- | generic/tclUtil.c | 30 | ||||
-rw-r--r-- | generic/tclZlib.c | 4 | ||||
-rw-r--r-- | tests/chanio.test | 2 | ||||
-rw-r--r-- | tests/io.test | 2 |
24 files changed, 111 insertions, 114 deletions
diff --git a/doc/AddErrInfo.3 b/doc/AddErrInfo.3 index 95451d3..e250127 100644 --- a/doc/AddErrInfo.3 +++ b/doc/AddErrInfo.3 @@ -61,7 +61,7 @@ in the form of a Tcl_Obj value. .AP size_t length in The number of bytes to copy from \fImessage\fR when appending to the \fB\-errorinfo\fR return option. -If TCL_AUTO_LENGTH, all bytes up to the first null byte are used. +If TCL_INDEX_NONE, all bytes up to the first null byte are used. .AP Tcl_Obj *errorObjPtr in The \fB\-errorcode\fR return option will be set to this value. .AP char *element in diff --git a/doc/DString.3 b/doc/DString.3 index b4d0922..cbce13f 100644 --- a/doc/DString.3 +++ b/doc/DString.3 @@ -48,7 +48,7 @@ Pointer to characters to append to dynamic string. .AP "const char" *element in Pointer to characters to append as list element to dynamic string. .AP size_t length in -Number of bytes from \fIbytes\fR to add to dynamic string. If TCL_AUTO_LENGTH, +Number of bytes from \fIbytes\fR to add to dynamic string. If TCL_INDEX_NONE, add all characters up to null terminating character. .AP size_t newLength in New length for dynamic string, not including null terminating diff --git a/doc/StringObj.3 b/doc/StringObj.3 index da1efb6..33c5c79 100644 --- a/doc/StringObj.3 +++ b/doc/StringObj.3 @@ -87,14 +87,14 @@ Tcl_Obj * Points to the first byte of an array of UTF-8-encoded bytes used to set or append to a string value. This byte array may contain embedded null characters -unless \fInumChars\fR is TCL_AUTO_LENGTH. (Applications needing null bytes +unless \fInumChars\fR is TCL_INDEX_NONE. (Applications needing null bytes should represent them as the two-byte sequence \fI\e300\e200\fR, use \fBTcl_ExternalToUtf\fR to convert, or \fBTcl_NewByteArrayObj\fR if the string is a collection of uninterpreted bytes.) .AP size_t length in The number of bytes to copy from \fIbytes\fR when initializing, setting, or appending to a string value. -If TCL_AUTO_LENGTH, all bytes up to the first null are used. +If TCL_INDEX_NONE, all bytes up to the first null are used. .AP "const Tcl_UniChar" *unicode in Points to the first byte of an array of Unicode characters used to set or append to a string value. @@ -103,7 +103,7 @@ unless \fInumChars\fR is negative. .AP size_t numChars in The number of Unicode characters to copy from \fIunicode\fR when initializing, setting, or appending to a string value. -If TCL_AUTO_LENGTH, all characters up to the first null character are used. +If TCL_INDEX_NONE, all characters up to the first null character are used. .AP size_t index in The index of the Unicode character to return. .AP size_t first in diff --git a/doc/TclZlib.3 b/doc/TclZlib.3 index 4093cfc..6d9179d 100644 --- a/doc/TclZlib.3 +++ b/doc/TclZlib.3 @@ -108,7 +108,7 @@ into a state where the decompressor can recover from on corruption, or \fBTCL_ZLIB_FINALIZE\fR to ensure that the stream is finished and that any trailer demanded by the format is written. .AP size_t count in -The maximum number of bytes to get from the stream, or TCL_AUTO_LENGTH to get +The maximum number of bytes to get from the stream, or TCL_INDEX_NONE to get all remaining bytes from the stream's buffers. .AP Tcl_Obj *compDict in A byte array value that is the compression dictionary to use with the stream. diff --git a/generic/tclBasic.c b/generic/tclBasic.c index 24ffe3c..2a9c02a 100644 --- a/generic/tclBasic.c +++ b/generic/tclBasic.c @@ -4944,7 +4944,7 @@ TclEvalEx( } } - if (numBytes == TCL_AUTO_LENGTH) { + if (numBytes == TCL_INDEX_NONE) { numBytes = strlen(script); } Tcl_ResetResult(interp); diff --git a/generic/tclBinary.c b/generic/tclBinary.c index ac319be..ea84b50 100644 --- a/generic/tclBinary.c +++ b/generic/tclBinary.c @@ -842,7 +842,7 @@ TclAppendBytesToByteArray( if (Tcl_IsShared(objPtr)) { Tcl_Panic("%s called with shared object","TclAppendBytesToByteArray"); } - if (len == TCL_AUTO_LENGTH) { + if (len == TCL_INDEX_NONE) { Tcl_Panic("%s must be called with definite number of bytes to append", "TclAppendBytesToByteArray"); } diff --git a/generic/tclCompExpr.c b/generic/tclCompExpr.c index 73b2ab3..60ccccb 100644 --- a/generic/tclCompExpr.c +++ b/generic/tclCompExpr.c @@ -1841,7 +1841,7 @@ Tcl_ParseExpr( Tcl_Parse *exprParsePtr = (Tcl_Parse *)TclStackAlloc(interp, sizeof(Tcl_Parse)); /* Holds the Tcl_Tokens of substitutions. */ - if (numBytes == TCL_AUTO_LENGTH) { + if (numBytes == TCL_INDEX_NONE) { numBytes = (start ? strlen(start) : 0); } diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c index e2754e1..49a1300 100644 --- a/generic/tclEncoding.c +++ b/generic/tclEncoding.c @@ -1071,7 +1071,7 @@ Tcl_ExternalToUtfDString( if (src == NULL) { srcLen = 0; - } else if (srcLen == TCL_AUTO_LENGTH) { + } else if (srcLen == TCL_INDEX_NONE) { srcLen = encodingPtr->lengthProc(src); } @@ -1161,7 +1161,7 @@ Tcl_ExternalToUtf( if (src == NULL) { srcLen = 0; - } else if (srcLen == TCL_AUTO_LENGTH) { + } else if (srcLen == TCL_INDEX_NONE) { srcLen = encodingPtr->lengthProc(src); } if (statePtr == NULL) { @@ -1261,7 +1261,7 @@ Tcl_UtfToExternalDString( if (src == NULL) { srcLen = 0; - } else if (srcLen == TCL_AUTO_LENGTH) { + } else if (srcLen == TCL_INDEX_NONE) { srcLen = strlen(src); } flags = TCL_ENCODING_START | TCL_ENCODING_END; @@ -1350,7 +1350,7 @@ Tcl_UtfToExternal( if (src == NULL) { srcLen = 0; - } else if (srcLen == TCL_AUTO_LENGTH) { + } else if (srcLen == TCL_INDEX_NONE) { srcLen = strlen(src); } if (statePtr == NULL) { diff --git a/generic/tclIO.c b/generic/tclIO.c index 3dd13f6..7303314 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -4012,7 +4012,7 @@ Tcl_Write( return TCL_IO_FAILURE; } - if (srcLen == TCL_AUTO_LENGTH) { + if (srcLen == TCL_INDEX_NONE) { srcLen = strlen(src); } if (WriteBytes(chanPtr, src, srcLen) == -1) { @@ -4062,7 +4062,7 @@ Tcl_WriteRaw( return TCL_IO_FAILURE; } - if (srcLen == TCL_AUTO_LENGTH) { + if (srcLen == TCL_INDEX_NONE) { srcLen = strlen(src); } @@ -4121,7 +4121,7 @@ Tcl_WriteChars( chanPtr = statePtr->topChanPtr; - if (len == TCL_AUTO_LENGTH) { + if (len == TCL_INDEX_NONE) { len = strlen(src); } if (statePtr->encoding) { @@ -9633,7 +9633,7 @@ CopyData( * unsuitable for updating totals and toRead. */ - if (sizeb == TCL_AUTO_LENGTH) { + if (sizeb == TCL_INDEX_NONE) { writeError: if (interp) { TclNewObj(errObj); diff --git a/generic/tclIORChan.c b/generic/tclIORChan.c index 54adf37..4ea92c8 100644 --- a/generic/tclIORChan.c +++ b/generic/tclIORChan.c @@ -1340,7 +1340,7 @@ ReflectInput( PassReceivedError(rcPtr->chan, &p); *errorCodePtr = EINVAL; } - p.input.toRead = TCL_AUTO_LENGTH; + p.input.toRead = TCL_INDEX_NONE; } else { *errorCodePtr = EOK; } diff --git a/generic/tclIORTrans.c b/generic/tclIORTrans.c index 7bf2499..896bdc8 100644 --- a/generic/tclIORTrans.c +++ b/generic/tclIORTrans.c @@ -2554,7 +2554,7 @@ ForwardProc( if (InvokeTclMethod(rtPtr, "read", bufObj, NULL, &resObj) != TCL_OK) { ForwardSetObjError(paramPtr, resObj); - paramPtr->transform.size = TCL_AUTO_LENGTH; + paramPtr->transform.size = TCL_INDEX_NONE; } else { /* * Process a regular return. Contains the transformation result. @@ -2588,7 +2588,7 @@ ForwardProc( if (InvokeTclMethod(rtPtr, "write", bufObj, NULL, &resObj) != TCL_OK) { ForwardSetObjError(paramPtr, resObj); - paramPtr->transform.size = TCL_AUTO_LENGTH; + paramPtr->transform.size = TCL_INDEX_NONE; } else { /* * Process a regular return. Contains the transformation result. @@ -2618,7 +2618,7 @@ ForwardProc( case ForwardedDrain: if (InvokeTclMethod(rtPtr, "drain", NULL, NULL, &resObj) != TCL_OK) { ForwardSetObjError(paramPtr, resObj); - paramPtr->transform.size = TCL_AUTO_LENGTH; + paramPtr->transform.size = TCL_INDEX_NONE; } else { /* * Process a regular return. Contains the transformation result. @@ -2644,7 +2644,7 @@ ForwardProc( case ForwardedFlush: if (InvokeTclMethod(rtPtr, "flush", NULL, NULL, &resObj) != TCL_OK) { ForwardSetObjError(paramPtr, resObj); - paramPtr->transform.size = TCL_AUTO_LENGTH; + paramPtr->transform.size = TCL_INDEX_NONE; } else { /* * Process a regular return. Contains the transformation result. diff --git a/generic/tclInt.h b/generic/tclInt.h index 306d431..013bbe6 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -1518,7 +1518,7 @@ typedef struct LiteralEntry { * table, the number of ByteCode structures * that share the literal object; the literal * entry can be freed when refCount drops to - * 0. If in a local literal table, TCL_AUTO_LENGTH. */ + * 0. If in a local literal table, TCL_INDEX_NONE. */ Namespace *nsPtr; /* Namespace in which this literal is used. We * try to avoid sharing literal non-FQ command * names among different namespaces to reduce @@ -4222,7 +4222,7 @@ MODULE_SCOPE size_t TclIndexDecode(int encoded, size_t endValue); /* * 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 == TCL_AUTO_LENGTH'. + * 'length == TCL_INDEX_NONE'. * Use empty 'if ; else' to handle use in unbraced outer if/else conditions. */ @@ -4234,7 +4234,7 @@ MODULE_SCOPE size_t TclIndexDecode(int encoded, size_t endValue); && ((objPtr)->bytes != &tclEmptyString)) { \ Tcl_Free((objPtr)->bytes); \ } \ - (objPtr)->length = TCL_AUTO_LENGTH; \ + (objPtr)->length = TCL_INDEX_NONE; \ TclFreeObjStorage(objPtr); \ TclIncrObjsFreed(); \ } else { \ diff --git a/generic/tclLiteral.c b/generic/tclLiteral.c index 99ea92d..e58125a 100644 --- a/generic/tclLiteral.c +++ b/generic/tclLiteral.c @@ -195,7 +195,7 @@ TclCreateLiteral( * Is it in the interpreter's global literal table? */ - if (hash == TCL_AUTO_LENGTH) { + if (hash == TCL_INDEX_NONE) { hash = HashString(bytes, length); } globalHash = (hash & globalTablePtr->mask); @@ -229,7 +229,7 @@ TclCreateLiteral( if (flags & LITERAL_ON_HEAP) { Tcl_Free((void *)bytes); } - if (globalPtr->refCount != TCL_AUTO_LENGTH) { + if (globalPtr->refCount != TCL_INDEX_NONE) { globalPtr->refCount++; } return objPtr; @@ -412,7 +412,7 @@ TclRegisterLiteral( int isNew; Namespace *nsPtr; - if (length == TCL_AUTO_LENGTH) { + if (length == TCL_INDEX_NONE) { length = (bytes ? strlen(bytes) : 0); } hash = HashString(bytes, length); @@ -628,7 +628,7 @@ TclAddLiteralObj( lPtr = &envPtr->literalArrayPtr[objIndex]; lPtr->objPtr = objPtr; Tcl_IncrRefCount(objPtr); - lPtr->refCount = TCL_AUTO_LENGTH; /* i.e., unused */ + lPtr->refCount = TCL_INDEX_NONE; /* i.e., unused */ lPtr->nextPtr = NULL; if (litPtrPtr) { @@ -851,7 +851,7 @@ TclReleaseLiteral( * literal table entry (decrement the ref count of the object). */ - if ((entryPtr->refCount != TCL_AUTO_LENGTH) && (entryPtr->refCount-- <= 1)) { + if ((entryPtr->refCount != TCL_INDEX_NONE) && (entryPtr->refCount-- <= 1)) { if (prevPtr == NULL) { globalTablePtr->buckets[index] = entryPtr->nextPtr; } else { @@ -1175,7 +1175,7 @@ TclVerifyLocalLiteralTable( for (localPtr=localTablePtr->buckets[i] ; localPtr!=NULL; localPtr=localPtr->nextPtr) { count++; - if (localPtr->refCount != TCL_AUTO_LENGTH) { + if (localPtr->refCount != TCL_INDEX_NONE) { bytes = TclGetStringFromObj(localPtr->objPtr, &length); Tcl_Panic("%s: local literal \"%.*s\" had bad refCount %" TCL_Z_MODIFIER "u", "TclVerifyLocalLiteralTable", diff --git a/generic/tclMain.c b/generic/tclMain.c index 848ad18..38612b2 100644 --- a/generic/tclMain.c +++ b/generic/tclMain.c @@ -472,7 +472,7 @@ Tcl_MainEx( Tcl_IncrRefCount(is.commandPtr); } length = Tcl_GetsObj(is.input, is.commandPtr); - if (length == TCL_AUTO_LENGTH) { + if (length == TCL_INDEX_NONE) { if (Tcl_InputBlocked(is.input)) { /* * This can only happen if stdin has been set to @@ -749,7 +749,7 @@ StdinProc( Tcl_IncrRefCount(commandPtr); } length = Tcl_GetsObj(chan, commandPtr); - if (length == TCL_AUTO_LENGTH) { + if (length == TCL_INDEX_NONE) { if (Tcl_InputBlocked(chan)) { return; } diff --git a/generic/tclNamesp.c b/generic/tclNamesp.c index 2f5b7da..86823c4 100644 --- a/generic/tclNamesp.c +++ b/generic/tclNamesp.c @@ -4928,7 +4928,7 @@ TclLogCommandInfo( } } - if (length == TCL_AUTO_LENGTH) { + if (length == TCL_INDEX_NONE) { length = strlen(command); } overflow = (length > (size_t)limit); diff --git a/generic/tclObj.c b/generic/tclObj.c index 8a628a7..c9d0e03 100644 --- a/generic/tclObj.c +++ b/generic/tclObj.c @@ -1309,16 +1309,16 @@ TclFreeObj( * sure we do not accept a second free when falling from 0 to -1. * Skip that possibility so any double free will trigger the panic. */ - objPtr->refCount = TCL_AUTO_LENGTH; + objPtr->refCount = TCL_INDEX_NONE; /* * 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 == TCL_AUTO_LENGTH'. + * with 'length == TCL_INDEX_NONE'. */ TclInvalidateStringRep(objPtr); - objPtr->length = TCL_AUTO_LENGTH; + objPtr->length = TCL_INDEX_NONE; if (ObjDeletePending(context)) { PushObjToDelete(context, objPtr); @@ -1386,7 +1386,7 @@ TclFreeObj( */ TclInvalidateStringRep(objPtr); - objPtr->length = TCL_AUTO_LENGTH; + objPtr->length = TCL_INDEX_NONE; if (!objPtr->typePtr || !objPtr->typePtr->freeIntRepProc) { /* @@ -1488,7 +1488,7 @@ int TclObjBeingDeleted( Tcl_Obj *objPtr) { - return (objPtr->length == TCL_AUTO_LENGTH); + return (objPtr->length == TCL_INDEX_NONE); } /* @@ -1607,7 +1607,7 @@ Tcl_GetString( objPtr->typePtr->name); } objPtr->typePtr->updateStringProc(objPtr); - if (objPtr->bytes == NULL || objPtr->length == TCL_AUTO_LENGTH + if (objPtr->bytes == NULL || objPtr->length == TCL_INDEX_NONE || objPtr->bytes[objPtr->length] != '\0') { Tcl_Panic("UpdateStringProc for type '%s' " "failed to create a valid string rep", @@ -1666,7 +1666,7 @@ Tcl_GetStringFromObj( objPtr->typePtr->name); } objPtr->typePtr->updateStringProc(objPtr); - if (objPtr->bytes == NULL || objPtr->length == TCL_AUTO_LENGTH + if (objPtr->bytes == NULL || objPtr->length == TCL_INDEX_NONE || objPtr->bytes[objPtr->length] != '\0') { Tcl_Panic("UpdateStringProc for type '%s' " "failed to create a valid string rep", diff --git a/generic/tclParse.c b/generic/tclParse.c index cb72e94..b822094 100644 --- a/generic/tclParse.c +++ b/generic/tclParse.c @@ -220,6 +220,10 @@ Tcl_ParseCommand( * point to char after terminating one. */ size_t scanned; + if (numBytes == TCL_INDEX_NONE && start) { + numBytes = strlen(start); + } + TclParseInit(interp, start, numBytes, parsePtr); if ((start == NULL) && (numBytes != 0)) { if (interp != NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj( @@ -227,10 +231,6 @@ Tcl_ParseCommand( } return TCL_ERROR; } - if (numBytes == TCL_AUTO_LENGTH) { - numBytes = strlen(start); - } - TclParseInit(interp, start, numBytes, parsePtr); parsePtr->commentStart = NULL; parsePtr->commentSize = 0; parsePtr->commandStart = NULL; @@ -1348,16 +1348,15 @@ Tcl_ParseVarName( int varIndex; unsigned array; - if ((numBytes == 0) || (start == NULL)) { - return TCL_ERROR; - } - if (numBytes == TCL_AUTO_LENGTH) { + if (numBytes == TCL_INDEX_NONE && start) { numBytes = strlen(start); } - if (!append) { TclParseInit(interp, start, numBytes, parsePtr); } + if ((numBytes == 0) || (start == NULL)) { + return TCL_ERROR; + } /* * Generate one token for the variable, an additional token for the name, @@ -1631,16 +1630,15 @@ Tcl_ParseBraces( int startIndex, level; size_t length; - if ((numBytes == 0) || (start == NULL)) { - return TCL_ERROR; - } - if (numBytes == TCL_AUTO_LENGTH) { + if (numBytes == TCL_INDEX_NONE && start) { numBytes = strlen(start); } - if (!append) { TclParseInit(interp, start, numBytes, parsePtr); } + if ((numBytes == 0) || (start == NULL)) { + return TCL_ERROR; + } src = start; startIndex = parsePtr->numTokens; @@ -1829,16 +1827,15 @@ Tcl_ParseQuotedString( * the quoted string's terminating close-quote * if the parse succeeds. */ { - if ((numBytes == 0) || (start == NULL)) { - return TCL_ERROR; - } - if (numBytes == TCL_AUTO_LENGTH) { + if (numBytes == TCL_INDEX_NONE && start) { numBytes = strlen(start); } - if (!append) { TclParseInit(interp, start, numBytes, parsePtr); } + if ((numBytes == 0) || (start == NULL)) { + return TCL_ERROR; + } if (TCL_OK != ParseTokens(start+1, numBytes-1, TYPE_QUOTE, TCL_SUBST_ALL, parsePtr)) { diff --git a/generic/tclStrToD.c b/generic/tclStrToD.c index b1e91d7..33b91a3 100644 --- a/generic/tclStrToD.c +++ b/generic/tclStrToD.c @@ -536,7 +536,7 @@ TclParseNumber( mp_err err = MP_OKAY; int under = 0; /* Flag trailing '_' as error if true once * number is accepted. */ - + #define ALL_BITS ((Tcl_WideUInt)-1) #define MOST_BITS (ALL_BITS >> 1) @@ -1193,7 +1193,7 @@ TclParseNumber( } } else { /* - * Back up to the last accepting state in the lexer. + * Back up to the last accepting state in the lexer. * If the last char seen is the numeric whitespace character '_', * backup to that. */ diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c index 09439fb..f9b2775 100644 --- a/generic/tclStringObj.c +++ b/generic/tclStringObj.c @@ -265,7 +265,7 @@ Tcl_NewStringObj( { Tcl_Obj *objPtr; - if (length == TCL_AUTO_LENGTH) { + if (length == TCL_INDEX_NONE) { length = (bytes? strlen(bytes) : 0); } TclNewStringObj(objPtr, bytes, length); @@ -317,7 +317,7 @@ Tcl_DbNewStringObj( { Tcl_Obj *objPtr; - if (length == TCL_AUTO_LENGTH) { + if (length == TCL_INDEX_NONE) { length = (bytes? strlen(bytes) : 0); } TclDbNewObj(objPtr, file, line); @@ -434,7 +434,7 @@ Tcl_GetCharLength( * If numChars is unknown, compute it. */ - if (numChars == TCL_AUTO_LENGTH) { + if (numChars == TCL_INDEX_NONE) { TclNumUtfChars(numChars, objPtr->bytes, objPtr->length); stringPtr->numChars = numChars; } @@ -537,7 +537,7 @@ Tcl_GetUniChar( * If numChars is unknown, compute it. */ - if (stringPtr->numChars == TCL_AUTO_LENGTH) { + if (stringPtr->numChars == TCL_INDEX_NONE) { TclNumUtfChars(stringPtr->numChars, objPtr->bytes, objPtr->length); } if (stringPtr->numChars == objPtr->length) { @@ -678,7 +678,7 @@ Tcl_GetRange( * If numChars is unknown, compute it. */ - if (stringPtr->numChars == TCL_AUTO_LENGTH) { + if (stringPtr->numChars == TCL_INDEX_NONE) { TclNumUtfChars(stringPtr->numChars, objPtr->bytes, objPtr->length); } if (stringPtr->numChars == objPtr->length) { @@ -769,7 +769,7 @@ Tcl_SetStringObj( */ TclInvalidateStringRep(objPtr); - if (length == TCL_AUTO_LENGTH) { + if (length == TCL_INDEX_NONE) { length = (bytes? strlen(bytes) : 0); } TclInitStringRep(objPtr, bytes, length); @@ -842,7 +842,7 @@ Tcl_SetObjLength( * Invalidate the unicode data. */ - stringPtr->numChars = TCL_AUTO_LENGTH; + stringPtr->numChars = TCL_INDEX_NONE; stringPtr->hasUnicode = 0; } else { if (length > stringPtr->maxChars) { @@ -939,7 +939,7 @@ Tcl_AttemptSetObjLength( * Invalidate the unicode data. */ - stringPtr->numChars = TCL_AUTO_LENGTH; + stringPtr->numChars = TCL_INDEX_NONE; stringPtr->hasUnicode = 0; } else { /* @@ -1009,7 +1009,7 @@ UnicodeLength( size_t numChars = 0; if (unicode) { - while ((numChars != TCL_AUTO_LENGTH) && (unicode[numChars] != 0)) { + while ((numChars != TCL_INDEX_NONE) && (unicode[numChars] != 0)) { numChars++; } } @@ -1026,7 +1026,7 @@ SetUnicodeObj( { String *stringPtr; - if (numChars == TCL_AUTO_LENGTH) { + if (numChars == TCL_INDEX_NONE) { numChars = UnicodeLength(unicode); } @@ -1084,7 +1084,7 @@ Tcl_AppendLimitedToObj( size_t toCopy = 0; size_t eLen = 0; - if (length == TCL_AUTO_LENGTH) { + if (length == TCL_INDEX_NONE) { length = (bytes ? strlen(bytes) : 0); } if (length == 0) { @@ -1165,7 +1165,7 @@ Tcl_AppendToObj( * If -1, then append all bytes up to NUL * byte. */ { - Tcl_AppendLimitedToObj(objPtr, bytes, length, TCL_AUTO_LENGTH, NULL); + Tcl_AppendLimitedToObj(objPtr, bytes, length, TCL_INDEX_NONE, NULL); } /* @@ -1245,7 +1245,7 @@ Tcl_AppendObjToObj( { String *stringPtr; size_t length = 0, numChars; - size_t appendNumChars = TCL_AUTO_LENGTH; + size_t appendNumChars = TCL_INDEX_NONE; const char *bytes; /* @@ -1350,7 +1350,7 @@ Tcl_AppendObjToObj( bytes = TclGetStringFromObj(appendObjPtr, &length); numChars = stringPtr->numChars; - if ((numChars != TCL_AUTO_LENGTH) && TclHasIntRep(appendObjPtr, &tclStringType)) { + if ((numChars != TCL_INDEX_NONE) && TclHasIntRep(appendObjPtr, &tclStringType)) { String *appendStringPtr = GET_STRING(appendObjPtr); appendNumChars = appendStringPtr->numChars; @@ -1358,7 +1358,7 @@ Tcl_AppendObjToObj( AppendUtfToUtfRep(objPtr, bytes, length); - if ((numChars != TCL_AUTO_LENGTH) && (appendNumChars != TCL_AUTO_LENGTH)) { + if ((numChars != TCL_INDEX_NONE) && (appendNumChars != TCL_INDEX_NONE)) { stringPtr->numChars = numChars + appendNumChars; } } @@ -1389,7 +1389,7 @@ AppendUnicodeToUnicodeRep( String *stringPtr; size_t numChars; - if (appendNumChars == TCL_AUTO_LENGTH) { + if (appendNumChars == TCL_INDEX_NONE) { appendNumChars = UnicodeLength(unicode); } if (appendNumChars == 0) { @@ -1478,7 +1478,7 @@ AppendUnicodeToUtfRep( numChars = ExtendStringRepWithUnicode(objPtr, unicode, numChars); - if (stringPtr->numChars != TCL_AUTO_LENGTH) { + if (stringPtr->numChars != TCL_INDEX_NONE) { stringPtr->numChars += numChars; } } @@ -1563,7 +1563,7 @@ AppendUtfToUtfRep( stringPtr = GET_STRING(objPtr); if (newLength > stringPtr->allocated) { - size_t offset = TCL_AUTO_LENGTH; + size_t offset = TCL_INDEX_NONE; /* * Protect against case where unicode points into the existing @@ -1587,7 +1587,7 @@ AppendUtfToUtfRep( * Relocate bytes if needed; see above. */ - if (offset != TCL_AUTO_LENGTH) { + if (offset != TCL_INDEX_NONE) { bytes = objPtr->bytes + offset; } } @@ -1596,7 +1596,7 @@ AppendUtfToUtfRep( * Invalidate the unicode data. */ - stringPtr->numChars = TCL_AUTO_LENGTH; + stringPtr->numChars = TCL_INDEX_NONE; stringPtr->hasUnicode = 0; if (bytes) { @@ -3387,7 +3387,7 @@ TclStringCmp( * length was requested. */ - if ((reqlength == TCL_AUTO_LENGTH) && !nocase) { + if ((reqlength == TCL_INDEX_NONE) && !nocase) { memCmpFn = (memCmpFn_t) TclpUtfNcmp2; } else { s1len = Tcl_NumUtfChars(s1, s1len); @@ -3399,7 +3399,7 @@ TclStringCmp( } length = (s1len < s2len) ? s1len : s2len; - if (reqlength == TCL_AUTO_LENGTH) { + if (reqlength == TCL_INDEX_NONE) { /* * The requested length is negative, so we ignore it by setting it * to length + 1 so we correct the match var. @@ -3458,7 +3458,7 @@ TclStringFirst( size_t value = TCL_IO_FAILURE; Tcl_UniChar *check, *end, *uh, *un; - if (start == TCL_AUTO_LENGTH) { + if (start == TCL_INDEX_NONE) { start = 0; } if (ln == 0) { @@ -3730,7 +3730,7 @@ TclStringReverse( } to = objPtr->bytes; - if ((numChars == TCL_AUTO_LENGTH) || (numChars < numBytes)) { + if ((numChars == TCL_INDEX_NONE) || (numChars < numBytes)) { /* * Either numChars == -1 and we don't know how many chars are * represented by objPtr->bytes and we need Pass 1 just in case, @@ -3953,7 +3953,7 @@ ExtendUnicodeRepWithString( if (stringPtr->hasUnicode) { numOrigChars = stringPtr->numChars; } - if (numAppendChars == TCL_AUTO_LENGTH) { + if (numAppendChars == TCL_INDEX_NONE) { TclNumUtfChars(numAppendChars, bytes, numBytes); } needed = numOrigChars + numAppendChars; @@ -4004,7 +4004,7 @@ DupStringInternalRep( String *srcStringPtr = GET_STRING(srcPtr); String *copyStringPtr = NULL; - if (srcStringPtr->numChars == TCL_AUTO_LENGTH) { + if (srcStringPtr->numChars == TCL_INDEX_NONE) { /* * The String struct in the source value holds zero useful data. Don't * bother copying it. Don't even bother allocating space in which to @@ -4154,7 +4154,7 @@ ExtendStringRepWithUnicode( char *dst; String *stringPtr = GET_STRING(objPtr); - if (numChars == TCL_AUTO_LENGTH) { + if (numChars == TCL_INDEX_NONE) { numChars = UnicodeLength(unicode); } diff --git a/generic/tclUtf.c b/generic/tclUtf.c index ac76309..ae87e1b 100644 --- a/generic/tclUtf.c +++ b/generic/tclUtf.c @@ -329,7 +329,7 @@ Tcl_UniCharToUtfDString( if (uniStr == NULL) { return NULL; } - if (uniLength == TCL_AUTO_LENGTH) { + if (uniLength == TCL_INDEX_NONE) { uniLength = 0; w = uniStr; while (*w != '\0') { @@ -371,7 +371,7 @@ Tcl_Char16ToUtfDString( if (uniStr == NULL) { return NULL; } - if (uniLength == TCL_AUTO_LENGTH) { + if (uniLength == TCL_INDEX_NONE) { uniLength = 0; w = uniStr; @@ -672,7 +672,7 @@ Tcl_UtfToUniCharDString( if (src == NULL) { return NULL; } - if (length == TCL_AUTO_LENGTH) { + if (length == TCL_INDEX_NONE) { length = strlen(src); } @@ -729,7 +729,7 @@ Tcl_UtfToChar16DString( if (src == NULL) { return NULL; } - if (length == TCL_AUTO_LENGTH) { + if (length == TCL_INDEX_NONE) { length = strlen(src); } @@ -817,12 +817,12 @@ size_t Tcl_NumUtfChars( const char *src, /* The UTF-8 string to measure. */ size_t length) /* The length of the string in bytes, or - * TCL_AUTO_LENGTH for strlen(src). */ + * TCL_INDEX_NONE for strlen(src). */ { Tcl_UniChar ch = 0; size_t i = 0; - if (length == TCL_AUTO_LENGTH) { + if (length == TCL_INDEX_NONE) { /* string is NUL-terminated, so TclUtfToUniChar calls are safe. */ while (*src != '\0') { src += TclUtfToUniChar(src, &ch); diff --git a/generic/tclUtil.c b/generic/tclUtil.c index c4da26d..de20ad8 100644 --- a/generic/tclUtil.c +++ b/generic/tclUtil.c @@ -392,7 +392,7 @@ TclMaxListLength( { size_t count = 0; - if ((numBytes == 0) || ((numBytes == TCL_AUTO_LENGTH) && (*bytes == '\0'))) { + if ((numBytes == 0) || ((numBytes == TCL_INDEX_NONE) && (*bytes == '\0'))) { /* Empty string case - quick exit */ goto done; } @@ -408,7 +408,7 @@ TclMaxListLength( */ while (numBytes) { - if ((numBytes == TCL_AUTO_LENGTH) && (*bytes == '\0')) { + if ((numBytes == TCL_INDEX_NONE) && (*bytes == '\0')) { break; } if (TclIsSpaceProcM(*bytes)) { @@ -419,9 +419,9 @@ TclMaxListLength( count++; do { bytes++; - numBytes -= (numBytes != TCL_AUTO_LENGTH); + numBytes -= (numBytes != TCL_INDEX_NONE); } while (numBytes && TclIsSpaceProcM(*bytes)); - if ((numBytes == 0) || ((numBytes == TCL_AUTO_LENGTH) && (*bytes == '\0'))) { + if ((numBytes == 0) || ((numBytes == TCL_INDEX_NONE) && (*bytes == '\0'))) { break; } @@ -430,7 +430,7 @@ TclMaxListLength( */ } bytes++; - numBytes -= (numBytes != TCL_AUTO_LENGTH); + numBytes -= (numBytes != TCL_INDEX_NONE); } /* @@ -1032,7 +1032,7 @@ TclScanElement( int braceCount = 0; /* Count of all braces '{' '}' seen. */ #endif /* COMPAT */ - if ((p == NULL) || (length == 0) || ((*p == '\0') && (length == TCL_AUTO_LENGTH))) { + if ((p == NULL) || (length == 0) || ((*p == '\0') && (length == TCL_INDEX_NONE))) { /* * Empty string element must be brace quoted. */ @@ -1115,7 +1115,7 @@ TclScanElement( break; case '\\': /* TYPE_SUBS */ extra++; /* Escape '\' => '\\' */ - if ((length == 1) || ((length == TCL_AUTO_LENGTH) && (p[1] == '\0'))) { + if ((length == 1) || ((length == TCL_INDEX_NONE) && (p[1] == '\0'))) { /* * Final backslash. Cannot format with brace quoting. */ @@ -1146,7 +1146,7 @@ TclScanElement( #endif /* COMPAT */ break; case '\0': /* TYPE_SUBS */ - if (length == TCL_AUTO_LENGTH) { + if (length == TCL_INDEX_NONE) { goto endOfString; } /* TODO: Panic on improper encoding? */ @@ -1395,7 +1395,7 @@ TclConvertElement( * No matter what the caller demands, empty string must be braced! */ - if ((src == NULL) || (length == 0) || (*src == '\0' && length == TCL_AUTO_LENGTH)) { + if ((src == NULL) || (length == 0) || (*src == '\0' && length == TCL_INDEX_NONE)) { p[0] = '{'; p[1] = '}'; return 2; @@ -1422,7 +1422,7 @@ TclConvertElement( */ if (conversion == CONVERT_NONE) { - if (length == TCL_AUTO_LENGTH) { + if (length == TCL_INDEX_NONE) { /* TODO: INT_MAX overflow? */ while (*src) { *p++ = *src++; @@ -1441,7 +1441,7 @@ TclConvertElement( if (conversion == CONVERT_BRACE) { *p = '{'; p++; - if (length == TCL_AUTO_LENGTH) { + if (length == TCL_INDEX_NONE) { /* TODO: INT_MAX overflow? */ while (*src) { *p++ = *src++; @@ -1514,7 +1514,7 @@ TclConvertElement( p++; continue; case '\0': - if (length == TCL_AUTO_LENGTH) { + if (length == TCL_INDEX_NONE) { return (size_t)(p - dst); } @@ -2560,14 +2560,14 @@ char * Tcl_DStringAppend( Tcl_DString *dsPtr, /* Structure describing dynamic string. */ const char *bytes, /* String to append. If length is - * TCL_AUTO_LENGTH then this must be null-terminated. */ + * TCL_INDEX_NONE then this must be null-terminated. */ size_t length) /* Number of bytes from "bytes" to append. If - * TCL_AUTO_LENGTH, then append all of bytes, up to null + * TCL_INDEX_NONE, then append all of bytes, up to null * at end. */ { size_t newSize; - if (length == TCL_AUTO_LENGTH) { + if (length == TCL_INDEX_NONE) { length = strlen(bytes); } newSize = length + dsPtr->length; diff --git a/generic/tclZlib.c b/generic/tclZlib.c index 1d4e362..1f47abe 100644 --- a/generic/tclZlib.c +++ b/generic/tclZlib.c @@ -1345,7 +1345,7 @@ Tcl_ZlibStreamGet( } if (zshPtr->mode == TCL_ZLIB_STREAM_INFLATE) { - if (count == TCL_AUTO_LENGTH) { + if (count == TCL_INDEX_NONE) { /* * The only safe thing to do is restict to 65k. We might cause a * panic for out of memory if we just kept growing the buffer. @@ -1502,7 +1502,7 @@ Tcl_ZlibStreamGet( } } else { Tcl_ListObjLength(NULL, zshPtr->outData, &listLen); - if (count == TCL_AUTO_LENGTH) { + if (count == TCL_INDEX_NONE) { count = 0; for (i=0; i<listLen; i++) { Tcl_ListObjIndex(NULL, zshPtr->outData, i, &itemObj); diff --git a/tests/chanio.test b/tests/chanio.test index c7c07ce..a0a2130 100644 --- a/tests/chanio.test +++ b/tests/chanio.test @@ -2724,7 +2724,7 @@ test chan-io-29.31 {Tcl_WriteChars, background flush} -setup { set result ok } # allow a little time for the background process to chan close. - # otherwise, the following test fails on the [file delete $path(output) + # otherwise, the following test fails on the [file delete $path(output)] # on Windows because a process still has the file open. after 100 set v 1; vwait v return $result diff --git a/tests/io.test b/tests/io.test index 73481ca..592f09f 100644 --- a/tests/io.test +++ b/tests/io.test @@ -2827,7 +2827,7 @@ test io-29.31 {Tcl_WriteChars, background flush} {stdio openpipe} { set result ok } # allow a little time for the background process to close. - # otherwise, the following test fails on the [file delete $path(output) + # otherwise, the following test fails on the [file delete $path(output)] # on Windows because a process still has the file open. after 100 set v 1; vwait v set result |