File: png-fixes-for-building-against-libpng-1.6-and-fn.pointer-.patch

package info (click to toggle)
sdl-image1.2 1.2.12-14
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 7,028 kB
  • sloc: sh: 10,194; ansic: 9,697; objc: 248; csh: 219; makefile: 83
file content (251 lines) | stat: -rw-r--r-- 10,436 bytes parent folder | download
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
From: Ozkan Sezer <sezeroz@gmail.com>
Date: Sun, 14 Oct 2018 15:00:50 +0300
Subject: png: fixes for building against libpng-1.6,
 and fn.pointer type fixes.

from default branch commits f83e70f2ec6c,  4c41cee3e961, 777206f89dd2,
4c73e89f2551, 43873c313f32, e729829dbfc2,  4078e65827ea, ace61a625208,
218eb926ba90, 71f0d661144f, and 4b70bfe18fb7 -- bugs 1884, 1912, 3082,
and 3214.

Origin: upstream, commit:019f68f9f9460bdc37e5098d360ebc85758cae5c
Bug-Debian: https://bugs.debian.org/1075498
---
 IMG_png.c | 90 +++++++++++++++++++++++++++++++++++----------------------------
 1 file changed, 50 insertions(+), 40 deletions(-)

diff --git a/IMG_png.c b/IMG_png.c
index 613bf2c..ecf17b1 100644
--- a/IMG_png.c
+++ b/IMG_png.c
@@ -71,34 +71,44 @@
 #include <png.h>
 
 /* Check for the older version of libpng */
-#if (PNG_LIBPNG_VER_MAJOR == 1) && (PNG_LIBPNG_VER_MINOR < 4)
+#if (PNG_LIBPNG_VER_MAJOR == 1) 
+#if (PNG_LIBPNG_VER_MINOR < 5)
 #define LIBPNG_VERSION_12
+typedef png_bytep png_const_bytep;
+typedef png_color *png_const_colorp;
+#endif
+#if (PNG_LIBPNG_VER_MINOR < 6)
+typedef png_structp png_const_structrp;
+typedef png_infop png_const_inforp;
+typedef png_structp png_structrp;
+typedef png_infop png_inforp;
+#endif
 #endif
 
 static struct {
 	int loaded;
 	void *handle;
-	png_infop (*png_create_info_struct) (png_structp png_ptr);
+	png_infop (*png_create_info_struct) (png_const_structrp png_ptr);
 	png_structp (*png_create_read_struct) (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn);
 	void (*png_destroy_read_struct) (png_structpp png_ptr_ptr, png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr);
-	png_uint_32 (*png_get_IHDR) (png_structp png_ptr, png_infop info_ptr, png_uint_32 *width, png_uint_32 *height, int *bit_depth, int *color_type, int *interlace_method, int *compression_method, int *filter_method);
-	png_voidp (*png_get_io_ptr) (png_structp png_ptr);
-	png_byte (*png_get_channels) (png_structp png_ptr, png_infop info_ptr);
-	png_uint_32 (*png_get_PLTE) (png_structp png_ptr, png_infop info_ptr, png_colorp *palette, int *num_palette);
-	png_uint_32 (*png_get_tRNS) (png_structp png_ptr, png_infop info_ptr, png_bytep *trans, int *num_trans, png_color_16p *trans_values);
-	png_uint_32 (*png_get_valid) (png_structp png_ptr, png_infop info_ptr, png_uint_32 flag);
-	void (*png_read_image) (png_structp png_ptr, png_bytepp image);
-	void (*png_read_info) (png_structp png_ptr, png_infop info_ptr);
-	void (*png_read_update_info) (png_structp png_ptr, png_infop info_ptr);
-	void (*png_set_expand) (png_structp png_ptr);
-	void (*png_set_gray_to_rgb) (png_structp png_ptr);
-	void (*png_set_packing) (png_structp png_ptr);
-	void (*png_set_read_fn) (png_structp png_ptr, png_voidp io_ptr, png_rw_ptr read_data_fn);
-	void (*png_set_strip_16) (png_structp png_ptr);
+	png_uint_32 (*png_get_IHDR) (png_const_structrp png_ptr, png_const_inforp info_ptr, png_uint_32 *width, png_uint_32 *height, int *bit_depth, int *color_type, int *interlace_method, int *compression_method, int *filter_method);
+	png_voidp (*png_get_io_ptr) (png_const_structrp png_ptr);
+	png_byte (*png_get_channels) (png_const_structrp png_ptr, png_const_inforp info_ptr);
+	png_uint_32 (*png_get_PLTE) (png_const_structrp png_ptr, png_inforp info_ptr, png_colorp *palette, int *num_palette);
+	png_uint_32 (*png_get_tRNS) (png_const_structrp png_ptr, png_inforp info_ptr, png_bytep *trans, int *num_trans, png_color_16p *trans_values);
+	png_uint_32 (*png_get_valid) (png_const_structrp png_ptr, png_const_inforp info_ptr, png_uint_32 flag);
+	void (*png_read_image) (png_structrp png_ptr, png_bytepp image);
+	void (*png_read_info) (png_structrp png_ptr, png_inforp info_ptr);
+	void (*png_read_update_info) (png_structrp png_ptr, png_inforp info_ptr);
+	void (*png_set_expand) (png_structrp png_ptr);
+	void (*png_set_gray_to_rgb) (png_structrp png_ptr);
+	void (*png_set_packing) (png_structrp png_ptr);
+	void (*png_set_read_fn) (png_structrp png_ptr, png_voidp io_ptr, png_rw_ptr read_data_fn);
+	void (*png_set_strip_16) (png_structrp png_ptr);
 	int (*png_set_interlace_handling) (png_structp png_ptr);
-	int (*png_sig_cmp) (png_bytep sig, png_size_t start, png_size_t num_to_check);
+	int (*png_sig_cmp) (png_const_bytep sig, png_size_t start, png_size_t num_to_check);
 #ifndef LIBPNG_VERSION_12
-	jmp_buf* (*png_set_longjmp_fn) (png_structp, png_longjmp_ptr, size_t);
+	jmp_buf* (*png_set_longjmp_fn) (png_structrp, png_longjmp_ptr, size_t);
 #endif
 } lib;
 
