File mtpaint-3.40-giflib5.diff of Package mtpaint

---
 src/png.c |   35 ++++++++++++++++++++++++++++++-----
 1 file changed, 30 insertions(+), 5 deletions(-)

Index: mtpaint-3.40/src/png.c
===================================================================
--- mtpaint-3.40.orig/src/png.c
+++ mtpaint-3.40/src/png.c
@@ -57,6 +57,12 @@
 #include <lcms.h>
 #endif
 
+#if defined(GIFLIB_MAJOR) && \
+	(GIFLIB_MAJOR < 5 || (GIFLIB_MAJOR == 5 && GIFLIB_MINOR < 1))
+#	define DGifCloseFile(a, b) DGifCloseFile(a)
+#	define EGifCloseFile(a, b) EGifCloseFile(a)
+#endif
+
 #include "global.h"
 
 #include "mygtk.h"
@@ -1509,8 +1515,11 @@ static int load_gif_frames(char *file_na
 	ls_settings w_set, init_set;
 	int res, val, disposal, bpp, cmask, lastzero = FALSE;
 
-
+#if GIFLIB_MAJOR < 5
 	if (!(giffy = DGifOpenFileName(file_name))) return (-1);
+#else
+	if (!(giffy = DGifOpenFileName(file_name, NULL))) return (-1);
+#endif
 
 	/* Init state structure */
 	memset(&stat, 0, sizeof(stat));
@@ -1608,7 +1617,7 @@ static int load_gif_frames(char *file_na
 	}
 	res = 1;
 fail:	mem_free_chanlist(w_set.img);
-	DGifCloseFile(giffy);
+	DGifCloseFile(giffy, NULL);
 	return (res);
 }
 
@@ -1621,7 +1630,11 @@ static int load_gif(char *file_name, ls_
 	int delay = settings->gif_delay, trans = -1;//, disposal = 0;
 
 
+#if GIFLIB_MAJOR < 5
 	if (!(giffy = DGifOpenFileName(file_name))) return (-1);
+#else
+	if (!(giffy = DGifOpenFileName(file_name, NULL))) return (-1);
+#endif
 
 	/* Get global palette */
 	settings->colors = convert_gif_palette(settings->pal, giffy->SColorMap);
@@ -1659,7 +1672,7 @@ static int load_gif(char *file_name, ls_
 		}
 	}
 	res = 1;
-fail:	DGifCloseFile(giffy);
+fail:	DGifCloseFile(giffy, NULL);
 	return (res);
 }
 
@@ -1682,10 +1695,17 @@ static int save_gif(char *file_name, ls_
 	nc |= nc >> 1; nc |= nc >> 2; nc |= nc >> 4;
 	nc += !nc + 1; // No less than 2 colors
 
+#if GIFLIB_MAJOR < 5
 	gif_map = MakeMapObject(nc, NULL);
 	if (!gif_map) return -1;
 
 	giffy = EGifOpenFileName(file_name, FALSE);
+#else
+	gif_map = GifMakeMapObject(nc, NULL);
+	if (!gif_map) return -1;
+
+	giffy = EGifOpenFileName(file_name, FALSE, NULL);
+#endif
 	if (!giffy) goto fail0;
 
 	for (i = 0; i < settings->colors; i++)
@@ -1725,14 +1745,19 @@ static int save_gif(char *file_name, ls_
 	if (!settings->silent) progress_end();
 	msg = 0;
 
-fail:	EGifCloseFile(giffy);
+fail:	EGifCloseFile(giffy, NULL);
 #ifndef WIN32
 	/* giflib creates files with 0600 permissions, which is nasty - WJ */
 	mode = umask(0022);
 	umask(mode);
 	chmod(file_name, 0666 & ~mode);
 #endif
-fail0:	FreeMapObject(gif_map);
+fail0:
+#if GIFLIB_MAJOR < 5
+	FreeMapObject(gif_map);
+#else
+	GifFreeMapObject(gif_map);
+#endif
 
 	return (msg);
 }
openSUSE Build Service is sponsored by