[master] Enabled iTXt support by default.

To ensure binary compatibility with
    previous versions, the "lang" and "lang_key" members will be assumed
    to be omitted from previous versions unless the current libpng
    version was built with PNG_iTXt_SUPPORTED (which is otherwise no
    longer necessary to gain iTXt support), as a signal that the user has
    been building previous versions with PNG_iTXt_SUPPORTED as well.
This commit is contained in:
Glenn Randers-Pehrson 2009-10-31 23:20:11 -05:00
parent 602d314ba0
commit 29b738b4e6
5 changed files with 66 additions and 10 deletions

View File

@ -92,6 +92,12 @@ version 1.2.41beta09 [November 1, 2009]
Merged libpng-1.2.41.txt with libpng-1.4.0.txt where appropriate. Merged libpng-1.2.41.txt with libpng-1.4.0.txt where appropriate.
version 1.2.41beta10 [November 1, 2009] version 1.2.41beta10 [November 1, 2009]
Enabled iTXt support by default. To ensure binary compatibility with
previous versions, the "lang" and "lang_key" members will be assumed
to be omitted from previous versions unless the current libpng
version was built with PNG_iTXt_SUPPORTED (which is otherwise no
longer necessary to gain iTXt support), as a signal that the user has
been building previous versions with PNG_iTXt_SUPPORTED as well.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net Send comments/corrections/commendations to png-mng-implement at lists.sf.net

View File

@ -2522,6 +2522,12 @@ version 1.2.41beta09 [November 1, 2009]
Merged libpng-1.2.41.txt with libpng-1.4.0.txt where appropriate. Merged libpng-1.2.41.txt with libpng-1.4.0.txt where appropriate.
version 1.2.41beta10 [November 1, 2009] version 1.2.41beta10 [November 1, 2009]
Enabled iTXt support by default. To ensure binary compatibility with
previous versions, the "lang" and "lang_key" members will be assumed
to be omitted from previous versions unless the current libpng
version was built with PNG_iTXt_SUPPORTED (which is otherwise no
longer necessary to gain iTXt support), as a signal that the user has
been building previous versions with PNG_iTXt_SUPPORTED as well.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit (subscription required; visit

View File

@ -2950,6 +2950,13 @@ accomplish this, the functions png_create_read_struct_2(),
png_create_write_struct_2(), png_set_mem_fn(), png_get_mem_ptr(), png_create_write_struct_2(), png_set_mem_fn(), png_get_mem_ptr(),
png_malloc_default(), and png_free_default() were added. png_malloc_default(), and png_free_default() were added.
Support for the iTXt chunk has been enabled by default as of
version 1.2.41. If you have been defining PNG_iTXt_SUPPORTED
already, please continue to do so, as a signal to libpng that your
previous versions also supported iTXt. If you have not been defining
PNG_iTXt_SUPPORTED, please don't start now; it will be enabled for
you by default.
Support for certain MNG features was enabled. Support for certain MNG features was enabled.
Support for numbered error messages was added. However, we never got Support for numbered error messages was added. However, we never got

View File

@ -526,6 +526,18 @@
* will be turned on by default in libpng-1.4.0. * will be turned on by default in libpng-1.4.0.
*/ */
/* If you have previously been defining PNG_iTXt_SUPPORTED, please
* continue to do so in libpng-1.2.41 and later, until you switch to
* libpng-1.4.0, even though it is not necessary now to gain iTXt support.
* Your PNG_iTXt_SUPPORTED definition will be interpreted in png_set_text()
* as a signal that you have defined it in your builds of previous libpng
* versions that did not support iTXt by default.
*/
#if !defined(PNG_iTXt_SUPPORTED) && !defined(PNG_READ_iTXt_SUPPORTED) && \
!defined(PNG_WRITE_iTXt_SUPPORTED)
# define PNG_iTXt_NOT_PREVIOUSLY_SUPPORTED
#endif
#if defined(PNG_1_0_X) || defined (PNG_1_2_X) #if defined(PNG_1_0_X) || defined (PNG_1_2_X)
# ifndef PNG_iTXt_SUPPORTED # ifndef PNG_iTXt_SUPPORTED
# ifndef PNG_NO_iTXt_SUPPORTED # ifndef PNG_NO_iTXt_SUPPORTED

View File

@ -653,6 +653,7 @@ png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
int num_text) int num_text)
{ {
int i; int i;
int caller_no_itxt = 0;
png_debug1(1, "in %s storage function", ((png_ptr == NULL || png_debug1(1, "in %s storage function", ((png_ptr == NULL ||
png_ptr->chunk_name[0] == '\0') ? png_ptr->chunk_name[0] == '\0') ?
@ -661,6 +662,19 @@ png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
if (png_ptr == NULL || info_ptr == NULL || num_text == 0) if (png_ptr == NULL || info_ptr == NULL || num_text == 0)
return(0); return(0);
#ifdef PNG_iTXt_NOT_PREVIOUSLY_SUPPORTED
/* If an earlier version of the library was used to build the
* application, it might be using a png_textp structure that
* does not contain the lang or lang_key elements. If you build
* this library with PNG_iTXt_SUPPORTED explicitly defined,
* then we assume that your older library was also built with
* PNG_iTXt_SUPPORTED defined and the complete png_textp structure
* has existed all along and it's safe to access them. See pngconf.h.
*/
if (png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH)
caller_no_itxt = 1;
#endif
/* Make sure we have enough space in the "text" array in info_struct /* Make sure we have enough space in the "text" array in info_struct
* to hold all of the incoming text_ptr objects. * to hold all of the incoming text_ptr objects.
*/ */
@ -721,6 +735,9 @@ png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
#ifdef PNG_iTXt_SUPPORTED #ifdef PNG_iTXt_SUPPORTED
{ {
/* Set iTXt data */ /* Set iTXt data */
if (caller_no_itxt == 0)
{
if (text_ptr[i].lang != NULL) if (text_ptr[i].lang != NULL)
lang_len = png_strlen(text_ptr[i].lang); lang_len = png_strlen(text_ptr[i].lang);
else else
@ -731,7 +748,15 @@ png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
lang_key_len = 0; lang_key_len = 0;
} }
#else else /* Caller does not support iTXt */
{
lang_len = 0;
lang_key_len = 0;
png_warning(png_ptr,
"iTXt lang and lang_key not available from application");
}
}
#else /* PNG_iTXt_SUPPORTED */
{ {
png_warning(png_ptr, "iTXt chunk not supported."); png_warning(png_ptr, "iTXt chunk not supported.");
continue; continue;