@@ -111,14 +121,14 @@ int IMG_InitPNG()
 			return -1;
 		}
 		lib.png_create_info_struct =
-			(png_infop (*) (png_structp))
+			(png_infop (*) (png_const_structrp))
 			SDL_LoadFunction(lib.handle, "png_create_info_struct");
 		if ( lib.png_create_info_struct == NULL ) {
 			SDL_UnloadObject(lib.handle);
 			return -1;
 		}
 		lib.png_create_read_struct =
-			(png_structp (*) (png_const_charp, png_voidp, png_error_ptr, png_error_ptr))
+			(png_structrp (*) (png_const_charp, png_voidp, png_error_ptr, png_error_ptr))
 			SDL_LoadFunction(lib.handle, "png_create_read_struct");
 		if ( lib.png_create_read_struct == NULL ) {
 			SDL_UnloadObject(lib.handle);
@@ -132,112 +142,112 @@ int IMG_InitPNG()
 			return -1;
 		}
 		lib.png_get_IHDR =
-			(png_uint_32 (*) (png_structp, png_infop, png_uint_32 *, png_uint_32 *, int *, int *, int *, int *, int *))
+			(png_uint_32 (*) (png_const_structrp, png_const_inforp, png_uint_32 *, png_uint_32 *, int *, int *, int *, int *, int *))
 			SDL_LoadFunction(lib.handle, "png_get_IHDR");
 		if ( lib.png_get_IHDR == NULL ) {
 			SDL_UnloadObject(lib.handle);
 			return -1;
 		}
 		lib.png_get_channels =
-			(png_byte (*) (png_structp, png_infop))
+			(png_byte (*) (png_const_structrp, png_const_inforp))
 			SDL_LoadFunction(lib.handle, "png_get_channels");
 		if ( lib.png_get_channels == NULL ) {
 			SDL_UnloadObject(lib.handle);
 			return -1;
 		}
 		lib.png_get_io_ptr =
-			(png_voidp (*) (png_structp))
+			(png_voidp (*) (png_const_structrp))
 			SDL_LoadFunction(lib.handle, "png_get_io_ptr");
 		if ( lib.png_get_io_ptr == NULL ) {
 			SDL_UnloadObject(lib.handle);
 			return -1;
 		}
 		lib.png_get_PLTE =
-			(png_uint_32 (*) (png_structp, png_infop, png_colorp *, int *))
+			(png_uint_32 (*) (png_const_structrp, png_inforp, png_colorp *, int *))
 			SDL_LoadFunction(lib.handle, "png_get_PLTE");
 		if ( lib.png_get_PLTE == NULL ) {
 			SDL_UnloadObject(lib.handle);
 			return -1;
 		}
 		lib.png_get_tRNS =
-			(png_uint_32 (*) (png_structp, png_infop, png_bytep *, int *, png_color_16p *))
+			(png_uint_32 (*) (png_const_structrp, png_inforp, png_bytep *, int *, png_color_16p *))
 			SDL_LoadFunction(lib.handle, "png_get_tRNS");
 		if ( lib.png_get_tRNS == NULL ) {
 			SDL_UnloadObject(lib.handle);
 			return -1;
 		}
 		lib.png_get_valid =
