Replace the remaining uses of PNG_CONST with const

In v1.6.0, compiler support for const became a requirement.
It should be used consistently. To maintain backwards compatibility,
PNG_CONST is still maintained in deprecated form.
This commit is contained in:
Cosmin Truta 2018-08-18 21:01:02 -04:00
parent 58eedced25
commit 1ef8882814
19 changed files with 75 additions and 76 deletions

View File

@ -42,7 +42,7 @@ component(png_const_bytep row, png_uint_32 x, unsigned int c,
png_uint_32 bit_offset_hi = bit_depth * ((x >> 6) * channels); png_uint_32 bit_offset_hi = bit_depth * ((x >> 6) * channels);
png_uint_32 bit_offset_lo = bit_depth * ((x & 0x3f) * channels + c); png_uint_32 bit_offset_lo = bit_depth * ((x & 0x3f) * channels + c);
row = (png_const_bytep)(((PNG_CONST png_byte (*)[8])row) + bit_offset_hi); row = (png_const_bytep)(((const png_byte (*)[8])row) + bit_offset_hi);
row += bit_offset_lo >> 3; row += bit_offset_lo >> 3;
bit_offset_lo &= 0x07; bit_offset_lo &= 0x07;
@ -73,7 +73,7 @@ static void
print_pixel(png_structp png_ptr, png_infop info_ptr, png_const_bytep row, print_pixel(png_structp png_ptr, png_infop info_ptr, png_const_bytep row,
png_uint_32 x) png_uint_32 x)
{ {
PNG_CONST unsigned int bit_depth = png_get_bit_depth(png_ptr, info_ptr); const unsigned int bit_depth = png_get_bit_depth(png_ptr, info_ptr);
switch (png_get_color_type(png_ptr, info_ptr)) switch (png_get_color_type(png_ptr, info_ptr))
{ {
@ -87,7 +87,7 @@ print_pixel(png_structp png_ptr, png_infop info_ptr, png_const_bytep row,
*/ */
case PNG_COLOR_TYPE_PALETTE: case PNG_COLOR_TYPE_PALETTE:
{ {
PNG_CONST int index = component(row, x, 0, bit_depth, 1); const int index = component(row, x, 0, bit_depth, 1);
png_colorp palette = NULL; png_colorp palette = NULL;
int num_palette = 0; int num_palette = 0;

View File

@ -146,7 +146,7 @@ int readpng2_init(mainprog_info *mainprog_ptr)
/* These byte strings were copied from png.h. If a future version /* These byte strings were copied from png.h. If a future version
* of readpng2.c recognizes more chunks, add them to this list. * of readpng2.c recognizes more chunks, add them to this list.
*/ */
static PNG_CONST png_byte chunks_to_process[] = { static const png_byte chunks_to_process[] = {
98, 75, 71, 68, '\0', /* bKGD */ 98, 75, 71, 68, '\0', /* bKGD */
103, 65, 77, 65, '\0', /* gAMA */ 103, 65, 77, 65, '\0', /* gAMA */
115, 82, 71, 66, '\0', /* sRGB */ 115, 82, 71, 66, '\0', /* sRGB */

View File

@ -372,7 +372,7 @@ print_opts(png_uint_32 opts)
*/ */
#define FORMAT_COUNT 64 #define FORMAT_COUNT 64
#define FORMAT_MASK 0x3f #define FORMAT_MASK 0x3f
static PNG_CONST char * PNG_CONST format_names[FORMAT_COUNT] = static const char * const format_names[FORMAT_COUNT] =
{ {
"sRGB-gray", "sRGB-gray",
"sRGB-gray+alpha", "sRGB-gray+alpha",

View File

@ -56,7 +56,7 @@
defined(PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED) defined(PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED)
#if PNG_LIBPNG_VER < 10500 #if PNG_LIBPNG_VER < 10500
/* This deliberately lacks the PNG_CONST. */ /* This deliberately lacks the const. */
typedef png_byte *png_const_bytep; typedef png_byte *png_const_bytep;
/* This is copied from 1.5.1 png.h: */ /* This is copied from 1.5.1 png.h: */

View File

@ -388,7 +388,7 @@ main(int argc, char **argv)
if (!test_only) if (!test_only)
{ {
printf("PNG_CONST png_uint_16 png_sRGB_table[256] =\n{\n "); printf("const png_uint_16 png_sRGB_table[256] =\n{\n ");
for (i=0; i<255; ) for (i=0; i<255; )
{ {
do do
@ -401,7 +401,7 @@ main(int argc, char **argv)
printf("%d\n};\n\n", png_sRGB_table[i]); printf("%d\n};\n\n", png_sRGB_table[i]);
printf("PNG_CONST png_uint_16 png_sRGB_base[512] =\n{\n "); printf("const png_uint_16 png_sRGB_base[512] =\n{\n ");
for (i=0; i<511; ) for (i=0; i<511; )
{ {
do do
@ -413,7 +413,7 @@ main(int argc, char **argv)
} }
printf("%d\n};\n\n", png_sRGB_base[i]); printf("%d\n};\n\n", png_sRGB_base[i]);
printf("PNG_CONST png_byte png_sRGB_delta[512] =\n{\n "); printf("const png_byte png_sRGB_delta[512] =\n{\n ");
for (i=0; i<511; ) for (i=0; i<511; )
{ {
do do

View File

@ -4870,7 +4870,7 @@ to png_bytepp, and in png_set_iCCP, from png_charp to png_const_bytep.
There are changes of form in png.h, including new and changed macros to There are changes of form in png.h, including new and changed macros to
declare parts of the API. Some API functions with arguments that are declare parts of the API. Some API functions with arguments that are
pointers to data not modified within the function have been corrected to pointers to data not modified within the function have been corrected to
declare these arguments with PNG_CONST. declare these arguments with const.
Much of the internal use of C macros to control the library build has also Much of the internal use of C macros to control the library build has also
changed and some of this is visible in the exported header files, in changed and some of this is visible in the exported header files, in

View File

@ -5389,7 +5389,7 @@ to png_bytepp, and in png_set_iCCP, from png_charp to png_const_bytep.
There are changes of form in png.h, including new and changed macros to There are changes of form in png.h, including new and changed macros to
declare parts of the API. Some API functions with arguments that are declare parts of the API. Some API functions with arguments that are
pointers to data not modified within the function have been corrected to pointers to data not modified within the function have been corrected to
declare these arguments with PNG_CONST. declare these arguments with const.
Much of the internal use of C macros to control the library build has also Much of the internal use of C macros to control the library build has also
changed and some of this is visible in the exported header files, in changed and some of this is visible in the exported header files, in

20
png.c
View File

@ -736,7 +736,7 @@ png_save_int_32(png_bytep buf, png_int_32 i)
int PNGAPI int PNGAPI
png_convert_to_rfc1123_buffer(char out[29], png_const_timep ptime) png_convert_to_rfc1123_buffer(char out[29], png_const_timep ptime)
{ {
static PNG_CONST char short_months[12][4] = static const char short_months[12][4] =
{"Jan", "Feb", "Mar", "Apr", "May", "Jun", {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
@ -3970,18 +3970,18 @@ png_gamma_correct(png_structrp png_ptr, unsigned int value,
*/ */
static void static void
png_build_16bit_table(png_structrp png_ptr, png_uint_16pp *ptable, png_build_16bit_table(png_structrp png_ptr, png_uint_16pp *ptable,
PNG_CONST unsigned int shift, PNG_CONST png_fixed_point gamma_val) const unsigned int shift, const png_fixed_point gamma_val)
{ {
/* Various values derived from 'shift': */ /* Various values derived from 'shift': */
PNG_CONST unsigned int num = 1U << (8U - shift); const unsigned int num = 1U << (8U - shift);
#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED #ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
/* CSE the division and work round wacky GCC warnings (see the comments /* CSE the division and work round wacky GCC warnings (see the comments
* in png_gamma_8bit_correct for where these come from.) * in png_gamma_8bit_correct for where these come from.)
*/ */
PNG_CONST double fmax = 1./(((png_int_32)1 << (16U - shift))-1); const double fmax = 1./(((png_int_32)1 << (16U - shift))-1);
#endif #endif
PNG_CONST unsigned int max = (1U << (16U - shift))-1U; const unsigned int max = (1U << (16U - shift))-1U;
PNG_CONST unsigned int max_by_2 = 1U << (15U-shift); const unsigned int max_by_2 = 1U << (15U-shift);
unsigned int i; unsigned int i;
png_uint_16pp table = *ptable = png_uint_16pp table = *ptable =
@ -4047,10 +4047,10 @@ png_build_16bit_table(png_structrp png_ptr, png_uint_16pp *ptable,
*/ */
static void static void
png_build_16to8_table(png_structrp png_ptr, png_uint_16pp *ptable, png_build_16to8_table(png_structrp png_ptr, png_uint_16pp *ptable,
PNG_CONST unsigned int shift, PNG_CONST png_fixed_point gamma_val) const unsigned int shift, const png_fixed_point gamma_val)
{ {
PNG_CONST unsigned int num = 1U << (8U - shift); const unsigned int num = 1U << (8U - shift);
PNG_CONST unsigned int max = (1U << (16U - shift))-1U; const unsigned int max = (1U << (16U - shift))-1U;
unsigned int i; unsigned int i;
png_uint_32 last; png_uint_32 last;
@ -4115,7 +4115,7 @@ png_build_16to8_table(png_structrp png_ptr, png_uint_16pp *ptable,
*/ */
static void static void
png_build_8bit_table(png_structrp png_ptr, png_bytepp ptable, png_build_8bit_table(png_structrp png_ptr, png_bytepp ptable,
PNG_CONST png_fixed_point gamma_val) const png_fixed_point gamma_val)
{ {
unsigned int i; unsigned int i;
png_bytep table = *ptable = (png_bytep)png_malloc(png_ptr, 256); png_bytep table = *ptable = (png_bytep)png_malloc(png_ptr, 256);

View File

@ -58,9 +58,8 @@
#endif /* PNG_BUILDING_SYMBOL_TABLE */ #endif /* PNG_BUILDING_SYMBOL_TABLE */
/* Prior to 1.6.0 it was possible to turn off 'const' in declarations using /* Prior to 1.6.0, it was possible to turn off 'const' in declarations,
* PNG_NO_CONST; this is no longer supported except for data declarations which * using PNG_NO_CONST. This is no longer supported.
* apparently still cause problems in 2011 on some compilers.
*/ */
#define PNG_CONST const /* backward compatibility only */ #define PNG_CONST const /* backward compatibility only */

View File

@ -425,7 +425,7 @@ png_app_error(png_const_structrp png_ptr, png_const_charp error_message)
* if the character is invalid. * if the character is invalid.
*/ */
#define isnonalpha(c) ((c) < 65 || (c) > 122 || ((c) > 90 && (c) < 97)) #define isnonalpha(c) ((c) < 65 || (c) > 122 || ((c) > 90 && (c) < 97))
static PNG_CONST char png_digit[16] = { static const char png_digit[16] = {
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'A', 'B', 'C', 'D', 'E', 'F' 'A', 'B', 'C', 'D', 'E', 'F'
}; };

View File

@ -972,20 +972,20 @@ png_read_push_finish_row(png_structrp png_ptr)
/* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
/* Start of interlace block */ /* Start of interlace block */
static PNG_CONST png_byte png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; static const png_byte png_pass_start[] = {0, 4, 0, 2, 0, 1, 0};
/* Offset to next interlace block */ /* Offset to next interlace block */
static PNG_CONST png_byte png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; static const png_byte png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1};
/* Start of interlace block in the y direction */ /* Start of interlace block in the y direction */
static PNG_CONST png_byte png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1}; static const png_byte png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1};
/* Offset to next interlace block in the y direction */ /* Offset to next interlace block in the y direction */
static PNG_CONST png_byte png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2}; static const png_byte png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};
/* Height of interlace block. This is not currently used - if you need /* Height of interlace block. This is not currently used - if you need
* it, uncomment it here and in png.h * it, uncomment it here and in png.h
static PNG_CONST png_byte png_pass_height[] = {8, 8, 4, 4, 2, 2, 1}; static const png_byte png_pass_height[] = {8, 8, 4, 4, 2, 2, 1};
*/ */
#endif #endif

View File

@ -1621,7 +1621,7 @@ png_image_skip_unused_chunks(png_structrp png_ptr)
* errors (which are unfortunately quite common.) * errors (which are unfortunately quite common.)
*/ */
{ {
static PNG_CONST png_byte chunks_to_process[] = { static const png_byte chunks_to_process[] = {
98, 75, 71, 68, '\0', /* bKGD */ 98, 75, 71, 68, '\0', /* bKGD */
99, 72, 82, 77, '\0', /* cHRM */ 99, 72, 82, 77, '\0', /* cHRM */
103, 65, 77, 65, '\0', /* gAMA */ 103, 65, 77, 65, '\0', /* gAMA */
@ -3946,7 +3946,7 @@ png_image_read_direct(png_voidp argument)
*/ */
if (linear != 0) if (linear != 0)
{ {
PNG_CONST png_uint_16 le = 0x0001; const png_uint_16 le = 0x0001;
if ((*(png_const_bytep) & le) != 0) if ((*(png_const_bytep) & le) != 0)
png_set_swap(png_ptr); png_set_swap(png_ptr);

View File

@ -2995,11 +2995,11 @@ png_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row)
if ((row_info->color_type & PNG_COLOR_MASK_PALETTE) == 0 && if ((row_info->color_type & PNG_COLOR_MASK_PALETTE) == 0 &&
(row_info->color_type & PNG_COLOR_MASK_COLOR) != 0) (row_info->color_type & PNG_COLOR_MASK_COLOR) != 0)
{ {
PNG_CONST png_uint_32 rc = png_ptr->rgb_to_gray_red_coeff; const png_uint_32 rc = png_ptr->rgb_to_gray_red_coeff;
PNG_CONST png_uint_32 gc = png_ptr->rgb_to_gray_green_coeff; const png_uint_32 gc = png_ptr->rgb_to_gray_green_coeff;
PNG_CONST png_uint_32 bc = 32768 - rc - gc; const png_uint_32 bc = 32768 - rc - gc;
PNG_CONST png_uint_32 row_width = row_info->width; const png_uint_32 row_width = row_info->width;
PNG_CONST int have_alpha = const int have_alpha =
(row_info->color_type & PNG_COLOR_MASK_ALPHA) != 0; (row_info->color_type & PNG_COLOR_MASK_ALPHA) != 0;
if (row_info->bit_depth == 8) if (row_info->bit_depth == 8)
@ -4143,11 +4143,11 @@ png_do_encode_alpha(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
{ {
if (row_info->bit_depth == 8) if (row_info->bit_depth == 8)
{ {
PNG_CONST png_bytep table = png_ptr->gamma_from_1; const png_bytep table = png_ptr->gamma_from_1;
if (table != NULL) if (table != NULL)
{ {
PNG_CONST int step = const int step =
(row_info->color_type & PNG_COLOR_MASK_COLOR) ? 4 : 2; (row_info->color_type & PNG_COLOR_MASK_COLOR) ? 4 : 2;
/* The alpha channel is the last component: */ /* The alpha channel is the last component: */
@ -4162,12 +4162,12 @@ png_do_encode_alpha(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
else if (row_info->bit_depth == 16) else if (row_info->bit_depth == 16)
{ {
PNG_CONST png_uint_16pp table = png_ptr->gamma_16_from_1; const png_uint_16pp table = png_ptr->gamma_16_from_1;
PNG_CONST int gamma_shift = png_ptr->gamma_shift; const int gamma_shift = png_ptr->gamma_shift;
if (table != NULL) if (table != NULL)
{ {
PNG_CONST int step = const int step =
(row_info->color_type & PNG_COLOR_MASK_COLOR) ? 8 : 4; (row_info->color_type & PNG_COLOR_MASK_COLOR) ? 8 : 4;
/* The alpha channel is the last component: */ /* The alpha channel is the last component: */

View File

@ -3363,7 +3363,7 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display)
/* Hence the pre-compiled masks indexed by PACKSWAP (or not), depth and /* Hence the pre-compiled masks indexed by PACKSWAP (or not), depth and
* then pass: * then pass:
*/ */
static PNG_CONST png_uint_32 row_mask[2/*PACKSWAP*/][3/*depth*/][6] = static const png_uint_32 row_mask[2/*PACKSWAP*/][3/*depth*/][6] =
{ {
/* Little-endian byte masks for PACKSWAP */ /* Little-endian byte masks for PACKSWAP */
{ S_MASKS(1,0), S_MASKS(2,0), S_MASKS(4,0) }, { S_MASKS(1,0), S_MASKS(2,0), S_MASKS(4,0) },
@ -3374,7 +3374,7 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display)
/* display_mask has only three entries for the odd passes, so index by /* display_mask has only three entries for the odd passes, so index by
* pass>>1. * pass>>1.
*/ */
static PNG_CONST png_uint_32 display_mask[2][3][3] = static const png_uint_32 display_mask[2][3][3] =
{ {
/* Little-endian byte masks for PACKSWAP */ /* Little-endian byte masks for PACKSWAP */
{ B_MASKS(1,0), B_MASKS(2,0), B_MASKS(4,0) }, { B_MASKS(1,0), B_MASKS(2,0), B_MASKS(4,0) },
@ -3687,7 +3687,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
{ {
/* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
/* Offset to next interlace block */ /* Offset to next interlace block */
static PNG_CONST unsigned int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; static const unsigned int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
png_debug(1, "in png_do_read_interlace"); png_debug(1, "in png_do_read_interlace");
if (row != NULL && row_info != NULL) if (row != NULL && row_info != NULL)
@ -4329,16 +4329,16 @@ png_read_finish_row(png_structrp png_ptr)
/* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
/* Start of interlace block */ /* Start of interlace block */
static PNG_CONST png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; static const png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
/* Offset to next interlace block */ /* Offset to next interlace block */
static PNG_CONST png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; static const png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
/* Start of interlace block in the y direction */ /* Start of interlace block in the y direction */
static PNG_CONST png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; static const png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
/* Offset to next interlace block in the y direction */ /* Offset to next interlace block in the y direction */
static PNG_CONST png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; static const png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
png_debug(1, "in png_read_finish_row"); png_debug(1, "in png_read_finish_row");
png_ptr->row_number++; png_ptr->row_number++;
@ -4394,16 +4394,16 @@ png_read_start_row(png_structrp png_ptr)
/* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
/* Start of interlace block */ /* Start of interlace block */
static PNG_CONST png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; static const png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
/* Offset to next interlace block */ /* Offset to next interlace block */
static PNG_CONST png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; static const png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
/* Start of interlace block in the y direction */ /* Start of interlace block in the y direction */
static PNG_CONST png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; static const png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
/* Offset to next interlace block in the y direction */ /* Offset to next interlace block in the y direction */
static PNG_CONST png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; static const png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
unsigned int max_pixel_depth; unsigned int max_pixel_depth;
size_t row_bytes; size_t row_bytes;

View File

@ -1399,7 +1399,7 @@ png_set_keep_unknown_chunks(png_structrp png_ptr, int keep,
/* Ignore all unknown chunks and all chunks recognized by /* Ignore all unknown chunks and all chunks recognized by
* libpng except for IHDR, PLTE, tRNS, IDAT, and IEND * libpng except for IHDR, PLTE, tRNS, IDAT, and IEND
*/ */
static PNG_CONST png_byte chunks_to_ignore[] = { static const png_byte chunks_to_ignore[] = {
98, 75, 71, 68, '\0', /* bKGD */ 98, 75, 71, 68, '\0', /* bKGD */
99, 72, 82, 77, '\0', /* cHRM */ 99, 72, 82, 77, '\0', /* cHRM */
101, 88, 73, 102, '\0', /* eXIf */ 101, 88, 73, 102, '\0', /* eXIf */

View File

@ -449,13 +449,13 @@ pngtest_write_data(png_structp png_ptr, png_bytep data, size_t length)
*/ */
typedef struct typedef struct
{ {
PNG_CONST char *file_name; const char *file_name;
} pngtest_error_parameters; } pngtest_error_parameters;
static void PNGCBAPI static void PNGCBAPI
pngtest_warning(png_structp png_ptr, png_const_charp message) pngtest_warning(png_structp png_ptr, png_const_charp message)
{ {
PNG_CONST char *name = "UNKNOWN (ERROR!)"; const char *name = "UNKNOWN (ERROR!)";
pngtest_error_parameters *test = pngtest_error_parameters *test =
(pngtest_error_parameters*)png_get_error_ptr(png_ptr); (pngtest_error_parameters*)png_get_error_ptr(png_ptr);
@ -850,7 +850,7 @@ pngtest_check_text_support(png_structp png_ptr, png_textp text_ptr,
/* Test one file */ /* Test one file */
static int static int
test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) test_one_file(const char *inname, const char *outname)
{ {
static png_FILE_p fpin; static png_FILE_p fpin;
static png_FILE_p fpout; /* "static" prevents setjmp corruption */ static png_FILE_p fpout; /* "static" prevents setjmp corruption */
@ -1809,11 +1809,11 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
/* Input and output filenames */ /* Input and output filenames */
#ifdef RISCOS #ifdef RISCOS
static PNG_CONST char *inname = "pngtest/png"; static const char *inname = "pngtest/png";
static PNG_CONST char *outname = "pngout/png"; static const char *outname = "pngout/png";
#else #else
static PNG_CONST char *inname = "pngtest.png"; static const char *inname = "pngtest.png";
static PNG_CONST char *outname = "pngout.png"; static const char *outname = "pngout.png";
#endif #endif
int int

View File

@ -345,7 +345,7 @@ png_do_swap(png_row_infop row_info, png_bytep row)
#endif #endif
#if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED) #if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED)
static PNG_CONST png_byte onebppswaptable[256] = { static const png_byte onebppswaptable[256] = {
0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0, 0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0,
0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0, 0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0,
0x08, 0x88, 0x48, 0xC8, 0x28, 0xA8, 0x68, 0xE8, 0x08, 0x88, 0x48, 0xC8, 0x28, 0xA8, 0x68, 0xE8,
@ -380,7 +380,7 @@ static PNG_CONST png_byte onebppswaptable[256] = {
0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFF 0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFF
}; };
static PNG_CONST png_byte twobppswaptable[256] = { static const png_byte twobppswaptable[256] = {
0x00, 0x40, 0x80, 0xC0, 0x10, 0x50, 0x90, 0xD0, 0x00, 0x40, 0x80, 0xC0, 0x10, 0x50, 0x90, 0xD0,
0x20, 0x60, 0xA0, 0xE0, 0x30, 0x70, 0xB0, 0xF0, 0x20, 0x60, 0xA0, 0xE0, 0x30, 0x70, 0xB0, 0xF0,
0x04, 0x44, 0x84, 0xC4, 0x14, 0x54, 0x94, 0xD4, 0x04, 0x44, 0x84, 0xC4, 0x14, 0x54, 0x94, 0xD4,
@ -415,7 +415,7 @@ static PNG_CONST png_byte twobppswaptable[256] = {
0x2F, 0x6F, 0xAF, 0xEF, 0x3F, 0x7F, 0xBF, 0xFF 0x2F, 0x6F, 0xAF, 0xEF, 0x3F, 0x7F, 0xBF, 0xFF
}; };
static PNG_CONST png_byte fourbppswaptable[256] = { static const png_byte fourbppswaptable[256] = {
0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70,
0x80, 0x90, 0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0, 0x80, 0x90, 0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0,
0x01, 0x11, 0x21, 0x31, 0x41, 0x51, 0x61, 0x71, 0x01, 0x11, 0x21, 0x31, 0x41, 0x51, 0x61, 0x71,

View File

@ -469,7 +469,7 @@ png_write_end(png_structrp png_ptr, png_inforp info_ptr)
#ifdef PNG_CONVERT_tIME_SUPPORTED #ifdef PNG_CONVERT_tIME_SUPPORTED
void PNGAPI void PNGAPI
png_convert_from_struct_tm(png_timep ptime, PNG_CONST struct tm * ttime) png_convert_from_struct_tm(png_timep ptime, const struct tm * ttime)
{ {
png_debug(1, "in png_convert_from_struct_tm"); png_debug(1, "in png_convert_from_struct_tm");
@ -2052,7 +2052,7 @@ png_image_write_main(png_voidp argument)
*/ */
if (write_16bit != 0) if (write_16bit != 0)
{ {
PNG_CONST png_uint_16 le = 0x0001; const png_uint_16 le = 0x0001;
if ((*(png_const_bytep) & le) != 0) if ((*(png_const_bytep) & le) != 0)
png_set_swap(png_ptr); png_set_swap(png_ptr);

View File

@ -1893,16 +1893,16 @@ png_write_start_row(png_structrp png_ptr)
/* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
/* Start of interlace block */ /* Start of interlace block */
static PNG_CONST png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; static const png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
/* Offset to next interlace block */ /* Offset to next interlace block */
static PNG_CONST png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; static const png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
/* Start of interlace block in the y direction */ /* Start of interlace block in the y direction */
static PNG_CONST png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; static const png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
/* Offset to next interlace block in the y direction */ /* Offset to next interlace block in the y direction */
static PNG_CONST png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; static const png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
#endif #endif
png_alloc_size_t buf_size; png_alloc_size_t buf_size;
@ -2008,16 +2008,16 @@ png_write_finish_row(png_structrp png_ptr)
/* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
/* Start of interlace block */ /* Start of interlace block */
static PNG_CONST png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; static const png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
/* Offset to next interlace block */ /* Offset to next interlace block */
static PNG_CONST png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; static const png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
/* Start of interlace block in the y direction */ /* Start of interlace block in the y direction */
static PNG_CONST png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; static const png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
/* Offset to next interlace block in the y direction */ /* Offset to next interlace block in the y direction */
static PNG_CONST png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; static const png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
#endif #endif
png_debug(1, "in png_write_finish_row"); png_debug(1, "in png_write_finish_row");
@ -2098,10 +2098,10 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
/* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
/* Start of interlace block */ /* Start of interlace block */
static PNG_CONST png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; static const png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
/* Offset to next interlace block */ /* Offset to next interlace block */
static PNG_CONST png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; static const png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
png_debug(1, "in png_do_write_interlace"); png_debug(1, "in png_do_write_interlace");