forked from gentoo/gentoo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
imlib-1.9.15-giflib51-1.patch
122 lines (117 loc) · 3.21 KB
/
imlib-1.9.15-giflib51-1.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
diff -Nru imlib-1.9.15.old/gdk_imlib/io-gif.c imlib-1.9.15/gdk_imlib/io-gif.c
--- imlib-1.9.15.old/gdk_imlib/io-gif.c 2014-05-28 13:54:48.860293627 +0100
+++ imlib-1.9.15/gdk_imlib/io-gif.c 2014-05-28 13:58:29.992185729 +0100
@@ -1,8 +1,10 @@
#include <config.h>
#include "gdk_imlib.h"
#include "gdk_imlib_private.h"
+#include <gifutil.h>
#ifndef HAVE_LIBGIF
+/*------------------------*/
unsigned char loader_gif (FILE *f, int *w, int *h, int *t)
{
return NULL;
@@ -43,14 +45,14 @@
{
if (DGifGetRecordType(gif, &rec) == GIF_ERROR)
{
- PrintGifError();
+ _PrintGifError(gif);
rec = TERMINATE_RECORD_TYPE;
}
if ((rec == IMAGE_DESC_RECORD_TYPE) && (!done))
{
if (DGifGetImageDesc(gif) == GIF_ERROR)
{
- PrintGifError();
+ _PrintGifError(gif);
rec = TERMINATE_RECORD_TYPE;
}
*w = gif->Image.Width;
diff -Nru imlib-1.9.15.old/gifutil.h imlib-1.9.15/gifutil.h
--- imlib-1.9.15.old/gifutil.h 1970-01-01 01:00:00.000000000 +0100
+++ imlib-1.9.15/gifutil.h 2014-05-28 13:57:45.019424755 +0100
@@ -0,0 +1,26 @@
+#ifndef __GIFUTIL_H__
+#define __GIFUTIL_H__
+
+static void
+_PrintGifError(GifFileType *gif)
+{
+ /* GIFLIB_MAJOR is only defined in libgif >= 4.2.0 */
+ /* libgif 4.2.0 has retired PrintGifError() and added GifErrorString() */
+#if defined(GIFLIB_MAJOR) && defined(GIFLIB_MINOR) && \
+ ((GIFLIB_MAJOR == 4 && GIFLIB_MINOR >= 2) || GIFLIB_MAJOR > 4)
+ /* Static string actually, hence the const char* cast */
+
+#if GIFLIB_MAJOR >= 5
+ const char* gifliberr = (const char*) GifErrorString(gif->Error);
+#else
+ const char* gifliberr = (const char*) GifErrorString();
+#endif
+ if (gifliberr == NULL)
+ gifliberr = "Unknown error";
+ fprintf(stderr, "%s\n", gifliberr);
+#else
+ PrintGifError();
+#endif
+}
+
+#endif
diff -Nru imlib-1.9.15.old/Imlib/load.c imlib-1.9.15/Imlib/load.c
--- imlib-1.9.15.old/Imlib/load.c 2014-05-28 13:54:49.008295568 +0100
+++ imlib-1.9.15/Imlib/load.c 2014-05-28 14:00:21.321983945 +0100
@@ -3,6 +3,7 @@
#include "Imlib.h"
#include "Imlib_private.h"
#include <setjmp.h>
+#include <gifutil.h>
#define G_MAXINT ((int) 0x7fffffff)
@@ -431,6 +432,8 @@
#endif /* HAVE_LIBTIFF */
#ifdef HAVE_LIBGIF
+/*------------------------*/
+/*------------------------*/
unsigned char *
_LoadGIF(ImlibData * id, FILE *f, int *w, int *h, int *t)
{
@@ -454,22 +457,38 @@
fd = fileno(f);
/* Apparently rewind(f) isn't sufficient */
lseek(fd, (long) 0, 0);
+
+#if GIFLIB_MAJOR >= 5
+ int errCode = 0;
+
+ gif = DGifOpenFileHandle(fd, &errCode);
+ if (!gif)
+ {
+ const char* gifliberr = (const char*) GifErrorString(errCode);
+ if (gifliberr == NULL)
+ gifliberr = "Unknown error";
+ fprintf(stderr, "%s\n", gifliberr);
+ return NULL;
+ }
+#else
gif = DGifOpenFileHandle(fd);
if (!gif)
return NULL;
+#endif
+
do
{
if (DGifGetRecordType(gif, &rec) == GIF_ERROR)
{
- PrintGifError();
+ _PrintGifError(gif);
rec = TERMINATE_RECORD_TYPE;
}
if ((rec == IMAGE_DESC_RECORD_TYPE) && (!done))
{
if (DGifGetImageDesc(gif) == GIF_ERROR)
{
- PrintGifError();
+ _PrintGifError(gif);
rec = TERMINATE_RECORD_TYPE;
}
*w = gif->Image.Width;