Imported from libpng-1.4.0beta51.tar

This commit is contained in:
Glenn Randers-Pehrson
2009-03-21 08:15:32 -05:00
parent 6917b51660
commit 8fb550cc3e
63 changed files with 480 additions and 263 deletions

View File

@@ -1,7 +1,7 @@
/* pngerror.c - stub functions for i/o and memory allocation
*
* Last changed in libpng 1.4.0 [March 9, 2009]
* Last changed in libpng 1.4.0 [March 21, 2009]
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2009 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -44,40 +44,19 @@ png_error(png_structp png_ptr, png_const_charp error_message)
{
if (*error_message == PNG_LITERAL_SHARP)
{
/* Strip "#nnnn " from beginning of error message. */
/*
* 012345678901234567890
* error_message: #nnnn text\0
* error_number: nnnn\0
* msg: : nnnn \0
* offset points to the first blank after nnnn
* In this example, offset is 5.
*/
/* Strip "#nnnn " from beginning of error message. */
int offset;
for (offset = 1; offset<15; offset++)
if (error_message[offset] == ' ')
break;
/* it is 5 because the loop iterations saw
* offset==1, error_message[1]=="n"; offset++.
* offset==2, error_message[2]=="n"; offset++.
* offset==3, error_message[3]=="n"; offset++.
* offset==4, error_message[4]=="n"; offset++.
* offset==5, error_message[5]==" "; break.
*/
if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT)
{
int i;
/* Copy the "nnnn" or however many there are, plus the
* blank to the beginning of "msg" string.
*/
for (i = 0; i < offset - 1; i++)
msg[i] = error_message[i + 1];
/* In the example, "i" ends up being 5.
*/
msg[i - 1] = '\0';
error_message = msg;
}
/* msg, and error_message, now contain "nnnn \0". */
else
error_message += offset;
}
@@ -259,16 +238,8 @@ png_default_error(png_structp png_ptr, png_const_charp error_message)
#ifndef PNG_NO_CONSOLE_IO
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
if (*error_message == PNG_LITERAL_SHARP)
{
/* Strip "#nnnn " from beginning of error message. */
/*
* 012345678901234567890
* error_message: #nnnn text\0
* error_number: nnnn\0
* offset points to the first blank after nnnn
* In this example, offset is 5, and we want to
* insert a terminating NULL at error_number[4].
*/
{
/* Strip "#nnnn " from beginning of error message. */
int offset;
char error_number[16];
for (offset = 0; offset<15; offset++)
@@ -277,21 +248,9 @@ png_default_error(png_structp png_ptr, png_const_charp error_message)
if (error_message[offset] == ' ')
break;
}
/* This is unnecessarily slightly different from above, but
* offset is still 5 because the loop iterations saw
* offset==0, error_message[0]=="#"; error_number[0]="n";offset++.
* offset==1, error_message[1]=="n"; error_number[1]="n";offset++
* offset==2, error_message[2]=="n"; error_number[2]="n";offset++
* offset==3, error_message[3]=="n"; error_number[3]="n";offset++
* offset==4, error_message[4]=="n"; error_number[4]=" ";offset++.
* offset==5, error_message[5]==" "; break.
*/
if ((offset > 1) && (offset < 15))
{
/* Replace the " " with a string-terminating NULL */
error_number[offset - 1] = '\0';
/* GRR: this should be [offset + 1] */
/* should we update "offset" to point to the beginning of the text? */
fprintf(stderr, "libpng error no. %s: %s",
error_number, error_message + offset + 1);
fprintf(stderr, PNG_STRING_NEWLINE);