From owner-svn-ports-head@freebsd.org Mon Jan 4 21:13:45 2021 Return-Path: Delivered-To: svn-ports-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4F7224CD883; Mon, 4 Jan 2021 21:13:45 +0000 (UTC) (envelope-from mi@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4D8pJn1j4Yz4XBv; Mon, 4 Jan 2021 21:13:45 +0000 (UTC) (envelope-from mi@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2366C209D5; Mon, 4 Jan 2021 21:13:45 +0000 (UTC) (envelope-from mi@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 104LDjDj053910; Mon, 4 Jan 2021 21:13:45 GMT (envelope-from mi@FreeBSD.org) Received: (from mi@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 104LDi3u053905; Mon, 4 Jan 2021 21:13:44 GMT (envelope-from mi@FreeBSD.org) Message-Id: <202101042113.104LDi3u053905@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mi set sender to mi@FreeBSD.org using -f From: Mikhail Teterin Date: Mon, 4 Jan 2021 21:13:44 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r560347 - in head/graphics/libimg: . files X-SVN-Group: ports-head X-SVN-Commit-Author: mi X-SVN-Commit-Paths: in head/graphics/libimg: . files X-SVN-Commit-Revision: 560347 X-SVN-Commit-Repository: ports MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-head@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: SVN commit messages for the ports tree for head List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Jan 2021 21:13:45 -0000 Author: mi Date: Mon Jan 4 21:13:43 2021 New Revision: 560347 URL: https://svnweb.freebsd.org/changeset/ports/560347 Log: Upgrade from 1.4.9 to 1.4.12. The relevant upstream improvements are: * Fixes in handling of BMP and XBM formats; * Fixes in handling of all 16-bit images. Reported by: portscout Sponsored by: United Marsupials Modified: head/graphics/libimg/Makefile head/graphics/libimg/distinfo head/graphics/libimg/files/patch-config head/graphics/libimg/files/patch-jpeg head/graphics/libimg/files/patch-tiff Modified: head/graphics/libimg/Makefile ============================================================================== --- head/graphics/libimg/Makefile Mon Jan 4 20:48:22 2021 (r560346) +++ head/graphics/libimg/Makefile Mon Jan 4 21:13:43 2021 (r560347) @@ -2,7 +2,7 @@ # $FreeBSD$ PORTNAME= libimg -PORTVERSION= 1.4.9 +PORTVERSION= 1.4.12 CATEGORIES?= graphics tk tcl MASTER_SITES= SF/tkimg/tkimg/${PORTVERSION:R}/tkimg%20${PORTVERSION} DISTNAME= Img-${PORTVERSION}-Source @@ -35,6 +35,7 @@ EXTRACT_AFTER_ARGS= --exclude 'config.*' --exclude Mak --exclude 'compat' --exclude win MAKE_ARGS+= INSTALL_ROOT="${STAGEDIR}" CONFIGURE_ENV= WRKDIR="${WRKDIR}" +CONFIGURE_ARGS+=--enable-shared --disable-stubs post-patch: ${REINPLACE_CMD} -E -e 's,"(zlib|tiff|jpeg|png)tcl.h",<\1.h>,' \ Modified: head/graphics/libimg/distinfo ============================================================================== --- head/graphics/libimg/distinfo Mon Jan 4 20:48:22 2021 (r560346) +++ head/graphics/libimg/distinfo Mon Jan 4 21:13:43 2021 (r560347) @@ -1,3 +1,3 @@ -TIMESTAMP = 1579572018 -SHA256 (Img-1.4.9-Source.tar.gz) = 89aa029d9352de02c483857bc85b27af52f1b77907ee276047e13e894d1e3629 -SIZE (Img-1.4.9-Source.tar.gz) = 7702460 +TIMESTAMP = 1609788426 +SHA256 (Img-1.4.12-Source.tar.gz) = 4ff4e4d836ec41f0b56eba5fb73e628387a0dbfdcb7d8bb5821bb6edde0922f9 +SIZE (Img-1.4.12-Source.tar.gz) = 8363871 Modified: head/graphics/libimg/files/patch-config ============================================================================== --- head/graphics/libimg/files/patch-config Mon Jan 4 20:48:22 2021 (r560346) +++ head/graphics/libimg/files/patch-config Mon Jan 4 21:13:43 2021 (r560347) @@ -30,8 +30,8 @@ + for p in Img/exec_prefix/lib/Img/*.sh ; do \ $(INSTALL_PROGRAM) $$p $(INSTALL_ROOT)$(libdir)/`basename $$p` ; \ done ---- configure.in 2014-06-09 15:13:46.000000000 -0400 -+++ configure.in 2013-11-21 17:03:14.000000000 -0500 +--- configure.ac 2020-08-29 18:40:53.178382500 -0400 ++++ configure.ac 2021-01-04 15:12:55.394745000 -0500 @@ -110,16 +110,12 @@ TEA_CONFIG_COLLECT Modified: head/graphics/libimg/files/patch-jpeg ============================================================================== --- head/graphics/libimg/files/patch-jpeg Mon Jan 4 20:48:22 2021 (r560346) +++ head/graphics/libimg/files/patch-jpeg Mon Jan 4 21:13:43 2021 (r560347) @@ -1,31 +1,43 @@ ---- jpeg/jpeg.c 2018-09-14 09:53:49.000000000 -0400 -+++ jpeg/jpeg.c 2020-01-20 21:56:13.089925000 -0500 -@@ -62,5 +62,9 @@ - +--- jpeg/jpeg.c 2019-03-22 10:47:24.654594000 -0400 ++++ jpeg/jpeg.c 2021-01-04 14:38:51.161931000 -0500 +@@ -64,5 +64,9 @@ #include "tkimg.h" + #ifdef USE_TCL_STUBS -#include "jpegtcl.h" +#ifdef EXTERN +# undef EXTERN +#endif +#include +#include + #else + #include "jpeglib.h" +@@ -70,8 +74,5 @@ + #endif - static int SetupJPegLibrary(Tcl_Interp *interp); -@@ -143,86 +147,11 @@ +-static int SetupJPegLibrary(Tcl_Interp *interp); +- +-#define MORE_INITIALIZATION \ +- if (SetupJPegLibrary (interp) != TCL_OK) { return TCL_ERROR; } ++#define MORE_INITIALIZATION {} + #include "init.c" +@@ -149,88 +150,4 @@ + - - static int - SetupJPegLibrary (interp) - Tcl_Interp *interp; - { +-static int +-SetupJPegLibrary( +- Tcl_Interp *interp +-) { - struct jpeg_compress_struct *cinfo; /* libjpeg's parameter structure */ - struct my_error_mgr jerror; /* for controlling libjpeg error handling */ - int i; - +-#ifdef USE_TCL_STUBS - if (Jpegtcl_InitStubs(interp, JPEGTCL_VERSION, 0) == NULL) { - return TCL_ERROR; - } +-#endif - - /* The followin code tries to determine if the JPEG library is - valid at all. The library might be configured differently, @@ -92,30 +104,23 @@ - } - jpeg_destroy_compress(cinfo); - ckfree((char *) cinfo); - return TCL_OK; - } - +- return TCL_OK; +-} - +- /* *---------------------------------------------------------------------- -@@ -860,8 +789,6 @@ - } +@@ -866,8 +783,6 @@ case 2: { + #ifdef USE_JPEGTCL_STUBS - if (jpeg_simple_progression != NULL) { - /* Select simple progressive mode. */ - jpeg_simple_progression(cinfo); - } + /* Select simple progressive mode. */ + jpeg_simple_progression(cinfo); - break; - } -@@ -899,5 +826,5 @@ - greenOffset = blockPtr->offset[1] - blockPtr->offset[0]; - blueOffset = blockPtr->offset[2] - blockPtr->offset[0]; -- if ((jpeg_set_colorspace != NULL) && -+ if ( - (grayscale || (!greenOffset && !blueOffset))) { - /* Generate monochrome JPEG file if source block is grayscale. */ + #else + jpeg_simple_progression(cinfo); --- tests/jpeg.test 2016-07-30 10:30:48.000000000 -0400 +++ tests/jpeg.test 2020-01-20 21:43:20.086115000 -0500 @@ -24,5 +24,5 @@ Modified: head/graphics/libimg/files/patch-tiff ============================================================================== --- head/graphics/libimg/files/patch-tiff Mon Jan 4 20:48:22 2021 (r560346) +++ head/graphics/libimg/files/patch-tiff Mon Jan 4 21:13:43 2021 (r560347) @@ -7,9 +7,9 @@ + vars="tiff.c" for i in $vars; do case $i in ---- tiff/tiff.c 2019-03-02 16:33:00.000000000 -0500 -+++ tiff/tiff.c 2020-01-20 21:20:18.135776000 -0500 -@@ -19,11 +19,15 @@ +--- tiff/tiff.c 2020-08-26 17:17:10.040341300 -0400 ++++ tiff/tiff.c 2021-01-04 15:02:19.857169000 -0500 +@@ -20,11 +20,15 @@ #endif #include "tkimg.h" -#include "tifftcl.h" @@ -27,17 +27,17 @@ -#include "jpegtcl.h" +#include + static int SetupTiffLibrary(Tcl_Interp *interp); +@@ -37,7 +41,4 @@ + #include "tiffInt.h" -@@ -35,7 +39,4 @@ - #include "init.c" - --#include "tiffInt.h" - +-extern DLLIMPORT int unlink(const char *); - - extern DLLIMPORT int unlink(const char *); - -@@ -88,52 +89,11 @@ - Tcl_Interp *interp; + /* + * Prototypes for local procedures defined in this file: +@@ -84,44 +85,7 @@ + SetupTiffLibrary (Tcl_Interp *interp) { - static int initialized = 0; - @@ -45,15 +45,15 @@ - return TCL_ERROR; - } - - if (errorMessage) { - ckfree(errorMessage); - errorMessage = NULL; - } +- if (errorMessage) { +- ckfree(errorMessage); +- errorMessage = NULL; +- } - if (TIFFSetErrorHandler != NULL) { - TIFFSetErrorHandler(_TIFFerr); - } - if (TIFFSetWarningHandler != NULL) { -- TIFFSetWarningHandler(_TIFFwarn); +- TIFFSetWarningHandler(_TIFFwarn); - } - - /* @@ -66,304 +66,374 @@ - } - - if (!initialized) { -- initialized = 1; -- if ( -- TIFFRegisterCODEC && TIFFError && TIFFPredictorInit && -- _TIFFMergeFieldInfo && TIFFFlushData1 && _TIFFNoPostDecode && -- TIFFTileRowSize && TIFFScanlineSize && _TIFFsetByteArray && -- TIFFVSetField && TIFFSwabArrayOfShort -- ) { +- initialized = 1; +- if (Zlibtcl_InitStubs(interp, ZLIBTCL_VERSION, 0) == NULL) { +- return TCL_ERROR; +- } +- TIFFRegisterCODEC (COMPRESSION_DEFLATE, "Deflate", TkimgTIFFInitZip); +- TIFFRegisterCODEC (COMPRESSION_ADOBE_DEFLATE, "AdobeDeflate", TkimgTIFFInitZip); - -- if (Zlibtcl_InitStubs(interp, ZLIBTCL_VERSION, 0) == NULL) { -- return TCL_ERROR; -- } -- TIFFRegisterCODEC (COMPRESSION_DEFLATE, "Deflate", TkimgTIFFInitZip); -- TIFFRegisterCODEC (COMPRESSION_ADOBE_DEFLATE, "AdobeDeflate", TkimgTIFFInitZip); +- if (Jpegtcl_InitStubs(interp, JPEGTCL_VERSION, 0) == NULL) { +- return TCL_ERROR; +- } +- TIFFRegisterCODEC (COMPRESSION_JPEG, "JPEG", TkimgTIFFInitJpeg); +- TIFFRegisterCODEC (COMPRESSION_PIXARLOG, "PixarLog", TkimgTIFFInitPixar); +- } + TIFFSetErrorHandler(_TIFFerr); + TIFFSetWarningHandler(_TIFFwarn); - -- if (Jpegtcl_InitStubs(interp, JPEGTCL_VERSION, 0) == NULL) { -- return TCL_ERROR; -- } -- TIFFRegisterCODEC (COMPRESSION_JPEG, "JPEG", TkimgTIFFInitJpeg); -- TIFFRegisterCODEC (COMPRESSION_PIXARLOG, "PixarLog", TkimgTIFFInitPixar); -- } -- } ++ return TCL_OK; } -@@ -451,9 +411,6 @@ - { +@@ -435,8 +399,6 @@ + ) { TIFF *tif; -- char *tempFileName = NULL, tempFileNameBuffer[256]; -- size_t count; - int result; +- char *dir, *tempFileName = NULL, tempFileNameBuffer[1024]; +- int count, result; ++ int result; tkimg_MFile handle; -- char buffer[1024]; +- char buffer[4096]; char *dataPtr = NULL; -@@ -462,35 +419,13 @@ +@@ -445,66 +407,13 @@ } - if (TIFFClientOpen) { -- if (handle.state != IMG_STRING) { -- dataPtr = ckalloc((handle.length*3)/4 + 2); -- handle.length = tkimg_Read2(&handle, dataPtr, handle.length); -- handle.data = dataPtr; -- } -- handle.state = 0; -- tif = TIFFClientOpen("inline data", "r", (thandle_t) &handle, -- readString, writeString, seekString, closeDummy, -- sizeString, mapDummy, unMapDummy); +- if (handle.state != IMG_STRING) { +- dataPtr = ckalloc((handle.length*3)/4 + 2); +- handle.length = tkimg_Read2(&handle, dataPtr, handle.length); +- handle.data = dataPtr; +- } +- handle.state = 0; +- tif = TIFFClientOpen("inline data", "r", (thandle_t) &handle, +- readString, writeString, seekString, closeDummy, +- sizeString, mapDummy, unMapDummy); - } else { -- Tcl_Channel outchan; -- tempFileName = tmpnam(tempFileNameBuffer); -- outchan = tkimg_OpenFileChannel(interp, tempFileName, 0644); -- if (!outchan) { -- return TCL_ERROR; -- } +- FILE *outfile; +-#ifdef WIN32 +- char dirBuffer[512]; +- HANDLE h; - -- count = (size_t)tkimg_Read2(&handle, buffer, 1024); -- while (count == 1024) { -- Tcl_Write(outchan, buffer, count); -- count = (size_t)tkimg_Read2(&handle, buffer, 1024); -- } -- if (count + 1 > 1){ -- Tcl_Write(outchan, buffer, count); -- } -- if (Tcl_Close(interp, outchan) == TCL_ERROR) { -- return TCL_ERROR; -- } -- tif = TIFFOpen(tempFileName, "r"); +- dir = dirBuffer; +- strcpy(dir, "."); +- GetTempPathA(sizeof (dirBuffer), dir); +- tempFileName = tempFileNameBuffer; +- tempFileName[0] = '\0'; +- GetTempFileNameA(dir, "tki", 0, tempFileName); +- h = CreateFileA(tempFileName, GENERIC_READ|GENERIC_WRITE, 0, NULL, +- CREATE_ALWAYS, FILE_ATTRIBUTE_TEMPORARY, NULL); +- if (h != INVALID_HANDLE_VALUE) { +- CloseHandle(h); +- } +-#else +- dir = getenv("TMPDIR"); +- tempFileName = tempFileNameBuffer; +- if (dir) { +- strcpy(tempFileName, dir); +- } else { +-#ifdef P_tmpdir +- strcpy(tempFileName, P_tmpdir); +-#else +- strcpy(tempFileName, "/tmp"); +-#endif +- } +- strcat(tempFileName, "/tkimgXXXXXX"); +- result = mkstemp(tempFileName); +- if (result >= 0) { +- close(result); +- } +-#endif +- outfile = fopen(tempFileName, "wb"); +- if (outfile == NULL) { +- Tcl_AppendResult(interp, "error open output file", (char *) NULL); +- return TCL_ERROR; +- } +- +- count = tkimg_Read2(&handle, buffer, sizeof (buffer)); +- while (count == sizeof (buffer)) { +- fwrite(buffer, 1, sizeof (buffer), outfile); +- count = tkimg_Read2(&handle, buffer, sizeof (buffer)); +- } +- if (count + 1 > 1){ +- fwrite(buffer, 1, count, outfile); +- } +- fclose(outfile); +- tif = TIFFOpen(tempFileName, "r"); - } + if (handle.state != IMG_STRING) { -+ dataPtr = ckalloc((handle.length*3)/4 + 2); -+ handle.length = tkimg_Read(&handle, dataPtr, handle.length); -+ handle.data = dataPtr; ++ dataPtr = ckalloc((handle.length*3)/4 + 2); ++ handle.length = tkimg_Read2(&handle, dataPtr, handle.length); ++ handle.data = dataPtr; + } + handle.state = 0; + tif = TIFFClientOpen("inline data", "r", (thandle_t) &handle, -+ readString, writeString, seekString, closeDummy, -+ sizeString, mapDummy, unMapDummy); ++ readString, writeString, seekString, closeDummy, ++ sizeString, mapDummy, unMapDummy); if (tif != NULL) { -@@ -500,7 +435,4 @@ - result = TCL_ERROR; +@@ -514,7 +423,4 @@ + result = TCL_ERROR; } - if (tempFileName) { -- unlink(tempFileName); +- unlink(tempFileName); - } if (result == TCL_ERROR) { - Tcl_AppendResult(interp, errorMessage, (char *) NULL); -@@ -527,38 +459,12 @@ - { + Tcl_AppendResult(interp, errorMessage, (char *) NULL); +@@ -540,68 +446,13 @@ + ) { TIFF *tif; -- char *tempFileName = NULL, tempFileNameBuffer[256]; -- size_t count; -- int result; -- char buffer[1024]; +- char *dir, *tempFileName = NULL, tempFileNameBuffer[1024]; +- int count, result; +- char buffer[4096]; - - if (TIFFClientOpen) { -- tkimg_MFile handle; -- handle.data = (char *) chan; -- handle.state = IMG_CHAN; -- tif = TIFFClientOpen(fileName, "r", (thandle_t) &handle, -- readMFile, writeDummy, seekMFile, closeDummy, -- sizeMFile, mapDummy, unMapDummy); +- tkimg_MFile handle; +- handle.data = (char *) chan; +- handle.state = IMG_CHAN; +- tif = TIFFClientOpen(fileName, "r", (thandle_t) &handle, +- readMFile, writeDummy, seekMFile, closeDummy, +- sizeMFile, mapDummy, unMapDummy); - } else { -- Tcl_Channel outchan; -- tempFileName = tmpnam(tempFileNameBuffer); -- outchan = tkimg_OpenFileChannel(interp, tempFileName, 0644); -- if (!outchan) { -- return TCL_ERROR; -- } -+ int result; -+ tkimg_MFile handle; - -- count = (size_t)Tcl_Read(chan, buffer, 1024); -- while (count == 1024) { -- Tcl_Write(outchan, buffer, count); -- count = (size_t)Tcl_Read(chan, buffer, 1024); -- } -- if (count + 1 > 1){ -- Tcl_Write(outchan, buffer, count); -- } -- if (Tcl_Close(interp, outchan) == TCL_ERROR) { -- return TCL_ERROR; -- } +- FILE *outfile; +-#ifdef WIN32 +- char dirBuffer[512]; +- HANDLE h; - -- tif = TIFFOpen(tempFileName, "r"); -- } +- dir = dirBuffer; +- strcpy(dir, "."); +- GetTempPathA(sizeof (dirBuffer), dir); +- tempFileName = tempFileNameBuffer; +- tempFileName[0] = '\0'; +- GetTempFileNameA(dir, "tki", 0, tempFileName); +- h = CreateFileA(tempFileName, GENERIC_READ|GENERIC_WRITE, 0, NULL, +- CREATE_ALWAYS, FILE_ATTRIBUTE_TEMPORARY, NULL); +- if (h != INVALID_HANDLE_VALUE) { +- CloseHandle(h); +- } +-#else +- dir = getenv("TMPDIR"); +- tempFileName = tempFileNameBuffer; +- if (dir) { +- strcpy(tempFileName, dir); +- } else { +-#ifdef P_tmpdir +- strcpy(tempFileName, P_tmpdir); +-#else +- strcpy(tempFileName, "/tmp"); +-#endif +- } +- strcat(tempFileName, "/tkimgXXXXXX"); +- result = mkstemp(tempFileName); +- if (result >= 0) { +- close(result); +- } +-#endif +- outfile = fopen(tempFileName, "wb"); +- if (outfile == NULL) { +- Tcl_AppendResult(interp, "error open output file", (char *) NULL); +- return TCL_ERROR; +- } ++ int result; + +- count = Tcl_Read(chan, buffer, sizeof (buffer)); +- while (count == sizeof (buffer)) { +- fwrite(buffer, 1, sizeof (buffer), outfile); +- count = Tcl_Read(chan, buffer, sizeof (buffer)); +- } +- if (count>0){ +- fwrite(buffer, 1, count, outfile); +- } +- fclose(outfile); ++ tkimg_MFile handle; + handle.data = (char *) chan; + handle.state = IMG_CHAN; + tif = TIFFClientOpen(fileName, "r", (thandle_t) &handle, -+ readMFile, writeDummy, seekMFile, closeDummy, -+ sizeMFile, mapDummy, unMapDummy); ++ readMFile, writeDummy, seekMFile, closeDummy, ++ sizeMFile, mapDummy, unMapDummy); + +- tif = TIFFOpen(tempFileName, "r"); +- } if (tif) { - result = CommonRead(interp, tif, format, imageHandle, -@@ -567,7 +473,4 @@ - result = TCL_ERROR; + result = CommonRead(interp, tif, format, imageHandle, +@@ -610,7 +461,4 @@ + result = TCL_ERROR; } - if (tempFileName) { -- unlink(tempFileName); +- unlink(tempFileName); - } if (result == TCL_ERROR) { - Tcl_AppendResult(interp, errorMessage, (char *) NULL); -@@ -637,5 +540,5 @@ + Tcl_AppendResult(interp, errorMessage, (char *) NULL); +@@ -678,5 +526,5 @@ npixels = w * h; - raster = (uint32*) TkimgTIFFmalloc(npixels * sizeof (uint32)); + raster = (uint32*) _TIFFmalloc(npixels * sizeof (uint32)); block.width = w; block.height = h; -@@ -648,5 +551,5 @@ +@@ -689,5 +537,5 @@ if (!TIFFReadRGBAImage(tif, w, h, raster, 0) || errorMessage) { - TkimgTIFFfree (raster); + _TIFFfree (raster); - if (errorMessage) { - Tcl_AppendResult(interp, errorMessage, (char *) NULL); -@@ -665,5 +568,5 @@ + if (errorMessage) { + Tcl_AppendResult(interp, errorMessage, (char *) NULL); +@@ -705,5 +553,5 @@ } - TkimgTIFFfree (raster); + _TIFFfree (raster); TIFFClose(tif); return result; -@@ -676,7 +579,6 @@ - ) { - TIFF *tif; -- int result, comp; -+ int result, comp, length; +@@ -718,5 +566,4 @@ + int result, comp; tkimg_MFile handle; -- char *tempFileName = NULL, tempFileNameBuffer[256]; +- char *dir, *tempFileName = NULL, tempFileNameBuffer[256]; Tcl_DString dstring; const char *mode; -@@ -688,14 +590,9 @@ +@@ -728,46 +575,9 @@ } - if (TIFFClientOpen) { -- Tcl_DStringInit(&dstring); -- tkimg_WriteInit(&dstring, &handle); -- tif = TIFFClientOpen("inline data", mode, (thandle_t) &handle, -- readString, writeString, seekString, closeDummy, -- sizeString, mapDummy, unMapDummy); +- Tcl_DStringInit(&dstring); +- tkimg_WriteInit(&dstring, &handle); +- tif = TIFFClientOpen("inline data", mode, (thandle_t) &handle, +- readString, writeString, seekString, closeDummy, +- sizeString, mapDummy, unMapDummy); - } else { -- tempFileName = tmpnam(tempFileNameBuffer); -- tif = TIFFOpen(tempFileName,mode); +-#ifdef WIN32 +- char dirBuffer[512]; +- HANDLE h; +- +- dir = dirBuffer; +- strcpy(dir, "."); +- GetTempPathA(sizeof (dirBuffer), dir); +- tempFileName = tempFileNameBuffer; +- tempFileName[0] = '\0'; +- GetTempFileNameA(dir, "tki", 0, tempFileName); +- h = CreateFileA(tempFileName, GENERIC_READ|GENERIC_WRITE, 0, NULL, +- CREATE_ALWAYS, FILE_ATTRIBUTE_TEMPORARY, NULL); +- if (h != INVALID_HANDLE_VALUE) { +- CloseHandle(h); +- } +-#else +- dir = getenv("TMPDIR"); +- tempFileName = tempFileNameBuffer; +- if (dir) { +- strcpy(tempFileName, dir); +- } else { +-#ifdef P_tmpdir +- strcpy(tempFileName, P_tmpdir); +-#else +- strcpy(tempFileName, "/tmp"); +-#endif +- } +- strcat(tempFileName, "/tkimgXXXXXX"); +- result = mkstemp(tempFileName); +- if (result >= 0) { +- close(result); +- } +-#endif +- tif = TIFFOpen(tempFileName,mode); - } + Tcl_DStringInit(&dstring); + tkimg_WriteInit(&dstring, &handle); + tif = TIFFClientOpen("inline data", mode, (thandle_t) &handle, -+ readString, writeString, seekString, closeDummy, -+ sizeString, mapDummy, unMapDummy); ++ readString, writeString, seekString, closeDummy, ++ sizeString, mapDummy, unMapDummy); result = CommonWrite(interp, tif, comp, blockPtr); -@@ -703,7 +600,4 @@ +@@ -775,11 +585,4 @@ if (result != TCL_OK) { -- if (tempFileName) { -- unlink(tempFileName); -- } - Tcl_AppendResult(interp, errorMessage, (char *) NULL); - ckfree(errorMessage); -@@ -712,29 +606,8 @@ +- if (tempFileName) { +-#ifdef WIN32 +- DeleteFileA(tempFileName); +-#else +- unlink(tempFileName); +-#endif +- } + Tcl_AppendResult(interp, errorMessage, (char *) NULL); + ckfree(errorMessage); +@@ -788,43 +591,13 @@ } - if (tempFileName) { -- Tcl_Channel inchan; -- char buffer[1024]; -- inchan = tkimg_OpenFileChannel(interp, tempFileName, 0644); -- if (!inchan) { -- return TCL_ERROR; -- } -- tkimg_WriteInit(&data, &handle); +- FILE *infile; +- char buffer[4096]; - -- result = Tcl_Read(inchan, buffer, 1024); -- while ((result == TCL_OK) && !Tcl_Eof(inchan)) { -- tkimg_Write2(&handle, buffer, result); -- result = Tcl_Read(inchan, buffer, 1024); -- } -- if (result == TCL_OK) { -- tkimg_Write2(&handle, buffer, result); -- result = Tcl_Close(interp, inchan); -- } -- unlink(tempFileName); +- infile = fopen(tempFileName, "rb"); +- if (infile == NULL) { +- Tcl_AppendResult(interp, "error open input file", (char *) NULL); +- return TCL_ERROR; +- } +- tkimg_WriteInit(&data, &handle); +- +- result = fread(buffer, 1, sizeof (buffer), infile); +- while (result > 0) { +- tkimg_Write2(&handle, buffer, result); +- result = fread(buffer, 1, sizeof (buffer), infile); +- } +- if (ferror(infile)) { +- Tcl_AppendResult(interp, "error reading input file", (char *) NULL); +- result = TCL_ERROR; +- } +- fclose(infile); +-#ifdef WIN32 +- DeleteFileA(tempFileName); +-#else +- unlink(tempFileName); +-#endif - } else { -- int length = handle.length; -- tkimg_WriteInit(&data, &handle); -- tkimg_Write2(&handle, Tcl_DStringValue(&dstring), length); -- Tcl_DStringFree(&dstring); +- int length = handle.length; +- tkimg_WriteInit(&data, &handle); +- tkimg_Write2(&handle, Tcl_DStringValue(&dstring), length); +- Tcl_DStringFree(&dstring); - } -+ length = handle.length; ++ int length = handle.length; + tkimg_WriteInit(&data, &handle); -+ tkimg_Write(&handle, Tcl_DStringValue(&dstring), length); ++ tkimg_Write2(&handle, Tcl_DStringValue(&dstring), length); + Tcl_DStringFree(&dstring); ++ tkimg_Putc(IMG_DONE, &handle); - if (result == TCL_OK) { -@@ -956,36 +829,2 @@ - return TCL_OK; +- if (result == TCL_OK) { +- Tcl_DStringResult(interp, &data); +- } else { +- Tcl_DStringFree(&data); +- } +- return result; ++ Tcl_DStringResult(interp, &data); ++ ++ return TCL_OK; } -- --void --TkimgTIFFfree (data) -- tdata_t data; --{ + +@@ -1043,9 +816,5 @@ + TkimgTIFFfree(tdata_t data) + { - if (_TIFFfree) { -- _TIFFfree(data); +- _TIFFfree(data); - } else { -- ckfree((char *) data); +- ckfree((char *) data); - } --} -- --tdata_t --TkimgTIFFmalloc(size) -- tsize_t size; --{ ++ _TIFFfree(data); + } + +@@ -1053,9 +822,5 @@ + TkimgTIFFmalloc(tsize_t size) + { - if (_TIFFmalloc) { -- return _TIFFmalloc(size); +- return _TIFFmalloc(size); - } else { -- return ckalloc(size); +- return attemptckalloc(size); - } --} -- --tdata_t --TkimgTIFFrealloc(data, size) -- tdata_t data; -- tsize_t size; --{ ++ return _TIFFmalloc(size); + } + +@@ -1065,8 +830,4 @@ + tsize_t size + ) { - if (_TIFFrealloc) { -- return _TIFFrealloc(data, size); +- return _TIFFrealloc(data, size); - } else { -- return ckrealloc(data, size); +- return attemptckrealloc(data, size); - } --} ---- tests/tiff.test 2016-07-30 10:31:08.000000000 -0400 -+++ tests/tiff.test 2020-01-20 21:44:30.430340000 -0500 -@@ -22,5 +22,5 @@ - source $file.base64 - -- test tiff-1.1 {} -setup { -+ test tiff-1.1 {} -constraints nonPortable -setup { - catch {image delete i} - } -body { -@@ -31,5 +31,5 @@ - } -result $imgdata - -- test tiff-1.2 {} -setup { -+ test tiff-1.2 {} -constraints nonPortable -setup { - catch {image delete i} - } -body { -@@ -40,5 +40,5 @@ - } -result $imgdata - -- test tiff-1.3 {} -setup { -+ test tiff-1.3 {} -constraints nonPortable -setup { - catch {image delete i} - } -body { -@@ -50,5 +50,5 @@ - } -result $imgdata - -- test tiff-1.4 {} -setup { -+ test tiff-1.4 {} -constraints nonPortable -setup { - catch {image delete i} - } -body { ++ return _TIFFrealloc(data, size); + }