git: 5f0d96d150d5 - main - graphics/libimg: upgrade from 1.4.12 to 1.4.16

From: Mikhail Teterin <mi_at_FreeBSD.org>
Date: Mon, 08 Jan 2024 17:23:54 UTC
The branch main has been updated by mi:

URL: https://cgit.FreeBSD.org/ports/commit/?id=5f0d96d150d59f1c53f7e949fb5eec86e6e6a138

commit 5f0d96d150d59f1c53f7e949fb5eec86e6e6a138
Author:     Mikhail Teterin <mi@FreeBSD.org>
AuthorDate: 2024-01-08 17:18:24 +0000
Commit:     Mikhail Teterin <mi@FreeBSD.org>
CommitDate: 2024-01-08 17:23:50 +0000

    graphics/libimg: upgrade from 1.4.12 to 1.4.16
    
    Changes:        https://sourceforge.net/p/tkimg/code/HEAD/tree/tags/1.4.16/ANNOUNCE
    Prodded by:     portscout
---
 graphics/libimg/Makefile         |   5 +-
 graphics/libimg/distinfo         |   6 +--
 graphics/libimg/files/patch-jpeg |  27 ++++++----
 graphics/libimg/files/patch-tiff | 110 +++++++++++++++++++--------------------
 graphics/libimg/pkg-plist        |   1 +
 5 files changed, 77 insertions(+), 72 deletions(-)

diff --git a/graphics/libimg/Makefile b/graphics/libimg/Makefile
index 84caec71ce44..d845377860c7 100644
--- a/graphics/libimg/Makefile
+++ b/graphics/libimg/Makefile
@@ -1,13 +1,12 @@
 PORTNAME=	libimg
-PORTVERSION=	1.4.12
-PORTREVISION=	1
+PORTVERSION=	1.4.16
 CATEGORIES?=	graphics tk tcl
 MASTER_SITES=	SF/tkimg/tkimg/${PORTVERSION:R}/tkimg%20${PORTVERSION}
 DISTNAME=	Img-${PORTVERSION}-Source
 
 MAINTAINER=	mi@aldan.algebra.com
 COMMENT=	Library of image format handlers for Tk4.1 and later
-WWW=		http://members1.chello.nl/~j.nijtmans/img.html
+WWW=		https://sourceforge.net/projects/tkimg/
 
 LICENSE=	TclTk
 LICENSE_NAME=	Tcl/Tk License
diff --git a/graphics/libimg/distinfo b/graphics/libimg/distinfo
index 126318166bff..eeb597e65a18 100644
--- a/graphics/libimg/distinfo
+++ b/graphics/libimg/distinfo
@@ -1,3 +1,3 @@
-TIMESTAMP = 1609788426
-SHA256 (Img-1.4.12-Source.tar.gz) = 4ff4e4d836ec41f0b56eba5fb73e628387a0dbfdcb7d8bb5821bb6edde0922f9
-SIZE (Img-1.4.12-Source.tar.gz) = 8363871
+TIMESTAMP = 1704732357
+SHA256 (Img-1.4.16-Source.tar.gz) = d99af4835fe3e20960817c7a1b5235dcfaa97c642593cce50bdb64c5827cd321
+SIZE (Img-1.4.16-Source.tar.gz) = 12129708
diff --git a/graphics/libimg/files/patch-jpeg b/graphics/libimg/files/patch-jpeg
index 46996060664e..70bebc3b46fe 100644
--- a/graphics/libimg/files/patch-jpeg
+++ b/graphics/libimg/files/patch-jpeg
@@ -1,5 +1,5 @@
---- jpeg/jpeg.c	2019-03-22 10:47:24.654594000 -0400
-+++ jpeg/jpeg.c	2021-01-04 14:38:51.161931000 -0500
+--- jpeg/jpeg.c	2023-04-19 09:19:56.206635300 -0400
++++ jpeg/jpeg.c	2024-01-08 11:50:37.142511000 -0500
 @@ -64,5 +64,9 @@
  #include "tkimg.h"
  #ifdef USE_TCL_STUBS
