wok-current view xplanet/stuff/xplanet-giflib5.patch @ rev 25174

updated python-flask (1.1.2 -> 1.1.4)
author Hans-G?nter Theisgen
date Fri Jul 01 17:16:59 2022 +0100 (2022-07-01)
parents
children
line source
1 --- xplanet-1.3.0.orig/src/libimage/gif.c 2006-03-25 14:50:51.000000000 -0800
2 +++ xplanet-1.3.0/src/libimage/gif.c 2015-01-30 21:01:52.000000000 -0800
3 @@ -28,6 +28,18 @@
4 distribution.
5 */
7 +#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5
8 +void
9 +PrintGifError(int ErrorCode) {
10 + const char *Err = GifErrorString(ErrorCode);
11 + if (Err != NULL)
12 + fprintf(stderr, "GIF-LIB error: %s.\n", Err);
13 + else
14 + fprintf(stderr, "GIF-LIB undefined error %d.\n", ErrorCode);
15 +}
16 +#endif
17 +
18 +
19 int
20 read_gif(const char *filename, int *width, int *height, unsigned char **rgb)
21 {
22 @@ -41,12 +53,23 @@
23 int i, j;
24 int color_index;
25 unsigned char *ptr = NULL;
26 -
27 +#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5
28 + int err;
29 +#endif
30 +
31 +#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5
32 + infile = DGifOpenFileName(filename, NULL);
33 +#else
34 infile = DGifOpenFileName(filename);
35 +#endif
37 if (infile == NULL)
38 {
39 +#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5
40 + PrintGifError(infile->Error);
41 +#else
42 PrintGifError();
43 +#endif
44 return(0);
45 }
47 @@ -54,7 +77,11 @@
48 {
49 if (DGifGetRecordType(infile, &record_type) == GIF_ERROR)
50 {
51 +#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5
52 + PrintGifError(infile->Error);
53 +#else
54 PrintGifError();
55 +#endif
56 return(0);
57 }
59 @@ -63,7 +90,11 @@
60 case IMAGE_DESC_RECORD_TYPE:
61 if (DGifGetImageDesc(infile) == GIF_ERROR)
62 {
63 +#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5
64 + PrintGifError(infile->Error);
65 +#else
66 PrintGifError();
67 +#endif
68 return(0);
69 }
71 @@ -107,14 +138,22 @@
72 GifByteType *ext;
73 if (DGifGetExtension(infile, &ext_code, &ext) == GIF_ERROR)
74 {
75 +#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5
76 + PrintGifError(infile->Error);
77 +#else
78 PrintGifError();
79 +#endif
80 return(0);
81 }
82 while (ext != NULL)
83 {
84 if (DGifGetExtensionNext(infile, &ext) == GIF_ERROR)
85 {
86 +#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5
87 + PrintGifError(infile->Error);
88 +#else
89 PrintGifError();
90 +#endif
91 return(0);
92 }
93 }
94 @@ -154,7 +193,11 @@
96 free(buffer);
98 +#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5 && GIFLIB_MINOR >= 1
99 + DGifCloseFile(infile, NULL);
100 +#else
101 DGifCloseFile(infile);
102 +#endif
103 return(1);
104 }
106 @@ -166,6 +209,9 @@
107 GifByteType *red, *green, *blue, *buffer, *ptr;
108 GifFileType *outfile;
109 ColorMapObject *colormap;
110 +#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5
111 + int err;
112 +#endif
114 red = malloc(width * height * sizeof(GifByteType));
115 green = malloc(width * height * sizeof(GifByteType));
116 @@ -178,7 +224,11 @@
117 return(0);
118 }
120 +#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5
121 + colormap = GifMakeMapObject(colormap_size, NULL);
122 +#else
123 colormap = MakeMapObject(colormap_size, NULL);
124 +#endif
126 for (i = 0; i < width * height; i++)
127 {
128 @@ -187,10 +237,17 @@
129 blue[i] = (GifByteType) rgb[3*i+2];
130 }
132 +#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5
133 + if (GifQuantizeBuffer(width, height, &colormap_size, red, green, blue,
134 + buffer, colormap->Colors) == GIF_ERROR)
135 + {
136 + PrintGifError(-1);
137 +#else
138 if (QuantizeBuffer(width, height, &colormap_size, red, green, blue,
139 buffer, colormap->Colors) == GIF_ERROR)
140 {
141 PrintGifError();
142 +#endif
143 return(0);
144 }
146 @@ -198,24 +255,41 @@
147 free(green);
148 free(blue);
150 +#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5
151 + outfile = EGifOpenFileName((char *) filename, 0, &err);
152 + if (outfile == NULL)
153 + {
154 + PrintGifError(err);
155 + return(0);
156 + }
157 +#else
158 outfile = EGifOpenFileName((char *) filename, FALSE);
159 if (outfile == NULL)
160 {
161 PrintGifError();
162 return(0);
163 }
164 +#endif
166 if (EGifPutScreenDesc(outfile, width, height, colormap_size, 0, colormap)
167 == GIF_ERROR)
168 {
169 +#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5
170 + PrintGifError(outfile->Error);
171 +#else
172 PrintGifError();
173 +#endif
174 return(0);
175 }
177 - if (EGifPutImageDesc(outfile, 0, 0, width, height, FALSE, NULL)
178 + if (EGifPutImageDesc(outfile, 0, 0, width, height, 0, NULL)
179 == GIF_ERROR)
180 {
181 +#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5
182 + PrintGifError(outfile->Error);
183 +#else
184 PrintGifError();
185 +#endif
186 return(0);
187 }
189 @@ -224,7 +298,11 @@
190 {
191 if (EGifPutLine(outfile, ptr, width) == GIF_ERROR)
192 {
193 +#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5
194 + PrintGifError(outfile->Error);
195 +#else
196 PrintGifError();
197 +#endif
198 return(0);
199 }
200 ptr += width;
201 @@ -232,8 +310,13 @@
203 EGifSpew(outfile);
205 +#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5 && GIFLIB_MINOR >= 1
206 + if (EGifCloseFile(outfile, &err) == GIF_ERROR)
207 + PrintGifError(err);
208 +#else
209 if (EGifCloseFile(outfile) == GIF_ERROR)
210 PrintGifError();
211 +#endif
213 free(buffer);