summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2018-10-06 19:20:43 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2018-10-06 19:20:43 (GMT)
commit99e9ce3656f195c60ba4e928559c05d47167901c (patch)
tree64fba30ebef34869f49fcdf5b36b3b41164698db
parentd84d03b91a4eb72f88b56011713706a6f36bc17c (diff)
downloadtcl-99e9ce3656f195c60ba4e928559c05d47167901c.zip
tcl-99e9ce3656f195c60ba4e928559c05d47167901c.tar.gz
tcl-99e9ce3656f195c60ba4e928559c05d47167901c.tar.bz2
Use more TCL_AUTO_LENGTH, when appropriate
-rw-r--r--doc/Encoding.32
-rw-r--r--generic/tclBasic.c6
-rw-r--r--generic/tclBinary.c6
-rw-r--r--generic/tclCompExpr.c4
-rw-r--r--generic/tclCompile.c2
-rw-r--r--generic/tclEncoding.c18
-rw-r--r--generic/tclEnv.c8
-rw-r--r--generic/tclIO.c26
-rw-r--r--generic/tclInt.h4
-rw-r--r--generic/tclStubInit.c11
-rw-r--r--generic/tclUtf.c6
-rw-r--r--generic/tclUtil.c26
-rw-r--r--generic/tclZlib.c4
-rw-r--r--win/tclWin32Dll.c12
-rw-r--r--win/tclWinPipe.c2
15 files changed, 72 insertions, 65 deletions
diff --git a/doc/Encoding.3 b/doc/Encoding.3
index 3c654ba..c3161e1 100644
--- a/doc/Encoding.3
+++ b/doc/Encoding.3
@@ -83,7 +83,7 @@ specified encoding that are to be converted to UTF-8. For the
UTF-8 characters to be converted to the specified encoding.
.AP "const TCHAR" *tsrc in
An array of Windows TCHAR characters to convert to UTF-8.
-.AP int srcLen in
+.AP size_t srcLen in
Length of \fIsrc\fR or \fItsrc\fR in bytes. If the length is negative, the
encoding-specific length of the string is used.
.AP Tcl_DString *dstPtr out
diff --git a/generic/tclBasic.c b/generic/tclBasic.c
index c22ec71..0a4e91d 100644
--- a/generic/tclBasic.c
+++ b/generic/tclBasic.c
@@ -4647,7 +4647,7 @@ Tcl_EvalEx(
Tcl_Interp *interp, /* Interpreter in which to evaluate the
* script. Also used for error reporting. */
const char *script, /* First character of script to evaluate. */
- size_t numBytes, /* Number of bytes in script. If (size_t)-1, the
+ size_t numBytes, /* Number of bytes in script. If -1, the
* script consists of all bytes up to the
* first null character. */
int flags) /* Collection of OR-ed bits that control the
@@ -4662,7 +4662,7 @@ TclEvalEx(
Tcl_Interp *interp, /* Interpreter in which to evaluate the
* script. Also used for error reporting. */
const char *script, /* First character of script to evaluate. */
- size_t numBytes, /* Number of bytes in script. If (size_t)-1, the
+ size_t numBytes, /* Number of bytes in script. If -1, the
* script consists of all bytes up to the
* first NUL character. */
int flags, /* Collection of OR-ed bits that control the
@@ -4727,7 +4727,7 @@ TclEvalEx(
}
}
- if (numBytes == (size_t)-1) {
+ if (numBytes == TCL_AUTO_LENGTH) {
numBytes = strlen(script);
}
Tcl_ResetResult(interp);
diff --git a/generic/tclBinary.c b/generic/tclBinary.c
index 0cc35b9..4c6ccc9 100644
--- a/generic/tclBinary.c
+++ b/generic/tclBinary.c
@@ -663,12 +663,12 @@ UpdateStringOfByteArray(
*/
size = length;
- for (i = 0; (i < length) && (size != (size_t)-1); i++) {
+ for (i = 0; (i < length) && (size != TCL_AUTO_LENGTH); i++) {
if ((src[i] == 0) || (src[i] > 127)) {
size++;
}
}
- if (size == (size_t)-1) {
+ if (size == TCL_AUTO_LENGTH) {
Tcl_Panic("max size for a Tcl value exceeded");
}
@@ -718,7 +718,7 @@ TclAppendBytesToByteArray(
if (Tcl_IsShared(objPtr)) {
Tcl_Panic("%s called with shared object","TclAppendBytesToByteArray");
}
- if (len == (size_t)-1) {
+ if (len == TCL_AUTO_LENGTH) {
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 2950087..7afb0e0 100644
--- a/generic/tclCompExpr.c
+++ b/generic/tclCompExpr.c
@@ -1819,7 +1819,7 @@ int
Tcl_ParseExpr(
Tcl_Interp *interp, /* Used for error reporting. */
const char *start, /* Start of source string to parse. */
- size_t numBytes, /* Number of bytes in string. If (size_t)-1, the
+ size_t numBytes, /* Number of bytes in string. If -1, the
* string consists of all bytes up to the
* first null character. */
Tcl_Parse *parsePtr) /* Structure to fill with information about
@@ -1833,7 +1833,7 @@ Tcl_ParseExpr(
Tcl_Parse *exprParsePtr = TclStackAlloc(interp, sizeof(Tcl_Parse));
/* Holds the Tcl_Tokens of substitutions. */
- if (numBytes == (size_t)-1) {
+ if (numBytes == TCL_AUTO_LENGTH) {
numBytes = (start ? strlen(start) : 0);
}
diff --git a/generic/tclCompile.c b/generic/tclCompile.c
index aa4adca..7e10512 100644
--- a/generic/tclCompile.c
+++ b/generic/tclCompile.c
@@ -2104,7 +2104,7 @@ TclCompileScript(
* serves as context for finding and compiling
* commands. May not be NULL. */
const char *script, /* The source script to compile. */
- size_t numBytes, /* Number of bytes in script. If (size_t)-1, the
+ size_t numBytes, /* Number of bytes in script. If -1, the
* script consists of all bytes up to the
* first null character. */
CompileEnv *envPtr) /* Holds resulting instructions. */
diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c
index bbc1b20..06041f1 100644
--- a/generic/tclEncoding.c
+++ b/generic/tclEncoding.c
@@ -1048,7 +1048,7 @@ Tcl_ExternalToUtfDString(
Tcl_Encoding encoding, /* The encoding for the source string, or NULL
* for the default system encoding. */
const char *src, /* Source string in specified encoding. */
- size_t srcLen, /* Source string length in bytes, or (size_t)-1 for
+ size_t srcLen, /* Source string length in bytes, or -1 for
* encoding-specific string length. */
Tcl_DString *dstPtr) /* Uninitialized or free DString in which the
* converted string is stored. */
@@ -1070,7 +1070,7 @@ Tcl_ExternalToUtfDString(
if (src == NULL) {
srcLen = 0;
- } else if (srcLen == (size_t)-1) {
+ } else if (srcLen == TCL_AUTO_LENGTH) {
srcLen = encodingPtr->lengthProc(src);
}
@@ -1122,7 +1122,7 @@ Tcl_ExternalToUtf(
Tcl_Encoding encoding, /* The encoding for the source string, or NULL
* for the default system encoding. */
const char *src, /* Source string in specified encoding. */
- size_t srcLen, /* Source string length in bytes, or (size_t)-1
+ size_t srcLen, /* Source string length in bytes, or -1
* for encoding-specific string length. */
int flags, /* Conversion control flags. */
Tcl_EncodingState *statePtr,/* Place for conversion routine to store state
@@ -1160,7 +1160,7 @@ Tcl_ExternalToUtf(
if (src == NULL) {
srcLen = 0;
- } else if (srcLen == (size_t)-1) {
+ } else if (srcLen == TCL_AUTO_LENGTH) {
srcLen = encodingPtr->lengthProc(src);
}
if (statePtr == NULL) {
@@ -1239,7 +1239,7 @@ Tcl_UtfToExternalDString(
Tcl_Encoding encoding, /* The encoding for the converted string, or
* NULL for the default system encoding. */
const char *src, /* Source string in UTF-8. */
- size_t srcLen, /* Source string length in bytes, or (size_t)-1 for
+ size_t srcLen, /* Source string length in bytes, or -1 for
* strlen(). */
Tcl_DString *dstPtr) /* Uninitialized or free DString in which the
* converted string is stored. */
@@ -1261,7 +1261,7 @@ Tcl_UtfToExternalDString(
if (src == NULL) {
srcLen = 0;
- } else if (srcLen == (size_t)-1) {
+ } else if (srcLen == TCL_AUTO_LENGTH) {
srcLen = strlen(src);
}
flags = TCL_ENCODING_START | TCL_ENCODING_END;
@@ -1315,7 +1315,7 @@ Tcl_UtfToExternal(
Tcl_Encoding encoding, /* The encoding for the converted string, or
* NULL for the default system encoding. */
const char *src, /* Source string in UTF-8. */
- size_t srcLen, /* Source string length in bytes, or (size_t)-1
+ size_t srcLen, /* Source string length in bytes, or -1
* for strlen(). */
int flags, /* Conversion control flags. */
Tcl_EncodingState *statePtr,/* Place for conversion routine to store state
@@ -1350,7 +1350,7 @@ Tcl_UtfToExternal(
if (src == NULL) {
srcLen = 0;
- } else if (srcLen == (size_t)-1) {
+ } else if (srcLen == TCL_AUTO_LENGTH) {
srcLen = strlen(src);
}
if (statePtr == NULL) {
@@ -1940,7 +1940,7 @@ LoadEscapeEncoding(
Tcl_DString lineString;
Tcl_DStringInit(&lineString);
- if (Tcl_Gets(chan, &lineString) == (size_t)-1) {
+ if (Tcl_Gets(chan, &lineString) == TCL_IO_FAILURE) {
break;
}
line = Tcl_DStringValue(&lineString);
diff --git a/generic/tclEnv.c b/generic/tclEnv.c
index abf361b..e69fb29 100644
--- a/generic/tclEnv.c
+++ b/generic/tclEnv.c
@@ -217,7 +217,7 @@ TclSetEnv(
Tcl_MutexLock(&envMutex);
index = TclpFindVariable(name, &length);
- if (index == (size_t)-1) {
+ if (index == TCL_AUTO_LENGTH) {
#ifndef USE_PUTENV
/*
* We need to handle the case where the environment may be changed
@@ -301,7 +301,7 @@ TclSetEnv(
* string in the cache.
*/
- if ((index != (size_t)-1) && (environ[index] == p)) {
+ if ((index != TCL_AUTO_LENGTH) && (environ[index] == p)) {
ReplaceString(oldValue, p);
#ifdef HAVE_PUTENV_THAT_COPIES
} else {
@@ -417,7 +417,7 @@ TclUnsetEnv(
* needless work and to avoid recursion on the unset.
*/
- if (index == (size_t)-1) {
+ if (index == TCL_AUTO_LENGTH) {
Tcl_MutexUnlock(&envMutex);
return;
}
@@ -522,7 +522,7 @@ TclGetEnv(
Tcl_MutexLock(&envMutex);
index = TclpFindVariable(name, &length);
result = NULL;
- if (index != (size_t)-1) {
+ if (index != TCL_AUTO_LENGTH) {
Tcl_DString envStr;
result = Tcl_ExternalToUtfDString(NULL, environ[index], -1, &envStr);
diff --git a/generic/tclIO.c b/generic/tclIO.c
index ff6bf0c..30ed68d 100644
--- a/generic/tclIO.c
+++ b/generic/tclIO.c
@@ -3988,7 +3988,7 @@ size_t
Tcl_Write(
Tcl_Channel chan, /* The channel to buffer output for. */
const char *src, /* Data to queue in output buffer. */
- size_t srcLen) /* Length of data in bytes, or (size_t)-1 for
+ size_t srcLen) /* Length of data in bytes, or -1 for
* strlen(). */
{
/*
@@ -4002,14 +4002,14 @@ Tcl_Write(
chanPtr = statePtr->topChanPtr;
if (CheckChannelErrors(statePtr, TCL_WRITABLE) != 0) {
- return -1;
+ return TCL_IO_FAILURE;
}
- if (srcLen == (size_t)-1) {
+ if (srcLen == TCL_AUTO_LENGTH) {
srcLen = strlen(src);
}
if (WriteBytes(chanPtr, src, srcLen) == -1) {
- return -1;
+ return TCL_IO_FAILURE;
}
return srcLen;
}
@@ -4109,12 +4109,12 @@ Tcl_WriteChars(
Tcl_Obj *objPtr;
if (CheckChannelErrors(statePtr, TCL_WRITABLE) != 0) {
- return (size_t)-1;
+ return TCL_IO_FAILURE;
}
chanPtr = statePtr->topChanPtr;
- if (len == (size_t)-1) {
+ if (len == TCL_AUTO_LENGTH) {
len = strlen(src);
}
if (statePtr->encoding) {
@@ -4182,7 +4182,7 @@ Tcl_WriteObj(
chanPtr = statePtr->topChanPtr;
if (CheckChannelErrors(statePtr, TCL_WRITABLE) != 0) {
- return (size_t)-1;
+ return TCL_IO_FAILURE;
}
if (statePtr->encoding == NULL) {
src = (char *) TclGetByteArrayFromObj(objPtr, &srcLen);
@@ -4518,7 +4518,7 @@ Tcl_GetsObj(
Tcl_EncodingState oldState;
if (CheckChannelErrors(statePtr, TCL_READABLE) != 0) {
- return (size_t)-1;
+ return TCL_IO_FAILURE;
}
/*
@@ -4533,7 +4533,7 @@ Tcl_GetsObj(
/* TODO: Do we need this? */
UpdateInterest(chanPtr);
- return (size_t)-1;
+ return TCL_IO_FAILURE;
}
/*
@@ -5586,7 +5586,7 @@ Tcl_Read(
chanPtr = statePtr->topChanPtr;
if (CheckChannelErrors(statePtr, TCL_READABLE) != 0) {
- return (size_t)-1;
+ return TCL_IO_FAILURE;
}
return DoRead(chanPtr, dst, bytesToRead, 0);
@@ -5627,7 +5627,7 @@ Tcl_ReadRaw(
assert(bytesToRead > 0);
if (CheckChannelErrors(statePtr, TCL_READABLE | CHANNEL_RAW_MODE) != 0) {
- return (size_t)-1;
+ return TCL_IO_FAILURE;
}
/*
@@ -5737,7 +5737,7 @@ Tcl_ReadChars(
Tcl_Channel chan, /* The channel to read. */
Tcl_Obj *objPtr, /* Input data is stored in this object. */
size_t toRead, /* Maximum number of characters to store, or
- * (size_t)-1 to read all available data (up to EOF or
+ * -1 to read all available data (up to EOF or
* when channel blocks). */
int appendFlag) /* If non-zero, data read from the channel
* will be appended to the object. Otherwise,
@@ -5793,7 +5793,7 @@ DoReadChars(
Channel *chanPtr, /* The channel to read. */
Tcl_Obj *objPtr, /* Input data is stored in this object. */
size_t toRead, /* Maximum number of characters to store, or
- * (size_t)-1 to read all available data (up to EOF or
+ * -1 to read all available data (up to EOF or
* when channel blocks). */
int appendFlag) /* If non-zero, data read from the channel
* will be appended to the object. Otherwise,
diff --git a/generic/tclInt.h b/generic/tclInt.h
index 1a9feda..3b7225c 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -4170,7 +4170,7 @@ typedef const char *TclDTraceStr;
/*
* 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 == (size_t)-1'.
+ * 'length == TCL_AUTO_LENGTH'.
* Use empty 'if ; else' to handle use in unbraced outer if/else conditions.
*/
@@ -4182,7 +4182,7 @@ typedef const char *TclDTraceStr;
&& ((objPtr)->bytes != &tclEmptyString)) { \
Tcl_Free((objPtr)->bytes); \
} \
- (objPtr)->length = (size_t)-1; \
+ (objPtr)->length = TCL_AUTO_LENGTH; \
TclFreeObjStorage(objPtr); \
TclIncrObjsFreed(); \
} else { \
diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c
index d16a80e..7064ec1 100644
--- a/generic/tclStubInit.c
+++ b/generic/tclStubInit.c
@@ -115,6 +115,9 @@ Tcl_WinUtfToTChar(
Tcl_DString *dsPtr)
{
Tcl_DStringInit(dsPtr);
+ if (!string) {
+ return NULL;
+ }
return (char *)Tcl_UtfToUniCharDString(string, len, dsPtr);
}
@@ -124,9 +127,13 @@ Tcl_WinTCharToUtf(
size_t len,
Tcl_DString *dsPtr)
{
- if (len != (size_t)-1) {
+ Tcl_DStringInit(dsPtr);
+ if (!string) {
+ return NULL;
+ }
+ if (len != TCL_AUTO_LENGTH) {
len /= 2;
- } else if (len == -1) {
+ } else {
len = wcslen((wchar_t *)string);
}
Tcl_DStringInit(dsPtr);
diff --git a/generic/tclUtf.c b/generic/tclUtf.c
index 3bfb68f..cf32345 100644
--- a/generic/tclUtf.c
+++ b/generic/tclUtf.c
@@ -425,7 +425,7 @@ Tcl_UtfToUniCharDString(
const char *p, *end;
size_t oldLength;
- if (length == (size_t)-1) {
+ if (length == TCL_AUTO_LENGTH) {
length = strlen(src);
}
@@ -527,7 +527,7 @@ Tcl_NumUtfChars(
* single-byte char case specially.
*/
- if (length == (size_t)-1) {
+ if (length == TCL_AUTO_LENGTH) {
while (*src != '\0') {
src += TclUtfToUniChar(src, &ch);
i++;
@@ -806,7 +806,7 @@ Tcl_UtfAtIndex(
int len = 1;
#endif
- if (index != (size_t)-1) {
+ if (index != TCL_AUTO_LENGTH) {
while (index--) {
#if TCL_UTF_MAX <= 4
src += (len = TclUtfToUniChar(src, &ch));
diff --git a/generic/tclUtil.c b/generic/tclUtil.c
index 93242e4..9a35e4e 100644
--- a/generic/tclUtil.c
+++ b/generic/tclUtil.c
@@ -390,7 +390,7 @@ TclMaxListLength(
{
size_t count = 0;
- if ((numBytes == 0) || ((numBytes == (size_t)-1) && (*bytes == '\0'))) {
+ if ((numBytes == 0) || ((numBytes == TCL_AUTO_LENGTH) && (*bytes == '\0'))) {
/* Empty string case - quick exit */
goto done;
}
@@ -406,7 +406,7 @@ TclMaxListLength(
*/
while (numBytes) {
- if ((numBytes == (size_t)-1) && (*bytes == '\0')) {
+ if ((numBytes == TCL_AUTO_LENGTH) && (*bytes == '\0')) {
break;
}
if (TclIsSpaceProc(*bytes)) {
@@ -417,9 +417,9 @@ TclMaxListLength(
count++;
do {
bytes++;
- numBytes -= (numBytes != (size_t)-1);
+ numBytes -= (numBytes != TCL_AUTO_LENGTH);
} while (numBytes && TclIsSpaceProc(*bytes));
- if ((numBytes == 0) || ((numBytes == (size_t)-1) && (*bytes == '\0'))) {
+ if ((numBytes == 0) || ((numBytes == TCL_AUTO_LENGTH) && (*bytes == '\0'))) {
break;
}
@@ -428,7 +428,7 @@ TclMaxListLength(
*/
}
bytes++;
- numBytes -= (numBytes != (size_t)-1);
+ numBytes -= (numBytes != TCL_AUTO_LENGTH);
}
/*
@@ -1012,7 +1012,7 @@ Tcl_ScanCountedElement(
size_t
TclScanElement(
const char *src, /* String to convert to Tcl list element. */
- size_t length, /* Number of bytes in src, or (size_t)-1. */
+ size_t length, /* Number of bytes in src, or -1. */
char *flagPtr) /* Where to store information to guide
* Tcl_ConvertElement. */
{
@@ -1329,7 +1329,7 @@ Tcl_ConvertElement(
size_t
Tcl_ConvertCountedElement(
register const char *src, /* Source information for list element. */
- size_t length, /* Number of bytes in src, or (size_t)-1. */
+ size_t length, /* Number of bytes in src, or -1. */
char *dst, /* Place to put list-ified element. */
int flags) /* Flags produced by Tcl_ScanElement. */
{
@@ -1362,7 +1362,7 @@ Tcl_ConvertCountedElement(
size_t
TclConvertElement(
register const char *src, /* Source information for list element. */
- size_t length, /* Number of bytes in src, or (size_t)-1. */
+ size_t length, /* Number of bytes in src, or -1. */
char *dst, /* Place to put list-ified element. */
int flags) /* Flags produced by Tcl_ScanElement. */
{
@@ -1381,7 +1381,7 @@ TclConvertElement(
* No matter what the caller demands, empty string must be braced!
*/
- if ((src == NULL) || (length == 0) || (*src == '\0' && length == (size_t)-1)) {
+ if ((src == NULL) || (length == 0) || (*src == '\0' && length == TCL_AUTO_LENGTH)) {
src = &tclEmptyString;
length = 0;
conversion = CONVERT_BRACE;
@@ -2656,12 +2656,12 @@ Tcl_DStringAppend(
const char *bytes, /* String to append. If length is -1 then this
* must be null-terminated. */
size_t length) /* Number of bytes from "bytes" to append. If
- * (size_t)-1, then append all of bytes, up to null
+ * -1, then append all of bytes, up to null
* at end. */
{
size_t newSize;
- if (length == (size_t)-1) {
+ if (length == TCL_AUTO_LENGTH) {
length = strlen(bytes);
}
newSize = length + dsPtr->length;
@@ -2680,7 +2680,7 @@ Tcl_DStringAppend(
memcpy(newString, dsPtr->string, dsPtr->length);
dsPtr->string = newString;
} else {
- size_t offset = (size_t)-1;
+ size_t offset = TCL_AUTO_LENGTH;
/* See [16896d49fd] */
if (bytes >= dsPtr->string
@@ -2690,7 +2690,7 @@ Tcl_DStringAppend(
dsPtr->string = Tcl_Realloc(dsPtr->string, dsPtr->spaceAvl);
- if (offset != (size_t)-1) {
+ if (offset != TCL_AUTO_LENGTH) {
bytes = dsPtr->string + offset;
}
}
diff --git a/generic/tclZlib.c b/generic/tclZlib.c
index d05d774..f2c3cb9 100644
--- a/generic/tclZlib.c
+++ b/generic/tclZlib.c
@@ -1329,7 +1329,7 @@ Tcl_ZlibStreamGet(
(void) TclGetByteArrayFromObj(data, &existing);
if (zshPtr->mode == TCL_ZLIB_STREAM_INFLATE) {
- if (count == (size_t)-1) {
+ if (count == TCL_AUTO_LENGTH) {
/*
* 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.
@@ -1486,7 +1486,7 @@ Tcl_ZlibStreamGet(
}
} else {
Tcl_ListObjLength(NULL, zshPtr->outData, &listLen);
- if (count == (size_t)-1) {
+ if (count == TCL_AUTO_LENGTH) {
count = 0;
for (i=0; i<listLen; i++) {
Tcl_ListObjIndex(NULL, zshPtr->outData, i, &itemObj);
diff --git a/win/tclWin32Dll.c b/win/tclWin32Dll.c
index 03bcc7c..25bddee 100644
--- a/win/tclWin32Dll.c
+++ b/win/tclWin32Dll.c
@@ -466,14 +466,14 @@ TclWinDriveLetterForVolMountPoint(
TCHAR *
Tcl_WinUtfToTChar(
const char *string, /* Source string in UTF-8. */
- size_t len, /* Source string length in bytes, or (size_t)-1
+ size_t len, /* Source string length in bytes, or -1
* for strlen(). */
Tcl_DString *dsPtr) /* Uninitialized or free DString in which the
* converted string is stored. */
{
Tcl_DStringInit(dsPtr);
if (!string) {
- return (TCHAR *)Tcl_DStringValue(dsPtr);
+ return NULL;
}
return Tcl_UtfToUniCharDString(string, len, dsPtr);
}
@@ -481,18 +481,18 @@ Tcl_WinUtfToTChar(
char *
Tcl_WinTCharToUtf(
const TCHAR *string, /* Source string in Unicode. */
- size_t len, /* Source string length in bytes, or (size_t)-1
+ size_t len, /* Source string length in bytes, or -1
* for platform-specific string length. */
Tcl_DString *dsPtr) /* Uninitialized or free DString in which the
* converted string is stored. */
{
Tcl_DStringInit(dsPtr);
if (!string) {
- return Tcl_DStringValue(dsPtr);
+ return NULL;
}
- if (len != (size_t)-1) {
+ if (len != TCL_AUTO_LENGTH) {
len /= 2;
- } else if (len < 0) {
+ } else {
len = wcslen(string);
}
return Tcl_UniCharToUtfDString(string, len, dsPtr);
diff --git a/win/tclWinPipe.c b/win/tclWinPipe.c
index 0313708..eda9fe0 100644
--- a/win/tclWinPipe.c
+++ b/win/tclWinPipe.c
@@ -851,7 +851,7 @@ TclpCloseFile(
* Results:
* Returns the process id for the child process. If the pid was not known
* by Tcl, either because the pid was not created by Tcl or the child
- * process has already been reaped, -1 is returned.
+ * process has already been reaped, (size_t)-1 is returned.
*
* Side effects:
* None.