@@ -11,17 +11,18 @@
 +#include <jerror.h>
  #else
  #include "jpeglib.h"
-@@ -70,8 +74,5 @@
+@@ -70,9 +74,6 @@
  #endif
  
 -static int SetupJPegLibrary(Tcl_Interp *interp);
--
--#define MORE_INITIALIZATION \
--    if (SetupJPegLibrary (interp) != TCL_OK) { return TCL_ERROR; }
 +#define MORE_INITIALIZATION {}
  
+-#define MORE_INITIALIZATION \
+-    if (SetupJPegLibrary (interp) != TCL_OK) { return TCL_ERROR; }
+-
  #include "init.c"
-@@ -149,88 +150,4 @@
+ 
+@@ -149,92 +150,4 @@
  
  
 -
@@ -50,18 +51,22 @@
 -    /* overallocat size, so we don't get a core-dump if the library
 -       thinks that the structure is much larger */
 -
--    cinfo = (struct jpeg_compress_struct *) ckalloc(8*sizeof(struct jpeg_compress_struct));
+-    cinfo = (struct jpeg_compress_struct *) attemptckalloc(8*sizeof(struct jpeg_compress_struct));
+-    if (cinfo == NULL) {
+-        Tcl_AppendResult (interp, "Unable to allocate memory for image data.", (char *) NULL);
+-        return TCL_ERROR;
+-    }
 -    cinfo->err = jpeg_std_error(&jerror.pub);
 -    jerror.pub.error_exit = my_error_exit;
 -    jerror.pub.output_message = my_output_message;
 -    /* Establish the setjmp return context for my_error_exit to use. */
