Tk Source Code

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

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

Overview
Comment:Use TCL_IO_FAILURE, for more readable TIP #494 compatibility.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: abe0d3b121cbb12d3b963ce4d5130797dd1145404dcff680a974f2538765818d
User & Date: jan.nijtmans 2018-09-06 12:40:33
Context
2018-09-07
20:40
Fix [05bd7f4da]: vista theme: combobox does not have disabled background. check-in: 0100c2ca user: fvogel tags: trunk
2018-09-06
12:40
Use TCL_IO_FAILURE, for more readable TIP #494 compatibility. check-in: abe0d3b1 user: jan.nijtmans tags: trunk
08:02
Header include reform: Since "tkInt.h" already contains header files like <stdlib.h>, <string.h> and <ctype.h>, we don't have to include those in every separate C-file. Just depend on tkInt.h to provide it. This mainly affects ttk, since most other files already adhered to this. check-in: d69113b3 user: jan.nijtmans tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

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 ((size_t)Tcl_WriteObj(psInfo.chan, psObj) == (size_t)-1) {
          494  +	    if (Tcl_WriteObj(psInfo.chan, psObj) == TCL_IO_FAILURE) {
   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 ((size_t)Tcl_WriteObj(psInfo.chan, psObj) == (size_t)-1) {
          548  +	    if (Tcl_WriteObj(psInfo.chan, psObj) == TCL_IO_FAILURE) {
   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 ((size_t)Tcl_WriteObj(psInfo.chan, psObj) == (size_t)-1) {
          590  +	    if (Tcl_WriteObj(psInfo.chan, psObj) == TCL_IO_FAILURE) {
   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 ((size_t)Tcl_WriteObj(psInfo.chan, psObj) == (size_t)-1) {
          611  +	    if (Tcl_WriteObj(psInfo.chan, psObj) == TCL_IO_FAILURE) {
   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/tkImgPNG.c.

  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 ((size_t)Tcl_Write(pngPtr->channel, (const char *) srcPtr, srcSz) == (size_t)-1) {
         2888  +    } else if (Tcl_Write(pngPtr->channel, (const char *) srcPtr, srcSz) == TCL_IO_FAILURE) {
  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.

   320    320   	if ((size_t)Tcl_Write(chan, (char *) pixLinePtr, nBytes) != nBytes) {
   321    321   	    goto writeerror;
   322    322   	}
   323    323       } else {
   324    324   	for (h = blockPtr->height; h > 0; h--) {
   325    325   	    pixelPtr = pixLinePtr;
   326    326   	    for (w = blockPtr->width; w > 0; w--) {
   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) {
          327  +		if (Tcl_Write(chan,(char *)&pixelPtr[0], 1) == TCL_IO_FAILURE ||
          328  +			Tcl_Write(chan,(char *)&pixelPtr[greenOffset],1) == TCL_IO_FAILURE ||
          329  +			Tcl_Write(chan,(char *)&pixelPtr[blueOffset],1) == TCL_IO_FAILURE) {
   330    330   		    goto writeerror;
   331    331   		}
   332    332   		pixelPtr += blockPtr->pixelSize;
   333    333   	    }
   334    334   	    pixLinePtr += blockPtr->pitch;
   335    335   	}
   336    336       }

Changes to generic/tkInt.h.

   838    838   /*
   839    839    * Flags passed to TkpMakeMenuWindow's 'transient' argument.
   840    840    */
   841    841   
   842    842   #define TK_MAKE_MENU_TEAROFF	0	/* Only non-transient case. */
   843    843   #define TK_MAKE_MENU_POPUP	1
   844    844   #define TK_MAKE_MENU_DROPDOWN	2
          845  +
          846  +/* See TIP #494 */
          847  +#ifndef TCL_IO_FAILURE
          848  +#   define TCL_IO_FAILURE (-1)
          849  +#endif
   845    850   
   846    851   /*
   847    852    * The following structure is used with TkMakeEnsemble to create ensemble
   848    853    * commands and optionally to create sub-ensembles.
   849    854    */
   850    855   
   851    856   typedef struct TkEnsemble {