diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2018-08-11 21:33:05 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2018-08-11 21:33:05 (GMT) |
commit | 09fba835c8c9d68042f6fef960c025be7c8c3641 (patch) | |
tree | 5e38501bee08c156d14cba01ccef64012a94521b | |
parent | 1d1ca3a5dde2d56b10fab0dfa5f430b98760de8e (diff) | |
download | tk-09fba835c8c9d68042f6fef960c025be7c8c3641.zip tk-09fba835c8c9d68042f6fef960c025be7c8c3641.tar.gz tk-09fba835c8c9d68042f6fef960c025be7c8c3641.tar.bz2 |
More preparation for TIP #494 compatibitly. Add 2 utility functions, which can retreive big strings and ByteArrays without length overflow.
-rw-r--r-- | generic/tkCanvText.c | 9 | ||||
-rw-r--r-- | generic/tkCanvas.c | 3 | ||||
-rw-r--r-- | generic/tkClipboard.c | 5 | ||||
-rw-r--r-- | generic/tkCmds.c | 7 | ||||
-rw-r--r-- | generic/tkConfig.c | 4 | ||||
-rw-r--r-- | generic/tkEntry.c | 7 | ||||
-rw-r--r-- | generic/tkFont.c | 10 | ||||
-rw-r--r-- | generic/tkFrame.c | 20 | ||||
-rw-r--r-- | generic/tkGrab.c | 4 | ||||
-rw-r--r-- | generic/tkGrid.c | 4 | ||||
-rw-r--r-- | generic/tkImgGIF.c | 8 | ||||
-rw-r--r-- | generic/tkImgListFormat.c | 4 | ||||
-rw-r--r-- | generic/tkImgPNG.c | 59 | ||||
-rw-r--r-- | generic/tkImgPPM.c | 5 | ||||
-rw-r--r-- | generic/tkImgPhoto.c | 16 | ||||
-rw-r--r-- | generic/tkInt.h | 16 | ||||
-rw-r--r-- | generic/tkListbox.c | 30 | ||||
-rw-r--r-- | generic/tkMenu.c | 4 | ||||
-rw-r--r-- | generic/tkMenu.h | 15 | ||||
-rw-r--r-- | generic/tkPack.c | 4 | ||||
-rw-r--r-- | generic/tkScale.c | 2 | ||||
-rw-r--r-- | generic/tkScale.h | 6 | ||||
-rw-r--r-- | generic/tkScrollbar.c | 6 | ||||
-rw-r--r-- | generic/tkSelect.c | 4 | ||||
-rw-r--r-- | generic/tkText.c | 18 | ||||
-rw-r--r-- | generic/tkTextDisp.c | 4 | ||||
-rw-r--r-- | generic/tkTextMark.c | 6 | ||||
-rw-r--r-- | generic/tkTextTag.c | 4 | ||||
-rw-r--r-- | generic/tkUtil.c | 38 | ||||
-rw-r--r-- | generic/tkWindow.c | 4 | ||||
-rw-r--r-- | generic/ttk/ttkEntry.c | 12 | ||||
-rw-r--r-- | unix/tkUnixWm.c | 10 |
32 files changed, 197 insertions, 151 deletions
diff --git a/generic/tkCanvText.c b/generic/tkCanvText.c index eb8dfe3..7c088b5 100644 --- a/generic/tkCanvText.c +++ b/generic/tkCanvText.c @@ -1006,12 +1006,13 @@ TextInsert( Tcl_Obj *obj) /* New characters to be inserted. */ { TextItem *textPtr = (TextItem *) itemPtr; - int byteIndex, byteCount, charsAdded; + int byteIndex, charsAdded; + size_t byteCount; char *newStr, *text; const char *string; Tk_CanvasTextInfo *textInfoPtr = textPtr->textInfoPtr; - string = Tcl_GetStringFromObj(obj, &byteCount); + string = TkGetStringFromObj(obj, &byteCount); text = textPtr->text; @@ -1343,11 +1344,11 @@ GetTextIndex( * index. */ { TextItem *textPtr = (TextItem *) itemPtr; - int length; + size_t length; int c; TkCanvas *canvasPtr = (TkCanvas *) canvas; Tk_CanvasTextInfo *textInfoPtr = textPtr->textInfoPtr; - const char *string = Tcl_GetStringFromObj(obj, &length); + const char *string = TkGetStringFromObj(obj, &length); c = string[0]; diff --git a/generic/tkCanvas.c b/generic/tkCanvas.c index 680b8b2..64e0f5d 100644 --- a/generic/tkCanvas.c +++ b/generic/tkCanvas.c @@ -1252,8 +1252,7 @@ CanvasWidgetCmd( result = TCL_ERROR; goto done; } - arg = Tcl_GetString(objv[2]); - length = objv[2]->length; + arg = TkGetStringFromObj(objv[2], &length); c = arg[0]; /* diff --git a/generic/tkClipboard.c b/generic/tkClipboard.c index b902625..aa6bb93 100644 --- a/generic/tkClipboard.c +++ b/generic/tkClipboard.c @@ -449,10 +449,11 @@ Tk_ClipboardObjCmd( "-displayof", "-format", "-type", NULL }; enum appendOptions { APPEND_DISPLAYOF, APPEND_FORMAT, APPEND_TYPE }; - int subIndex, length; + int subIndex; + size_t length; for (i = 2; i < objc - 1; i++) { - string = Tcl_GetStringFromObj(objv[i], &length); + string = TkGetStringFromObj(objv[i], &length); if (string[0] != '-') { break; } diff --git a/generic/tkCmds.c b/generic/tkCmds.c index 434772b..81bb335 100644 --- a/generic/tkCmds.c +++ b/generic/tkCmds.c @@ -2071,13 +2071,14 @@ TkGetDisplayOf( * present. */ { const char *string; + size_t length; if (objc < 1) { return 0; } - string = Tcl_GetString(objv[0]); - if ((objv[0]->length >= 2) && - (strncmp(string, "-displayof", objv[0]->length) == 0)) { + string = TkGetStringFromObj(objv[0], &length); + if ((length >= 2) && + (strncmp(string, "-displayof", length) == 0)) { if (objc < 2) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "value for \"-displayof\" missing", -1)); diff --git a/generic/tkConfig.c b/generic/tkConfig.c index 62b0857..4e90fab 100644 --- a/generic/tkConfig.c +++ b/generic/tkConfig.c @@ -656,14 +656,14 @@ DoObjConfig( case TK_OPTION_STRING: { char *newStr; const char *value; - int length; + size_t length; if (nullOK && ObjectIsEmpty(valuePtr)) { valuePtr = NULL; } if (internalPtr != NULL) { if (valuePtr != NULL) { - value = Tcl_GetStringFromObj(valuePtr, &length); + value = TkGetStringFromObj(valuePtr, &length); newStr = ckalloc(length + 1); strcpy(newStr, value); } else { diff --git a/generic/tkEntry.c b/generic/tkEntry.c index 1ab5477..018380d 100644 --- a/generic/tkEntry.c +++ b/generic/tkEntry.c @@ -4386,16 +4386,17 @@ SpinboxInvoke( * there. If not, move to the first element of the list. */ - int i, listc, elemLen, length = entryPtr->numChars; + int i, listc; + size_t elemLen, length = entryPtr->numChars; const char *bytes; Tcl_Obj **listv; Tcl_ListObjGetElements(interp, sbPtr->listObj, &listc, &listv); for (i = 0; i < listc; i++) { - bytes = Tcl_GetStringFromObj(listv[i], &elemLen); + bytes = TkGetStringFromObj(listv[i], &elemLen); if ((length == elemLen) && (memcmp(bytes, entryPtr->string, - (size_t) length) == 0)) { + length) == 0)) { sbPtr->eIndex = i; break; } diff --git a/generic/tkFont.c b/generic/tkFont.c index 834e944..9f2fa11 100644 --- a/generic/tkFont.c +++ b/generic/tkFont.c @@ -712,7 +712,8 @@ Tk_FontObjCmd( case FONT_MEASURE: { const char *string; Tk_Font tkfont; - int length = 0, skip = 0; + size_t length = 0; + int skip = 0; if (objc > 4) { skip = TkGetDisplayOf(interp, objc - 3, objv + 3, &tkwin); @@ -729,7 +730,7 @@ Tk_FontObjCmd( if (tkfont == NULL) { return TCL_ERROR; } - string = Tcl_GetStringFromObj(objv[3 + skip], &length); + string = TkGetStringFromObj(objv[3 + skip], &length); Tcl_SetObjResult(interp, Tcl_NewIntObj( Tk_TextWidth(tkfont, string, length))); Tk_FreeFont(tkfont); @@ -3245,7 +3246,8 @@ Tk_TextLayoutToPostscript( LayoutChunk *chunkPtr = layoutPtr->chunks; int baseline = chunkPtr->y; Tcl_Obj *psObj = Tcl_NewObj(); - int i, j, len; + int i, j; + size_t len; const char *p, *glyphname; char uindex[5], c, *ps; int ch; @@ -3303,7 +3305,7 @@ Tk_TextLayoutToPostscript( sprintf(uindex, "%04X", ch); /* endianness? */ glyphname = Tcl_GetVar2(interp, "::tk::psglyphs", uindex, 0); if (glyphname) { - ps = Tcl_GetStringFromObj(psObj, &len); + ps = TkGetStringFromObj(psObj, &len); if (ps[len-1] == '(') { /* * In-place edit. Ewww! diff --git a/generic/tkFrame.c b/generic/tkFrame.c index 0f1a1b3..e2aee37 100644 --- a/generic/tkFrame.c +++ b/generic/tkFrame.c @@ -488,7 +488,8 @@ CreateFrame( Tk_Window newWin; const char *className, *screenName, *visualName, *colormapName; const char *arg, *useOption; - int i, length, depth; + int i, depth; + size_t length; unsigned int mask; Colormap colormap; Visual *visual; @@ -515,24 +516,24 @@ CreateFrame( className = colormapName = screenName = visualName = useOption = NULL; colormap = None; for (i = 2; i < objc; i += 2) { - arg = Tcl_GetStringFromObj(objv[i], &length); + arg = TkGetStringFromObj(objv[i], &length); if (length < 2) { continue; } if ((arg[1] == 'c') && (length >= 3) - && (strncmp(arg, "-class", (unsigned) length) == 0)) { + && (strncmp(arg, "-class", length) == 0)) { className = Tcl_GetString(objv[i+1]); } else if ((arg[1] == 'c') && (length >= 3) - && (strncmp(arg, "-colormap", (unsigned) length) == 0)) { + && (strncmp(arg, "-colormap", length) == 0)) { colormapName = Tcl_GetString(objv[i+1]); } else if ((arg[1] == 's') && (type == TYPE_TOPLEVEL) - && (strncmp(arg, "-screen", (unsigned) length) == 0)) { + && (strncmp(arg, "-screen", length) == 0)) { screenName = Tcl_GetString(objv[i+1]); } else if ((arg[1] == 'u') && (type == TYPE_TOPLEVEL) - && (strncmp(arg, "-use", (unsigned) length) == 0)) { + && (strncmp(arg, "-use", length) == 0)) { useOption = Tcl_GetString(objv[i+1]); } else if ((arg[1] == 'v') - && (strncmp(arg, "-visual", (unsigned) length) == 0)) { + && (strncmp(arg, "-visual", length) == 0)) { visualName = Tcl_GetString(objv[i+1]); } } @@ -743,7 +744,8 @@ FrameWidgetObjCmd( }; register Frame *framePtr = clientData; int result = TCL_OK, index; - int c, i, length; + int c, i; + size_t length; Tcl_Obj *objPtr; if (objc < 2) { @@ -787,7 +789,7 @@ FrameWidgetObjCmd( */ for (i = 2; i < objc; i++) { - const char *arg = Tcl_GetStringFromObj(objv[i], &length); + const char *arg = TkGetStringFromObj(objv[i], &length); if (length < 2) { continue; diff --git a/generic/tkGrab.c b/generic/tkGrab.c index 00d4511..c37b6be 100644 --- a/generic/tkGrab.c +++ b/generic/tkGrab.c @@ -190,7 +190,7 @@ Tk_GrabObjCmd( TkDisplay *dispPtr; const char *arg; int index; - int len; + size_t len; static const char *const optionStrings[] = { "current", "release", "set", "status", NULL }; @@ -227,7 +227,7 @@ Tk_GrabObjCmd( * First check for a window name or "-global" as the first argument. */ - arg = Tcl_GetStringFromObj(objv[1], &len); + arg = TkGetStringFromObj(objv[1], &len); if (arg[0] == '.') { /* [grab window] */ if (objc != 2) { diff --git a/generic/tkGrid.c b/generic/tkGrid.c index 20e66b6..aaed30f 100644 --- a/generic/tkGrid.c +++ b/generic/tkGrid.c @@ -2965,10 +2965,10 @@ ConfigureSlaves( firstChar = 0; for (numWindows=0, i=0; i < objc; i++) { - int length; + size_t length; char prevChar = firstChar; - string = Tcl_GetStringFromObj(objv[i], &length); + string = TkGetStringFromObj(objv[i], &length); firstChar = string[0]; if (firstChar == '.') { diff --git a/generic/tkImgGIF.c b/generic/tkImgGIF.c index b7bcd81..aacde56 100644 --- a/generic/tkImgGIF.c +++ b/generic/tkImgGIF.c @@ -757,10 +757,10 @@ StringMatchGIF( Tcl_Interp *interp) /* not used */ { unsigned char *data, header[10]; - int got, length; + size_t got, length; MFile handle; - data = Tcl_GetByteArrayFromObj(dataObj, &length); + data = TkGetByteArrayFromObj(dataObj, &length); /* * Header is a minimum of 10 bytes. @@ -826,9 +826,9 @@ StringReadGIF( int srcX, int srcY) { MFile handle, *hdlPtr = &handle; - int length; + size_t length; const char *xferFormat; - unsigned char *data = Tcl_GetByteArrayFromObj(dataObj, &length); + unsigned char *data = TkGetByteArrayFromObj(dataObj, &length); mInit(data, hdlPtr, length); diff --git a/generic/tkImgListFormat.c b/generic/tkImgListFormat.c index 1c3bff8..4636c41 100644 --- a/generic/tkImgListFormat.c +++ b/generic/tkImgListFormat.c @@ -772,13 +772,13 @@ ParseColor( unsigned char *alphaPtr) { const char *specString; - int charCount; + size_t charCount; /* * Find out which color format we have */ - specString = Tcl_GetStringFromObj(specObj, &charCount); + specString = TkGetStringFromObj(specObj, &charCount); if (charCount == 0) { /* Empty string */ diff --git a/generic/tkImgPNG.c b/generic/tkImgPNG.c index c985c92..52135ed 100644 --- a/generic/tkImgPNG.c +++ b/generic/tkImgPNG.c @@ -127,7 +127,7 @@ typedef struct { Tcl_Channel channel; /* Channel for from-file reads. */ Tcl_Obj *objDataPtr; unsigned char *strDataBuf; /* Raw source data for from-string reads. */ - int strDataLen; /* Length of source data. */ + size_t strDataLen; /* Length of source data. */ unsigned char *base64Data; /* base64 encoded string data. */ unsigned char base64Bits; /* Remaining bits from last base64 read. */ unsigned char base64State; /* Current state of base64 decoder. */ @@ -215,16 +215,16 @@ static inline unsigned char Paeth(int a, int b, int c); static int ParseFormat(Tcl_Interp *interp, Tcl_Obj *fmtObj, PNGImage *pngPtr); static int ReadBase64(Tcl_Interp *interp, PNGImage *pngPtr, - unsigned char *destPtr, int destSz, + unsigned char *destPtr, size_t destSz, unsigned long *crcPtr); static int ReadByteArray(Tcl_Interp *interp, PNGImage *pngPtr, - unsigned char *destPtr, int destSz, + unsigned char *destPtr, size_t destSz, unsigned long *crcPtr); static int ReadData(Tcl_Interp *interp, PNGImage *pngPtr, - unsigned char *destPtr, int destSz, + unsigned char *destPtr, size_t destSz, unsigned long *crcPtr); static int ReadChunkHeader(Tcl_Interp *interp, PNGImage *pngPtr, - int *sizePtr, unsigned long *typePtr, + size_t *sizePtr, unsigned long *typePtr, unsigned long *crcPtr); static int ReadIDAT(Tcl_Interp *interp, PNGImage *pngPtr, int chunkSz, unsigned long crc); @@ -251,9 +251,9 @@ static inline int WriteByte(Tcl_Interp *interp, PNGImage *pngPtr, unsigned char c, unsigned long *crcPtr); static inline int WriteChunk(Tcl_Interp *interp, PNGImage *pngPtr, unsigned long chunkType, - const unsigned char *dataPtr, int dataSize); + const unsigned char *dataPtr, size_t dataSize); static int WriteData(Tcl_Interp *interp, PNGImage *pngPtr, - const unsigned char *srcPtr, int srcSz, + const unsigned char *srcPtr, size_t srcSz, unsigned long *crcPtr); static int WriteExtraChunks(Tcl_Interp *interp, PNGImage *pngPtr); @@ -320,7 +320,7 @@ InitPNGImage( Tcl_IncrRefCount(objPtr); pngPtr->objDataPtr = objPtr; pngPtr->strDataBuf = - Tcl_GetByteArrayFromObj(objPtr, &pngPtr->strDataLen); + TkGetByteArrayFromObj(objPtr, &pngPtr->strDataLen); } /* @@ -431,7 +431,7 @@ ReadBase64( Tcl_Interp *interp, PNGImage *pngPtr, unsigned char *destPtr, - int destSz, + size_t destSz, unsigned long *crcPtr) { static const unsigned char from64[] = { @@ -556,14 +556,14 @@ ReadByteArray( Tcl_Interp *interp, PNGImage *pngPtr, unsigned char *destPtr, - int destSz, + size_t destSz, unsigned long *crcPtr) { /* * Check to make sure the number of requested bytes are available. */ - if (pngPtr->strDataLen < destSz) { + if ((size_t)pngPtr->strDataLen < destSz) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "unexpected end of image data", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "EARLY_END", NULL); @@ -571,7 +571,7 @@ ReadByteArray( } while (destSz) { - int blockSz = PNG_MIN(destSz, PNG_BLOCK_SZ); + size_t blockSz = PNG_MIN(destSz, PNG_BLOCK_SZ); memcpy(destPtr, pngPtr->strDataBuf, blockSz); @@ -614,7 +614,7 @@ ReadData( Tcl_Interp *interp, PNGImage *pngPtr, unsigned char *destPtr, - int destSz, + size_t destSz, unsigned long *crcPtr) { if (pngPtr->base64Data) { @@ -859,7 +859,7 @@ static int ReadChunkHeader( Tcl_Interp *interp, PNGImage *pngPtr, - int *sizePtr, + size_t *sizePtr, unsigned long *typePtr, unsigned long *crcPtr) { @@ -1240,7 +1240,7 @@ ReadIHDR( { unsigned char sigBuf[PNG_SIG_SZ]; unsigned long chunkType; - int chunkSz; + size_t chunkSz; unsigned long crc; unsigned long width, height; int mismatch; @@ -1264,7 +1264,7 @@ ReadIHDR( */ if (mismatch && pngPtr->strDataBuf) { - pngPtr->strDataBuf = Tcl_GetByteArrayFromObj(pngPtr->objDataPtr, + pngPtr->strDataBuf = TkGetByteArrayFromObj(pngPtr->objDataPtr, &pngPtr->strDataLen); pngPtr->base64Data = pngPtr->strDataBuf; @@ -2098,7 +2098,7 @@ ReadIDAT( */ while (chunkSz && !Tcl_ZlibStreamEof(pngPtr->stream)) { - int len1, len2; + size_t len1, len2; /* * Read another block of input into the zlib stream if data remains. @@ -2147,14 +2147,14 @@ ReadIDAT( */ getNextLine: - Tcl_GetByteArrayFromObj(pngPtr->thisLineObj, &len1); + TkGetByteArrayFromObj(pngPtr->thisLineObj, &len1); if (Tcl_ZlibStreamGet(pngPtr->stream, pngPtr->thisLineObj, pngPtr->phaseSize - len1) == TCL_ERROR) { return TCL_ERROR; } - Tcl_GetByteArrayFromObj(pngPtr->thisLineObj, &len2); + TkGetByteArrayFromObj(pngPtr->thisLineObj, &len2); - if (len2 == pngPtr->phaseSize) { + if (len2 == (size_t)pngPtr->phaseSize) { if (pngPtr->phase > 7) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "extra data after final scan line of final phase", @@ -2383,7 +2383,7 @@ DecodePNG( int destY) { unsigned long chunkType; - int chunkSz; + size_t chunkSz; unsigned long crc; /* @@ -2768,7 +2768,7 @@ StringMatchPNG( InitPNGImage(NULL, &png, NULL, pObjData, TCL_ZLIB_STREAM_INFLATE); - png.strDataBuf = Tcl_GetByteArrayFromObj(pObjData, &png.strDataLen); + png.strDataBuf = TkGetByteArrayFromObj(pObjData, &png.strDataLen); if (ReadIHDR(interp, &png) == TCL_OK) { *widthPtr = png.block.width; @@ -2846,7 +2846,7 @@ WriteData( Tcl_Interp *interp, PNGImage *pngPtr, const unsigned char *srcPtr, - int srcSz, + size_t srcSz, unsigned long *crcPtr) { if (!srcPtr || !srcSz) { @@ -2863,12 +2863,12 @@ WriteData( */ if (pngPtr->objDataPtr) { - int objSz; + size_t objSz; unsigned char *destPtr; - Tcl_GetByteArrayFromObj(pngPtr->objDataPtr, &objSz); + TkGetByteArrayFromObj(pngPtr->objDataPtr, &objSz); - if (objSz > INT_MAX - srcSz) { + if (objSz + srcSz > INT_MAX) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "image too large to store completely in byte array", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "TOO_LARGE", NULL); @@ -2961,7 +2961,7 @@ WriteChunk( PNGImage *pngPtr, unsigned long chunkType, const unsigned char *dataPtr, - int dataSize) + size_t dataSize) { unsigned long crc = Tcl_ZlibCRC32(0, NULL, 0); int result = TCL_OK; @@ -3132,9 +3132,10 @@ WriteIDAT( PNGImage *pngPtr, Tk_PhotoImageBlock *blockPtr) { - int rowNum, flush = TCL_ZLIB_NO_FLUSH, outputSize, result; + int rowNum, flush = TCL_ZLIB_NO_FLUSH, result; Tcl_Obj *outputObj; unsigned char *outputBytes; + size_t outputSize; /* * Filter and compress each row one at a time. @@ -3226,7 +3227,7 @@ WriteIDAT( outputObj = Tcl_NewObj(); (void) Tcl_ZlibStreamGet(pngPtr->stream, outputObj, -1); - outputBytes = Tcl_GetByteArrayFromObj(outputObj, &outputSize); + outputBytes = TkGetByteArrayFromObj(outputObj, &outputSize); result = WriteChunk(interp, pngPtr, CHUNK_IDAT, outputBytes, outputSize); Tcl_DecrRefCount(outputObj); return result; diff --git a/generic/tkImgPPM.c b/generic/tkImgPPM.c index 6dd92a2..1cedc43 100644 --- a/generic/tkImgPPM.c +++ b/generic/tkImgPPM.c @@ -764,10 +764,11 @@ ReadPPMStringHeader( { #define BUFFER_SIZE 1000 char buffer[BUFFER_SIZE], c; - int i, numFields, dataSize, type = 0; + int i, numFields, type = 0; + size_t dataSize; unsigned char *dataBuffer; - dataBuffer = Tcl_GetByteArrayFromObj(dataPtr, &dataSize); + dataBuffer = TkGetByteArrayFromObj(dataPtr, &dataSize); /* * Read 4 space-separated fields from the string, ignoring comments (any diff --git a/generic/tkImgPhoto.c b/generic/tkImgPhoto.c index fa58c86..e1d54dd 100644 --- a/generic/tkImgPhoto.c +++ b/generic/tkImgPhoto.c @@ -448,8 +448,7 @@ ImgPhotoCmd( Tcl_WrongNumArgs(interp, 2, objv, "option"); return TCL_ERROR; } - arg = Tcl_GetString(objv[2]); - length = objv[2]->length; + arg = TkGetStringFromObj(objv[2], &length); if (strncmp(arg,"-data", length) == 0) { if (masterPtr->dataString) { Tcl_SetObjResult(interp, masterPtr->dataString); @@ -498,9 +497,8 @@ ImgPhotoCmd( return TCL_OK; } else if (objc == 3) { - const char *arg = Tcl_GetString(objv[2]); + const char *arg = TkGetStringFromObj(objv[2], &length); - length = objv[2]->length; if (length > 1 && !strncmp(arg, "-data", length)) { Tcl_AppendResult(interp, "-data {} {} {}", NULL); if (masterPtr->dataString) { @@ -1491,8 +1489,7 @@ ParseSubcommandOptions( * optPtr->name. */ - expandedOption = option = Tcl_GetString(objv[index]); - length = objv[index]->length; + expandedOption = option = TkGetStringFromObj(objv[index], &length); if (option[0] != '-') { if (optPtr->name == NULL) { optPtr->name = objv[index]; @@ -1770,8 +1767,7 @@ ImgPhotoConfigureMaster( args = ckalloc((objc + 1) * sizeof(char *)); for (i = 0, j = 0; i < objc; i++,j++) { - args[j] = Tcl_GetString(objv[i]); - length = objv[i]->length; + args[j] = TkGetStringFromObj(objv[i], &length); if ((length > 1) && (args[j][0] == '-')) { if ((args[j][1] == 'd') && !strncmp(args[j], "-data", length)) { @@ -1850,9 +1846,9 @@ ImgPhotoConfigureMaster( * Force into ByteArray format, which most (all) image handlers will * use anyway. Empty length means ignore the -data option. */ - int bytesize; + size_t bytesize; - (void) Tcl_GetByteArrayFromObj(data, &bytesize); + (void) TkGetByteArrayFromObj(data, &bytesize); if (bytesize) { Tcl_IncrRefCount(data); } else { diff --git a/generic/tkInt.h b/generic/tkInt.h index d21b14f..62560bd 100644 --- a/generic/tkInt.h +++ b/generic/tkInt.h @@ -1242,13 +1242,21 @@ MODULE_SCOPE void TkUnixSetXftClipRegion(TkRegion clipRegion); #endif #if TCL_UTF_MAX > 4 -# define TkUtfToUniChar Tcl_UtfToUniChar -# define TkUniCharToUtf Tcl_UniCharToUtf +# define TkUtfToUniChar (size_t)Tcl_UtfToUniChar +# define TkUniCharToUtf (size_t)Tcl_UniCharToUtf #else - MODULE_SCOPE int TkUtfToUniChar(const char *, int *); - MODULE_SCOPE int TkUniCharToUtf(int, char *); + MODULE_SCOPE size_t TkUtfToUniChar(const char *, int *); + MODULE_SCOPE size_t TkUniCharToUtf(int, char *); #endif +#define TkGetStringFromObj(objPtr, lenPtr) \ + (((objPtr)->bytes \ + ? 0 : Tcl_GetString((objPtr)), \ + *(lenPtr) = (objPtr)->length, (objPtr)->bytes)) + +MODULE_SCOPE unsigned char *TkGetByteArrayFromObj(Tcl_Obj *objPtr, + size_t *lengthPtr); + /* * Unsupported commands. */ diff --git a/generic/tkListbox.c b/generic/tkListbox.c index 5f650fe..1e5b92e 100644 --- a/generic/tkListbox.c +++ b/generic/tkListbox.c @@ -1102,7 +1102,8 @@ ListboxBboxSubCmd( if ((listPtr->topIndex <= index) && (index < lastVisibleIndex)) { Tcl_Obj *el, *results[4]; const char *stringRep; - int pixelWidth, stringLen, x, y, result; + int pixelWidth, x, y, result; + size_t stringLen; Tk_FontMetrics fm; /* @@ -1114,7 +1115,7 @@ ListboxBboxSubCmd( return result; } - stringRep = Tcl_GetStringFromObj(el, &stringLen); + stringRep = TkGetStringFromObj(el, &stringLen); Tk_GetFontMetrics(listPtr->tkfont, &fm); pixelWidth = Tk_TextWidth(listPtr->tkfont, stringRep, stringLen); @@ -1840,7 +1841,8 @@ DisplayListbox( register Listbox *listPtr = clientData; register Tk_Window tkwin = listPtr->tkwin; GC gc; - int i, limit, x, y, prevSelected, freeGC, stringLen; + int i, limit, x, y, prevSelected, freeGC; + size_t stringLen; Tk_FontMetrics fm; Tcl_Obj *curElement; Tcl_HashEntry *entry; @@ -2074,7 +2076,7 @@ DisplayListbox( */ Tcl_ListObjIndex(listPtr->interp, listPtr->listObj, i, &curElement); - stringRep = Tcl_GetStringFromObj(curElement, &stringLen); + stringRep = TkGetStringFromObj(curElement, &stringLen); textWidth = Tk_TextWidth(listPtr->tkfont, stringRep, stringLen); Tk_GetFontMetrics(listPtr->tkfont, &fm); @@ -2236,7 +2238,8 @@ ListboxComputeGeometry( * Tk_UnsetGrid to update gridding for the * window. */ { - int width, height, pixelWidth, pixelHeight, textLength, i, result; + int width, height, pixelWidth, pixelHeight, i, result; + size_t textLength; Tk_FontMetrics fm; Tcl_Obj *element; const char *text; @@ -2257,7 +2260,7 @@ ListboxComputeGeometry( if (result != TCL_OK) { continue; } - text = Tcl_GetStringFromObj(element, &textLength); + text = TkGetStringFromObj(element, &textLength); Tk_GetFontMetrics(listPtr->tkfont, &fm); pixelWidth = Tk_TextWidth(listPtr->tkfont, text, textLength); if (pixelWidth > listPtr->maxWidth) { @@ -2323,7 +2326,8 @@ ListboxInsertSubCmd( int objc, /* Number of new elements to add. */ Tcl_Obj *const objv[]) /* New elements (one per entry). */ { - int i, oldMaxWidth, pixelWidth, result, length; + int i, oldMaxWidth, pixelWidth, result; + size_t length; Tcl_Obj *newListObj; const char *stringRep; @@ -2334,7 +2338,7 @@ ListboxInsertSubCmd( * if so, update our notion of "widest." */ - stringRep = Tcl_GetStringFromObj(objv[i], &length); + stringRep = TkGetStringFromObj(objv[i], &length); pixelWidth = Tk_TextWidth(listPtr->tkfont, stringRep, length); if (pixelWidth > listPtr->maxWidth) { listPtr->maxWidth = pixelWidth; @@ -2437,7 +2441,8 @@ ListboxDeleteSubCmd( int first, /* Index of first element to delete. */ int last) /* Index of last element to delete. */ { - int count, i, widthChanged, length, result, pixelWidth; + int count, i, widthChanged, result, pixelWidth; + size_t length; Tcl_Obj *newListObj, *element; const char *stringRep; Tcl_HashEntry *entry; @@ -2492,7 +2497,7 @@ ListboxDeleteSubCmd( if (widthChanged == 0) { Tcl_ListObjIndex(listPtr->interp, listPtr->listObj, i, &element); - stringRep = Tcl_GetStringFromObj(element, &length); + stringRep = TkGetStringFromObj(element, &length); pixelWidth = Tk_TextWidth(listPtr->tkfont, stringRep, length); if (pixelWidth == listPtr->maxWidth) { widthChanged = 1; @@ -3122,7 +3127,8 @@ ListboxFetchSelection( { register Listbox *listPtr = clientData; Tcl_DString selection; - int length, count, needNewline, stringLen, i; + int count, needNewline, i; + size_t length, stringLen; Tcl_Obj *curElement; const char *stringRep; Tcl_HashEntry *entry; @@ -3145,7 +3151,7 @@ ListboxFetchSelection( } Tcl_ListObjIndex(listPtr->interp, listPtr->listObj, i, &curElement); - stringRep = Tcl_GetStringFromObj(curElement, &stringLen); + stringRep = TkGetStringFromObj(curElement, &stringLen); Tcl_DStringAppend(&selection, stringRep, stringLen); needNewline = 1; } diff --git a/generic/tkMenu.c b/generic/tkMenu.c index 7b06035..7441ca2 100644 --- a/generic/tkMenu.c +++ b/generic/tkMenu.c @@ -1700,12 +1700,12 @@ PostProcessEntry( if (mePtr->labelPtr == NULL) { mePtr->labelLength = 0; } else { - Tcl_GetStringFromObj(mePtr->labelPtr, &mePtr->labelLength); + (void)TkGetStringFromObj(mePtr->labelPtr, &mePtr->labelLength); } if (mePtr->accelPtr == NULL) { mePtr->accelLength = 0; } else { - Tcl_GetStringFromObj(mePtr->accelPtr, &mePtr->accelLength); + (void)TkGetStringFromObj(mePtr->accelPtr, &mePtr->accelLength); } /* diff --git a/generic/tkMenu.h b/generic/tkMenu.h index bac51aa..b4269a5 100644 --- a/generic/tkMenu.h +++ b/generic/tkMenu.h @@ -68,11 +68,15 @@ typedef struct TkMenuEntry { Tk_OptionTable optionTable; /* Option table for this menu entry. */ Tcl_Obj *labelPtr; /* Main text label displayed in entry (NULL if * no label). */ - int labelLength; /* Number of non-NULL characters in label. */ +#if TK_MAJOR_VERSION > 8 + size_t labelLength; /* Number of non-NULL characters in label. */ +#else + unsigned int labelLength; /* Number of non-NULL characters in label. */ +#endif int state; /* State of button for display purposes: * normal, active, or disabled. */ int underline; /* Value of -underline option: specifies index - * of character to underline (<0 means don't + * of character to underline (-1 means don't * underline anything). */ Tcl_Obj *underlinePtr; /* Index of character to underline. */ Tcl_Obj *bitmapPtr; /* Bitmap to display in menu entry, or None. @@ -89,8 +93,13 @@ typedef struct TkMenuEntry { Tcl_Obj *accelPtr; /* Accelerator string displayed at right of * menu entry. NULL means no such accelerator. * Malloc'ed. */ - int accelLength; /* Number of non-NULL characters in +#if TK_MAJOR_VERSION > 8 + size_t accelLength; /* Number of non-NULL characters in + * accelerator. */ +#else + unsigned int accelLength; /* Number of non-NULL characters in * accelerator. */ +#endif int indicatorOn; /* True means draw indicator, false means * don't draw it. This field is ignored unless * the entry is a radio or check button. */ diff --git a/generic/tkPack.c b/generic/tkPack.c index bee38d5..d7fabca 100644 --- a/generic/tkPack.c +++ b/generic/tkPack.c @@ -1181,8 +1181,8 @@ PackAfter( packPtr->flags |= OLD_STYLE; for (index = 0 ; index < optionCount; index++) { Tcl_Obj *curOptPtr = options[index]; - const char *curOpt = Tcl_GetString(curOptPtr); - size_t length = curOptPtr->length; + size_t length; + const char *curOpt = TkGetStringFromObj(curOptPtr, &length); c = curOpt[0]; diff --git a/generic/tkScale.c b/generic/tkScale.c index af45afa..1c65001 100644 --- a/generic/tkScale.c +++ b/generic/tkScale.c @@ -638,7 +638,7 @@ ConfigureScale( ComputeFormat(scalePtr); - scalePtr->labelLength = scalePtr->label ? (int)strlen(scalePtr->label) : 0; + scalePtr->labelLength = scalePtr->label ? strlen(scalePtr->label) : 0; Tk_SetBackgroundFromBorder(scalePtr->tkwin, scalePtr->bgBorder); diff --git a/generic/tkScale.h b/generic/tkScale.h index aa0feff..043d23c 100644 --- a/generic/tkScale.h +++ b/generic/tkScale.h @@ -85,7 +85,11 @@ typedef struct TkScale { int repeatInterval; /* Interval between autorepeats (in ms). */ char *label; /* Label to display above or to right of * scale; NULL means don't display a label. */ - int labelLength; /* Number of non-NULL chars. in label. */ +#if TK_MAJOR_VERSION > 8 + size_t labelLength; /* Number of non-NULL chars. in label. */ +#else + unsigned int labelLength; /* Number of non-NULL chars. in label. */ +#endif enum state state; /* Values are active, normal, or disabled. * Value of scale cannot be changed when * disabled. */ diff --git a/generic/tkScrollbar.c b/generic/tkScrollbar.c index 8ace793..02fb740 100644 --- a/generic/tkScrollbar.c +++ b/generic/tkScrollbar.c @@ -226,8 +226,8 @@ ScrollbarWidgetObjCmd( Tcl_Obj *const objv[]) /* Argument strings. */ { register TkScrollbar *scrollPtr = clientData; - int result = TCL_OK; - int length, cmdIndex; + int result = TCL_OK, cmdIndex; + size_t length; static const char *const commandNames[] = { "activate", "cget", "configure", "delta", "fraction", "get", "identify", "set", NULL @@ -271,7 +271,7 @@ ScrollbarWidgetObjCmd( Tcl_WrongNumArgs(interp, 1, objv, "activate element"); goto error; } - c = Tcl_GetStringFromObj(objv[2], &length)[0]; + c = TkGetStringFromObj(objv[2], &length)[0]; oldActiveField = scrollPtr->activeField; if ((c == 'a') && (strcmp(Tcl_GetString(objv[2]), "arrow1") == 0)) { scrollPtr->activeField = TOP_ARROW; diff --git a/generic/tkSelect.c b/generic/tkSelect.c index 139ef3a..02268d3 100644 --- a/generic/tkSelect.c +++ b/generic/tkSelect.c @@ -831,7 +831,7 @@ Tk_SelectionObjCmd( const char *targetName = NULL; const char *formatName = NULL; register CommandInfo *cmdInfoPtr; - int cmdLength; + size_t cmdLength; static const char *const handleOptionStrings[] = { "-format", "-selection", "-type", NULL }; @@ -900,7 +900,7 @@ Tk_SelectionObjCmd( } else { format = XA_STRING; } - string = Tcl_GetStringFromObj(objs[1], &cmdLength); + string = TkGetStringFromObj(objs[1], &cmdLength); if (cmdLength == 0) { Tk_DeleteSelHandler(tkwin, selection, target); } else { diff --git a/generic/tkText.c b/generic/tkText.c index b2bffbf..bc60e90 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -866,10 +866,9 @@ TextWidgetObjCmd( for (i = 2; i < objc-2; i++) { int value; size_t length; - const char *option = Tcl_GetString(objv[i]); + const char *option = TkGetStringFromObj(objv[i], &length); char c; - length = objv[i]->length; if (length < 2 || option[0] != '-') { goto badOption; } @@ -1277,14 +1276,12 @@ TextWidgetObjCmd( i = 2; if (objc > 3) { - name = Tcl_GetString(objv[i]); - length = objv[i]->length; + name = TkGetStringFromObj(objv[i], &length); if (length > 1 && name[0] == '-') { if (strncmp("-displaychars", name, length) == 0) { i++; visible = 1; - name = Tcl_GetString(objv[i]); - length = objv[i]->length; + name = TkGetStringFromObj(objv[i], &length); } if ((i < objc-1) && (length == 2) && !strcmp("--", name)) { i++; @@ -2640,9 +2637,8 @@ InsertChars( int *lineAndByteIndex; int resetViewCount; int pixels[2*PIXEL_CLIENTS]; - const char *string = Tcl_GetString(stringPtr); + const char *string = TkGetStringFromObj(stringPtr, &length); - length = stringPtr->length; if (sharedTextPtr == NULL) { sharedTextPtr = textPtr->sharedTextPtr; } @@ -4764,8 +4760,7 @@ TextDumpCmd( if (TkTextGetObjIndex(interp, textPtr, objv[arg], &index2) != TCL_OK) { return TCL_ERROR; } - str = Tcl_GetString(objv[arg]); - length = objv[arg]->length; + str = TkGetStringFromObj(objv[arg], &length); if (strncmp(str, "end", length) == 0) { atEnd = 1; } @@ -5838,8 +5833,7 @@ SearchCore( * it has dual purpose. */ - pattern = Tcl_GetString(patObj); - matchLength = patObj->length; + pattern = Tcl_GetStringFromObj(patObj, &matchLength); nl = strchr(pattern, '\n'); /* diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 00c86b8..0764a87 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -6089,7 +6089,7 @@ TkTextYviewCmd( TextDInfo *dInfoPtr = textPtr->dInfoPtr; int pickPlace, type; int pixels, count; - int switchLength; + size_t switchLength; double fraction; TkTextIndex index; @@ -6109,7 +6109,7 @@ TkTextYviewCmd( pickPlace = 0; if (Tcl_GetString(objv[2])[0] == '-') { register const char *switchStr = - Tcl_GetStringFromObj(objv[2], &switchLength); + TkGetStringFromObj(objv[2], &switchLength); if ((switchLength >= 2) && (strncmp(switchStr, "-pickplace", (unsigned) switchLength) == 0)) { diff --git a/generic/tkTextMark.c b/generic/tkTextMark.c index 6a41c77..19d0c2a 100644 --- a/generic/tkTextMark.c +++ b/generic/tkTextMark.c @@ -126,14 +126,14 @@ TkTextMarkCmd( switch ((enum markOptions) optionIndex) { case MARK_GRAVITY: { char c; - int length; + size_t length; const char *str; if (objc < 4 || objc > 5) { Tcl_WrongNumArgs(interp, 3, objv, "markName ?gravity?"); return TCL_ERROR; } - str = Tcl_GetStringFromObj(objv[3], &length); + str = TkGetStringFromObj(objv[3], &length); if (length == 6 && !strcmp(str, "insert")) { markPtr = textPtr->insertMarkPtr; } else if (length == 7 && !strcmp(str, "current")) { @@ -160,7 +160,7 @@ TkTextMarkCmd( Tcl_SetObjResult(interp, Tcl_NewStringObj(typeStr, -1)); return TCL_OK; } - str = Tcl_GetStringFromObj(objv[4],&length); + str = TkGetStringFromObj(objv[4],&length); c = str[0]; if ((c == 'l') && (strncmp(str, "left", (unsigned) length) == 0)) { newTypePtr = &tkTextLeftMarkType; diff --git a/generic/tkTextTag.c b/generic/tkTextTag.c index 9ade3ad..66f467b 100644 --- a/generic/tkTextTag.c +++ b/generic/tkTextTag.c @@ -1108,10 +1108,10 @@ FindTag( Tcl_Obj *tagName) /* Name of desired tag. */ { Tcl_HashEntry *hPtr; - int len; + size_t len; const char *str; - str = Tcl_GetStringFromObj(tagName, &len); + str = TkGetStringFromObj(tagName, &len); if (len == 3 && !strcmp(str, "sel")) { return textPtr->selTagPtr; } diff --git a/generic/tkUtil.c b/generic/tkUtil.c index 1db7684..9f2dab1 100644 --- a/generic/tkUtil.c +++ b/generic/tkUtil.c @@ -729,8 +729,8 @@ Tk_GetScrollInfoObj( int *intPtr) /* Filled in with number of pages or lines to * scroll, if any. */ { - const char *arg = Tcl_GetString(objv[2]); - size_t length = objv[2]->length; + size_t length; + const char *arg = TkGetStringFromObj(objv[2], &length); #define ArgPfxEq(str) \ ((arg[0] == str[0]) && !strncmp(arg, str, length)) @@ -753,8 +753,7 @@ Tk_GetScrollInfoObj( return TK_SCROLL_ERROR; } - arg = Tcl_GetString(objv[4]); - length = objv[4]->length; + arg = TkGetStringFromObj(objv[4], &length); if (ArgPfxEq("pages")) { return TK_SCROLL_PAGES; } else if (ArgPfxEq("units")) { @@ -1213,7 +1212,7 @@ TkSendVirtualEvent( *--------------------------------------------------------------------------- */ -int +size_t TkUtfToUniChar( const char *src, /* The UTF-8 string. */ int *chPtr) /* Filled with the Tcl_UniChar represented by @@ -1221,12 +1220,12 @@ TkUtfToUniChar( { Tcl_UniChar uniChar = 0; - int len = Tcl_UtfToUniChar(src, &uniChar); + size_t len = Tcl_UtfToUniChar(src, &uniChar); if ((uniChar & 0xfc00) == 0xd800) { Tcl_UniChar high = uniChar; /* This can only happen if Tcl is compiled with TCL_UTF_MAX=4, * or when a high surrogate character is detected in UTF-8 form */ - int len2 = Tcl_UtfToUniChar(src+len, &uniChar); + size_t len2 = Tcl_UtfToUniChar(src+len, &uniChar); if ((uniChar & 0xfc00) == 0xdc00) { *chPtr = (((high & 0x3ff) << 10) | (uniChar & 0x3ff)) + 0x10000; len += len2; @@ -1257,9 +1256,9 @@ TkUtfToUniChar( *--------------------------------------------------------------------------- */ -int TkUniCharToUtf(int ch, char *buf) +size_t TkUniCharToUtf(int ch, char *buf) { - int size = Tcl_UniCharToUtf(ch, buf); + size_t size = Tcl_UniCharToUtf(ch, buf); if ((((unsigned)(ch - 0x10000) <= 0xFFFFF)) && (size < 4)) { /* Hey, this is wrong, we must be running TCL_UTF_MAX==3 * The best thing we can do is spit out 2 surrogates */ @@ -1272,6 +1271,27 @@ int TkUniCharToUtf(int ch, char *buf) #endif + + +unsigned char * +TkGetByteArrayFromObj( + Tcl_Obj *objPtr, + size_t *lengthPtr +) { + int length; + + unsigned char *result = Tcl_GetByteArrayFromObj(objPtr, &length); +#ifdef TCL_WIDE_INT_IS_LONG + if (sizeof(TCL_HASH_TYPE) > sizeof(int)) { + /* 64-bit and TIP #494 situation: */ + *lengthPtr = *(TCL_HASH_TYPE *) objPtr->internalRep.twoPtrValue.ptr1; + } else +#endif + /* 32-bit or without TIP #494 */ + *lengthPtr = (size_t) (unsigned) length; + return result; +} + /* * Local Variables: * mode: c diff --git a/generic/tkWindow.c b/generic/tkWindow.c index 9afb22f..bc57165 100644 --- a/generic/tkWindow.c +++ b/generic/tkWindow.c @@ -3202,8 +3202,8 @@ Initialize( */ { - int numBytes; - const char *bytes = Tcl_GetStringFromObj(nameObj, &numBytes); + size_t numBytes; + const char *bytes = TkGetStringFromObj(nameObj, &numBytes); classObj = Tcl_NewStringObj(bytes, numBytes); diff --git a/generic/ttk/ttkEntry.c b/generic/ttk/ttkEntry.c index 16a3bbe..5c8e98b 100644 --- a/generic/ttk/ttkEntry.c +++ b/generic/ttk/ttkEntry.c @@ -319,7 +319,7 @@ static char *EntryDisplayString(const char *showChar, int numChars) */ static void EntryUpdateTextLayout(Entry *entryPtr) { - int length; + size_t length; char *text; Tk_FreeTextLayout(entryPtr->entry.textLayout); if ((entryPtr->entry.numChars != 0) || (entryPtr->entry.placeholderObj == NULL)) { @@ -329,7 +329,7 @@ static void EntryUpdateTextLayout(Entry *entryPtr) 0/*wraplength*/, entryPtr->entry.justify, TK_IGNORE_NEWLINES, &entryPtr->entry.layoutWidth, &entryPtr->entry.layoutHeight); } else { - text = Tcl_GetStringFromObj(entryPtr->entry.placeholderObj, &length); + text = TkGetStringFromObj(entryPtr->entry.placeholderObj, &length); entryPtr->entry.textLayout = Tk_ComputeTextLayout( Tk_GetFontFromObj(entryPtr->core.tkwin, entryPtr->entry.fontObj), text, length, @@ -1303,9 +1303,9 @@ static void EntryDisplay(void *clientData, Drawable d) } /* Use placeholder text width */ leftIndex = 0; - Tcl_GetStringFromObj(entryPtr->entry.placeholderObj,&rightIndex); + Tcl_GetStringFromObj(entryPtr->entry.placeholderObj,&rightIndex); } else { - foregroundObj = es.foregroundObj; + foregroundObj = es.foregroundObj; } gc = EntryGetGC(entryPtr, foregroundObj, clipRegion); Tk_DrawTextLayout( @@ -1359,8 +1359,8 @@ EntryIndex( int *indexPtr) /* Return value */ { # define EntryWidth(e) (Tk_Width(entryPtr->core.tkwin)) /* Not Right */ - const char *string = Tcl_GetString(indexObj); - size_t length = indexObj->length; + size_t length; + const char *string = TkGetStringFromObj(indexObj, &length); if (strncmp(string, "end", length) == 0) { *indexPtr = entryPtr->entry.numChars; diff --git a/unix/tkUnixWm.c b/unix/tkUnixWm.c index 68ab6d6..0d14e03 100644 --- a/unix/tkUnixWm.c +++ b/unix/tkUnixWm.c @@ -36,7 +36,7 @@ typedef struct ProtocolHandler { } ProtocolHandler; #define HANDLER_SIZE(cmdLength) \ - ((unsigned) ((Tk_Offset(ProtocolHandler, command) + 1) + cmdLength)) + (((Tk_Offset(ProtocolHandler, command) + 1) + cmdLength)) /* * Data for [wm attributes] command: @@ -3005,7 +3005,7 @@ WmProtocolCmd( register ProtocolHandler *protPtr, *prevPtr; Atom protocol; const char *cmd; - int cmdLength; + size_t cmdLength; if ((objc < 3) || (objc > 5)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?name? ?command?"); @@ -3071,7 +3071,7 @@ WmProtocolCmd( break; } } - cmd = Tcl_GetStringFromObj(objv[4], &cmdLength); + cmd = TkGetStringFromObj(objv[4], &cmdLength); if (cmdLength > 0) { protPtr = ckalloc(HANDLER_SIZE(cmdLength)); protPtr->protocol = protocol; @@ -5450,8 +5450,8 @@ SetNetWmType( for (n = 0; n < objc; ++n) { Tcl_DString ds, dsName; - int len; - char *name = Tcl_GetStringFromObj(objv[n], &len); + size_t len; + char *name = TkGetStringFromObj(objv[n], &len); Tcl_UtfToUpper(name); Tcl_UtfToExternalDString(NULL, name, len, &dsName); |