Imported from libpng-1.4.0beta24.tar

This commit is contained in:
Glenn Randers-Pehrson
2008-07-25 08:51:18 -05:00
parent 72b633026b
commit 895a9c97e2
60 changed files with 262 additions and 219 deletions

View File

@@ -1,7 +1,7 @@
/* pngerror.c - stub functions for i/o and memory allocation
*
* Last changed in libpng 1.4.0 [July 22, 2008]
* Last changed in libpng 1.4.0 [July 25, 2008]
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2008 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -44,16 +44,23 @@ png_error(png_structp png_ptr, png_const_charp error_message)
{
if (*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.
*/
int offset;
for (offset = 1; offset<15; offset++)
if (*(error_message + offset) == ' ')
if (error_message[offset] == ' ')
break;
if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT)
{
int i;
for (i=0; i<offset - 1; i++)
msg[i]=error_message[i+1];
msg[i]='\0';
for (i = 0; i < offset - 1; i++)
msg[i] = error_message[i + 1];
msg[i] = '\0';
error_message = msg;
}
else
@@ -63,9 +70,9 @@ png_error(png_structp png_ptr, png_const_charp error_message)
{
if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT)
{
msg[0]='0';
msg[1]='\0';
error_message=msg;
msg[0] = '0';
msg[1] = '\0';
error_message = msg;
}
}
}
@@ -110,8 +117,8 @@ png_warning(png_structp png_ptr, png_const_charp warning_message)
{
if (*warning_message == '#')
{
for (offset = 1; offset<15; offset++)
if (*(warning_message + offset) == ' ')
for (offset = 1; offset < 15; offset++)
if (warning_message[offset] == ' ')
break;
}
}
@@ -238,17 +245,26 @@ png_default_error(png_structp png_ptr, png_const_charp error_message)
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
if (*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].
*/
int offset;
char error_number[16];
for (offset=0; offset<15; offset++)
for (offset = 0; offset<15; offset++)
{
error_number[offset] = *(error_message + offset + 1);
if (*(error_message + offset) == ' ')
error_number[offset] = error_message[offset + 1];
if (error_message[offset] == ' ')
break;
}
if ((offset > 1) && (offset < 15))
{
error_number[offset - 1]='\0';
error_number[offset - 1] = '\0'; /* should this be [offset + 1]? */
/* should we update "offset" to point to the beginning of the text? */
fprintf(stderr, "libpng error no. %s: %s\n", error_number,
error_message + offset);
}
@@ -296,15 +312,15 @@ png_default_warning(png_structp png_ptr, png_const_charp warning_message)
{
int offset;
char warning_number[16];
for (offset=0; offset<15; offset++)
for (offset = 0; offset < 15; offset++)
{
warning_number[offset]=*(warning_message + offset + 1);
if (*(warning_message + offset) == ' ')
warning_number[offset] = warning_message[offset + 1];
if (warning_message[offset] == ' ')
break;
}
if ((offset > 1) && (offset < 15))
{
warning_number[offset + 1]='\0';
warning_number[offset + 1] = '\0';
fprintf(stderr, "libpng warning no. %s: %s\n", warning_number,
warning_message + offset);
}