summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--generic/tcl.decls26
-rw-r--r--generic/tclBinary.c33
-rw-r--r--generic/tclCmdMZ.c3
-rw-r--r--generic/tclCompile.c3
-rw-r--r--generic/tclDecls.h56
-rw-r--r--generic/tclGet.c2
-rw-r--r--generic/tclInt.h3
-rw-r--r--generic/tclObj.c13
-rw-r--r--generic/tclPathObj.c4
-rw-r--r--generic/tclProc.c10
-rw-r--r--generic/tclStringObj.c54
-rw-r--r--generic/tclThread.c6
-rw-r--r--generic/tclUtil.c4
-rw-r--r--generic/tclVar.c3
-rw-r--r--macosx/tclMacOSXFCmd.c2
15 files changed, 112 insertions, 110 deletions
diff --git a/generic/tcl.decls b/generic/tcl.decls
index 0ee5eec..5ce1f8b 100644
--- a/generic/tcl.decls
+++ b/generic/tcl.decls
@@ -86,7 +86,7 @@ declare 15 {
void Tcl_AppendStringsToObj(Tcl_Obj *objPtr, ...)
}
declare 16 {
- void Tcl_AppendToObj(Tcl_Obj *objPtr, const char *bytes, int length)
+ void Tcl_AppendToObj(Tcl_Obj *objPtr, const char *bytes, size_t length)
}
declare 17 {
Tcl_Obj *Tcl_ConcatObj(int objc, Tcl_Obj *const objv[])
@@ -126,7 +126,7 @@ declare 27 {
Tcl_Obj *Tcl_DbNewObj(const char *file, int line)
}
declare 28 {
- Tcl_Obj *Tcl_DbNewStringObj(const char *bytes, int length,
+ Tcl_Obj *Tcl_DbNewStringObj(const char *bytes, size_t length,
const char *file, int line)
}
declare 29 {
@@ -227,11 +227,11 @@ declare 57 {
void Tcl_SetBooleanObj(Tcl_Obj *objPtr, int boolValue)
}
declare 58 {
- unsigned char *Tcl_SetByteArrayLength(Tcl_Obj *objPtr, int length)
+ unsigned char *Tcl_SetByteArrayLength(Tcl_Obj *objPtr, size_t length)
}
declare 59 {
void Tcl_SetByteArrayObj(Tcl_Obj *objPtr, const unsigned char *bytes,
- int length)
+ size_t length)
}
declare 60 {
void Tcl_SetDoubleObj(Tcl_Obj *objPtr, double doubleValue)
@@ -246,10 +246,10 @@ declare 63 {
void Tcl_SetLongObj(Tcl_Obj *objPtr, long longValue)
}
declare 64 {
- void Tcl_SetObjLength(Tcl_Obj *objPtr, int length)
+ void Tcl_SetObjLength(Tcl_Obj *objPtr, size_t length)
}
declare 65 {
- void Tcl_SetStringObj(Tcl_Obj *objPtr, const char *bytes, int length)
+ void Tcl_SetStringObj(Tcl_Obj *objPtr, const char *bytes, size_t length)
}
declare 66 {
void Tcl_AddErrorInfo(Tcl_Interp *interp, const char *message)
@@ -1110,7 +1110,7 @@ declare 304 {
int *indexPtr)
}
declare 305 {
- void *Tcl_GetThreadData(Tcl_ThreadDataKey *keyPtr, int size)
+ void *Tcl_GetThreadData(Tcl_ThreadDataKey *keyPtr, size_t size)
}
declare 306 {
Tcl_Obj *Tcl_GetVar2Ex(Tcl_Interp *interp, const char *part1,
@@ -1360,10 +1360,10 @@ declare 378 {
}
declare 379 {
void Tcl_SetUnicodeObj(Tcl_Obj *objPtr, const Tcl_UniChar *unicode,
- int numChars)
+ size_t numChars)
}
declare 380 {
- int Tcl_GetCharLength(Tcl_Obj *objPtr)
+ size_t Tcl_GetCharLength(Tcl_Obj *objPtr)
}
declare 381 {
Tcl_UniChar Tcl_GetUniChar(Tcl_Obj *objPtr, int index)
@@ -1376,7 +1376,7 @@ declare 383 {
}
declare 384 {
void Tcl_AppendUnicodeToObj(Tcl_Obj *objPtr, const Tcl_UniChar *unicode,
- int length)
+ size_t length)
}
declare 385 {
int Tcl_RegExpMatchObj(Tcl_Interp *interp, Tcl_Obj *textObj,
@@ -1549,7 +1549,7 @@ declare 431 {
const char *file, int line)
}
declare 432 {
- int Tcl_AttemptSetObjLength(Tcl_Obj *objPtr, int length)
+ int Tcl_AttemptSetObjLength(Tcl_Obj *objPtr, size_t length)
}
# TIP#10 (thread-aware channels) akupries
@@ -2107,8 +2107,8 @@ declare 574 {
void Tcl_AppendObjToErrorInfo(Tcl_Interp *interp, Tcl_Obj *objPtr)
}
declare 575 {
- void Tcl_AppendLimitedToObj(Tcl_Obj *objPtr, const char *bytes, int length,
- int limit, const char *ellipsis)
+ void Tcl_AppendLimitedToObj(Tcl_Obj *objPtr, const char *bytes, size_t length,
+ size_t limit, const char *ellipsis)
}
declare 576 {
Tcl_Obj *Tcl_Format(Tcl_Interp *interp, const char *format, int objc,
diff --git a/generic/tclBinary.c b/generic/tclBinary.c
index d17583f..25013bd 100644
--- a/generic/tclBinary.c
+++ b/generic/tclBinary.c
@@ -192,9 +192,9 @@ const Tcl_ObjType tclByteArrayType = {
*/
typedef struct {
- int used; /* The number of bytes used in the byte
+ size_t used; /* The number of bytes used in the byte
* array. */
- int allocated; /* The amount of space actually allocated
+ size_t allocated; /* The amount of space actually allocated
* minus 1 byte. */
unsigned char bytes[1]; /* The array of bytes. The actual size of this
* field depends on the 'allocated' field
@@ -317,7 +317,7 @@ Tcl_SetByteArrayObj(
Tcl_Obj *objPtr, /* Object to initialize as a ByteArray. */
const unsigned char *bytes, /* The array of bytes to use as the new
value. May be NULL even if length > 0. */
- int length) /* Length of the array of bytes, which must
+ size_t length) /* Length of the array of bytes, which must
be >= 0. */
{
ByteArray *byteArrayPtr;
@@ -404,7 +404,7 @@ Tcl_GetByteArrayFromObj(
unsigned char *
Tcl_SetByteArrayLength(
Tcl_Obj *objPtr, /* The ByteArray object. */
- int length) /* New length for internal byte array. */
+ size_t length) /* New length for internal byte array. */
{
ByteArray *byteArrayPtr;
@@ -447,14 +447,15 @@ SetByteArrayFromAny(
Tcl_Interp *interp, /* Not used. */
Tcl_Obj *objPtr) /* The object to convert to type ByteArray. */
{
- int length;
+ size_t length;
const char *src, *srcEnd;
unsigned char *dst;
ByteArray *byteArrayPtr;
Tcl_UniChar ch;
if (objPtr->typePtr != &tclByteArrayType) {
- src = TclGetStringFromObj(objPtr, &length);
+ src = TclGetString(objPtr);
+ length = objPtr->length;
srcEnd = src + length;
byteArrayPtr = ckalloc(BYTEARRAY_SIZE(length));
@@ -520,7 +521,7 @@ DupByteArrayInternalRep(
Tcl_Obj *srcPtr, /* Object with internal rep to copy. */
Tcl_Obj *copyPtr) /* Object with internal rep to set. */
{
- int length;
+ size_t length;
ByteArray *srcArrayPtr, *copyArrayPtr;
srcArrayPtr = GET_BYTEARRAY(srcPtr);
@@ -529,7 +530,7 @@ DupByteArrayInternalRep(
copyArrayPtr = ckalloc(BYTEARRAY_SIZE(length));
copyArrayPtr->used = length;
copyArrayPtr->allocated = length;
- memcpy(copyArrayPtr->bytes, srcArrayPtr->bytes, (size_t) length);
+ memcpy(copyArrayPtr->bytes, srcArrayPtr->bytes, length);
SET_BYTEARRAY(copyPtr, copyArrayPtr);
copyPtr->typePtr = &tclByteArrayType;
@@ -562,7 +563,7 @@ UpdateStringOfByteArray(
Tcl_Obj *objPtr) /* ByteArray object whose string rep to
* update. */
{
- int i, length, size;
+ size_t i, length, size;
unsigned char *src;
char *dst;
ByteArray *byteArrayPtr;
@@ -576,12 +577,12 @@ UpdateStringOfByteArray(
*/
size = length;
- for (i = 0; i < length && size >= 0; i++) {
+ for (i = 0; (i < length) && (size != (size_t)-1); i++) {
if ((src[i] == 0) || (src[i] > 127)) {
size++;
}
}
- if (size < 0) {
+ if (size == (size_t)-1) {
Tcl_Panic("max size for a Tcl value (%d bytes) exceeded", INT_MAX);
}
@@ -590,7 +591,7 @@ UpdateStringOfByteArray(
objPtr->length = size;
if (size == length) {
- memcpy(dst, src, (size_t) size);
+ memcpy(dst, src, size);
dst[size] = '\0';
} else {
for (i = 0; i < length; i++) {
@@ -625,14 +626,14 @@ void
TclAppendBytesToByteArray(
Tcl_Obj *objPtr,
const unsigned char *bytes,
- int len)
+ size_t len)
{
ByteArray *byteArrayPtr;
if (Tcl_IsShared(objPtr)) {
Tcl_Panic("%s called with shared object","TclAppendBytesToByteArray");
}
- if (len < 0) {
+ if (len == (size_t)-1) {
Tcl_Panic("%s must be called with definite number of bytes to append",
"TclAppendBytesToByteArray");
}
@@ -646,7 +647,7 @@ TclAppendBytesToByteArray(
*/
if (byteArrayPtr->used + len > byteArrayPtr->allocated) {
- unsigned int attempt, used = byteArrayPtr->used;
+ size_t attempt, used = byteArrayPtr->used;
ByteArray *tmpByteArrayPtr = NULL;
attempt = byteArrayPtr->allocated;
@@ -689,7 +690,7 @@ TclAppendBytesToByteArray(
* Do the append if there's any point.
*/
- if (len > 0) {
+ if ((len > 0) && (len != (size_t)-1)) {
memcpy(byteArrayPtr->bytes + byteArrayPtr->used, bytes, len);
byteArrayPtr->used += len;
Tcl_InvalidateStringRep(objPtr);
diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c
index 5b8f9ac..56777e1 100644
--- a/generic/tclCmdMZ.c
+++ b/generic/tclCmdMZ.c
@@ -1540,7 +1540,8 @@ StringIsCmd(
case STR_IS_BOOL:
case STR_IS_TRUE:
case STR_IS_FALSE:
- if (TCL_OK != Tcl_ConvertToType(NULL, objPtr, &tclBooleanType)) {
+ if ((objPtr->typePtr != &tclBooleanType)
+ && (TCL_OK != TclSetBooleanFromAny(NULL, objPtr))) {
if (strict) {
result = 0;
} else {
diff --git a/generic/tclCompile.c b/generic/tclCompile.c
index 33d67ff..4069cf0 100644
--- a/generic/tclCompile.c
+++ b/generic/tclCompile.c
@@ -789,8 +789,7 @@ SetByteCodeFromAny(
if (interp == NULL) {
return TCL_ERROR;
}
- TclSetByteCodeFromAny(interp, objPtr, NULL, NULL);
- return TCL_OK;
+ return TclSetByteCodeFromAny(interp, objPtr, NULL, NULL);
}
/*
diff --git a/generic/tclDecls.h b/generic/tclDecls.h
index 9b2b6e0..ce1163a 100644
--- a/generic/tclDecls.h
+++ b/generic/tclDecls.h
@@ -79,7 +79,7 @@ TCLAPI int Tcl_AppendAllObjTypes(Tcl_Interp *interp,
TCLAPI void Tcl_AppendStringsToObj(Tcl_Obj *objPtr, ...);
/* 16 */
TCLAPI void Tcl_AppendToObj(Tcl_Obj *objPtr, const char *bytes,
- int length);
+ size_t length);
/* 17 */
TCLAPI Tcl_Obj * Tcl_ConcatObj(int objc, Tcl_Obj *const objv[]);
/* 18 */
@@ -112,7 +112,7 @@ TCLAPI Tcl_Obj * Tcl_DbNewLongObj(long longValue, const char *file,
/* 27 */
TCLAPI Tcl_Obj * Tcl_DbNewObj(const char *file, int line);
/* 28 */
-TCLAPI Tcl_Obj * Tcl_DbNewStringObj(const char *bytes, int length,
+TCLAPI Tcl_Obj * Tcl_DbNewStringObj(const char *bytes, size_t length,
const char *file, int line);
/* 29 */
TCLAPI Tcl_Obj * Tcl_DuplicateObj(Tcl_Obj *objPtr);
@@ -190,10 +190,11 @@ TCLAPI Tcl_Obj * Tcl_NewStringObj(const char *bytes, int length);
/* 57 */
TCLAPI void Tcl_SetBooleanObj(Tcl_Obj *objPtr, int boolValue);
/* 58 */
-TCLAPI unsigned char * Tcl_SetByteArrayLength(Tcl_Obj *objPtr, int length);
+TCLAPI unsigned char * Tcl_SetByteArrayLength(Tcl_Obj *objPtr,
+ size_t length);
/* 59 */
TCLAPI void Tcl_SetByteArrayObj(Tcl_Obj *objPtr,
- const unsigned char *bytes, int length);
+ const unsigned char *bytes, size_t length);
/* 60 */
TCLAPI void Tcl_SetDoubleObj(Tcl_Obj *objPtr, double doubleValue);
/* 61 */
@@ -204,10 +205,10 @@ TCLAPI void Tcl_SetListObj(Tcl_Obj *objPtr, int objc,
/* 63 */
TCLAPI void Tcl_SetLongObj(Tcl_Obj *objPtr, long longValue);
/* 64 */
-TCLAPI void Tcl_SetObjLength(Tcl_Obj *objPtr, int length);
+TCLAPI void Tcl_SetObjLength(Tcl_Obj *objPtr, size_t length);
/* 65 */
TCLAPI void Tcl_SetStringObj(Tcl_Obj *objPtr, const char *bytes,
- int length);
+ size_t length);
/* 66 */
TCLAPI void Tcl_AddErrorInfo(Tcl_Interp *interp,
const char *message);
@@ -864,7 +865,7 @@ TCLAPI int Tcl_GetIndexFromObjStruct(Tcl_Interp *interp,
int *indexPtr);
/* 305 */
TCLAPI void * Tcl_GetThreadData(Tcl_ThreadDataKey *keyPtr,
- int size);
+ size_t size);
/* 306 */
TCLAPI Tcl_Obj * Tcl_GetVar2Ex(Tcl_Interp *interp, const char *part1,
const char *part2, int flags);
@@ -1053,9 +1054,9 @@ TCLAPI Tcl_Obj * Tcl_NewUnicodeObj(const Tcl_UniChar *unicode,
int numChars);
/* 379 */
TCLAPI void Tcl_SetUnicodeObj(Tcl_Obj *objPtr,
- const Tcl_UniChar *unicode, int numChars);
+ const Tcl_UniChar *unicode, size_t numChars);
/* 380 */
-TCLAPI int Tcl_GetCharLength(Tcl_Obj *objPtr);
+TCLAPI size_t Tcl_GetCharLength(Tcl_Obj *objPtr);
/* 381 */
TCLAPI Tcl_UniChar Tcl_GetUniChar(Tcl_Obj *objPtr, int index);
/* 382 */
@@ -1064,7 +1065,7 @@ TCLAPI Tcl_UniChar * Tcl_GetUnicode(Tcl_Obj *objPtr);
TCLAPI Tcl_Obj * Tcl_GetRange(Tcl_Obj *objPtr, int first, int last);
/* 384 */
TCLAPI void Tcl_AppendUnicodeToObj(Tcl_Obj *objPtr,
- const Tcl_UniChar *unicode, int length);
+ const Tcl_UniChar *unicode, size_t length);
/* 385 */
TCLAPI int Tcl_RegExpMatchObj(Tcl_Interp *interp,
Tcl_Obj *textObj, Tcl_Obj *patternObj);
@@ -1200,7 +1201,8 @@ TCLAPI void * Tcl_AttemptMemRealloc(void *ptr, size_t size);
TCLAPI void * Tcl_AttemptDbCkrealloc(void *ptr, size_t size,
const char *file, int line);
/* 432 */
-TCLAPI int Tcl_AttemptSetObjLength(Tcl_Obj *objPtr, int length);
+TCLAPI int Tcl_AttemptSetObjLength(Tcl_Obj *objPtr,
+ size_t length);
/* 433 */
TCLAPI Tcl_ThreadId Tcl_GetChannelThread(Tcl_Channel channel);
/* 434 */
@@ -1598,8 +1600,8 @@ TCLAPI void Tcl_AppendObjToErrorInfo(Tcl_Interp *interp,
Tcl_Obj *objPtr);
/* 575 */
TCLAPI void Tcl_AppendLimitedToObj(Tcl_Obj *objPtr,
- const char *bytes, int length, int limit,
- const char *ellipsis);
+ const char *bytes, size_t length,
+ size_t limit, const char *ellipsis);
/* 576 */
TCLAPI Tcl_Obj * Tcl_Format(Tcl_Interp *interp, const char *format,
int objc, Tcl_Obj *const objv[]);
@@ -1800,7 +1802,7 @@ typedef struct TclStubs {
int (*tcl_WaitForEvent) (const Tcl_Time *timePtr); /* 13 */
int (*tcl_AppendAllObjTypes) (Tcl_Interp *interp, Tcl_Obj *objPtr); /* 14 */
void (*tcl_AppendStringsToObj) (Tcl_Obj *objPtr, ...); /* 15 */
- void (*tcl_AppendToObj) (Tcl_Obj *objPtr, const char *bytes, int length); /* 16 */
+ void (*tcl_AppendToObj) (Tcl_Obj *objPtr, const char *bytes, size_t length); /* 16 */
Tcl_Obj * (*tcl_ConcatObj) (int objc, Tcl_Obj *const objv[]); /* 17 */
int (*tcl_ConvertToType) (Tcl_Interp *interp, Tcl_Obj *objPtr, const Tcl_ObjType *typePtr); /* 18 */
void (*tcl_DbDecrRefCount) (Tcl_Obj *objPtr, const char *file, int line); /* 19 */
@@ -1812,7 +1814,7 @@ typedef struct TclStubs {
Tcl_Obj * (*tcl_DbNewListObj) (int objc, Tcl_Obj *const *objv, const char *file, int line); /* 25 */
Tcl_Obj * (*tcl_DbNewLongObj) (long longValue, const char *file, int line); /* 26 */
Tcl_Obj * (*tcl_DbNewObj) (const char *file, int line); /* 27 */
- Tcl_Obj * (*tcl_DbNewStringObj) (const char *bytes, int length, const char *file, int line); /* 28 */
+ Tcl_Obj * (*tcl_DbNewStringObj) (const char *bytes, size_t length, const char *file, int line); /* 28 */
Tcl_Obj * (*tcl_DuplicateObj) (Tcl_Obj *objPtr); /* 29 */
void (*tclFreeObj) (Tcl_Obj *objPtr); /* 30 */
int (*tcl_GetBoolean) (Tcl_Interp *interp, const char *src, int *boolPtr); /* 31 */
@@ -1842,14 +1844,14 @@ typedef struct TclStubs {
Tcl_Obj * (*tcl_NewObj) (void); /* 55 */
Tcl_Obj * (*tcl_NewStringObj) (const char *bytes, int length); /* 56 */
void (*tcl_SetBooleanObj) (Tcl_Obj *objPtr, int boolValue); /* 57 */
- unsigned char * (*tcl_SetByteArrayLength) (Tcl_Obj *objPtr, int length); /* 58 */
- void (*tcl_SetByteArrayObj) (Tcl_Obj *objPtr, const unsigned char *bytes, int length); /* 59 */
+ unsigned char * (*tcl_SetByteArrayLength) (Tcl_Obj *objPtr, size_t length); /* 58 */
+ void (*tcl_SetByteArrayObj) (Tcl_Obj *objPtr, const unsigned char *bytes, size_t length); /* 59 */
void (*tcl_SetDoubleObj) (Tcl_Obj *objPtr, double doubleValue); /* 60 */
void (*tcl_SetIntObj) (Tcl_Obj *objPtr, int intValue); /* 61 */
void (*tcl_SetListObj) (Tcl_Obj *objPtr, int objc, Tcl_Obj *const objv[]); /* 62 */
void (*tcl_SetLongObj) (Tcl_Obj *objPtr, long longValue); /* 63 */
- void (*tcl_SetObjLength) (Tcl_Obj *objPtr, int length); /* 64 */
- void (*tcl_SetStringObj) (Tcl_Obj *objPtr, const char *bytes, int length); /* 65 */
+ void (*tcl_SetObjLength) (Tcl_Obj *objPtr, size_t length); /* 64 */
+ void (*tcl_SetStringObj) (Tcl_Obj *objPtr, const char *bytes, size_t length); /* 65 */
void (*tcl_AddErrorInfo) (Tcl_Interp *interp, const char *message); /* 66 */
void (*tcl_AddObjErrorInfo) (Tcl_Interp *interp, const char *message, int length); /* 67 */
void (*tcl_AllowExceptions) (Tcl_Interp *interp); /* 68 */
@@ -2097,7 +2099,7 @@ typedef struct TclStubs {
const char * (*tcl_GetEncodingName) (Tcl_Encoding encoding); /* 302 */
void (*tcl_GetEncodingNames) (Tcl_Interp *interp); /* 303 */
int (*tcl_GetIndexFromObjStruct) (Tcl_Interp *interp, Tcl_Obj *objPtr, const void *tablePtr, int offset, const char *msg, int flags, int *indexPtr); /* 304 */
- void * (*tcl_GetThreadData) (Tcl_ThreadDataKey *keyPtr, int size); /* 305 */
+ void * (*tcl_GetThreadData) (Tcl_ThreadDataKey *keyPtr, size_t size); /* 305 */
Tcl_Obj * (*tcl_GetVar2Ex) (Tcl_Interp *interp, const char *part1, const char *part2, int flags); /* 306 */
ClientData (*tcl_InitNotifier) (void); /* 307 */
void (*tcl_MutexLock) (Tcl_Mutex *mutexPtr); /* 308 */
@@ -2171,12 +2173,12 @@ typedef struct TclStubs {
int (*tcl_RegExpExecObj) (Tcl_Interp *interp, Tcl_RegExp regexp, Tcl_Obj *textObj, int offset, int nmatches, int flags); /* 376 */
void (*tcl_RegExpGetInfo) (Tcl_RegExp regexp, Tcl_RegExpInfo *infoPtr); /* 377 */
Tcl_Obj * (*tcl_NewUnicodeObj) (const Tcl_UniChar *unicode, int numChars); /* 378 */
- void (*tcl_SetUnicodeObj) (Tcl_Obj *objPtr, const Tcl_UniChar *unicode, int numChars); /* 379 */
- int (*tcl_GetCharLength) (Tcl_Obj *objPtr); /* 380 */
+ void (*tcl_SetUnicodeObj) (Tcl_Obj *objPtr, const Tcl_UniChar *unicode, size_t numChars); /* 379 */
+ size_t (*tcl_GetCharLength) (Tcl_Obj *objPtr); /* 380 */
Tcl_UniChar (*tcl_GetUniChar) (Tcl_Obj *objPtr, int index); /* 381 */
Tcl_UniChar * (*tcl_GetUnicode) (Tcl_Obj *objPtr); /* 382 */
Tcl_Obj * (*tcl_GetRange) (Tcl_Obj *objPtr, int first, int last); /* 383 */
- void (*tcl_AppendUnicodeToObj) (Tcl_Obj *objPtr, const Tcl_UniChar *unicode, int length); /* 384 */
+ void (*tcl_AppendUnicodeToObj) (Tcl_Obj *objPtr, const Tcl_UniChar *unicode, size_t length); /* 384 */
int (*tcl_RegExpMatchObj) (Tcl_Interp *interp, Tcl_Obj *textObj, Tcl_Obj *patternObj); /* 385 */
void (*tcl_SetNotifier) (Tcl_NotifierProcs *notifierProcPtr); /* 386 */
Tcl_Mutex * (*tcl_GetAllocMutex) (void); /* 387 */
@@ -2224,7 +2226,7 @@ typedef struct TclStubs {
void * (*tcl_AttemptDbCkalloc) (size_t size, const char *file, int line); /* 429 */
void * (*tcl_AttemptMemRealloc) (void *ptr, size_t size); /* 430 */
void * (*tcl_AttemptDbCkrealloc) (void *ptr, size_t size, const char *file, int line); /* 431 */
- int (*tcl_AttemptSetObjLength) (Tcl_Obj *objPtr, int length); /* 432 */
+ int (*tcl_AttemptSetObjLength) (Tcl_Obj *objPtr, size_t length); /* 432 */
Tcl_ThreadId (*tcl_GetChannelThread) (Tcl_Channel channel); /* 433 */
Tcl_UniChar * (*tcl_GetUnicodeFromObj) (Tcl_Obj *objPtr, int *lengthPtr); /* 434 */
void (*reserved435)(void);
@@ -2367,7 +2369,7 @@ typedef struct TclStubs {
const char * (*tcl_GetEncodingNameFromEnvironment) (Tcl_DString *bufPtr); /* 572 */
int (*tcl_PkgRequireProc) (Tcl_Interp *interp, const char *name, int objc, Tcl_Obj *const objv[], void *clientDataPtr); /* 573 */
void (*tcl_AppendObjToErrorInfo) (Tcl_Interp *interp, Tcl_Obj *objPtr); /* 574 */
- void (*tcl_AppendLimitedToObj) (Tcl_Obj *objPtr, const char *bytes, int length, int limit, const char *ellipsis); /* 575 */
+ void (*tcl_AppendLimitedToObj) (Tcl_Obj *objPtr, const char *bytes, size_t length, size_t limit, const char *ellipsis); /* 575 */
Tcl_Obj * (*tcl_Format) (Tcl_Interp *interp, const char *format, int objc, Tcl_Obj *const objv[]); /* 576 */
int (*tcl_AppendFormatToObj) (Tcl_Interp *interp, Tcl_Obj *objPtr, const char *format, int objc, Tcl_Obj *const objv[]); /* 577 */
Tcl_Obj * (*tcl_ObjPrintf) (const char *format, ...) TCL_FORMAT_PRINTF(1, 2); /* 578 */
@@ -3753,10 +3755,10 @@ TCLAPI void Tcl_MainExW(int argc, wchar_t **argv,
#if defined(USE_TCL_STUBS) && !defined(TCL_COMPAT_8)
# undef Tcl_GetString
# define Tcl_GetString(obj) \
- ((obj)?((obj)->bytes?(obj)->bytes:tclStubsPtr->tcl_GetString(obj)):NULL)
+ ((obj)?((obj)->bytes?(obj)->bytes:tclStubsPtr->tcl_GetString(obj)):(char *)(obj))
# undef Tcl_GetStringFromObj
# define Tcl_GetStringFromObj(obj, lengthPtr) \
- ((obj)?(Tcl_GetString(obj),(*(lengthPtr)=(obj)->length),(obj)->bytes):((*(lengthPtr)=0),NULL))
+ ((obj)?(Tcl_GetString(obj),(*(lengthPtr)=(obj)->length),(obj)->bytes):((*(lengthPtr)=0),(char *)(obj)))
#endif
#endif /* _TCLDECLS */
diff --git a/generic/tclGet.c b/generic/tclGet.c
index 4c19b55..97e8c7b 100644
--- a/generic/tclGet.c
+++ b/generic/tclGet.c
@@ -137,7 +137,7 @@ Tcl_GetBoolean(
obj.length = strlen(src);
obj.typePtr = NULL;
- code = Tcl_ConvertToType(interp, &obj, &tclBooleanType);
+ code = TclSetBooleanFromAny(interp, &obj);
if (obj.refCount > 1) {
Tcl_Panic("invalid sharing of Tcl_Obj on C stack");
}
diff --git a/generic/tclInt.h b/generic/tclInt.h
index 584885b..3f697bc 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -2844,7 +2844,7 @@ struct Tcl_LoadHandle_ {
*/
MODULE_SCOPE void TclAppendBytesToByteArray(Tcl_Obj *objPtr,
- const unsigned char *bytes, int len);
+ const unsigned char *bytes, size_t len);
MODULE_SCOPE int TclNREvalCmd(Tcl_Interp *interp, Tcl_Obj *objPtr,
int flags);
MODULE_SCOPE void TclAdvanceContinuations(int *line, int **next,
@@ -3092,6 +3092,7 @@ MODULE_SCOPE void TclSetBgErrorHandler(Tcl_Interp *interp,
Tcl_Obj *cmdPrefix);
MODULE_SCOPE void TclSetBignumIntRep(Tcl_Obj *objPtr,
mp_int *bignumValue);
+MODULE_SCOPE int TclSetBooleanFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr);
MODULE_SCOPE void TclSetCmdNameObj(Tcl_Interp *interp, Tcl_Obj *objPtr,
Command *cmdPtr);
MODULE_SCOPE void TclSetDuplicateObj(Tcl_Obj *dupPtr, Tcl_Obj *objPtr);
diff --git a/generic/tclObj.c b/generic/tclObj.c
index 2c3f1f0..b2bdec7 100644
--- a/generic/tclObj.c
+++ b/generic/tclObj.c
@@ -208,7 +208,6 @@ static Tcl_ThreadDataKey pendingObjDataKey;
*/
static int ParseBoolean(Tcl_Obj *objPtr);
-static int SetBooleanFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr);
static int SetDoubleFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr);
static int SetIntFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr);
static void UpdateStringOfDouble(Tcl_Obj *objPtr);
@@ -250,14 +249,14 @@ static const Tcl_ObjType oldBooleanType = {
NULL, /* freeIntRepProc */
NULL, /* dupIntRepProc */
NULL, /* updateStringProc */
- SetBooleanFromAny /* setFromAnyProc */
+ TclSetBooleanFromAny /* setFromAnyProc */
};
const Tcl_ObjType tclBooleanType = {
"booleanString", /* name */
NULL, /* freeIntRepProc */
NULL, /* dupIntRepProc */
NULL, /* updateStringProc */
- SetBooleanFromAny /* setFromAnyProc */
+ TclSetBooleanFromAny /* setFromAnyProc */
};
const Tcl_ObjType tclDoubleType = {
"double", /* name */
@@ -1911,7 +1910,7 @@ Tcl_GetBooleanFromObj(
/*
*----------------------------------------------------------------------
*
- * SetBooleanFromAny --
+ * TclSetBooleanFromAny --
*
* Attempt to generate a boolean internal form for the Tcl object
* "objPtr".
@@ -1928,8 +1927,8 @@ Tcl_GetBooleanFromObj(
*----------------------------------------------------------------------
*/
-static int
-SetBooleanFromAny(
+int
+TclSetBooleanFromAny(
Tcl_Interp *interp, /* Used for error reporting if not NULL. */
register Tcl_Obj *objPtr) /* The object to convert. */
{
@@ -4171,7 +4170,7 @@ Tcl_GetCommandFromObj(
* had is invalid one way or another.
*/
- if (tclCmdNameType.setFromAnyProc(interp, objPtr) != TCL_OK) {
+ if (SetCmdNameFromAny(interp, objPtr) != TCL_OK) {
return NULL;
}
resPtr = objPtr->internalRep.twoPtrValue.ptr1;
diff --git a/generic/tclPathObj.c b/generic/tclPathObj.c
index 7bad09c..ea5c1b8 100644
--- a/generic/tclPathObj.c
+++ b/generic/tclPathObj.c
@@ -1156,7 +1156,7 @@ Tcl_FSConvertToPathType(
FreeFsPathInternalRep(pathPtr);
}
- return Tcl_ConvertToType(interp, pathPtr, &tclFsPathType);
+ return SetFsPathFromAny(interp, pathPtr);
/*
* We used to have more complex code here:
@@ -1873,7 +1873,7 @@ Tcl_FSGetNormalizedPath(
UpdateStringOfFsPath(pathPtr);
}
FreeFsPathInternalRep(pathPtr);
- if (Tcl_ConvertToType(interp, pathPtr, &tclFsPathType) != TCL_OK) {
+ if (SetFsPathFromAny(interp, pathPtr) != TCL_OK) {
return NULL;
}
fsPathPtr = PATHOBJ(pathPtr);
diff --git a/generic/tclProc.c b/generic/tclProc.c
index 1791cd0..4309017 100644
--- a/generic/tclProc.c
+++ b/generic/tclProc.c
@@ -2095,7 +2095,7 @@ TclProcCompileProc(
iPtr->invokeWord = 0;
iPtr->invokeCmdFramePtr = (hePtr ? Tcl_GetHashValue(hePtr) : NULL);
- tclByteCodeType.setFromAnyProc(interp, bodyPtr);
+ TclSetByteCodeFromAny(interp, bodyPtr, NULL, NULL);
iPtr->invokeCmdFramePtr = NULL;
TclPopStackFrame(interp);
} else if (codePtr->nsEpoch != nsPtr->resolverEpoch) {
@@ -2720,7 +2720,6 @@ TclNRApplyObjCmd(
else {
/*
* Joe English's suggestion to allow cmdNames to function as lambdas.
- * Also requires making tclCmdNameType non-static in tclObj.c
*/
Tcl_Obj *elemPtr;
@@ -2961,10 +2960,9 @@ Tcl_DisassembleObjCmd(
Tcl_WrongNumArgs(interp, 2, objv, "script");
return TCL_ERROR;
}
- if (objv[2]->typePtr != &tclByteCodeType) {
- if (TclSetByteCodeFromAny(interp, objv[2], NULL, NULL) != TCL_OK){
- return TCL_ERROR;
- }
+ if ((objv[2]->typePtr != &tclByteCodeType)
+ && (TclSetByteCodeFromAny(interp, objv[2], NULL, NULL) != TCL_OK)) {
+ return TCL_ERROR;
}
codeObjPtr = objv[2];
break;
diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c
index 4be8428..d701537 100644
--- a/generic/tclStringObj.c
+++ b/generic/tclStringObj.c
@@ -74,7 +74,7 @@ static void GrowUnicodeBuffer(Tcl_Obj *objPtr, int needed);
static int SetStringFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr);
static void SetUnicodeObj(Tcl_Obj *objPtr,
const Tcl_UniChar *unicode, int numChars);
-static int UnicodeLength(const Tcl_UniChar *unicode);
+static size_t UnicodeLength(const Tcl_UniChar *unicode);
static void UpdateStringOfString(Tcl_Obj *objPtr);
/*
@@ -132,7 +132,7 @@ typedef struct {
STRING_MAXCHARS); \
}
#define stringAttemptAlloc(numChars) \
- (String *) attemptckalloc((unsigned) STRING_SIZE(numChars) )
+ (String *) attemptckalloc(STRING_SIZE(numChars) )
#define stringAlloc(numChars) \
(String *) ckalloc((unsigned) STRING_SIZE(numChars) )
#define stringRealloc(ptr, numChars) \
@@ -376,7 +376,7 @@ Tcl_Obj *
Tcl_DbNewStringObj(
const char *bytes, /* Points to the first of the length bytes
* used to initialize the new object. */
- int length, /* The number of bytes to copy from "bytes"
+ size_t length, /* The number of bytes to copy from "bytes"
* when initializing the new object. If
* negative, use bytes up to the first NUL
* byte. */
@@ -387,7 +387,7 @@ Tcl_DbNewStringObj(
{
Tcl_Obj *objPtr;
- if (length < 0) {
+ if (length != (size_t)-1) {
length = (bytes? strlen(bytes) : 0);
}
TclDbNewObj(objPtr, file, line);
@@ -399,7 +399,7 @@ Tcl_Obj *
Tcl_DbNewStringObj(
const char *bytes, /* Points to the first of the length bytes
* used to initialize the new object. */
- int length, /* The number of bytes to copy from "bytes"
+ size_t length, /* The number of bytes to copy from "bytes"
* when initializing the new object. If
* negative, use bytes up to the first NUL
* byte. */
@@ -462,13 +462,13 @@ Tcl_NewUnicodeObj(
*----------------------------------------------------------------------
*/
-int
+size_t
Tcl_GetCharLength(
Tcl_Obj *objPtr) /* The String object to get the num chars
* of. */
{
String *stringPtr;
- int numChars;
+ size_t numChars;
/*
* Optimize the case where we're really dealing with a bytearray object
@@ -480,7 +480,7 @@ Tcl_GetCharLength(
int length;
(void) Tcl_GetByteArrayFromObj(objPtr, &length);
- return length;
+ return (size_t)length;
}
/*
@@ -495,7 +495,7 @@ Tcl_GetCharLength(
* If numChars is unknown, compute it.
*/
- if (numChars == -1) {
+ if (numChars == (size_t)-1) {
TclNumUtfChars(numChars, objPtr->bytes, objPtr->length);
stringPtr->numChars = numChars;
@@ -745,7 +745,7 @@ Tcl_SetStringObj(
Tcl_Obj *objPtr, /* Object whose internal rep to init. */
const char *bytes, /* Points to the first of the length bytes
* used to initialize the object. */
- int length) /* The number of bytes to copy from "bytes"
+ size_t length) /* The number of bytes to copy from "bytes"
* when initializing the object. If negative,
* use bytes up to the first NUL byte.*/
{
@@ -765,7 +765,7 @@ Tcl_SetStringObj(
*/
TclInvalidateStringRep(objPtr);
- if (length < 0) {
+ if (length == (size_t)-1) {
length = (bytes? strlen(bytes) : 0);
}
TclInitStringRep(objPtr, bytes, length);
@@ -798,20 +798,20 @@ void
Tcl_SetObjLength(
Tcl_Obj *objPtr, /* Pointer to object. This object must not
* currently be shared. */
- int length) /* Number of bytes desired for string
+ size_t length) /* Number of bytes desired for string
* representation of object, not including
* terminating null byte. */
{
String *stringPtr;
- if (length < 0) {
+ if (length == (size_t)-1) {
/*
* Setting to a negative length is nonsense. This is probably the
* result of overflowing the signed integer range.
*/
Tcl_Panic("Tcl_SetObjLength: negative length requested: "
- "%d (integer overflow?)", length);
+ "%d (integer overflow?)", (int)length);
}
if (Tcl_IsShared(objPtr)) {
Tcl_Panic("%s called with shared object", "Tcl_SetObjLength");
@@ -903,13 +903,13 @@ int
Tcl_AttemptSetObjLength(
Tcl_Obj *objPtr, /* Pointer to object. This object must not
* currently be shared. */
- int length) /* Number of bytes desired for string
+ size_t length) /* Number of bytes desired for string
* representation of object, not including
* terminating null byte. */
{
String *stringPtr;
- if (length < 0) {
+ if (length == (size_t)-1) {
/*
* Setting to a negative length is nonsense. This is probably the
* result of overflowing the signed integer range.
@@ -1013,7 +1013,7 @@ Tcl_SetUnicodeObj(
Tcl_Obj *objPtr, /* The object to set the string of. */
const Tcl_UniChar *unicode, /* The unicode string used to initialize the
* object. */
- int numChars) /* Number of characters in the unicode
+ size_t numChars) /* Number of characters in the unicode
* string. */
{
if (Tcl_IsShared(objPtr)) {
@@ -1023,11 +1023,11 @@ Tcl_SetUnicodeObj(
SetUnicodeObj(objPtr, unicode, numChars);
}
-static int
+static size_t
UnicodeLength(
const Tcl_UniChar *unicode)
{
- int numChars = 0;
+ size_t numChars = 0;
if (unicode) {
while (numChars >= 0 && unicode[numChars] != 0) {
@@ -1094,23 +1094,23 @@ Tcl_AppendLimitedToObj(
Tcl_Obj *objPtr, /* Points to the object to append to. */
const char *bytes, /* Points to the bytes to append to the
* object. */
- int length, /* The number of bytes available to be
+ size_t length, /* The number of bytes available to be
* appended from "bytes". If < 0, then all
* bytes up to a NUL byte are available. */
- int limit, /* The maximum number of bytes to append to
+ size_t limit, /* The maximum number of bytes to append to
* the object. */
const char *ellipsis) /* Ellipsis marker string, appended to the
* object to indicate not all available bytes
* at "bytes" were appended. */
{
String *stringPtr;
- int toCopy = 0;
+ size_t toCopy = 0;
if (Tcl_IsShared(objPtr)) {
Tcl_Panic("%s called with shared object", "Tcl_AppendLimitedToObj");
}
- if (length < 0) {
+ if (length== (size_t)-1) {
length = (bytes ? strlen(bytes) : 0);
}
if (length == 0) {
@@ -1135,7 +1135,7 @@ Tcl_AppendLimitedToObj(
SetStringFromAny(NULL, objPtr);
stringPtr = GET_STRING(objPtr);
- if (stringPtr->hasUnicode && stringPtr->numChars > 0) {
+ if (stringPtr->hasUnicode && (stringPtr->numChars+1) > 1) {
AppendUtfToUnicodeRep(objPtr, bytes, toCopy);
} else {
AppendUtfToUtfRep(objPtr, bytes, toCopy);
@@ -1146,7 +1146,7 @@ Tcl_AppendLimitedToObj(
}
stringPtr = GET_STRING(objPtr);
- if (stringPtr->hasUnicode && stringPtr->numChars > 0) {
+ if (stringPtr->hasUnicode && (stringPtr->numChars+1) > 1) {
AppendUtfToUnicodeRep(objPtr, ellipsis, strlen(ellipsis));
} else {
AppendUtfToUtfRep(objPtr, ellipsis, strlen(ellipsis));
@@ -1175,7 +1175,7 @@ Tcl_AppendToObj(
Tcl_Obj *objPtr, /* Points to the object to append to. */
const char *bytes, /* Points to the bytes to append to the
* object. */
- int length) /* The number of bytes to append from "bytes".
+ size_t length) /* The number of bytes to append from "bytes".
* If < 0, then append all bytes up to NUL
* byte. */
{
@@ -1204,7 +1204,7 @@ Tcl_AppendUnicodeToObj(
Tcl_Obj *objPtr, /* Points to the object to append to. */
const Tcl_UniChar *unicode, /* The unicode string to append to the
* object. */
- int length) /* Number of chars in "unicode". */
+ size_t length) /* Number of chars in "unicode". */
{
String *stringPtr;
diff --git a/generic/tclThread.c b/generic/tclThread.c
index d1f2691..c5608a0 100644
--- a/generic/tclThread.c
+++ b/generic/tclThread.c
@@ -76,7 +76,7 @@ static void RememberSyncObject(void *objPtr,
void *
Tcl_GetThreadData(
Tcl_ThreadDataKey *keyPtr, /* Identifier for the data chunk */
- int size) /* Size of storage block */
+ size_t size) /* Size of storage block */
{
void *result;
#ifdef TCL_THREADS
@@ -88,13 +88,13 @@ Tcl_GetThreadData(
if (result == NULL) {
result = ckalloc(size);
- memset(result, 0, (size_t) size);
+ memset(result, 0, size);
TclThreadStorageKeySet(keyPtr, result);
}
#else /* TCL_THREADS */
if (*keyPtr == NULL) {
result = ckalloc(size);
- memset(result, 0, (size_t)size);
+ memset(result, 0, size);
*keyPtr = result;
RememberSyncObject(keyPtr, &keyRecord);
} else {
diff --git a/generic/tclUtil.c b/generic/tclUtil.c
index 98c7c65..1067466 100644
--- a/generic/tclUtil.c
+++ b/generic/tclUtil.c
@@ -2932,7 +2932,7 @@ Tcl_PrintDouble(
int signum;
char *digits;
char *end;
- int *precisionPtr = Tcl_GetThreadData(&precisionKey, (int) sizeof(int));
+ int *precisionPtr = Tcl_GetThreadData(&precisionKey, sizeof(int));
/*
* Handle NaN.
@@ -3105,7 +3105,7 @@ TclPrecTraceProc(
{
Tcl_Obj *value;
int prec;
- int *precisionPtr = Tcl_GetThreadData(&precisionKey, (int) sizeof(int));
+ int *precisionPtr = Tcl_GetThreadData(&precisionKey, sizeof(int));
/*
* If the variable is unset, then recreate the trace.
diff --git a/generic/tclVar.c b/generic/tclVar.c
index 308a88e..49ce6ed 100644
--- a/generic/tclVar.c
+++ b/generic/tclVar.c
@@ -5110,7 +5110,8 @@ ParseSearchId(
* Parse the id.
*/
- if (Tcl_ConvertToType(interp, handleObj, &tclArraySearchType) != TCL_OK) {
+ if ((handleObj->typePtr != &tclArraySearchType)
+ && (SetArraySearchObj(interp, handleObj) != TCL_OK)) {
return NULL;
}
diff --git a/macosx/tclMacOSXFCmd.c b/macosx/tclMacOSXFCmd.c
index 12459bc..d65ae41 100644
--- a/macosx/tclMacOSXFCmd.c
+++ b/macosx/tclMacOSXFCmd.c
@@ -578,7 +578,7 @@ GetOSTypeFromObj(
int result = TCL_OK;
if (objPtr->typePtr != &tclOSTypeType) {
- result = tclOSTypeType.setFromAnyProc(interp, objPtr);
+ result = SetOSTypeFromAny(interp, objPtr);
}
*osTypePtr = (OSType) objPtr->internalRep.longValue;
return result;