Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: third_party/libpng/pngerror.c

Issue 15041: Update libpng to 1.2.33. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 12 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « third_party/libpng/pngconf.h ('k') | third_party/libpng/pngget.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* pngerror.c - stub functions for i/o and memory allocation 2 /* pngerror.c - stub functions for i/o and memory allocation
3 * 3 *
4 * Last changed in libpng 1.2.22 [October 13, 2007] 4 * Last changed in libpng 1.2.30 [August 15, 2008]
5 * For conditions of distribution and use, see copyright notice in png.h 5 * For conditions of distribution and use, see copyright notice in png.h
6 * Copyright (c) 1998-2007 Glenn Randers-Pehrson 6 * Copyright (c) 1998-2008 Glenn Randers-Pehrson
7 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 7 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
8 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) 8 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
9 * 9 *
10 * This file provides a location for all error handling. Users who 10 * This file provides a location for all error handling. Users who
11 * need special error handling are expected to write replacement functions 11 * need special error handling are expected to write replacement functions
12 * and use png_set_error_fn() to use those functions. See the instructions 12 * and use png_set_error_fn() to use those functions. See the instructions
13 * at each function. 13 * at each function.
14 */ 14 */
15 15
16 #define PNG_INTERNAL 16 #define PNG_INTERNAL
17 #include "png.h" 17 #include "png.h"
18 #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
18 19
19 #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
20 static void /* PRIVATE */ 20 static void /* PRIVATE */
21 png_default_error PNGARG((png_structp png_ptr, 21 png_default_error PNGARG((png_structp png_ptr,
22 png_const_charp error_message)); 22 png_const_charp error_message));
23 #ifndef PNG_NO_WARNINGS 23 #ifndef PNG_NO_WARNINGS
24 static void /* PRIVATE */ 24 static void /* PRIVATE */
25 png_default_warning PNGARG((png_structp png_ptr, 25 png_default_warning PNGARG((png_structp png_ptr,
26 png_const_charp warning_message)); 26 png_const_charp warning_message));
27 #endif /* PNG_NO_WARNINGS */ 27 #endif /* PNG_NO_WARNINGS */
28 28
29 /* This function is called whenever there is a fatal error. This function 29 /* This function is called whenever there is a fatal error. This function
30 * should not be changed. If there is a need to handle errors differently, 30 * should not be changed. If there is a need to handle errors differently,
31 * you should supply a replacement error function and use png_set_error_fn() 31 * you should supply a replacement error function and use png_set_error_fn()
32 * to replace the error function at run-time. 32 * to replace the error function at run-time.
33 */ 33 */
34 #ifndef PNG_NO_ERROR_TEXT 34 #ifndef PNG_NO_ERROR_TEXT
35 void PNGAPI 35 void PNGAPI
36 png_error(png_structp png_ptr, png_const_charp error_message) 36 png_error(png_structp png_ptr, png_const_charp error_message)
37 { 37 {
38 #ifdef PNG_ERROR_NUMBERS_SUPPORTED 38 #ifdef PNG_ERROR_NUMBERS_SUPPORTED
39 char msg[16]; 39 char msg[16];
40 if (png_ptr != NULL) 40 if (png_ptr != NULL)
41 { 41 {
42 if (png_ptr->flags& 42 if (png_ptr->flags&
43 (PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) 43 (PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))
44 { 44 {
45 if (*error_message == '#') 45 if (*error_message == '#')
46 { 46 {
47 /* Strip "#nnnn " from beginning of error message. */
47 int offset; 48 int offset;
48 for (offset=1; offset<15; offset++) 49 for (offset = 1; offset<15; offset++)
49 if (*(error_message+offset) == ' ') 50 if (error_message[offset] == ' ')
50 break; 51 break;
51 if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT) 52 if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT)
52 { 53 {
53 int i; 54 int i;
54 for (i=0; i<offset-1; i++) 55 for (i = 0; i < offset - 1; i++)
55 msg[i]=error_message[i+1]; 56 msg[i] = error_message[i + 1];
56 msg[i]='\0'; 57 msg[i - 1] = '\0';
57 error_message=msg; 58 error_message = msg;
58 } 59 }
59 else 60 else
60 error_message+=offset; 61 error_message += offset;
61 } 62 }
62 else 63 else
63 { 64 {
64 if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT) 65 if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT)
65 { 66 {
66 msg[0]='0'; 67 msg[0] = '0';
67 msg[1]='\0'; 68 msg[1] = '\0';
68 error_message=msg; 69 error_message = msg;
69 } 70 }
70 } 71 }
71 } 72 }
72 } 73 }
73 #endif 74 #endif
74 if (png_ptr != NULL && png_ptr->error_fn != NULL) 75 if (png_ptr != NULL && png_ptr->error_fn != NULL)
75 (*(png_ptr->error_fn))(png_ptr, error_message); 76 (*(png_ptr->error_fn))(png_ptr, error_message);
76 77
77 /* If the custom handler doesn't exist, or if it returns, 78 /* If the custom handler doesn't exist, or if it returns,
78 use the default handler, which will not return. */ 79 use the default handler, which will not return. */
(...skipping 24 matching lines...) Expand all
103 int offset = 0; 104 int offset = 0;
104 if (png_ptr != NULL) 105 if (png_ptr != NULL)
105 { 106 {
106 #ifdef PNG_ERROR_NUMBERS_SUPPORTED 107 #ifdef PNG_ERROR_NUMBERS_SUPPORTED
107 if (png_ptr->flags& 108 if (png_ptr->flags&
108 (PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) 109 (PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))
109 #endif 110 #endif
110 { 111 {
111 if (*warning_message == '#') 112 if (*warning_message == '#')
112 { 113 {
113 for (offset=1; offset<15; offset++) 114 for (offset = 1; offset < 15; offset++)
114 if (*(warning_message+offset) == ' ') 115 if (warning_message[offset] == ' ')
115 break; 116 break;
116 } 117 }
117 } 118 }
118 if (png_ptr != NULL && png_ptr->warning_fn != NULL) 119 if (png_ptr != NULL && png_ptr->warning_fn != NULL)
119 (*(png_ptr->warning_fn))(png_ptr, warning_message+offset); 120 (*(png_ptr->warning_fn))(png_ptr, warning_message + offset);
120 } 121 }
121 else 122 else
122 png_default_warning(png_ptr, warning_message+offset); 123 png_default_warning(png_ptr, warning_message + offset);
123 } 124 }
124 #endif /* PNG_NO_WARNINGS */ 125 #endif /* PNG_NO_WARNINGS */
125 126
126 127
127 /* These utilities are used internally to build an error message that relates 128 /* These utilities are used internally to build an error message that relates
128 * to the current chunk. The chunk name comes from png_ptr->chunk_name, 129 * to the current chunk. The chunk name comes from png_ptr->chunk_name,
129 * this is used to prefix the message. The message is limited in length 130 * this is used to prefix the message. The message is limited in length
130 * to 63 bytes, the name characters are output as hex digits wrapped in [] 131 * to 63 bytes, the name characters are output as hex digits wrapped in []
131 * if the character is invalid. 132 * if the character is invalid.
132 */ 133 */
(...skipping 27 matching lines...) Expand all
160 buffer[iout++] = (png_byte)c; 161 buffer[iout++] = (png_byte)c;
161 } 162 }
162 } 163 }
163 164
164 if (error_message == NULL) 165 if (error_message == NULL)
165 buffer[iout] = '\0'; 166 buffer[iout] = '\0';
166 else 167 else
167 { 168 {
168 buffer[iout++] = ':'; 169 buffer[iout++] = ':';
169 buffer[iout++] = ' '; 170 buffer[iout++] = ' ';
170 png_memcpy(buffer+iout, error_message, PNG_MAX_ERROR_TEXT); 171 png_memcpy(buffer + iout, error_message, PNG_MAX_ERROR_TEXT);
171 buffer[iout+PNG_MAX_ERROR_TEXT-1] = '\0'; 172 buffer[iout + PNG_MAX_ERROR_TEXT - 1] = '\0';
172 } 173 }
173 } 174 }
174 175
175 #ifdef PNG_READ_SUPPORTED 176 #ifdef PNG_READ_SUPPORTED
176 void PNGAPI 177 void PNGAPI
177 png_chunk_error(png_structp png_ptr, png_const_charp error_message) 178 png_chunk_error(png_structp png_ptr, png_const_charp error_message)
178 { 179 {
179 char msg[18+PNG_MAX_ERROR_TEXT]; 180 char msg[18+PNG_MAX_ERROR_TEXT];
180 if (png_ptr == NULL) 181 if (png_ptr == NULL)
181 png_error(png_ptr, error_message); 182 png_error(png_ptr, error_message);
(...skipping 27 matching lines...) Expand all
209 * function is used by default, or if the program supplies NULL for the 210 * function is used by default, or if the program supplies NULL for the
210 * error function pointer in png_set_error_fn(). 211 * error function pointer in png_set_error_fn().
211 */ 212 */
212 static void /* PRIVATE */ 213 static void /* PRIVATE */
213 png_default_error(png_structp png_ptr, png_const_charp error_message) 214 png_default_error(png_structp png_ptr, png_const_charp error_message)
214 { 215 {
215 #ifndef PNG_NO_CONSOLE_IO 216 #ifndef PNG_NO_CONSOLE_IO
216 #ifdef PNG_ERROR_NUMBERS_SUPPORTED 217 #ifdef PNG_ERROR_NUMBERS_SUPPORTED
217 if (*error_message == '#') 218 if (*error_message == '#')
218 { 219 {
220 /* Strip "#nnnn " from beginning of warning message. */
219 int offset; 221 int offset;
220 char error_number[16]; 222 char error_number[16];
221 for (offset=0; offset<15; offset++) 223 for (offset = 0; offset<15; offset++)
222 { 224 {
223 error_number[offset] = *(error_message+offset+1); 225 error_number[offset] = error_message[offset + 1];
224 if (*(error_message+offset) == ' ') 226 if (error_message[offset] == ' ')
225 break; 227 break;
226 } 228 }
227 if((offset > 1) && (offset < 15)) 229 if ((offset > 1) && (offset < 15))
228 { 230 {
229 error_number[offset-1]='\0'; 231 error_number[offset - 1] = '\0';
230 fprintf(stderr, "libpng error no. %s: %s\n", error_number, 232 fprintf(stderr, "libpng error no. %s: %s\n", error_number,
231 error_message+offset); 233 error_message + offset + 1);
232 } 234 }
233 else 235 else
234 fprintf(stderr, "libpng error: %s, offset=%d\n", error_message,offset); 236 fprintf(stderr, "libpng error: %s, offset=%d\n", error_message, offset);
235 } 237 }
236 else 238 else
237 #endif 239 #endif
238 fprintf(stderr, "libpng error: %s\n", error_message); 240 fprintf(stderr, "libpng error: %s\n", error_message);
239 #endif 241 #endif
240 242
241 #ifdef PNG_SETJMP_SUPPORTED 243 #ifdef PNG_SETJMP_SUPPORTED
242 if (png_ptr) 244 if (png_ptr)
243 { 245 {
244 # ifdef USE_FAR_KEYWORD 246 # ifdef USE_FAR_KEYWORD
(...skipping 22 matching lines...) Expand all
267 */ 269 */
268 static void /* PRIVATE */ 270 static void /* PRIVATE */
269 png_default_warning(png_structp png_ptr, png_const_charp warning_message) 271 png_default_warning(png_structp png_ptr, png_const_charp warning_message)
270 { 272 {
271 #ifndef PNG_NO_CONSOLE_IO 273 #ifndef PNG_NO_CONSOLE_IO
272 # ifdef PNG_ERROR_NUMBERS_SUPPORTED 274 # ifdef PNG_ERROR_NUMBERS_SUPPORTED
273 if (*warning_message == '#') 275 if (*warning_message == '#')
274 { 276 {
275 int offset; 277 int offset;
276 char warning_number[16]; 278 char warning_number[16];
277 for (offset=0; offset<15; offset++) 279 for (offset = 0; offset < 15; offset++)
278 { 280 {
279 warning_number[offset]=*(warning_message+offset+1); 281 warning_number[offset] = warning_message[offset + 1];
280 if (*(warning_message+offset) == ' ') 282 if (warning_message[offset] == ' ')
281 break; 283 break;
282 } 284 }
283 if((offset > 1) && (offset < 15)) 285 if ((offset > 1) && (offset < 15))
284 { 286 {
285 warning_number[offset-1]='\0'; 287 warning_number[offset + 1] = '\0';
286 fprintf(stderr, "libpng warning no. %s: %s\n", warning_number, 288 fprintf(stderr, "libpng warning no. %s: %s\n", warning_number,
287 warning_message+offset); 289 warning_message + offset);
288 } 290 }
289 else 291 else
290 fprintf(stderr, "libpng warning: %s\n", warning_message); 292 fprintf(stderr, "libpng warning: %s\n", warning_message);
291 } 293 }
292 else 294 else
293 # endif 295 # endif
294 fprintf(stderr, "libpng warning: %s\n", warning_message); 296 fprintf(stderr, "libpng warning: %s\n", warning_message);
295 #else 297 #else
296 warning_message = warning_message; /* make compiler happy */ 298 warning_message = warning_message; /* make compiler happy */
297 #endif 299 #endif
(...skipping 28 matching lines...) Expand all
326 if (png_ptr == NULL) 328 if (png_ptr == NULL)
327 return NULL; 329 return NULL;
328 return ((png_voidp)png_ptr->error_ptr); 330 return ((png_voidp)png_ptr->error_ptr);
329 } 331 }
330 332
331 333
332 #ifdef PNG_ERROR_NUMBERS_SUPPORTED 334 #ifdef PNG_ERROR_NUMBERS_SUPPORTED
333 void PNGAPI 335 void PNGAPI
334 png_set_strip_error_numbers(png_structp png_ptr, png_uint_32 strip_mode) 336 png_set_strip_error_numbers(png_structp png_ptr, png_uint_32 strip_mode)
335 { 337 {
336 if(png_ptr != NULL) 338 if (png_ptr != NULL)
337 { 339 {
338 png_ptr->flags &= 340 png_ptr->flags &=
339 ((~(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))&strip_mode); 341 ((~(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))&strip_mode);
340 } 342 }
341 } 343 }
342 #endif 344 #endif
343 #endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ 345 #endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
OLDNEW
« no previous file with comments | « third_party/libpng/pngconf.h ('k') | third_party/libpng/pngget.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698