-			(png_uint_32 (*) (png_structp, png_infop, png_uint_32))
+			(png_uint_32 (*) (png_const_structrp, png_const_inforp, png_uint_32))
 			SDL_LoadFunction(lib.handle, "png_get_valid");
 		if ( lib.png_get_valid == NULL ) {
 			SDL_UnloadObject(lib.handle);
 			return -1;
 		}
 		lib.png_read_image =
-			(void (*) (png_structp, png_bytepp))
+			(void (*) (png_structrp, png_bytepp))
 			SDL_LoadFunction(lib.handle, "png_read_image");
 		if ( lib.png_read_image == NULL ) {
 			SDL_UnloadObject(lib.handle);
 			return -1;
 		}
 		lib.png_read_info =
-			(void (*) (png_structp, png_infop))
+			(void (*) (png_structrp, png_inforp))
 			SDL_LoadFunction(lib.handle, "png_read_info");
 		if ( lib.png_read_info == NULL ) {
 			SDL_UnloadObject(lib.handle);
 			return -1;
 		}
 		lib.png_read_update_info =
-			(void (*) (png_structp, png_infop))
+			(void (*) (png_structrp, png_inforp))
 			SDL_LoadFunction(lib.handle, "png_read_update_info");
 		if ( lib.png_read_update_info == NULL ) {
 			SDL_UnloadObject(lib.handle);
 			return -1;
 		}
 		lib.png_set_expand =
-			(void (*) (png_structp))
+			(void (*) (png_structrp))
 			SDL_LoadFunction(lib.handle, "png_set_expand");
 		if ( lib.png_set_expand == NULL ) {
 			SDL_UnloadObject(lib.handle);
 			return -1;
 		}
 		lib.png_set_gray_to_rgb =
-			(void (*) (png_structp))
+			(void (*) (png_structrp))
 			SDL_LoadFunction(lib.handle, "png_set_gray_to_rgb");
 		if ( lib.png_set_gray_to_rgb == NULL ) {
 			SDL_UnloadObject(lib.handle);
 			return -1;
 		}
 		lib.png_set_packing =
-			(void (*) (png_structp))
+			(void (*) (png_structrp))
 			SDL_LoadFunction(lib.handle, "png_set_packing");
 		if ( lib.png_set_packing == NULL ) {
 			SDL_UnloadObject(lib.handle);
 			return -1;
 		}
 		lib.png_set_read_fn =
-			(void (*) (png_structp, png_voidp, png_rw_ptr))
+			(void (*) (png_structrp, png_voidp, png_rw_ptr))
 			SDL_LoadFunction(lib.handle, "png_set_read_fn");
 		if ( lib.png_set_read_fn == NULL ) {
 			SDL_UnloadObject(lib.handle);
 			return -1;
 		}
 		lib.png_set_strip_16 =
-			(void (*) (png_structp))
+			(void (*) (png_structrp))
 			SDL_LoadFunction(lib.handle, "png_set_strip_16");
 		if ( lib.png_set_strip_16 == NULL ) {
 			SDL_UnloadObject(lib.handle);
 			return -1;
 		}
 		lib.png_set_interlace_handling =
-			(int (*) (png_structp))
+			(void (*) (png_structp))
 			SDL_LoadFunction(lib.handle, "png_set_interlace_handling");
 		if ( lib.png_set_interlace_handling == NULL ) {
 			SDL_UnloadObject(lib.handle);
 			return -1;
 		}
 		lib.png_sig_cmp =
-			(int (*) (png_bytep, png_size_t, png_size_t))
+			(int (*) (png_const_bytep, png_size_t, png_size_t))
 			SDL_LoadFunction(lib.handle, "png_sig_cmp");
 		if ( lib.png_sig_cmp == NULL ) {
 			SDL_UnloadObject(lib.handle);
@@ -245,7 +255,7 @@ int IMG_InitPNG()
 		}
 #ifndef LIBPNG_VERSION_12
 		lib.png_set_longjmp_fn =
-			(jmp_buf * (*) (png_structp, png_longjmp_ptr, size_t))
+			(jmp_buf * (*) (png_structrp, png_longjmp_ptr, size_t))
 			SDL_LoadFunction(lib.handle, "png_set_longjmp_fn");
 		if ( lib.png_set_longjmp_fn == NULL ) {
 			SDL_UnloadObject(lib.handle);
@@ -527,9 +537,9 @@ SDL_Surface *IMG_LoadPNG_RW(SDL_RWops *src)
 	    if(color_type == PNG_COLOR_TYPE_GRAY) {
 		palette->ncolors = 256;
 		for(i = 0; i < 256; i++) {
-		    palette->colors[i].r = i;
-		    palette->colors[i].g = i;
-		    palette->colors[i].b = i;
+		    palette->colors[i].r = (Uint8)i;
+		    palette->colors[i].g = (Uint8)i;
+		    palette->colors[i].b = (Uint8)i;
 		}
 	    } else if (png_num_palette > 0 ) {
 		palette->ncolors = png_num_palette;