summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--generic/tcl.h6
-rw-r--r--generic/tclExecute.c9
-rw-r--r--generic/tclHash.c2
-rw-r--r--generic/tclObj.c2
-rw-r--r--generic/tclStringObj.c95
-rw-r--r--generic/tclStringRep.h6
-rw-r--r--generic/tclTest.c2
-rw-r--r--generic/tclTestObj.c2
-rwxr-xr-xwin/configure2
-rw-r--r--win/tcl.m42
10 files changed, 64 insertions, 64 deletions
diff --git a/generic/tcl.h b/generic/tcl.h
index d59a378..a88beb1 100644
--- a/generic/tcl.h
+++ b/generic/tcl.h
@@ -610,7 +610,7 @@ typedef struct Tcl_ObjType {
*/
typedef struct Tcl_Obj {
- int refCount; /* When 0 the object will be freed. */
+ size_t refCount; /* When 0 the object will be freed. */
char *bytes; /* This points to the first byte of the
* object's string representation. The array
* must be followed by a null byte (i.e., at
@@ -622,7 +622,7 @@ typedef struct Tcl_Obj {
* should use Tcl_GetStringFromObj or
* Tcl_GetString to get a pointer to the byte
* array as a readonly value. */
- int length; /* The number of bytes at *bytes, not
+ size_t length; /* The number of bytes at *bytes, not
* including the terminating null. */
const Tcl_ObjType *typePtr; /* Denotes the object's type. Always
* corresponds to the type of the object's
@@ -1076,7 +1076,7 @@ struct Tcl_HashTable {
typedef struct Tcl_HashSearch {
Tcl_HashTable *tablePtr; /* Table being searched. */
- int nextIndex; /* Index of next bucket to be enumerated after
+ size_t nextIndex; /* Index of next bucket to be enumerated after
* present one. */
Tcl_HashEntry *nextEntryPtr;/* Next entry to be enumerated in the current
* bucket. */
diff --git a/generic/tclExecute.c b/generic/tclExecute.c
index 03ff73b..f69a59c 100644
--- a/generic/tclExecute.c
+++ b/generic/tclExecute.c
@@ -4877,7 +4877,8 @@ TEBCresume(
{
int index, numIndices, fromIdx, toIdx;
- int nocase, match, length2, cflags, s1len, s2len;
+ int nocase, match, length2, cflags;
+ int s1len, s2len;
const char *s1, *s2;
case INST_LIST:
@@ -5176,7 +5177,8 @@ TEBCresume(
value2Ptr = OBJ_AT_TOS;
valuePtr = OBJ_UNDER_TOS;
- s1 = TclGetStringFromObj(valuePtr, &s1len);
+ s1 = TclGetString(valuePtr);
+ s1len = valuePtr->length;
TRACE(("\"%.30s\" \"%.30s\" => ", O2S(valuePtr), O2S(value2Ptr)));
if (TclListObjLength(interp, value2Ptr, &length) != TCL_OK) {
TRACE_ERROR(interp);
@@ -5194,7 +5196,8 @@ TEBCresume(
do {
Tcl_ListObjIndex(NULL, value2Ptr, i, &o);
if (o != NULL) {
- s2 = TclGetStringFromObj(o, &s2len);
+ s2 = TclGetString(o);
+ s2len = o->length;
} else {
s2 = "";
s2len = 0;
diff --git a/generic/tclHash.c b/generic/tclHash.c
index 97a2fc6..b302029 100644
--- a/generic/tclHash.c
+++ b/generic/tclHash.c
@@ -432,7 +432,7 @@ Tcl_DeleteHashTable(
{
register Tcl_HashEntry *hPtr, *nextPtr;
const Tcl_HashKeyType *typePtr;
- int i;
+ size_t i;
if (tablePtr->keyType == TCL_STRING_KEYS) {
typePtr = &tclStringHashKeyType;
diff --git a/generic/tclObj.c b/generic/tclObj.c
index d062211..4e7a208 100644
--- a/generic/tclObj.c
+++ b/generic/tclObj.c
@@ -4486,7 +4486,7 @@ Tcl_RepresentationCmd(
descObj = Tcl_ObjPrintf("value is a %s with a refcount of %d,"
" object pointer at %s",
objv[1]->typePtr ? objv[1]->typePtr->name : "pure string",
- objv[1]->refCount, ptrBuffer);
+ (int) objv[1]->refCount, ptrBuffer);
if (objv[1]->typePtr) {
sprintf(ptrBuffer, "%p:%p",
diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c
index c644cf5..bc4b35e 100644
--- a/generic/tclStringObj.c
+++ b/generic/tclStringObj.c
@@ -54,27 +54,27 @@
static void AppendPrintfToObjVA(Tcl_Obj *objPtr,
const char *format, va_list argList);
static void AppendUnicodeToUnicodeRep(Tcl_Obj *objPtr,
- const Tcl_UniChar *unicode, int appendNumChars);
+ const Tcl_UniChar *unicode, size_t appendNumChars);
static void AppendUnicodeToUtfRep(Tcl_Obj *objPtr,
- const Tcl_UniChar *unicode, int numChars);
+ const Tcl_UniChar *unicode, size_t numChars);
static void AppendUtfToUnicodeRep(Tcl_Obj *objPtr,
- const char *bytes, int numBytes);
+ const char *bytes, size_t numBytes);
static void AppendUtfToUtfRep(Tcl_Obj *objPtr,
- const char *bytes, int numBytes);
+ const char *bytes, size_t numBytes);
static void DupStringInternalRep(Tcl_Obj *objPtr,
Tcl_Obj *copyPtr);
static int ExtendStringRepWithUnicode(Tcl_Obj *objPtr,
- const Tcl_UniChar *unicode, int numChars);
+ const Tcl_UniChar *unicode, size_t numChars);
static void ExtendUnicodeRepWithString(Tcl_Obj *objPtr,
- const char *bytes, int numBytes,
- int numAppendChars);
+ const char *bytes, size_t numBytes,
+ size_t numAppendChars);
static void FillUnicodeRep(Tcl_Obj *objPtr);
static void FreeStringInternalRep(Tcl_Obj *objPtr);
-static void GrowStringBuffer(Tcl_Obj *objPtr, int needed, int flag);
-static void GrowUnicodeBuffer(Tcl_Obj *objPtr, int needed);
+static void GrowStringBuffer(Tcl_Obj *objPtr, size_t needed, int flag);
+static void GrowUnicodeBuffer(Tcl_Obj *objPtr, size_t needed);
static int SetStringFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr);
static void SetUnicodeObj(Tcl_Obj *objPtr,
- const Tcl_UniChar *unicode, int numChars);
+ const Tcl_UniChar *unicode, size_t numChars);
static size_t UnicodeLength(const Tcl_UniChar *unicode);
static void UpdateStringOfString(Tcl_Obj *objPtr);
@@ -131,7 +131,7 @@ const Tcl_ObjType tclStringType = {
static void
GrowStringBuffer(
Tcl_Obj *objPtr,
- int needed,
+ size_t needed,
int flag)
{
/*
@@ -143,7 +143,7 @@ GrowStringBuffer(
String *stringPtr = GET_STRING(objPtr);
char *ptr = NULL;
- int attempt;
+ size_t attempt;
if (objPtr->bytes == tclEmptyStringRep) {
objPtr->bytes = NULL;
@@ -182,7 +182,7 @@ GrowStringBuffer(
static void
GrowUnicodeBuffer(
Tcl_Obj *objPtr,
- int needed)
+ size_t needed)
{
/*
* Pre-conditions:
@@ -192,7 +192,7 @@ GrowUnicodeBuffer(
*/
String *ptr = NULL, *stringPtr = GET_STRING(objPtr);
- int attempt;
+ size_t attempt;
if (stringPtr->maxChars > 0) {
/*
@@ -209,10 +209,10 @@ GrowUnicodeBuffer(
* overflow into invalid argument values for attempt.
*/
- unsigned int limit = STRING_MAXCHARS - needed;
- unsigned int extra = needed - stringPtr->numChars
+ size_t limit = STRING_MAXCHARS - needed;
+ size_t extra = needed - stringPtr->numChars
+ TCL_MIN_UNICHAR_GROWTH;
- int growth = (int) ((extra > limit) ? limit : extra);
+ size_t growth = (extra > limit) ? limit : extra;
attempt = needed + growth;
ptr = stringAttemptRealloc(stringPtr, attempt);
@@ -510,7 +510,7 @@ Tcl_GetUniChar(
* If numChars is unknown, compute it.
*/
- if (stringPtr->numChars == -1) {
+ if (stringPtr->numChars == (size_t)-1) {
TclNumUtfChars(stringPtr->numChars, objPtr->bytes, objPtr->length);
}
if (stringPtr->numChars == objPtr->length) {
@@ -644,7 +644,7 @@ Tcl_GetRange(
* If numChars is unknown, compute it.
*/
- if (stringPtr->numChars == -1) {
+ if (stringPtr->numChars == (size_t)-1) {
TclNumUtfChars(stringPtr->numChars, objPtr->bytes, objPtr->length);
}
if (stringPtr->numChars == objPtr->length) {
@@ -990,12 +990,12 @@ 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. */
{
String *stringPtr;
- if (numChars < 0) {
+ if (numChars == (size_t)-1) {
numChars = UnicodeLength(unicode);
}
@@ -1071,7 +1071,7 @@ Tcl_AppendLimitedToObj(
ellipsis = "...";
}
toCopy = (bytes == NULL) ? limit
- : Tcl_UtfPrev(bytes+limit+1-strlen(ellipsis), bytes) - bytes;
+ : (size_t)(Tcl_UtfPrev(bytes+limit+1-strlen(ellipsis), bytes) - bytes);
}
/*
@@ -1348,10 +1348,10 @@ static void
AppendUnicodeToUnicodeRep(
Tcl_Obj *objPtr, /* Points to the object to append to. */
const Tcl_UniChar *unicode, /* String to append. */
- int appendNumChars) /* Number of chars of "unicode" to append. */
+ size_t appendNumChars) /* Number of chars of "unicode" to append. */
{
String *stringPtr;
- int numChars;
+ size_t numChars;
if (appendNumChars < 0) {
appendNumChars = UnicodeLength(unicode);
@@ -1437,13 +1437,13 @@ static void
AppendUnicodeToUtfRep(
Tcl_Obj *objPtr, /* Points to the object to append to. */
const Tcl_UniChar *unicode, /* String to convert to UTF. */
- int numChars) /* Number of chars of "unicode" to convert. */
+ size_t numChars) /* Number of chars of "unicode" to convert. */
{
String *stringPtr = GET_STRING(objPtr);
numChars = ExtendStringRepWithUnicode(objPtr, unicode, numChars);
- if (stringPtr->numChars != -1) {
+ if (stringPtr->numChars != (size_t)-1) {
stringPtr->numChars += numChars;
}
@@ -1478,7 +1478,7 @@ static void
AppendUtfToUnicodeRep(
Tcl_Obj *objPtr, /* Points to the object to append to. */
const char *bytes, /* String to convert to Unicode. */
- int numBytes) /* Number of bytes of "bytes" to convert. */
+ size_t numBytes) /* Number of bytes of "bytes" to convert. */
{
String *stringPtr;
@@ -1514,10 +1514,10 @@ static void
AppendUtfToUtfRep(
Tcl_Obj *objPtr, /* Points to the object to append to. */
const char *bytes, /* String to append. */
- int numBytes) /* Number of bytes of "bytes" to append. */
+ size_t numBytes) /* Number of bytes of "bytes" to append. */
{
String *stringPtr;
- int newLength, oldLength;
+ size_t newLength, oldLength;
if (numBytes == 0) {
return;
@@ -1533,13 +1533,10 @@ AppendUtfToUtfRep(
}
oldLength = objPtr->length;
newLength = numBytes + oldLength;
- if (newLength < 0) {
- Tcl_Panic("max size for a Tcl value (%d bytes) exceeded", INT_MAX);
- }
stringPtr = GET_STRING(objPtr);
if (newLength > stringPtr->allocated) {
- int offset = -1;
+ size_t offset = (size_t)-1;
/*
* Protect against case where unicode points into the existing
@@ -1563,7 +1560,7 @@ AppendUtfToUtfRep(
* Relocate bytes if needed; see above.
*/
- if (offset >= 0) {
+ if (offset != (size_t)-1) {
bytes = objPtr->bytes + offset;
}
}
@@ -1572,7 +1569,7 @@ AppendUtfToUtfRep(
* Invalidate the unicode data.
*/
- stringPtr->numChars = -1;
+ stringPtr->numChars = (size_t)-1;
stringPtr->hasUnicode = 0;
if (bytes) {
@@ -2730,8 +2727,8 @@ TclStringObjReverse(
}
if (objPtr->bytes) {
- int numChars = stringPtr->numChars;
- int numBytes = objPtr->length;
+ size_t numChars = stringPtr->numChars;
+ size_t numBytes = objPtr->length;
char *to, *from = objPtr->bytes;
if (Tcl_IsShared(objPtr)) {
@@ -2749,8 +2746,8 @@ TclStringObjReverse(
*
* Pass 1. Reverse the bytes of each multi-byte character.
*/
- int charCount = 0;
- int bytesLeft = numBytes;
+ size_t charCount = 0;
+ size_t bytesLeft = numBytes;
while (bytesLeft) {
/*
@@ -2810,17 +2807,17 @@ static void
ExtendUnicodeRepWithString(
Tcl_Obj *objPtr,
const char *bytes,
- int numBytes,
- int numAppendChars)
+ size_t numBytes,
+ size_t numAppendChars)
{
String *stringPtr = GET_STRING(objPtr);
- int needed, numOrigChars = 0;
+ size_t needed, numOrigChars = 0;
Tcl_UniChar *dst;
if (stringPtr->hasUnicode) {
numOrigChars = stringPtr->numChars;
}
- if (numAppendChars == -1) {
+ if (numAppendChars == (size_t)-1) {
TclNumUtfChars(numAppendChars, bytes, numBytes);
}
needed = numOrigChars + numAppendChars;
@@ -2872,7 +2869,7 @@ DupStringInternalRep(
String *copyStringPtr = NULL;
#if COMPAT==0
- if (srcStringPtr->numChars == -1) {
+ if (srcStringPtr->numChars == (size_t)-1) {
/*
* 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
@@ -2922,7 +2919,7 @@ DupStringInternalRep(
* the string rep of the new object.
*/
- if (srcStringPtr->hasUnicode && srcStringPtr->numChars > 0) {
+ if (srcStringPtr->hasUnicode && srcStringPtr->numChars+1 > 1) {
/*
* Copy the full allocation for the Unicode buffer.
*/
@@ -2991,7 +2988,7 @@ SetStringFromAny(
* already in place at objPtr->bytes.
*/
- stringPtr->numChars = -1;
+ stringPtr->numChars = (size_t)-1;
stringPtr->allocated = objPtr->length;
stringPtr->maxChars = 0;
stringPtr->hasUnicode = 0;
@@ -3037,17 +3034,17 @@ static int
ExtendStringRepWithUnicode(
Tcl_Obj *objPtr,
const Tcl_UniChar *unicode,
- int numChars)
+ size_t numChars)
{
/*
* Pre-condition: this is the "string" Tcl_ObjType.
*/
- int i, origLength, size = 0;
+ size_t i, origLength, size = 0;
char *dst;
String *stringPtr = GET_STRING(objPtr);
- if (numChars < 0) {
+ if (numChars == (size_t)-1) {
numChars = UnicodeLength(unicode);
}
diff --git a/generic/tclStringRep.h b/generic/tclStringRep.h
index db6f7e4..d71eefa 100644
--- a/generic/tclStringRep.h
+++ b/generic/tclStringRep.h
@@ -47,15 +47,15 @@
*/
typedef struct {
- int numChars; /* The number of chars in the string. -1 means
+ size_t numChars; /* The number of chars in the string. -1 means
* this value has not been calculated. >= 0
* means that there is a valid Unicode rep, or
* that the number of UTF bytes == the number
* of chars. */
- int allocated; /* The amount of space actually allocated for
+ size_t allocated; /* The amount of space actually allocated for
* the UTF string (minus 1 byte for the
* termination char). */
- int maxChars; /* Max number of chars that can fit in the
+ size_t maxChars; /* Max number of chars that can fit in the
* space allocated for the unicode array. */
int hasUnicode; /* Boolean determining whether the string has
* a Unicode representation. */
diff --git a/generic/tclTest.c b/generic/tclTest.c
index 1bb5f96..c83eb52 100644
--- a/generic/tclTest.c
+++ b/generic/tclTest.c
@@ -6643,7 +6643,7 @@ TestHashSystemHashCmd(
Tcl_SetHashValue(hPtr, INT2PTR(i+42));
}
- if (hash.numEntries != limit) {
+ if (hash.numEntries != (size_t)limit) {
Tcl_AppendResult(interp, "unexpected maximal size", NULL);
Tcl_DeleteHashTable(&hash);
return TCL_ERROR;
diff --git a/generic/tclTestObj.c b/generic/tclTestObj.c
index adc6063..bdf20f8 100644
--- a/generic/tclTestObj.c
+++ b/generic/tclTestObj.c
@@ -1242,7 +1242,7 @@ TeststringobjCmd(
goto wrongNumArgs;
}
Tcl_SetLongObj(Tcl_GetObjResult(interp), (varPtr[varIndex] != NULL)
- ? varPtr[varIndex]->length : -1);
+ ? varPtr[varIndex]->length : (size_t)-1);
break;
case 5: /* length2 */
if (objc != 3) {
diff --git a/win/configure b/win/configure
index e99b1c5..21c60e4 100755
--- a/win/configure
+++ b/win/configure
@@ -4165,7 +4165,7 @@ $as_echo "using shared flags" >&6; }
CFLAGS_DEBUG=-g
CFLAGS_OPTIMIZE="-O2 -fomit-frame-pointer"
- CFLAGS_WARNING="-Wall -Wwrite-strings -Wsign-compare -Wdeclaration-after-statement"
+ CFLAGS_WARNING="-Wall -Wwrite-strings -Wdeclaration-after-statement"
LDFLAGS_DEBUG=
LDFLAGS_OPTIMIZE=
diff --git a/win/tcl.m4 b/win/tcl.m4
index 6701b1e..4e9abba 100644
--- a/win/tcl.m4
+++ b/win/tcl.m4
@@ -727,7 +727,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
CFLAGS_DEBUG=-g
CFLAGS_OPTIMIZE="-O2 -fomit-frame-pointer"
- CFLAGS_WARNING="-Wall -Wwrite-strings -Wsign-compare -Wdeclaration-after-statement"
+ CFLAGS_WARNING="-Wall -Wwrite-strings -Wdeclaration-after-statement"
LDFLAGS_DEBUG=
LDFLAGS_OPTIMIZE=