Tk Source Code

Check-in [bda7be3d]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to tclconference@googlegroups.com
or submit via the online form by Sep 9.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Promote some internal variables from int to size_t. This makes Tk compile with TIP #494-enabled Tcl, without the need for -DTCL_USE_INT_RETURN
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:bda7be3dee5f41499bdc0bbeedf3c613eeb8ef0718b63a9698c9e463b22ba686
User & Date: jan.nijtmans 2018-07-11 19:55:48
Context
2018-07-17
18:49
Fix [1088825fff]: frame-3.9 and frame-3.10 fail on macOS check-in: d7225b61 user: fvogel tags: trunk
2018-07-11
19:55
Promote some internal variables from int to size_t. This makes Tk compile with TIP #494-enabled Tcl, without the need for -DTCL_USE_INT_RETURN check-in: bda7be3d user: jan.nijtmans tags: trunk
2018-07-10
19:22
Make Tk sufficiently 64-bit aware in order to withstand TIP #494 possible problems Closed-Leaf check-in: 785b85f4 user: jan.nijtmans tags: tip-494
2018-07-09
18:10
Make Tk compile with TIP #494 (being tested now) using compatibility macros. Without TIP #494 there is no effect check-in: cc2ef92f user: jan.nijtmans tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to generic/tkBind.c.

  1918   1918       KeySym keySym,		/* KeySym: only relevant for KeyPress and
  1919   1919   				 * KeyRelease events). */
  1920   1920       unsigned int scriptCount,	/* The number of script-based binding patterns
  1921   1921   				 * matched so far for this event. */
  1922   1922       Tcl_DString *dsPtr)		/* Dynamic string in which to append new
  1923   1923   				 * command. */
  1924   1924   {
  1925         -    int spaceNeeded, cvtFlags;	/* Used to substitute string as proper Tcl
         1925  +    size_t spaceNeeded;
         1926  +    int cvtFlags;	/* Used to substitute string as proper Tcl
  1926   1927   				 * list element. */
  1927   1928       int number, flags, length;
  1928   1929   #define NUM_SIZE 40
  1929   1930       const char *string;
  1930   1931       Tcl_DString buf;
  1931   1932       char numStorage[NUM_SIZE+1];
  1932   1933   

Changes to generic/tkCanvPs.c.

   487    487   	/*
   488    488   	 * Insert the prolog
   489    489   	 */
   490    490   
   491    491   	Tcl_AppendObjToObj(psObj, preambleObj);
   492    492   
   493    493   	if (psInfo.chan != NULL) {
   494         -	    if (Tcl_WriteObj(psInfo.chan, psObj) == -1) {
          494  +	    if ((size_t)Tcl_WriteObj(psInfo.chan, psObj) == (size_t)-1) {
   495    495   	    channelWriteFailed:
   496    496   		Tcl_SetObjResult(interp, Tcl_ObjPrintf(
   497    497   			"problem writing postscript data to channel: %s",
   498    498   			Tcl_PosixError(interp)));
   499    499   		result = TCL_ERROR;
   500    500   		goto cleanup;
   501    501   	    }
................................................................................
   541    541   		psInfo.x2, Tk_PostscriptY((double)psInfo.y,
   542    542   			(Tk_PostscriptInfo)psInfoPtr),
   543    543   		psInfo.x2, Tk_PostscriptY((double)psInfo.y2,
   544    544   			(Tk_PostscriptInfo)psInfoPtr),
   545    545   		psInfo.x, Tk_PostscriptY((double)psInfo.y2,
   546    546   			(Tk_PostscriptInfo)psInfoPtr));
   547    547   	if (psInfo.chan != NULL) {
   548         -	    if (Tcl_WriteObj(psInfo.chan, psObj) == -1) {
          548  +	    if ((size_t)Tcl_WriteObj(psInfo.chan, psObj) == (size_t)-1) {
   549    549   		goto channelWriteFailed;
   550    550   	    }
   551    551   	    Tcl_DecrRefCount(psObj);
   552    552   	    psObj = Tcl_NewObj();
   553    553   	}
   554    554       }
   555    555   
................................................................................
   583    583   	}
   584    584   
   585    585   	Tcl_AppendToObj(psObj, "gsave\n", -1);
   586    586   	Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
   587    587   	Tcl_AppendToObj(psObj, "grestore\n", -1);
   588    588   
   589    589   	if (psInfo.chan != NULL) {
   590         -	    if (Tcl_WriteObj(psInfo.chan, psObj) == -1) {
          590  +	    if ((size_t)Tcl_WriteObj(psInfo.chan, psObj) == (size_t)-1) {
   591    591   		goto channelWriteFailed;
   592    592   	    }
   593    593   	    Tcl_DecrRefCount(psObj);
   594    594   	    psObj = Tcl_NewObj();
   595    595   	}
   596    596       }
   597    597   
................................................................................
   604    604   	Tcl_AppendToObj(psObj,
   605    605   		"restore showpage\n\n"
   606    606   		"%%Trailer\n"
   607    607   		"end\n"
   608    608   		"%%EOF\n", -1);
   609    609   
   610    610   	if (psInfo.chan != NULL) {
   611         -	    if (Tcl_WriteObj(psInfo.chan, psObj) == -1) {
          611  +	    if ((size_t)Tcl_WriteObj(psInfo.chan, psObj) == (size_t)-1) {
   612    612   		goto channelWriteFailed;
   613    613   	    }
   614    614   	}
   615    615       }
   616    616   
   617    617       if (psInfo.chan == NULL) {
   618    618   	Tcl_SetObjResult(interp, psObj);

Changes to generic/tkFont.c.

   559    559   
   560    560   	/*
   561    561   	 * The 'charPtr' arg must be a single Unicode.
   562    562   	 */
   563    563   
   564    564   	if (charPtr != NULL) {
   565    565   	    const char *string = Tcl_GetString(charPtr);
   566         -	    int len = TkUtfToUniChar(string, &uniChar);
          566  +	    size_t len = TkUtfToUniChar(string, &uniChar);
   567    567   
   568         -	    if (len != charPtr->length) {
          568  +	    if (len != (size_t)charPtr->length) {
   569    569   		resultPtr = Tcl_NewStringObj(
   570    570   			"expected a single character but got \"", -1);
   571    571   		Tcl_AppendLimitedToObj(resultPtr, string,
   572    572   			-1, 40, "...");
   573    573   		Tcl_AppendToObj(resultPtr, "\"", -1);
   574    574   		Tcl_SetObjResult(interp, resultPtr);
   575    575   		Tcl_SetErrorCode(interp, "TK", "VALUE", "FONT_SAMPLE", NULL);

Changes to generic/tkImgBmap.c.

  1075   1075    */
  1076   1076   
  1077   1077   static int
  1078   1078   GetByte(
  1079   1079       Tcl_Channel chan)	/* The channel we read from. */
  1080   1080   {
  1081   1081       char buffer;
  1082         -    int size;
         1082  +    size_t size;
  1083   1083   
  1084   1084       size = Tcl_Read(chan, &buffer, 1);
  1085         -    if (size <= 0) {
         1085  +    if ((size + 1) < 2) {
  1086   1086   	return EOF;
  1087   1087       } else {
  1088   1088   	return buffer;
  1089   1089       }
  1090   1090   }
  1091   1091   
  1092   1092   /*

Changes to generic/tkImgGIF.c.

    51     51    * state keeps track of which byte we are about to read, or EOF.
    52     52    */
    53     53   
    54     54   typedef struct mFile {
    55     55       unsigned char *data;	/* mmencoded source string */
    56     56       int c;			/* bits left over from previous character */
    57     57       int state;			/* decoder state (0-4 or GIF_DONE) */
    58         -    int length;			/* Total amount of bytes in data */
           58  +    size_t length;			/* Total amount of bytes in data */
    59     59   } MFile;
    60     60   
    61     61   /*
    62     62    * Non-ASCII encoding support:
    63     63    * Most data in a GIF image is binary and is treated as such. However, a few
    64     64    * key bits are stashed in ASCII. If we try to compare those pieces to the
    65     65    * char they represent, it will fail on any non-ASCII (eg, EBCDIC) system. To
................................................................................
   107    107   } GIFImageConfig;
   108    108   
   109    109   /*
   110    110    * Type of a function used to do the writing to a file or buffer when
   111    111    * serializing in the GIF format.
   112    112    */
   113    113   
   114         -typedef int (WriteBytesFunc) (ClientData clientData, const char *bytes,
   115         -			    int byteCount);
          114  +typedef size_t (WriteBytesFunc) (ClientData clientData, const char *bytes,
          115  +			    size_t byteCount);
   116    116   
   117    117   /*
   118    118    * The format record for the GIF file format:
   119    119    */
   120    120   
   121    121   static int		FileMatchGIF(Tcl_Channel chan, const char *fileName,
   122    122   			    Tcl_Obj *format, int *widthPtr, int *heightPtr,
................................................................................
   183    183   			    unsigned char cmap[MAXCOLORMAPSIZE][4], int srcX,
   184    184   			    int srcY, int interlace, int transparent);
   185    185   
   186    186   /*
   187    187    * these are for the BASE64 image reader code only
   188    188    */
   189    189   
   190         -static int		Fread(GIFImageConfig *gifConfPtr, unsigned char *dst,
          190  +static size_t		Fread(GIFImageConfig *gifConfPtr, unsigned char *dst,
   191    191   			    size_t size, size_t count, Tcl_Channel chan);
   192         -static int		Mread(unsigned char *dst, size_t size, size_t count,
          192  +static size_t		Mread(unsigned char *dst, size_t size, size_t count,
   193    193   			    MFile *handle);
   194    194   static int		Mgetc(MFile *handle);
   195    195   static int		char64(int c);
   196    196   static void		mInit(unsigned char *string, MFile *handle,
   197         -			    int length);
          197  +			    size_t length);
   198    198   
   199    199   /*
   200    200    * Types, defines and variables needed to write and compress a GIF.
   201    201    */
   202    202   
   203    203   #define LSB(a)		((unsigned char) (((short)(a)) & 0x00FF))
   204    204   #define MSB(a)		((unsigned char) (((short)(a)) >> 8))
................................................................................
   913    913       int number,
   914    914       unsigned char buffer[MAXCOLORMAPSIZE][4])
   915    915   {
   916    916       int i;
   917    917       unsigned char rgb[3];
   918    918   
   919    919       for (i = 0; i < number; ++i) {
   920         -	if (Fread(gifConfPtr, rgb, sizeof(rgb), 1, chan) <= 0) {
          920  +	if (((size_t)Fread(gifConfPtr, rgb, sizeof(rgb), 1, chan) + 1) < 2) {
   921    921   	    return 0;
   922    922   	}
   923    923   
   924    924   	if (buffer) {
   925    925   	    buffer[i][CM_RED] = rgb[0];
   926    926   	    buffer[i][CM_GREEN] = rgb[1];
   927    927   	    buffer[i][CM_BLUE] = rgb[2];
................................................................................
   979    979   GetDataBlock(
   980    980       GIFImageConfig *gifConfPtr,
   981    981       Tcl_Channel chan,
   982    982       unsigned char *buf)
   983    983   {
   984    984       unsigned char count;
   985    985   
   986         -    if (Fread(gifConfPtr, &count, 1, 1, chan) <= 0) {
          986  +    if (((size_t)Fread(gifConfPtr, &count, 1, 1, chan) + 1) < 2) {
   987    987   	return -1;
   988    988       }
   989    989   
   990         -    if ((count != 0) && (Fread(gifConfPtr, buf, count, 1, chan) <= 0)) {
          990  +    if ((count != 0) && (((size_t)Fread(gifConfPtr, buf, count, 1, chan) + 1) < 2)) {
   991    991   	return -1;
   992    992       }
   993    993   
   994    994       return count;
   995    995   }
   996    996   
   997    997   /*
................................................................................
  1045   1045       int codeSize, clearCode, inCode, endCode, oldCode, maxCode;
  1046   1046       int code, firstCode, v;
  1047   1047   
  1048   1048       /*
  1049   1049        * Initialize the decoder
  1050   1050        */
  1051   1051   
  1052         -    if (Fread(gifConfPtr, &initialCodeSize, 1, 1, chan) <= 0) {
         1052  +    if (((size_t)Fread(gifConfPtr, &initialCodeSize, 1, 1, chan) + 1) < 2) {
  1053   1053   	Tcl_SetObjResult(interp, Tcl_ObjPrintf(
  1054   1054   		"error reading GIF image: %s", Tcl_PosixError(interp)));
  1055   1055   	return TCL_ERROR;
  1056   1056       }
  1057   1057   
  1058   1058       if (initialCodeSize > MAX_LWZ_BITS) {
  1059   1059   	Tcl_SetObjResult(interp, Tcl_NewStringObj("malformed image", -1));
................................................................................
  1373   1373    *----------------------------------------------------------------------
  1374   1374    */
  1375   1375   
  1376   1376   static void
  1377   1377   mInit(
  1378   1378       unsigned char *string,	/* string containing initial mmencoded data */
  1379   1379       MFile *handle,		/* mmdecode "file" handle */
  1380         -    int length)			/* Number of bytes in string */
         1380  +    size_t length)			/* Number of bytes in string */
  1381   1381   {
  1382   1382       handle->data = string;
  1383   1383       handle->state = 0;
  1384   1384       handle->c = 0;
  1385   1385       handle->length = length;
  1386   1386   }
  1387   1387   
................................................................................
  1399   1399    *
  1400   1400    * Side effects:
  1401   1401    *	The base64 handle will change state.
  1402   1402    *
  1403   1403    *----------------------------------------------------------------------
  1404   1404    */
  1405   1405   
  1406         -static int
         1406  +static size_t
  1407   1407   Mread(
  1408   1408       unsigned char *dst,		/* where to put the result */
  1409   1409       size_t chunkSize,		/* size of each transfer */
  1410   1410       size_t numChunks,		/* number of chunks */
  1411   1411       MFile *handle)		/* mmdecode "file" handle */
  1412   1412   {
  1413         -    register int i, c;
  1414         -    int count = chunkSize * numChunks;
         1413  +    int c;
         1414  +    size_t i, count = chunkSize * numChunks;
  1415   1415   
  1416   1416       for (i=0; i<count && (c=Mgetc(handle)) != GIF_DONE; i++) {
  1417   1417   	*dst++ = c;
  1418   1418       }
  1419   1419       return i;
  1420   1420   }
  1421   1421   
................................................................................
  1548   1548    *	a base64 encoded string.
  1549   1549    *
  1550   1550    * Results: - same as POSIX fread() or Tcl Tcl_Read()
  1551   1551    *
  1552   1552    *----------------------------------------------------------------------
  1553   1553    */
  1554   1554   
  1555         -static int
         1555  +static size_t
  1556   1556   Fread(
  1557   1557       GIFImageConfig *gifConfPtr,
  1558   1558       unsigned char *dst,		/* where to put the result */
  1559   1559       size_t hunk, size_t count,	/* how many */
  1560   1560       Tcl_Channel chan)
  1561   1561   {
  1562   1562       if (gifConfPtr->fromData == INLINE_DATA_BASE64) {
  1563   1563   	return Mread(dst, hunk, count, (MFile *) chan);
  1564   1564       }
  1565   1565   
  1566   1566       if (gifConfPtr->fromData == INLINE_DATA_BINARY) {
  1567   1567   	MFile *handle = (MFile *) chan;
  1568   1568   
  1569         -	if (handle->length <= 0 || (size_t) handle->length < hunk*count) {
  1570         -	    return -1;
         1569  +	if ((handle->length + 1 < 2) || (handle->length < hunk*count)) {
         1570  +	    return (size_t)-1;
  1571   1571   	}
  1572         -	memcpy(dst, handle->data, (size_t) (hunk * count));
         1572  +	memcpy(dst, handle->data, hunk * count);
  1573   1573   	handle->data += hunk * count;
  1574   1574   	handle->length -= hunk * count;
  1575         -	return (int)(hunk * count);
         1575  +	return hunk * count;
  1576   1576       }
  1577   1577   
  1578   1578       /*
  1579   1579        * Otherwise we've got a real file to read.
  1580   1580        */
  1581   1581   
  1582         -    return Tcl_Read(chan, (char *) dst, (int) (hunk * count));
         1582  +    return Tcl_Read(chan, (char *) dst, hunk * count);
  1583   1583   }
  1584   1584   
  1585   1585   /*
  1586   1586    * ChanWriteGIF - writes a image in GIF format.
  1587   1587    *-------------------------------------------------------------------------
  1588   1588    * Author:		Lolo
  1589   1589    *			Engeneering Projects Area
................................................................................
  1654   1654       if (result == TCL_OK) {
  1655   1655   	Tcl_SetObjResult(interp, objPtr);
  1656   1656       }
  1657   1657       Tcl_DecrRefCount(objPtr);
  1658   1658       return result;
  1659   1659   }
  1660   1660   
  1661         -static int
         1661  +static size_t
  1662   1662   WriteToChannel(
  1663   1663       ClientData clientData,
  1664   1664       const char *bytes,
  1665         -    int byteCount)
         1665  +    size_t byteCount)
  1666   1666   {
  1667   1667       Tcl_Channel handle = clientData;
  1668   1668   
  1669   1669       return Tcl_Write(handle, bytes, byteCount);
  1670   1670   }
  1671   1671   
  1672         -static int
         1672  +static size_t
  1673   1673   WriteToByteArray(
  1674   1674       ClientData clientData,
  1675   1675       const char *bytes,
  1676         -    int byteCount)
         1676  +    size_t byteCount)
  1677   1677   {
  1678   1678       Tcl_Obj *objPtr = clientData;
  1679   1679       Tcl_Obj *tmpObj = Tcl_NewByteArrayObj((unsigned char *) bytes, byteCount);
  1680   1680   
  1681   1681       Tcl_IncrRefCount(tmpObj);
  1682   1682       Tcl_AppendObjToObj(objPtr, tmpObj);
  1683   1683       Tcl_DecrRefCount(tmpObj);

Changes to generic/tkImgPNG.c.

   620    620       if (pngPtr->base64Data) {
   621    621   	return ReadBase64(interp, pngPtr, destPtr, destSz, crcPtr);
   622    622       } else if (pngPtr->strDataBuf) {
   623    623   	return ReadByteArray(interp, pngPtr, destPtr, destSz, crcPtr);
   624    624       }
   625    625   
   626    626       while (destSz) {
   627         -	int blockSz = PNG_MIN(destSz, PNG_BLOCK_SZ);
          627  +	size_t blockSz = PNG_MIN(destSz, PNG_BLOCK_SZ);
   628    628   
   629         -	blockSz = Tcl_Read(pngPtr->channel, (char *)destPtr, blockSz);
   630         -	if (blockSz < 0) {
          629  +	blockSz = (size_t)Tcl_Read(pngPtr->channel, (char *)destPtr, blockSz);
          630  +	if (blockSz == (size_t)-1) {
   631    631   	    /* TODO: failure info... */
   632    632   	    Tcl_SetObjResult(interp, Tcl_ObjPrintf(
   633    633   		    "channel read failed: %s", Tcl_PosixError(interp)));
   634    634   	    return TCL_ERROR;
   635    635   	}
   636    636   
   637    637   	/*
................................................................................
  2881   2881   	    Tcl_SetObjResult(interp, Tcl_NewStringObj(
  2882   2882   		    "memory allocation failed", -1));
  2883   2883   	    Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL);
  2884   2884   	    return TCL_ERROR;
  2885   2885   	}
  2886   2886   
  2887   2887   	memcpy(destPtr+objSz, srcPtr, srcSz);
  2888         -    } else if (Tcl_Write(pngPtr->channel, (const char *) srcPtr, srcSz) < 0) {
         2888  +    } else if ((size_t)Tcl_Write(pngPtr->channel, (const char *) srcPtr, srcSz) == (size_t)-1) {
  2889   2889   	Tcl_SetObjResult(interp, Tcl_ObjPrintf(
  2890   2890   		"write to channel failed: %s", Tcl_PosixError(interp)));
  2891   2891   	return TCL_ERROR;
  2892   2892       }
  2893   2893   
  2894   2894       return TCL_OK;
  2895   2895   }

Changes to generic/tkImgPPM.c.

   137    137   				 * image to be written to. */
   138    138       int width, int height,	/* Dimensions of block of photo image to be
   139    139   				 * written to. */
   140    140       int srcX, int srcY)		/* Coordinates of top-left pixel to be used in
   141    141   				 * image being read. */
   142    142   {
   143    143       int fileWidth, fileHeight, maxIntensity;
   144         -    int nLines, nBytes, h, type, count, bytesPerChannel = 1;
          144  +    int nLines, h, type, bytesPerChannel = 1;
          145  +    size_t nBytes, count;
   145    146       unsigned char *pixelPtr;
   146    147       Tk_PhotoImageBlock block;
   147    148   
   148    149       type = ReadPPMFileHeader(chan, &fileWidth, &fileHeight, &maxIntensity);
   149    150       if (type == 0) {
   150    151   	Tcl_SetObjResult(interp, Tcl_ObjPrintf(
   151    152   		"couldn't read raw PPM header from file \"%s\"", fileName));
................................................................................
   281    282   FileWritePPM(
   282    283       Tcl_Interp *interp,
   283    284       const char *fileName,
   284    285       Tcl_Obj *format,
   285    286       Tk_PhotoImageBlock *blockPtr)
   286    287   {
   287    288       Tcl_Channel chan;
   288         -    int w, h, greenOffset, blueOffset, nBytes;
          289  +    int w, h, greenOffset, blueOffset;
          290  +    size_t nBytes;
   289    291       unsigned char *pixelPtr, *pixLinePtr;
   290    292       char header[16 + TCL_INTEGER_SPACE * 2];
   291    293   
   292    294       chan = Tcl_OpenFileChannel(interp, fileName, "w", 0666);
   293    295       if (chan == NULL) {
   294    296   	return TCL_ERROR;
   295    297       }
................................................................................
   311    313       pixLinePtr = blockPtr->pixelPtr + blockPtr->offset[0];
   312    314       greenOffset = blockPtr->offset[1] - blockPtr->offset[0];
   313    315       blueOffset = blockPtr->offset[2] - blockPtr->offset[0];
   314    316   
   315    317       if ((greenOffset == 1) && (blueOffset == 2) && (blockPtr->pixelSize == 3)
   316    318   	    && (blockPtr->pitch == (blockPtr->width * 3))) {
   317    319   	nBytes = blockPtr->height * blockPtr->pitch;
   318         -	if (Tcl_Write(chan, (char *) pixLinePtr, nBytes) != nBytes) {
          320  +	if ((size_t)Tcl_Write(chan, (char *) pixLinePtr, nBytes) != nBytes) {
   319    321   	    goto writeerror;
   320    322   	}
   321    323       } else {
   322    324   	for (h = blockPtr->height; h > 0; h--) {
   323    325   	    pixelPtr = pixLinePtr;
   324    326   	    for (w = blockPtr->width; w > 0; w--) {
   325         -		if (    Tcl_Write(chan,(char *)&pixelPtr[0], 1) == -1 ||
   326         -			Tcl_Write(chan,(char *)&pixelPtr[greenOffset],1)==-1 ||
   327         -			Tcl_Write(chan,(char *)&pixelPtr[blueOffset],1) ==-1) {
          327  +		if ((size_t)Tcl_Write(chan,(char *)&pixelPtr[0], 1) == (size_t)-1 ||
          328  +			(size_t)Tcl_Write(chan,(char *)&pixelPtr[greenOffset],1)==(size_t)-1 ||
          329  +			(size_t)Tcl_Write(chan,(char *)&pixelPtr[blueOffset],1) ==(size_t)-1) {
   328    330   		    goto writeerror;
   329    331   		}
   330    332   		pixelPtr += blockPtr->pixelSize;
   331    333   	    }
   332    334   	    pixLinePtr += blockPtr->pitch;
   333    335   	}
   334    336       }

Changes to generic/tkInt.h.

   820    820   
   821    821   /*
   822    822    * Real definition of some events. Note that these events come from outside
   823    823    * but have internally generated pieces added to them.
   824    824    */
   825    825   
   826    826   typedef struct {
   827         -    XKeyEvent keyEvent;		/* The real event from X11. */
   828         -    char *charValuePtr;		/* A pointer to a string that holds the key's
          827  +    XKeyEvent keyEvent;	/* The real event from X11. */
          828  +    char *charValuePtr;	/* A pointer to a string that holds the key's
   829    829   				 * %A substitution text (before backslash
   830    830   				 * adding), or NULL if that has not been
   831    831   				 * computed yet. If non-NULL, this string was
   832    832   				 * allocated with ckalloc(). */
   833         -    int charValueLen;		/* Length of string in charValuePtr when that
          833  +    size_t charValueLen;	/* Length of string in charValuePtr when that
   834    834   				 * is non-NULL. */
   835    835       KeySym keysym;		/* Key symbol computed after input methods
   836    836   				 * have been invoked */
   837    837   } TkKeyEvent;
   838    838   
   839    839   /*
   840    840    * Flags passed to TkpMakeMenuWindow's 'transient' argument.

Changes to generic/tkMain.c.

   416    416       /* ARGSUSED */
   417    417   static void
   418    418   StdinProc(
   419    419       ClientData clientData,	/* The state of interactive cmd line */
   420    420       int mask)			/* Not used. */
   421    421   {
   422    422       char *cmd;
   423         -    int code, count;
          423  +    int code;
          424  +    size_t count;
   424    425       InteractiveState *isPtr = clientData;
   425    426       Tcl_Channel chan = isPtr->input;
   426    427       Tcl_Interp *interp = isPtr->interp;
   427    428   
   428    429       count = Tcl_Gets(chan, &isPtr->line);
   429    430   
   430         -    if (count < 0 && !isPtr->gotPartial) {
          431  +    if (count == (size_t)-1 && !isPtr->gotPartial) {
   431    432   	if (isPtr->tty) {
   432    433   	    Tcl_Exit(0);
   433    434   	} else {
   434    435   	    Tcl_DeleteChannelHandler(chan, StdinProc, isPtr);
   435    436   	}
   436    437   	return;
   437    438       }

Changes to generic/tkOption.c.

  1077   1077       int priority)		/* Priority level to use for options in this
  1078   1078   				 * file, such as TK_USER_DEFAULT_PRIO or
  1079   1079   				 * TK_INTERACTIVE_PRIO. Must be between 0 and
  1080   1080   				 * TK_MAX_PRIO. */
  1081   1081   {
  1082   1082       const char *realName;
  1083   1083       Tcl_Obj *buffer;
  1084         -    int result, bufferSize;
         1084  +    int result;
         1085  +    size_t bufferSize;
  1085   1086       Tcl_Channel chan;
  1086   1087       Tcl_DString newName;
  1087   1088   
  1088   1089       /*
  1089   1090        * Prevent file system access in a safe interpreter.
  1090   1091        */
  1091   1092   
................................................................................
  1108   1109   	return TCL_ERROR;
  1109   1110       }
  1110   1111   
  1111   1112       buffer = Tcl_NewObj();
  1112   1113       Tcl_IncrRefCount(buffer);
  1113   1114       Tcl_SetChannelOption(NULL, chan, "-encoding", "utf-8");
  1114   1115       bufferSize = Tcl_ReadChars(chan, buffer, -1, 0);
  1115         -    if (bufferSize < 0) {
         1116  +    if (bufferSize == (size_t)-1) {
  1116   1117   	Tcl_SetObjResult(interp, Tcl_ObjPrintf(
  1117   1118   		"error reading file \"%s\": %s",
  1118   1119   		fileName, Tcl_PosixError(interp)));
  1119   1120   	Tcl_Close(NULL, chan);
  1120   1121   	return TCL_ERROR;
  1121   1122       }
  1122   1123       Tcl_Close(NULL, chan);

Changes to generic/tkUtil.c.

   729    729       int *intPtr)		/* Filled in with number of pages or lines to
   730    730   				 * scroll, if any. */
   731    731   {
   732    732       const char *arg = Tcl_GetString(objv[2]);
   733    733       size_t length = objv[2]->length;
   734    734   
   735    735   #define ArgPfxEq(str) \
   736         -	((arg[0] == str[0]) && !strncmp(arg, str, (unsigned)length))
          736  +	((arg[0] == str[0]) && !strncmp(arg, str, length))
   737    737   
   738    738       if (ArgPfxEq("moveto")) {
   739    739   	if (objc != 4) {
   740    740   	    Tcl_WrongNumArgs(interp, 2, objv, "moveto fraction");
   741    741   	    return TK_SCROLL_ERROR;
   742    742   	}
   743    743   	if (Tcl_GetDoubleFromObj(interp, objv[3], dblPtr) != TCL_OK) {

Changes to generic/ttk/ttkState.c.

   126    126   
   127    127   static void StateSpecUpdateString(Tcl_Obj *objPtr)
   128    128   {
   129    129       unsigned int onbits = (objPtr->internalRep.longValue & 0xFFFF0000) >> 16;
   130    130       unsigned int offbits = objPtr->internalRep.longValue & 0x0000FFFF;
   131    131       unsigned int mask = onbits | offbits;
   132    132       Tcl_DString result;
   133         -    int i, len;
          133  +    int i;
          134  +    size_t len;
   134    135   
   135    136       Tcl_DStringInit(&result);
   136    137   
   137    138       for (i=0; stateNames[i] != NULL; ++i) {
   138    139   	if (mask & (1<<i)) {
   139    140   	    if (offbits & (1<<i))
   140    141   		Tcl_DStringAppend(&result, "!", 1);
................................................................................
   142    143   	    Tcl_DStringAppend(&result, " ", 1);
   143    144   	}
   144    145       }
   145    146   
   146    147       len = Tcl_DStringLength(&result);
   147    148       if (len) {
   148    149   	/* 'len' includes extra trailing ' ' */
   149         -	objPtr->bytes = Tcl_Alloc((unsigned)len);
          150  +	objPtr->bytes = Tcl_Alloc(len);
   150    151   	objPtr->length = len-1;
   151         -	strncpy(objPtr->bytes, Tcl_DStringValue(&result), (size_t)len-1);
          152  +	strncpy(objPtr->bytes, Tcl_DStringValue(&result), len-1);
   152    153   	objPtr->bytes[len-1] = '\0';
   153    154       } else {
   154    155   	/* empty string */
   155    156   	objPtr->length = 0;
   156    157   	objPtr->bytes = Tcl_Alloc(1);
   157    158   	*objPtr->bytes = '\0';
   158    159       }

Changes to unix/Makefile.in.

   133    133   CFLAGS_OPTIMIZE		= @CFLAGS_OPTIMIZE@
   134    134   
   135    135   # To change the compiler switches, for example to change from optimization to
   136    136   # debugging symbols, change the following line:
   137    137   #CFLAGS			= $(CFLAGS_DEBUG)
   138    138   #CFLAGS			= $(CFLAGS_OPTIMIZE)
   139    139   #CFLAGS			= $(CFLAGS_DEBUG) $(CFLAGS_OPTIMIZE)
   140         -CFLAGS			= @CFLAGS_DEFAULT@ @CFLAGS@ -DTCL_USE_INT_RETURN
          140  +CFLAGS			= @CFLAGS_DEFAULT@ @CFLAGS@ 
   141    141   
   142    142   # Flags to pass to the linker
   143    143   LDFLAGS_DEBUG		= @LDFLAGS_DEBUG@
   144    144   LDFLAGS_OPTIMIZE	= @LDFLAGS_OPTIMIZE@
   145    145   LDFLAGS			= @LDFLAGS_DEFAULT@ @LDFLAGS@
   146    146   
   147    147   # A "-I" switch that can be used when compiling to make all of the

Changes to unix/tkUnixKey.c.

   106    106   
   107    107   const char *
   108    108   TkpGetString(
   109    109       TkWindow *winPtr,		/* Window where event occurred */
   110    110       XEvent *eventPtr,		/* X keyboard event. */
   111    111       Tcl_DString *dsPtr)		/* Initialized, empty string to hold result. */
   112    112   {
   113         -    int len, mincode, maxcode;
          113  +    size_t len;
          114  +    int mincode, maxcode;
   114    115       Tcl_DString buf;
   115    116       TkKeyEvent *kePtr = (TkKeyEvent *) eventPtr;
   116    117   
   117    118       /*
   118    119        * If we have the value cached already, use it now. [Bug 1373712]
   119    120        */
   120    121   
   121    122       if (kePtr->charValuePtr != NULL) {
   122    123   	Tcl_DStringSetLength(dsPtr, kePtr->charValueLen);
   123    124   	memcpy(Tcl_DStringValue(dsPtr), kePtr->charValuePtr,
   124         -		(unsigned) kePtr->charValueLen+1);
          125  +		kePtr->charValueLen+1);
   125    126   	return Tcl_DStringValue(dsPtr);
   126    127       }
   127    128   
   128    129       /*
   129    130        * Only do this for KeyPress events, otherwise
   130    131        * further Xlib function behavior might be undefined.
   131    132        */
................................................................................
   242    243        * function, we will be able to produce it without asking X. This stops us
   243    244        * from having to reenter the XIM engine. [Bug 1373712]
   244    245        */
   245    246   
   246    247   done:
   247    248       kePtr->charValuePtr = ckalloc(len + 1);
   248    249       kePtr->charValueLen = len;
   249         -    memcpy(kePtr->charValuePtr, Tcl_DStringValue(dsPtr), (unsigned) len + 1);
          250  +    memcpy(kePtr->charValuePtr, Tcl_DStringValue(dsPtr), len + 1);
   250    251       return Tcl_DStringValue(dsPtr);
   251    252   }
   252    253   
   253    254   /*
   254    255    * When mapping from a keysym to a keycode, need information about the
   255    256    * modifier state to be used so that when they call TkKeycodeToKeysym taking
   256    257    * into account the xkey.state, they will get back the original keysym.

Changes to win/Makefile.in.

   166    166   LDFLAGS_OPTIMIZE = @LDFLAGS_OPTIMIZE@
   167    167   
   168    168   # To change the compiler switches, for example to change from optimization to
   169    169   # debugging symbols, change the following line:
   170    170   #CFLAGS		= $(CFLAGS_DEBUG)
   171    171   #CFLAGS		= $(CFLAGS_OPTIMIZE)
   172    172   #CFLAGS		= $(CFLAGS_DEBUG) $(CFLAGS_OPTIMIZE)
   173         -CFLAGS		= @CFLAGS@ @CFLAGS_DEFAULT@ -DUNICODE -D_UNICODE -D_ATL_XP_TARGETING -DTCL_USE_INT_RETURN
          173  +CFLAGS		= @CFLAGS@ @CFLAGS_DEFAULT@ -DUNICODE -D_UNICODE -D_ATL_XP_TARGETING
   174    174   
   175    175   # Special compiler flags to use when building man2tcl on Windows.
   176    176   MAN2TCLFLAGS	= @MAN2TCLFLAGS@
   177    177   
   178    178   AR		= @AR@
   179    179   RANLIB		= @RANLIB@
   180    180   CC		= @CC@