From f2715a558ac910fcfd74e3679682ae157fccd26c Mon Sep 17 00:00:00 2001 From: Glenn Randers-Pehrson Date: Thu, 15 Mar 2012 19:52:03 -0500 Subject: [PATCH] [libpng16] Revised example.c to put text strings in a temporary character array instead of directly assigning string constants to png_textp members. This avoids compiler warnings when -Wwrite-strings is enabled. --- ANNOUNCE | 7 +++++-- CHANGES | 5 ++++- example.c | 51 ++++++++++++++++++++++++++++++++------------------- pngtest.c | 24 +++++++++++++++++++++++- 4 files changed, 64 insertions(+), 23 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index 8cbf646d8..b69c62a92 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,5 +1,5 @@ -Libpng 1.6.0beta18 - March 11, 2012 +Libpng 1.6.0beta18 - March 15, 2012 This is not intended to be a public release. It will be replaced within a few weeks by a public version or by another test version. @@ -298,11 +298,14 @@ Version 1.6.0beta17 [March 10, 2012] chunks could end up with a too-small windowBits value in the deflate header. -Version 1.6.0beta18 [March 11, 2012] +Version 1.6.0beta18 [March 15, 2012] Issue a png_benign_error() instead of png_warning() about bad palette index. In pngtest, treat benign errors as errors if "-strict" is present. Fixed an off-by-one error in the palette index checking function. Fixed a compiler warning under Cygwin (Windows-7, 32-bit system) + Revised example.c to put text strings in a temporary character array + instead of directly assigning string constants to png_textp members. + This avoids compiler warnings when -Wwrite-strings is enabled. Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit diff --git a/CHANGES b/CHANGES index ea8437152..5d6bf5773 100644 --- a/CHANGES +++ b/CHANGES @@ -4049,11 +4049,14 @@ Version 1.6.0beta17 [March 10, 2012] chunks could end up with a too-small windowBits value in the deflate header. -Version 1.6.0beta18 [March 11, 2012] +Version 1.6.0beta18 [March 15, 2012] Issue a png_benign_error() instead of png_warning() about bad palette index. In pngtest, treat benign errors as errors if "-strict" is present. Fixed an off-by-one error in the palette index checking function. Fixed a compiler warning under Cygwin (Windows-7, 32-bit system) + Revised example.c to put text strings in a temporary character array + instead of directly assigning string constants to png_textp members. + This avoids compiler warnings when -Wwrite-strings is enabled. Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit diff --git a/example.c b/example.c index 61d9d74db..ebc43dc60 100644 --- a/example.c +++ b/example.c @@ -864,25 +864,38 @@ void write_png(char *file_name /* , ... other image information ... */) png_set_gAMA(png_ptr, info_ptr, gamma); /* Optionally write comments into the image */ - text_ptr[0].key = "Title"; - text_ptr[0].text = "Mona Lisa"; - text_ptr[0].compression = PNG_TEXT_COMPRESSION_NONE; - text_ptr[0].itxt_length = 0; - text_ptr[0].lang = NULL; - text_ptr[0].lang_key = NULL; - text_ptr[1].key = "Author"; - text_ptr[1].text = "Leonardo DaVinci"; - text_ptr[1].compression = PNG_TEXT_COMPRESSION_NONE; - text_ptr[1].itxt_length = 0; - text_ptr[1].lang = NULL; - text_ptr[1].lang_key = NULL; - text_ptr[2].key = "Description"; - text_ptr[2].text = ""; - text_ptr[2].compression = PNG_TEXT_COMPRESSION_zTXt; - text_ptr[2].itxt_length = 0; - text_ptr[2].lang = NULL; - text_ptr[2].lang_key = NULL; - png_set_text(png_ptr, info_ptr, text_ptr, 3); + { + png_text text_ptr[3]; + + char key0[]="Title"; + char text0[]="Mona Lisa"; + text_ptr[0].key = key0; + text_ptr[0].text = text0; + text_ptr[0].compression = PNG_TEXT_COMPRESSION_NONE; + text_ptr[0].itxt_length = 0; + text_ptr[0].lang = NULL; + text_ptr[0].lang_key = NULL; + + char key1[]="Author"; + char text1[]="Leonardo DaVinci"; + text_ptr[1].key = key1; + text_ptr[1].text = text1; + text_ptr[1].compression = PNG_TEXT_COMPRESSION_NONE; + text_ptr[1].itxt_length = 0; + text_ptr[1].lang = NULL; + text_ptr[1].lang_key = NULL; + + char key2[]="Description"; + char text2[]=""; + text_ptr[2].key = key2; + text_ptr[2].text = text2; + text_ptr[2].compression = PNG_TEXT_COMPRESSION_zTXt; + text_ptr[2].itxt_length = 0; + text_ptr[2].lang = NULL; + text_ptr[2].lang_key = NULL; + + png_set_text(write_ptr, write_info_ptr, text_ptr, 3); + } /* Other optional chunks like cHRM, bKGD, tRNS, tIME, oFFs, pHYs */ diff --git a/pngtest.c b/pngtest.c index 5b1da5622..f69ed2b3e 100644 --- a/pngtest.c +++ b/pngtest.c @@ -1023,7 +1023,16 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) pngtest_debug1("Handling %d iTXt/tEXt/zTXt chunks", num_text); if (verbose) - printf("\n Text compression=%d\n", text_ptr->compression); + { + int i; + + printf("\n"); + for (i=0; i 0) { pngtest_debug1("Handling %d iTXt/tEXt/zTXt chunks", num_text); + + if (verbose) + { + int i; + + printf("\n"); + for (i=0; i