summaryrefslogtreecommitdiffstats
path: root/generic/tclStringObj.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2023-09-18 10:27:48 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2023-09-18 10:27:48 (GMT)
commit69ca53fb44da71d3f9dc902324395732f403d3d7 (patch)
tree65363a8d02946947f42ab3357572de25b88f077c /generic/tclStringObj.c
parentb363db3cde0b28030afc5d59432f0b2ebc5a9cf6 (diff)
downloadtcl-69ca53fb44da71d3f9dc902324395732f403d3d7.zip
tcl-69ca53fb44da71d3f9dc902324395732f403d3d7.tar.gz
tcl-69ca53fb44da71d3f9dc902324395732f403d3d7.tar.bz2
int -> Tcl_Size (where appropriate)
Diffstat (limited to 'generic/tclStringObj.c')
-rw-r--r--generic/tclStringObj.c197
1 files changed, 98 insertions, 99 deletions
diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c
index 1170169..2b6d7c2 100644
--- a/generic/tclStringObj.c
+++ b/generic/tclStringObj.c
@@ -59,8 +59,8 @@ static void ExtendUnicodeRepWithString(Tcl_Obj *objPtr,
Tcl_Size 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, Tcl_Size needed, int flag);
+static void GrowUnicodeBuffer(Tcl_Obj *objPtr, Tcl_Size needed);
static int SetStringFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr);
static void SetUnicodeObj(Tcl_Obj *objPtr,
const Tcl_UniChar *unicode, Tcl_Size numChars);
@@ -267,8 +267,8 @@ UpdateStringOfUTF16String(
static void
GrowStringBuffer(
Tcl_Obj *objPtr,
- int needed,
- int flag)
+ Tcl_Size needed, /* Not including terminating nul */
+ int flag) /* If 0, try to overallocate */
{
/*
* Preconditions:
@@ -279,28 +279,28 @@ GrowStringBuffer(
UniCharString *stringPtr = GET_UNICHAR_STRING(objPtr);
char *ptr = NULL;
- int attempt;
+ Tcl_Size capacity;
if (objPtr->bytes == &tclEmptyString) {
objPtr->bytes = NULL;
}
if (flag == 0 || stringPtr->allocated > 0) {
if (needed <= INT_MAX / 2) {
- attempt = 2 * needed;
- ptr = (char *)attemptckrealloc(objPtr->bytes, attempt + 1U);
+ capacity = 2 * needed;
+ ptr = (char *)attemptckrealloc(objPtr->bytes, capacity + 1U);
}
if (ptr == NULL) {
/*
* Take care computing the amount of modest growth to avoid
- * overflow into invalid argument values for attempt.
+ * overflow into invalid argument values for capacity.
*/
unsigned int limit = INT_MAX - needed;
unsigned int extra = needed - objPtr->length + TCL_MIN_GROWTH;
int growth = (int) ((extra > limit) ? limit : extra);
- attempt = needed + growth;
- ptr = (char *)attemptckrealloc(objPtr->bytes, attempt + 1U);
+ capacity = needed + growth;
+ ptr = (char *)attemptckrealloc(objPtr->bytes, capacity + 1U);
}
}
if (ptr == NULL) {
@@ -308,18 +308,18 @@ GrowStringBuffer(
* First allocation - just big enough; or last chance fallback.
*/
- attempt = needed;
- ptr = (char *)ckrealloc(objPtr->bytes, attempt + 1U);
+ capacity = needed;
+ ptr = (char *)ckrealloc(objPtr->bytes, capacity + 1U);
}
objPtr->bytes = ptr;
- stringPtr->allocated = attempt;
- memset(ptr + objPtr->length, 0, attempt + 1U - objPtr->length);
+ stringPtr->allocated = capacity;
+ memset(ptr + objPtr->length, 0, capacity + 1U - objPtr->length);
}
static void
GrowUnicodeBuffer(
Tcl_Obj *objPtr,
- int needed)
+ Tcl_Size needed)
{
/*
* Preconditions:
@@ -329,7 +329,7 @@ GrowUnicodeBuffer(
*/
UniCharString *ptr = NULL, *stringPtr = GET_UNICHAR_STRING(objPtr);
- int attempt;
+ Tcl_Size capacity;
if (stringPtr->maxChars > 0) {
/*
@@ -337,13 +337,13 @@ GrowUnicodeBuffer(
*/
if (needed <= UNICHAR_STRING_MAXCHARS / 2) {
- attempt = 2 * needed;
- ptr = uniCharStringAttemptRealloc(stringPtr, attempt);
+ capacity = 2 * needed;
+ ptr = uniCharStringAttemptRealloc(stringPtr, capacity);
}
if (ptr == NULL) {
/*
* Take care computing the amount of modest growth to avoid
- * overflow into invalid argument values for attempt.
+ * overflow into invalid argument values for capacity.
*/
unsigned int limit = UNICHAR_STRING_MAXCHARS - needed;
@@ -351,8 +351,8 @@ GrowUnicodeBuffer(
+ TCL_MIN_UNICHAR_GROWTH;
int growth = (int) ((extra > limit) ? limit : extra);
- attempt = needed + growth;
- ptr = uniCharStringAttemptRealloc(stringPtr, attempt);
+ capacity = needed + growth;
+ ptr = uniCharStringAttemptRealloc(stringPtr, capacity);
}
}
if (ptr == NULL) {
@@ -360,11 +360,11 @@ GrowUnicodeBuffer(
* First allocation - just big enough; or last chance fallback.
*/
- attempt = needed;
- ptr = uniCharStringRealloc(stringPtr, attempt);
+ capacity = needed;
+ ptr = uniCharStringRealloc(stringPtr, capacity);
}
stringPtr = ptr;
- stringPtr->maxChars = attempt;
+ stringPtr->maxChars = capacity;
SET_UNICHAR_STRING(objPtr, stringPtr);
}
@@ -459,10 +459,9 @@ 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"
- * when initializing the new object. If
- * negative, use bytes up to the first NUL
- * byte. */
+ Tcl_Size length, /* The number of bytes to copy from "bytes"
+ * when initializing the new object. If negative,
+ * use bytes up to the first NUL byte. */
const char *file, /* The name of the source file calling this
* function; used for debugging. */
int line) /* Line number in the source file; used for
@@ -482,7 +481,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"
+ Tcl_Size length, /* The number of bytes to copy from "bytes"
* when initializing the new object. If
* negative, use bytes up to the first NUL
* byte. */
@@ -516,7 +515,7 @@ Tcl_Obj *
TclNewUnicodeObj(
const Tcl_UniChar *unicode, /* The unicode string used to initialize the
* new object. */
- int numChars) /* Number of characters in the unicode
+ Tcl_Size numChars) /* Number of characters in the unicode
* string. */
{
Tcl_Obj *objPtr;
@@ -576,13 +575,13 @@ Tcl_NewUnicodeObj(
*----------------------------------------------------------------------
*/
-int
+Tcl_Size
TclGetCharLength(
Tcl_Obj *objPtr) /* The String object to get the num chars
* of. */
{
UniCharString *stringPtr;
- int numChars;
+ Tcl_Size numChars;
/*
* Quick, no-shimmer return for short string reps.
@@ -621,7 +620,7 @@ TclGetCharLength(
* If numChars is unknown, compute it.
*/
- if (numChars == -1) {
+ if (numChars < 0) {
TclNumUtfCharsM(numChars, objPtr->bytes, objPtr->length);
stringPtr->numChars = numChars;
}
@@ -630,12 +629,12 @@ TclGetCharLength(
#if !defined(TCL_NO_DEPRECATED)
#undef Tcl_GetCharLength
-int
+Tcl_Size
Tcl_GetCharLength(
Tcl_Obj *objPtr) /* The String object to get the num chars
* of. */
{
- int numChars;
+ Tcl_Size numChars = 0;
/*
* Quick, no-shimmer return for short string reps.
@@ -761,7 +760,7 @@ Tcl_GetUniChar(
return -1;
}
- return (int) bytes[index];
+ return bytes[index];
}
/*
@@ -807,8 +806,8 @@ TclGetUniChar(
}
/*
- * Optimize the ByteArray case: N need need to convert to a string to
- * perform the indexing operation.
+ * Optimize the case where we're really dealing with a ByteArray object
+ * we don't need to convert to a string to perform the indexing operation.
*/
if (TclIsPureByteArray(objPtr)) {
@@ -818,7 +817,7 @@ TclGetUniChar(
return -1;
}
- return (int) bytes[index];
+ return bytes[index];
}
/*
@@ -833,7 +832,7 @@ TclGetUniChar(
* If numChars is unknown, compute it.
*/
- if (stringPtr->numChars == -1) {
+ if (stringPtr->numChars == TCL_INDEX_NONE) {
TclNumUtfCharsM(stringPtr->numChars, objPtr->bytes, objPtr->length);
}
if (index >= stringPtr->numChars) {
@@ -886,7 +885,7 @@ Tcl_GetUnicode(
/*
*----------------------------------------------------------------------
*
- * Tcl_GetUnicodeFromObj --
+ * Tcl_GetUnicodeFromObj/TclGetUnicodeFromObj --
*
* Get the Unicode form of the String object with length. If the object
* is not already a String object, it will be converted to one. If the
@@ -931,7 +930,7 @@ unsigned short *
Tcl_GetUnicodeFromObj(
Tcl_Obj *objPtr, /* The object to find the Unicode string
* for. */
- int *lengthPtr) /* If non-NULL, the location where the string
+ Tcl_Size *lengthPtr) /* If non-NULL, the location where the string
* rep's Tcl_UniChar length should be stored. If
* NULL, no length is stored. */
{
@@ -972,11 +971,11 @@ Tcl_GetUnicodeFromObj(
Tcl_Obj *
Tcl_GetRange(
Tcl_Obj *objPtr, /* The Tcl object to find the range of. */
- int first, /* First index of the range. */
- int last) /* Last index of the range. */
+ Tcl_Size first, /* First index of the range. */
+ Tcl_Size last) /* Last index of the range. */
{
Tcl_Obj *newObjPtr; /* The Tcl object to find the range of. */
- int length;
+ Tcl_Size length;
if (first < 0) {
first = 0;
@@ -1000,7 +999,7 @@ Tcl_GetRange(
return Tcl_NewByteArrayObj(bytes + first, last - first + 1);
}
- int numChars = TclNumUtfChars(objPtr->bytes, objPtr->length);
+ Tcl_Size numChars = TclNumUtfChars(objPtr->bytes, objPtr->length);
if (last < 0 || last >= numChars) {
last = numChars - 1;
@@ -1018,19 +1017,19 @@ Tcl_GetRange(
Tcl_Obj *
TclGetRange(
Tcl_Obj *objPtr, /* The Tcl object to find the range of. */
- int first, /* First index of the range. */
- int last) /* Last index of the range. */
+ Tcl_Size first, /* First index of the range. */
+ Tcl_Size last) /* Last index of the range. */
{
Tcl_Obj *newObjPtr; /* The Tcl object to find the range of. */
UniCharString *stringPtr;
- int length;
+ Tcl_Size length;
if (first < 0) {
first = 0;
}
/*
- * Optimize the case where we're really dealing with a ByteArray object
+ * Optimize the case where we're really dealing with a bytearray object
* we don't need to convert to a string to perform the substring operation.
*/
@@ -1202,9 +1201,9 @@ Tcl_SetObjLength(
* Need to enlarge the buffer.
*/
if (objPtr->bytes == &tclEmptyString) {
- objPtr->bytes = (char *)ckalloc((unsigned int)length + 1U);
+ objPtr->bytes = (char *)ckalloc(length + 1U);
} else {
- objPtr->bytes = (char *)ckrealloc(objPtr->bytes, (unsigned int)length + 1U);
+ objPtr->bytes = (char *)ckrealloc(objPtr->bytes, length + 1U);
}
stringPtr->allocated = length;
}
@@ -1305,9 +1304,9 @@ Tcl_AttemptSetObjLength(
char *newBytes;
if (objPtr->bytes == &tclEmptyString) {
- newBytes = (char *)attemptckalloc((unsigned int)length + 1U);
+ newBytes = (char *)attemptckalloc(length + 1U);
} else {
- newBytes = (char *)attemptckrealloc(objPtr->bytes, (unsigned int)length + 1U);
+ newBytes = (char *)attemptckrealloc(objPtr->bytes, length + 1U);
}
if (newBytes == NULL) {
return 0;
@@ -1380,7 +1379,7 @@ Tcl_SetUnicodeObj(
Tcl_Obj *objPtr, /* The object to set the string of. */
const unsigned short *unicode, /* The Unicode string used to initialize the
* object. */
- int numChars) /* Number of characters in the Unicode
+ Tcl_Size numChars) /* Number of characters in the Unicode
* string. */
{
String *stringPtr;
@@ -1408,11 +1407,11 @@ Tcl_SetUnicodeObj(
stringPtr->allocated = numChars;
}
-static int
+static Tcl_Size
UTF16Length(
const unsigned short *ucs2Ptr)
{
- int numChars = 0;
+ Tcl_Size numChars = 0;
if (ucs2Ptr) {
while (numChars >= 0 && ucs2Ptr[numChars] != 0) {
@@ -1595,7 +1594,7 @@ Tcl_AppendToObj(
* If negative, then append all bytes up to NUL
* byte. */
{
- Tcl_AppendLimitedToObj(objPtr, bytes, length, INT_MAX, NULL);
+ Tcl_AppendLimitedToObj(objPtr, bytes, length, TCL_SIZE_MAX, NULL);
}
/*
@@ -1604,7 +1603,7 @@ Tcl_AppendToObj(
* Tcl_AppendUnicodeToObj --
*
* This function appends a Unicode string to an object in the most
- * efficient manner possible. Length must be >= 0.
+ * efficient manner possible.
*
* Results:
* None.
@@ -1727,7 +1726,7 @@ Tcl_AppendObjToObj(
if ((TclIsPureByteArray(objPtr) || objPtr->bytes == &tclEmptyString)
&& TclIsPureByteArray(appendObjPtr)) {
/*
- * You might expect the code here to be
+ * One might expect the code here to be
*
* bytes = Tcl_GetByteArrayFromObj(appendObjPtr, &length);
* TclAppendBytesToByteArray(objPtr, bytes, length);
@@ -1768,7 +1767,7 @@ Tcl_AppendObjToObj(
*/
TclAppendBytesToByteArray(objPtr,
- Tcl_GetByteArrayFromObj(appendObjPtr, NULL), lengthSrc);
+ Tcl_GetByteArrayFromObj(appendObjPtr, (Tcl_Size *) NULL), lengthSrc);
return;
}
@@ -1825,7 +1824,7 @@ Tcl_AppendObjToObj(
AppendUtfToUtfRep(objPtr, bytes, length);
- if (numChars >= 0 && appendNumChars >= 0) {
+ if ((numChars >= 0) && (appendNumChars >= 0)) {
stringPtr->numChars = numChars + appendNumChars;
}
}
@@ -2027,8 +2026,8 @@ AppendUtfToUtfRep(
objPtr->length = 0;
}
oldLength = objPtr->length;
- if (numBytes > INT_MAX - oldLength) {
- Tcl_Panic("max size for a Tcl value (%d bytes) exceeded", INT_MAX);
+ if (numBytes > TCL_SIZE_MAX - oldLength) {
+ Tcl_Panic("max size for a Tcl value (%" TCL_SIZE_MODIFIER "d bytes) exceeded", TCL_SIZE_MAX);
}
newLength = numBytes + oldLength;
@@ -2188,7 +2187,7 @@ Tcl_AppendFormatToObj(
Tcl_Panic("%s called with shared object", "Tcl_AppendFormatToObj");
}
TclGetStringFromObj(appendObj, &originalLength);
- limit = INT_MAX - originalLength;
+ limit = TCL_SIZE_MAX - originalLength;
/*
* Format string is NUL-terminated.
@@ -2557,7 +2556,7 @@ Tcl_AppendFormatToObj(
TclNewObj(segment);
allocSegment = 1;
- segmentLimit = INT_MAX;
+ segmentLimit = TCL_SIZE_MAX;
Tcl_IncrRefCount(segment);
if ((isNegative || gotPlus || gotSpace) && (useBig || ch=='d')) {
@@ -2661,8 +2660,8 @@ Tcl_AppendFormatToObj(
case 'x':
case 'X':
case 'b': {
- Tcl_WideUInt bits = (Tcl_WideUInt) 0;
- Tcl_WideInt numDigits = (Tcl_WideInt) 0;
+ Tcl_WideUInt bits = 0;
+ Tcl_WideInt numDigits = 0;
int numBits = 4, base = 16, index = 0, shift = 0;
Tcl_Size length;
Tcl_Obj *pure;
@@ -2728,9 +2727,9 @@ Tcl_AppendFormatToObj(
numDigits = 1;
}
TclNewObj(pure);
- Tcl_SetObjLength(pure, (int) numDigits);
+ Tcl_SetObjLength(pure, numDigits);
bytes = TclGetString(pure);
- toAppend = length = (int) numDigits;
+ toAppend = length = numDigits;
while (numDigits--) {
int digitOffset;
@@ -2742,7 +2741,7 @@ Tcl_AppendFormatToObj(
}
shift -= numBits;
}
- digitOffset = (int) (bits % base);
+ digitOffset = bits % base;
if (digitOffset > 9) {
if (ch == 'X') {
bytes[numDigits] = 'A' + digitOffset - 10;
@@ -2833,7 +2832,7 @@ Tcl_AppendFormatToObj(
if (gotPrecision) {
*p++ = '.';
p += snprintf(p, TCL_INTEGER_SPACE, "%" TCL_LL_MODIFIER "d", precision);
- if (precision > INT_MAX - length) {
+ if (precision > TCL_SIZE_MAX - length) {
msg = overflow;
errCode = "OVERFLOW";
goto errorMsg;
@@ -3037,7 +3036,7 @@ AppendPrintfToObjVA(
*/
q = Tcl_UtfPrev(end, bytes);
- if (!Tcl_UtfCharComplete(q, (int)(end - q))) {
+ if (!Tcl_UtfCharComplete(q, end - q)) {
end = q;
}
@@ -3048,7 +3047,7 @@ AppendPrintfToObjVA(
}
Tcl_ListObjAppendElement(NULL, list,
- Tcl_NewStringObj(bytes , (int)(end - bytes)));
+ Tcl_NewStringObj(bytes , end - bytes));
break;
}
@@ -3102,7 +3101,7 @@ AppendPrintfToObjVA(
seekingConversion = 0;
break;
case '*':
- lastNum = (int) va_arg(argList, int);
+ lastNum = va_arg(argList, int);
Tcl_ListObjAppendElement(NULL, list, Tcl_NewWideIntObj(lastNum));
p++;
break;
@@ -3110,7 +3109,7 @@ AppendPrintfToObjVA(
case '5': case '6': case '7': case '8': case '9': {
char *end;
- lastNum = (int) strtoul(p, &end, 10);
+ lastNum = strtoul(p, &end, 10);
p = end;
break;
}
@@ -3248,7 +3247,7 @@ TclGetStringStorage(
UniCharString *stringPtr;
if (!TclHasInternalRep(objPtr, &tclUniCharStringType) || objPtr->bytes == NULL) {
- return TclGetStringFromObj(objPtr, (int *)sizePtr);
+ return TclGetStringFromObj(objPtr, (Tcl_Size *)sizePtr);
}
stringPtr = GET_UNICHAR_STRING(objPtr);
@@ -3324,7 +3323,8 @@ TclStringRepeat(
if (count > INT_MAX/length) {
if (interp) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "max size for a Tcl value (%d bytes) exceeded", INT_MAX));
+ "max size for a Tcl value (%" TCL_SIZE_MODIFIER
+ "d bytes) exceeded", TCL_SIZE_MAX));
Tcl_SetErrorCode(interp, "TCL", "MEMORY", NULL);
}
return NULL;
@@ -3342,7 +3342,7 @@ TclStringRepeat(
done *= 2;
}
TclAppendBytesToByteArray(objResultPtr,
- Tcl_GetByteArrayFromObj(objResultPtr, NULL),
+ Tcl_GetByteArrayFromObj(objResultPtr, (Tcl_Size *) NULL),
(count - done) * length);
} else if (unichar) {
/*
@@ -3387,7 +3387,7 @@ TclStringRepeat(
if (0 == Tcl_AttemptSetObjLength(objResultPtr, count*length)) {
if (interp) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "string size overflow: unable to alloc %u bytes",
+ "string size overflow: unable to alloc %" TCL_SIZE_MODIFIER "d bytes",
count*length));
Tcl_SetErrorCode(interp, "TCL", "MEMORY", NULL);
}
@@ -3518,7 +3518,7 @@ TclStringCat(
if (length == 0) {
first = last;
}
- if (length > (INT_MAX-numBytes)) {
+ if (length > (TCL_SIZE_MAX-numBytes)) {
goto overflow;
}
length += numBytes;
@@ -3543,7 +3543,7 @@ TclStringCat(
last = objc - oc;
if (length == 0) {
first = last;
- } else if (numChars > INT_MAX - length) {
+ } else if (length > TCL_SIZE_MAX - numChars) {
goto overflow;
}
length += numChars;
@@ -3610,7 +3610,7 @@ TclStringCat(
if (numBytes) {
first = last;
}
- } else if (numBytes > INT_MAX - length) {
+ } else if (numBytes > TCL_SIZE_MAX - length) {
goto overflow;
}
length += numBytes;
@@ -3626,7 +3626,7 @@ TclStringCat(
TclGetStringFromObj(objPtr, &numBytes); /* PANIC? */
if (numBytes) {
last = objc - oc;
- if (numBytes > INT_MAX - length) {
+ if (numBytes > TCL_SIZE_MAX - length) {
goto overflow;
}
length += numBytes;
@@ -3742,7 +3742,7 @@ TclStringCat(
if (0 == Tcl_AttemptSetObjLength(objResultPtr, length)) {
if (interp) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "concatenation failed: unable to alloc %u bytes",
+ "concatenation failed: unable to alloc %" TCL_SIZE_MODIFIER "d bytes",
length));
Tcl_SetErrorCode(interp, "TCL", "MEMORY", NULL);
}
@@ -3758,7 +3758,7 @@ TclStringCat(
Tcl_DecrRefCount(objResultPtr);
if (interp) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "concatenation failed: unable to alloc %u bytes",
+ "concatenation failed: unable to alloc %" TCL_SIZE_MODIFIER "d bytes",
length));
Tcl_SetErrorCode(interp, "TCL", "MEMORY", NULL);
}
@@ -3785,7 +3785,7 @@ TclStringCat(
overflow:
if (interp) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "max size for a Tcl value (%d bytes) exceeded", INT_MAX));
+ "max size for a Tcl value (%" TCL_SIZE_MODIFIER "d bytes) exceeded", TCL_SIZE_MAX));
Tcl_SetErrorCode(interp, "TCL", "MEMORY", NULL);
}
return NULL;
@@ -4010,7 +4010,7 @@ TclStringFirst(
Tcl_Obj *haystack,
Tcl_Size start)
{
- int lh, ln = TclGetCharLength(needle);
+ Tcl_Size lh, ln = TclGetCharLength(needle);
Tcl_Size value = TCL_INDEX_NONE;
Tcl_UniChar *checkStr, *endStr, *uh, *un;
Tcl_Obj *obj;
@@ -4115,7 +4115,7 @@ Tcl_Obj *
TclStringLast(
Tcl_Obj *needle,
Tcl_Obj *haystack,
- int last)
+ Tcl_Size last)
{
Tcl_Size lh, ln = TclGetCharLength(needle);
Tcl_Size value = TCL_INDEX_NONE;
@@ -4238,7 +4238,7 @@ TclStringReverse(
if (!inPlace || Tcl_IsShared(objPtr)) {
objPtr = Tcl_NewByteArrayObj(NULL, numBytes);
}
- ReverseBytes(Tcl_GetByteArrayFromObj(objPtr, NULL), from, numBytes);
+ ReverseBytes(Tcl_GetByteArrayFromObj(objPtr, (Tcl_Size *)NULL), from, numBytes);
return objPtr;
}
@@ -4356,8 +4356,8 @@ Tcl_Obj *
TclStringReplace(
Tcl_Interp *interp, /* For error reporting, may be NULL */
Tcl_Obj *objPtr, /* String to act upon */
- int first, /* First index to replace */
- int count, /* How many chars to replace */
+ Tcl_Size first, /* First index to replace */
+ Tcl_Size count, /* How many chars to replace */
Tcl_Obj *insertPtr, /* Replacement string, may be NULL */
int flags) /* TCL_STRING_IN_PLACE => attempt in-place */
{
@@ -4422,11 +4422,11 @@ TclStringReplace(
return objPtr;
}
- if (newBytes > (INT_MAX - (numBytes - count))) {
+ if (newBytes > (TCL_SIZE_MAX - (numBytes - count))) {
if (interp) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "max size for a Tcl value (%d bytes) exceeded",
- INT_MAX));
+ "max size for a Tcl value (%" TCL_SIZE_MODIFIER "d bytes) exceeded",
+ TCL_SIZE_MAX));
Tcl_SetErrorCode(interp, "TCL", "MEMORY", NULL);
}
return NULL;
@@ -4581,7 +4581,6 @@ DupStringInternalRep(
* bother copying it. Don't even bother allocating space in which to
* copy it. Just let the copy be untyped.
*/
-
return;
}
@@ -4742,16 +4741,16 @@ ExtendStringRepWithUnicode(
* Quick cheap check in case we have more than enough room.
*/
- if (numChars <= (INT_MAX - size)/TCL_UTF_MAX
+ if (numChars <= (TCL_SIZE_MAX - size)/TCL_UTF_MAX
&& stringPtr->allocated >= size + numChars * TCL_UTF_MAX) {
goto copyBytes;
}
for (i = 0; i < numChars && size >= 0; i++) {
- size += (unsigned int)TclUtfCount(unicode[i]);
+ size += TclUtfCount(unicode[i]);
}
if (size < 0) {
- Tcl_Panic("max size for a Tcl value (%d bytes) exceeded", INT_MAX);
+ Tcl_Panic("max size for a Tcl value (%" TCL_SIZE_MODIFIER "d bytes) exceeded", TCL_SIZE_MAX);
}
/*