diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2018-07-09 18:12:01 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2018-07-09 18:12:01 (GMT) |
commit | ac8ab4d638645c3ac8828e9aa4000c99df68c019 (patch) | |
tree | 39b2c04d67bb9eaf389e3a1f2ea56403fc825733 | |
parent | d07b440441377877d7b922abd0c153b0fccd2b68 (diff) | |
download | tk-ac8ab4d638645c3ac8828e9aa4000c99df68c019.zip tk-ac8ab4d638645c3ac8828e9aa4000c99df68c019.tar.gz tk-ac8ab4d638645c3ac8828e9aa4000c99df68c019.tar.bz2 |
Ongoing work (not finished yet) making Tk fully 64-bit size_t aware (see TIP #494) without compatibility macros
-rw-r--r-- | generic/tkBind.c | 5 | ||||
-rw-r--r-- | generic/tkCanvPs.c | 8 | ||||
-rw-r--r-- | generic/tkFont.c | 4 | ||||
-rw-r--r-- | generic/tkImgGIF.c | 32 | ||||
-rw-r--r-- | generic/tkImgPNG.c | 8 | ||||
-rw-r--r-- | generic/tkMain.c | 8 | ||||
-rw-r--r-- | generic/tkOption.c | 6 |
7 files changed, 40 insertions, 31 deletions
diff --git a/generic/tkBind.c b/generic/tkBind.c index 9594f29..295da46 100644 --- a/generic/tkBind.c +++ b/generic/tkBind.c @@ -21,6 +21,8 @@ #else #include "tkUnixInt.h" #endif +#undef Tcl_ScanElement +#undef Tcl_ConvertElement /* * File structure: @@ -1922,7 +1924,8 @@ ExpandPercents( Tcl_DString *dsPtr) /* Dynamic string in which to append new * command. */ { - int spaceNeeded, cvtFlags; /* Used to substitute string as proper Tcl + size_t spaceNeeded; + int cvtFlags; /* Used to substitute string as proper Tcl * list element. */ int number, flags, length; #define NUM_SIZE 40 diff --git a/generic/tkCanvPs.c b/generic/tkCanvPs.c index 2bfdcc5..496e0a7 100644 --- a/generic/tkCanvPs.c +++ b/generic/tkCanvPs.c @@ -491,7 +491,7 @@ TkCanvPostscriptCmd( Tcl_AppendObjToObj(psObj, preambleObj); if (psInfo.chan != NULL) { - if (Tcl_WriteObj(psInfo.chan, psObj) == -1) { + if ((size_t)Tcl_WriteObj(psInfo.chan, psObj) == (size_t)-1) { channelWriteFailed: Tcl_SetObjResult(interp, Tcl_ObjPrintf( "problem writing postscript data to channel: %s", @@ -545,7 +545,7 @@ TkCanvPostscriptCmd( psInfo.x, Tk_PostscriptY((double)psInfo.y2, (Tk_PostscriptInfo)psInfoPtr)); if (psInfo.chan != NULL) { - if (Tcl_WriteObj(psInfo.chan, psObj) == -1) { + if ((size_t)Tcl_WriteObj(psInfo.chan, psObj) == (size_t)-1) { goto channelWriteFailed; } Tcl_DecrRefCount(psObj); @@ -587,7 +587,7 @@ TkCanvPostscriptCmd( Tcl_AppendToObj(psObj, "grestore\n", -1); if (psInfo.chan != NULL) { - if (Tcl_WriteObj(psInfo.chan, psObj) == -1) { + if ((size_t)Tcl_WriteObj(psInfo.chan, psObj) == (size_t)-1) { goto channelWriteFailed; } Tcl_DecrRefCount(psObj); @@ -608,7 +608,7 @@ TkCanvPostscriptCmd( "%%EOF\n", -1); if (psInfo.chan != NULL) { - if (Tcl_WriteObj(psInfo.chan, psObj) == -1) { + if ((size_t)Tcl_WriteObj(psInfo.chan, psObj) == (size_t)-1) { goto channelWriteFailed; } } diff --git a/generic/tkFont.c b/generic/tkFont.c index f2140bf..834e944 100644 --- a/generic/tkFont.c +++ b/generic/tkFont.c @@ -563,9 +563,9 @@ Tk_FontObjCmd( if (charPtr != NULL) { const char *string = Tcl_GetString(charPtr); - int len = TkUtfToUniChar(string, &uniChar); + size_t len = TkUtfToUniChar(string, &uniChar); - if (len != charPtr->length) { + if (len != (size_t)charPtr->length) { resultPtr = Tcl_NewStringObj( "expected a single character but got \"", -1); Tcl_AppendLimitedToObj(resultPtr, string, diff --git a/generic/tkImgGIF.c b/generic/tkImgGIF.c index be90f06..ed4868b 100644 --- a/generic/tkImgGIF.c +++ b/generic/tkImgGIF.c @@ -55,7 +55,7 @@ typedef struct mFile { unsigned char *data; /* mmencoded source string */ int c; /* bits left over from previous character */ int state; /* decoder state (0-4 or GIF_DONE) */ - int length; /* Total amount of bytes in data */ + size_t length; /* Total amount of bytes in data */ } MFile; /* @@ -187,9 +187,9 @@ static int ReadImage(GIFImageConfig *gifConfPtr, * these are for the BASE64 image reader code only */ -static int Fread(GIFImageConfig *gifConfPtr, unsigned char *dst, +static size_t Fread(GIFImageConfig *gifConfPtr, unsigned char *dst, size_t size, size_t count, Tcl_Channel chan); -static int Mread(unsigned char *dst, size_t size, size_t count, +static size_t Mread(unsigned char *dst, size_t size, size_t count, MFile *handle); static int Mgetc(MFile *handle); static int char64(int c); @@ -917,7 +917,7 @@ ReadColorMap( unsigned char rgb[3]; for (i = 0; i < number; ++i) { - if (Fread(gifConfPtr, rgb, sizeof(rgb), 1, chan) <= 0) { + if (((size_t)Fread(gifConfPtr, rgb, sizeof(rgb), 1, chan) + 1) < 2) { return 0; } @@ -983,11 +983,11 @@ GetDataBlock( { unsigned char count; - if (Fread(gifConfPtr, &count, 1, 1, chan) <= 0) { + if (((size_t)Fread(gifConfPtr, &count, 1, 1, chan) + 1) < 2) { return -1; } - if ((count != 0) && (Fread(gifConfPtr, buf, count, 1, chan) <= 0)) { + if ((count != 0) && (((size_t)Fread(gifConfPtr, buf, count, 1, chan) + 1) < 2)) { return -1; } @@ -1049,7 +1049,7 @@ ReadImage( * Initialize the decoder */ - if (Fread(gifConfPtr, &initialCodeSize, 1, 1, chan) <= 0) { + if (((size_t)Fread(gifConfPtr, &initialCodeSize, 1, 1, chan) + 1) < 2) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "error reading GIF image: %s", Tcl_PosixError(interp))); return TCL_ERROR; @@ -1403,15 +1403,15 @@ mInit( *---------------------------------------------------------------------- */ -static int +static size_t Mread( unsigned char *dst, /* where to put the result */ size_t chunkSize, /* size of each transfer */ size_t numChunks, /* number of chunks */ MFile *handle) /* mmdecode "file" handle */ { - register int i, c; - int count = chunkSize * numChunks; + int c; + size_t i, count = chunkSize * numChunks; for (i=0; i<count && (c=Mgetc(handle)) != GIF_DONE; i++) { *dst++ = c; @@ -1552,7 +1552,7 @@ char64( *---------------------------------------------------------------------- */ -static int +static size_t Fread( GIFImageConfig *gifConfPtr, unsigned char *dst, /* where to put the result */ @@ -1566,20 +1566,20 @@ Fread( if (gifConfPtr->fromData == INLINE_DATA_BINARY) { MFile *handle = (MFile *) chan; - if (handle->length <= 0 || (size_t) handle->length < hunk*count) { - return -1; + if ((handle->length + 1 < 2) || (handle->length < hunk*count)) { + return (size_t)-1; } - memcpy(dst, handle->data, (size_t) (hunk * count)); + memcpy(dst, handle->data, hunk * count); handle->data += hunk * count; handle->length -= hunk * count; - return (int)(hunk * count); + return hunk * count; } /* * Otherwise we've got a real file to read. */ - return Tcl_Read(chan, (char *) dst, (int) (hunk * count)); + return Tcl_Read(chan, (char *) dst, hunk * count); } /* diff --git a/generic/tkImgPNG.c b/generic/tkImgPNG.c index bfb2457..c985c92 100644 --- a/generic/tkImgPNG.c +++ b/generic/tkImgPNG.c @@ -624,10 +624,10 @@ ReadData( } while (destSz) { - int blockSz = PNG_MIN(destSz, PNG_BLOCK_SZ); + size_t blockSz = PNG_MIN(destSz, PNG_BLOCK_SZ); - blockSz = Tcl_Read(pngPtr->channel, (char *)destPtr, blockSz); - if (blockSz < 0) { + blockSz = (size_t)Tcl_Read(pngPtr->channel, (char *)destPtr, blockSz); + if (blockSz == (size_t)-1) { /* TODO: failure info... */ Tcl_SetObjResult(interp, Tcl_ObjPrintf( "channel read failed: %s", Tcl_PosixError(interp))); @@ -2885,7 +2885,7 @@ WriteData( } memcpy(destPtr+objSz, srcPtr, srcSz); - } else if (Tcl_Write(pngPtr->channel, (const char *) srcPtr, srcSz) < 0) { + } else if ((size_t)Tcl_Write(pngPtr->channel, (const char *) srcPtr, srcSz) == (size_t)-1) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "write to channel failed: %s", Tcl_PosixError(interp))); return TCL_ERROR; diff --git a/generic/tkMain.c b/generic/tkMain.c index 87a3cf7..354ff6d 100644 --- a/generic/tkMain.c +++ b/generic/tkMain.c @@ -38,6 +38,9 @@ #else # include <stdlib.h> #endif +#undef Tcl_Gets +#undef Tcl_WriteObj +#undef Tcl_WriteChars extern int TkCygwinMainEx(int, char **, Tcl_AppInitProc *, Tcl_Interp *); @@ -420,14 +423,15 @@ StdinProc( int mask) /* Not used. */ { char *cmd; - int code, count; + int code; + size_t count; InteractiveState *isPtr = clientData; Tcl_Channel chan = isPtr->input; Tcl_Interp *interp = isPtr->interp; count = Tcl_Gets(chan, &isPtr->line); - if (count < 0 && !isPtr->gotPartial) { + if (count == (size_t)-1 && !isPtr->gotPartial) { if (isPtr->tty) { Tcl_Exit(0); } else { diff --git a/generic/tkOption.c b/generic/tkOption.c index 24e7fb3..c837a50 100644 --- a/generic/tkOption.c +++ b/generic/tkOption.c @@ -13,6 +13,7 @@ */ #include "tkInt.h" +#undef Tcl_ReadChars /* * The option database is stored as one tree for each main window. Each name @@ -1081,7 +1082,8 @@ ReadOptionFile( { const char *realName; Tcl_Obj *buffer; - int result, bufferSize; + int result; + size_t bufferSize; Tcl_Channel chan; Tcl_DString newName; @@ -1112,7 +1114,7 @@ ReadOptionFile( Tcl_IncrRefCount(buffer); Tcl_SetChannelOption(NULL, chan, "-encoding", "utf-8"); bufferSize = Tcl_ReadChars(chan, buffer, -1, 0); - if (bufferSize < 0) { + if (bufferSize == (size_t)-1) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "error reading file \"%s\": %s", fileName, Tcl_PosixError(interp))); |