--    if (setjmp(jerror.setjmp_buffer)) {
+-    if (SETJMP(jerror.setjmp_buffer)) {
 -      /* If we get here, the JPEG library is invalid. */
 -      jpeg_destroy_compress(cinfo);
 -      ckfree((char *)cinfo);
 -
 -      if (interp) {
--	Tcl_AppendResult(interp, "couldn't use \"", "jpegtcl",
+-	Tcl_AppendResult(interp, "Could not use \"", "jpegtcl",
 -		"\": please upgrade to at least version 6a", (char *) NULL);
 -      }
 -      return TCL_ERROR;
@@ -110,7 +115,7 @@
 -
  /*
   *----------------------------------------------------------------------
-@@ -866,8 +783,6 @@
+@@ -873,8 +786,6 @@
  		case 2: {
  #ifdef USE_JPEGTCL_STUBS
 -		    if (jpeg_simple_progression != NULL) {
diff --git a/graphics/libimg/files/patch-tiff b/graphics/libimg/files/patch-tiff
index 76afeb99e3cc..2011309e7157 100644
--- a/graphics/libimg/files/patch-tiff
+++ b/graphics/libimg/files/patch-tiff
@@ -7,8 +7,8 @@
 +    vars="tiff.c"
      for i in $vars; do
  	case $i in
---- tiff/tiff.c	2020-08-26 17:17:10.040341300 -0400
-+++ tiff/tiff.c	2021-01-04 15:02:19.857169000 -0500
+--- tiff/tiff.c	2023-10-27 17:01:40.715604300 -0400
++++ tiff/tiff.c	2024-01-08 12:09:34.186075000 -0500
 @@ -20,11 +20,15 @@
  #endif
  #include "tkimg.h"
@@ -84,7 +84,7 @@
 + 
      return TCL_OK;
  }
-@@ -435,8 +399,6 @@
+@@ -438,9 +402,7 @@
  ) {
      TIFF *tif;
 -    char *dir, *tempFileName = NULL, tempFileNameBuffer[1024];
@@ -92,14 +92,20 @@
 +    int result;
      tkimg_MFile handle;
 -    char buffer[4096];
-     char *dataPtr = NULL;
+-    char *dataPtr = NULL;
++    void *dataPtr = NULL;
  
-@@ -445,66 +407,13 @@
+     if (!tkimg_ReadInit(data, '\115', &handle)) {
+@@ -448,70 +410,17 @@
      }
  
 -    if (TIFFClientOpen) {
 -        if (handle.state != IMG_STRING) {
--            dataPtr = ckalloc((handle.length*3)/4 + 2);
+-            dataPtr = attemptckalloc((handle.length*3)/4 + 2);
+-            if (dataPtr == NULL) {
+-                Tcl_AppendResult (interp, "Unable to allocate memory for image data.", (char *) NULL);
+-                return TCL_ERROR;
+-            }
 -            handle.length = tkimg_Read2(&handle, dataPtr, handle.length);
 -            handle.data = dataPtr;
 -        }
@@ -145,8 +151,12 @@
 -        outfile = fopen(tempFileName, "wb");
 -        if (outfile == NULL) {
 -            Tcl_AppendResult(interp, "error open output file", (char *) NULL);
--            return TCL_ERROR;
--        }
++    if (handle.state != IMG_STRING) {
++        dataPtr = attemptckalloc((handle.length*3)/4 + 2);
++        if (dataPtr == NULL) {
++            Tcl_AppendResult (interp, "Unable to allocate memory for image data.", (char *) NULL);
+             return TCL_ERROR;
+         }
 -
 -        count = tkimg_Read2(&handle, buffer, sizeof (buffer));
 -        while (count == sizeof (buffer)) {
@@ -158,35 +168,33 @@
 -        }
 -        fclose(outfile);
 -        tif = TIFFOpen(tempFileName, "r");
--    }
-+    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 (tif != NULL) {
-@@ -514,7 +423,4 @@
+@@ -522,7 +431,4 @@
          result = TCL_ERROR;
      }
 -    if (tempFileName) {
 -        unlink(tempFileName);
 -    }
      if (result == TCL_ERROR) {
-         Tcl_AppendResult(interp, errorMessage, (char *) NULL);
-@@ -540,68 +446,13 @@
+         if (strlen (Tcl_GetStringResult(interp)) == 0 && errorMessage) {
+@@ -550,68 +456,13 @@
  ) {
      TIFF *tif;
 -    char *dir, *tempFileName = NULL, tempFileNameBuffer[1024];
 -    int count, result;
++    int result;
+     tkimg_MFile handle;
 -    char buffer[4096];
--
+ 
 -    if (TIFFClientOpen) {
--        tkimg_MFile handle;
 -        handle.data = (char *) chan;
 -        handle.state = IMG_CHAN;
 -        tif = TIFFClientOpen(fileName, "r", (thandle_t) &handle,
@@ -232,8 +240,7 @@
 -            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);
@@ -243,53 +250,46 @@
 -            fwrite(buffer, 1, count, outfile);
 -        }
 -        fclose(outfile);
-+    tkimg_MFile handle;
-+    handle.data = (char *) chan;
+-
+-        tif = TIFFOpen(tempFileName, "r");
+-    }
++    handle.data = (void *) chan;
 +    handle.state = IMG_CHAN;
 +    tif = TIFFClientOpen(fileName, "r", (thandle_t) &handle,
 +          readMFile, writeDummy, seekMFile, closeDummy,
 +          sizeMFile, mapDummy, unMapDummy);
- 
--        tif = TIFFOpen(tempFileName, "r");
--    }
++ 
      if (tif) {
          result = CommonRead(interp, tif, format, imageHandle,
-@@ -610,7 +461,4 @@
+@@ -621,7 +472,4 @@
          result = TCL_ERROR;
      }
 -    if (tempFileName) {
 -        unlink(tempFileName);
 -    }
      if (result == TCL_ERROR) {
-         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;
-@@ -689,5 +537,5 @@
- 
-     if (!TIFFReadRGBAImage(tif, w, h, raster, 0) || errorMessage) {
+         if (strlen (Tcl_GetStringResult(interp)) == 0 && errorMessage) {
+@@ -710,5 +558,5 @@
+             errorMessage = NULL;
+         }
 -        TkimgTIFFfree (raster);
 +        _TIFFfree (raster);
-         if (errorMessage) {
-             Tcl_AppendResult(interp, errorMessage, (char *) NULL);
-@@ -705,5 +553,5 @@
+         return TCL_ERROR;
+     }
+@@ -722,5 +570,5 @@
      }
  
 -    TkimgTIFFfree (raster);
 +    _TIFFfree (raster);
-     TIFFClose(tif);
-     return result;
-@@ -718,5 +566,4 @@
+     return TCL_OK;
+ }
+@@ -734,5 +582,4 @@
      int result, comp;
      tkimg_MFile handle;
 -    char *dir, *tempFileName = NULL, tempFileNameBuffer[256];
      Tcl_DString dstring;
      const char *mode;
-@@ -728,46 +575,9 @@
+@@ -744,58 +591,14 @@
      }
  
 -    if (TIFFClientOpen) {
@@ -302,7 +302,12 @@
 -#ifdef WIN32
 -        char dirBuffer[512];
 -        HANDLE h;
--
++    Tcl_DStringInit(&dstring);
++    tkimg_WriteInit(&dstring, &handle);
++    tif = TIFFClientOpen("inline data", mode, (thandle_t) &handle,
++            readString, writeString, seekString, closeDummy,
++            sizeString, mapDummy, unMapDummy);
+ 
 -        dir = dirBuffer;
 -        strcpy(dir, ".");
 -        GetTempPathA(sizeof (dirBuffer), dir);
@@ -334,14 +339,9 @@
 -#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);
- 
+-
      result = CommonWrite(interp, tif, comp, blockPtr);
-@@ -775,11 +585,4 @@
+     TIFFClose(tif);
  
      if (result != TCL_OK) {
 -        if (tempFileName) {
@@ -353,7 +353,7 @@
 -        }
          Tcl_AppendResult(interp, errorMessage, (char *) NULL);
          ckfree(errorMessage);
-@@ -788,43 +591,13 @@
+@@ -804,43 +607,13 @@
      }
  
 -    if (tempFileName) {
@@ -405,7 +405,7 @@
 +    return TCL_OK;
  }
  
-@@ -1043,9 +816,5 @@
+@@ -1063,9 +836,5 @@
  TkimgTIFFfree(tdata_t data)
  {
 -    if (_TIFFfree) {
@@ -416,7 +416,7 @@
 +    _TIFFfree(data);
  }
  
-@@ -1053,9 +822,5 @@
+@@ -1073,9 +842,5 @@
  TkimgTIFFmalloc(tsize_t size)
  {
 -    if (_TIFFmalloc) {
@@ -427,7 +427,7 @@
 +    return _TIFFmalloc(size);
  }
  
-@@ -1065,8 +830,4 @@
+@@ -1085,8 +850,4 @@
      tsize_t size
  ) {
 -    if (_TIFFrealloc) {
diff --git a/graphics/libimg/pkg-plist b/graphics/libimg/pkg-plist
index 1eb929fd1ee3..5c3d1775c480 100644
--- a/graphics/libimg/pkg-plist
+++ b/graphics/libimg/pkg-plist
@@ -10,6 +10,7 @@
 man/mann/img-bmp.n.gz
 man/mann/img-dted.n.gz
 man/mann/img-gif.n.gz
+man/mann/img-flir.n.gz
 man/mann/img-ico.n.gz
 man/mann/img-jpeg.n.gz
 man/mann/img-pcx.n.gz