diff options
author | Sam James <sam@gentoo.org> | 2022-09-21 14:18:08 +0100 |
---|---|---|
committer | Sam James <sam@gentoo.org> | 2022-10-02 04:31:25 +0100 |
commit | a529111f77ff46f4836fe7312e70953bc16587cf (patch) | |
tree | 9dc3924cb1a6ef3ef853b7bb45f735365e0b4e6d /tiff/test | |
parent | Import Ghostscript 9.56.1 (diff) | |
download | ghostscript-gpl-patches-ghostscript-10.tar.gz ghostscript-gpl-patches-ghostscript-10.tar.bz2 ghostscript-gpl-patches-ghostscript-10.zip |
Import Ghostscript 10.0ghostscript-10.0ghostscript-10
Signed-off-by: Sam James <sam@gentoo.org>
Diffstat (limited to 'tiff/test')
-rw-r--r-- | tiff/test/CMakeLists.txt | 70 | ||||
-rw-r--r-- | tiff/test/Makefile.in | 13 | ||||
-rw-r--r-- | tiff/test/ascii_tag.c | 8 | ||||
-rw-r--r-- | tiff/test/check_tag.c | 36 | ||||
-rw-r--r-- | tiff/test/custom_dir.c | 20 | ||||
-rw-r--r-- | tiff/test/custom_dir_EXIF_231.c | 268 | ||||
-rw-r--r-- | tiff/test/defer_strile_writing.c | 2 | ||||
-rw-r--r-- | tiff/test/long_tag.c | 10 | ||||
-rw-r--r-- | tiff/test/rational_precision2double.c | 22 | ||||
-rw-r--r-- | tiff/test/raw_decode.c | 42 | ||||
-rw-r--r-- | tiff/test/rewrite_tag.c | 34 | ||||
-rw-r--r-- | tiff/test/short_tag.c | 24 | ||||
-rw-r--r-- | tiff/test/strip.c | 56 | ||||
-rw-r--r-- | tiff/test/strip_rw.c | 18 | ||||
-rw-r--r-- | tiff/test/testtypes.c | 19 | ||||
-rw-r--r-- | tiff/test/tifftest.h | 6 |
16 files changed, 344 insertions, 304 deletions
diff --git a/tiff/test/CMakeLists.txt b/tiff/test/CMakeLists.txt index bffb8bf7..0a445c94 100644 --- a/tiff/test/CMakeLists.txt +++ b/tiff/test/CMakeLists.txt @@ -22,11 +22,6 @@ # LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE # OF THIS SOFTWARE. -include_directories(${PROJECT_SOURCE_DIR}/libtiff - ${PROJECT_BINARY_DIR}/libtiff - ${CMAKE_CURRENT_BINARY_DIR} - ${TIFF_INCLUDES}) - # Test scripts (not used by CMake) set(TESTSCRIPTS bmp2tiff_palette.sh @@ -168,58 +163,65 @@ set(IMAGES_EXTRA_DIST ${PNMIMAGES} ${TIFFIMAGES}) -extra_dist( - ${TESTSCRIPTS} - ${IMAGES_EXTRA_DIST} - common.sh) - set(noinst_HEADERS tifftest.h) -add_executable(ascii_tag ascii_tag.c) -target_link_libraries(ascii_tag tiff port) +add_executable(ascii_tag) +target_sources(ascii_tag PRIVATE ascii_tag.c) +target_link_libraries(ascii_tag PRIVATE tiff port) -add_executable(long_tag long_tag.c check_tag.c) -target_link_libraries(long_tag tiff port) +add_executable(long_tag) +target_sources(long_tag PRIVATE long_tag.c check_tag.c) +target_link_libraries(long_tag PRIVATE tiff port) -add_executable(short_tag short_tag.c check_tag.c) -target_link_libraries(short_tag tiff port) +add_executable(short_tag) +target_sources(short_tag PRIVATE short_tag.c check_tag.c) +target_link_libraries(short_tag PRIVATE tiff port) -add_executable(strip_rw strip_rw.c strip.c test_arrays.c test_arrays.h) -target_link_libraries(strip_rw tiff port) +add_executable(strip_rw) +target_sources(strip_rw PRIVATE strip_rw.c strip.c test_arrays.c test_arrays.h) +target_link_libraries(strip_rw PRIVATE tiff port) -add_executable(rewrite rewrite_tag.c) -target_link_libraries(rewrite tiff port) +add_executable(rewrite) +target_sources(rewrite PRIVATE rewrite_tag.c) +target_link_libraries(rewrite PRIVATE tiff port) if(JPEG_SUPPORT) - add_executable(raw_decode raw_decode.c) - target_link_libraries(raw_decode tiff port) + add_executable(raw_decode) + target_sources(raw_decode PRIVATE raw_decode.c) + target_link_libraries(raw_decode PRIVATE tiff port JPEG::JPEG) endif() -add_executable(custom_dir custom_dir.c) -target_link_libraries(custom_dir tiff port) +add_executable(custom_dir) +target_sources(custom_dir PRIVATE custom_dir.c) +target_link_libraries(custom_dir PRIVATE tiff port) if(NOT BUILD_SHARED_LIBS) -add_executable(rational_precision2double rational_precision2double.c) -target_link_libraries(rational_precision2double tiff port) +add_executable(rational_precision2double) +target_sources(rational_precision2double PRIVATE rational_precision2double.c) +target_link_libraries(rational_precision2double PRIVATE tiff port) add_test(NAME "rational_precision2double" COMMAND "rational_precision2double") endif() if(NOT BUILD_SHARED_LIBS) -add_executable(custom_dir_EXIF_231 custom_dir_EXIF_231.c) -target_link_libraries(custom_dir_EXIF_231 tiff port) +add_executable(custom_dir_EXIF_231) +target_sources(custom_dir_EXIF_231 PRIVATE custom_dir_EXIF_231.c) +target_link_libraries(custom_dir_EXIF_231 PRIVATE tiff port) add_test(NAME "custom_dir_EXIF_231" COMMAND "custom_dir_EXIF_231") endif() -add_executable(defer_strile_loading defer_strile_loading.c) -target_link_libraries(defer_strile_loading tiff port) +add_executable(defer_strile_loading) +target_sources(defer_strile_loading PRIVATE defer_strile_loading.c) +target_link_libraries(defer_strile_loading PRIVATE tiff port) -add_executable(defer_strile_writing defer_strile_writing.c) -target_link_libraries(defer_strile_writing tiff port) +add_executable(defer_strile_writing) +target_sources(defer_strile_writing PRIVATE defer_strile_writing.c) +target_link_libraries(defer_strile_writing PRIVATE tiff port) -add_executable(testtypes testtypes.c) -target_link_libraries(testtypes tiff port) +add_executable(testtypes) +target_sources(testtypes PRIVATE testtypes.c) +target_link_libraries(testtypes PRIVATE tiff port) if(WEBP_SUPPORT AND EMSCRIPTEN) # Emscripten is pretty finnicky about linker flags. diff --git a/tiff/test/Makefile.in b/tiff/test/Makefile.in index 15b7b826..0c2ceb4e 100644 --- a/tiff/test/Makefile.in +++ b/tiff/test/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.2 from Makefile.am. +# Makefile.in generated by automake 1.16.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2020 Free Software Foundation, Inc. +# Copyright (C) 1994-2018 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -132,8 +132,10 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ DIST_COMMON = $(srcdir)/Makefile.am $(noinst_HEADERS) \ $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/libtiff/tif_config.h \ - $(top_builddir)/libtiff/tiffconf.h +CONFIG_HEADER = $(top_builddir)/config.h \ + $(top_builddir)/libtiff/tif_config.h \ + $(top_builddir)/libtiff/tiffconf.h \ + $(top_builddir)/port/libport_config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = @HAVE_JPEG_TRUE@am__EXEEXT_1 = raw_decode$(EXEEXT) @@ -192,7 +194,7 @@ AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = -DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/libtiff +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/libtiff -I$(top_builddir)/port depcomp = $(SHELL) $(top_srcdir)/config/depcomp am__maybe_remake_depfiles = depfiles am__depfiles_remade = ./$(DEPDIR)/ascii_tag.Po \ @@ -661,6 +663,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ diff --git a/tiff/test/ascii_tag.c b/tiff/test/ascii_tag.c index 9a56d31d..944dd57c 100644 --- a/tiff/test/ascii_tag.c +++ b/tiff/test/ascii_tag.c @@ -108,8 +108,8 @@ main() for (i = 0; i < NTAGS; i++) { if (!TIFFSetField(tif, ascii_tags[i].tag, ascii_tags[i].value)) { - fprintf(stderr, "Can't set tag %lu.\n", - (unsigned long)ascii_tags[i].tag); + fprintf(stderr, "Can't set tag %"PRIu32".\n", + ascii_tags[i].tag); goto failure; } } @@ -144,8 +144,8 @@ main() for (i = 0; i < NTAGS; i++) { if (!TIFFGetField(tif, ascii_tags[i].tag, &value) || strcmp(value, ascii_tags[i].value)) { - fprintf(stderr, "Can't get tag %lu.\n", - (unsigned long)ascii_tags[i].tag); + fprintf(stderr, "Can't get tag %"PRIu32".\n", + ascii_tags[i].tag); goto failure; } } diff --git a/tiff/test/check_tag.c b/tiff/test/check_tag.c index 5750d683..63554866 100644 --- a/tiff/test/check_tag.c +++ b/tiff/test/check_tag.c @@ -30,18 +30,18 @@ #include "tiffio.h" int -CheckShortField(TIFF *tif, const ttag_t field, const uint16 value) +CheckShortField(TIFF *tif, const ttag_t field, const uint16_t value) { - uint16 tmp = 123; + uint16_t tmp = 123; if (!TIFFGetField(tif, field, &tmp)) { - fprintf (stderr, "Problem fetching tag %lu.\n", - (unsigned long) field); + fprintf (stderr, "Problem fetching tag %"PRIu32".\n", + field); return -1; } if (tmp != value) { - fprintf (stderr, "Wrong SHORT value fetched for tag %lu.\n", - (unsigned long) field); + fprintf (stderr, "Wrong SHORT value fetched for tag %"PRIu32".\n", + field); return -1; } @@ -49,18 +49,18 @@ CheckShortField(TIFF *tif, const ttag_t field, const uint16 value) } int -CheckShortPairedField(TIFF *tif, const ttag_t field, const uint16 *values) +CheckShortPairedField(TIFF *tif, const ttag_t field, const uint16_t *values) { - uint16 tmp[2] = { 123, 456 }; + uint16_t tmp[2] = {123, 456 }; if (!TIFFGetField(tif, field, tmp, tmp + 1)) { - fprintf (stderr, "Problem fetching tag %lu.\n", - (unsigned long) field); + fprintf (stderr, "Problem fetching tag %"PRIu32".\n", + field); return -1; } if (tmp[0] != values[0] || tmp[1] != values[1]) { - fprintf (stderr, "Wrong SHORT PAIR fetched for tag %lu.\n", - (unsigned long) field); + fprintf (stderr, "Wrong SHORT PAIR fetched for tag %"PRIu32".\n", + field); return -1; } @@ -68,18 +68,18 @@ CheckShortPairedField(TIFF *tif, const ttag_t field, const uint16 *values) } int -CheckLongField(TIFF *tif, const ttag_t field, const uint32 value) +CheckLongField(TIFF *tif, const ttag_t field, const uint32_t value) { - uint32 tmp = 123; + uint32_t tmp = 123; if (!TIFFGetField(tif, field, &tmp)) { - fprintf (stderr, "Problem fetching tag %lu.\n", - (unsigned long) field); + fprintf (stderr, "Problem fetching tag %"PRIu32".\n", + field); return -1; } if (tmp != value) { - fprintf (stderr, "Wrong LONG value fetched for tag %lu.\n", - (unsigned long) field); + fprintf (stderr, "Wrong LONG value fetched for tag %"PRIu32".\n", + field); return -1; } diff --git a/tiff/test/custom_dir.c b/tiff/test/custom_dir.c index 3b3ad279..42290ae8 100644 --- a/tiff/test/custom_dir.c +++ b/tiff/test/custom_dir.c @@ -42,12 +42,12 @@ static const char filename[] = "custom_dir.tif"; #define SPP 3 /* Samples per pixel */ -const uint16 width = 1; -const uint16 length = 1; -const uint16 bps = 8; -const uint16 photometric = PHOTOMETRIC_RGB; -const uint16 rows_per_strip = 1; -const uint16 planarconfig = PLANARCONFIG_CONTIG; +const uint16_t width = 1; +const uint16_t length = 1; +const uint16_t bps = 8; +const uint16_t photometric = PHOTOMETRIC_RGB; +const uint16_t rows_per_strip = 1; +const uint16_t planarconfig = PLANARCONFIG_CONTIG; static TIFFField customFields[] = { @@ -62,11 +62,11 @@ main() { TIFF *tif; unsigned char buf[SPP] = { 0, 127, 255 }; - uint64 dir_offset = 0, dir_offset2 = 0; - uint64 read_dir_offset = 0, read_dir_offset2 = 0; - uint64 *dir_offset2_ptr = NULL; + uint64_t dir_offset = 0, dir_offset2 = 0; + uint64_t read_dir_offset = 0, read_dir_offset2 = 0; + uint64_t *dir_offset2_ptr = NULL; char *ascii_value; - uint16 count16 = 0; + uint16_t count16 = 0; /* We write the main directory as a simple image. */ diff --git a/tiff/test/custom_dir_EXIF_231.c b/tiff/test/custom_dir_EXIF_231.c index 4c70e48f..892c442b 100644 --- a/tiff/test/custom_dir_EXIF_231.c +++ b/tiff/test/custom_dir_EXIF_231.c @@ -1,4 +1,3 @@ - /* * Copyright (c) 2012, Frank Warmerdam <warmerdam@pobox.com> * @@ -40,7 +39,7 @@ /*------------ - * This version writes the GPS and EXIF tags correctly, without additonal main-IFD and parameters! + * This version writes the GPS and EXIF tags correctly, without additional main-IFD and parameters! * In contrary, custom_dir.c does write additional main-IFD and parameters to file. -------------*/ @@ -67,6 +66,7 @@ #include "tif_config.h" #include <stdio.h> +#include <stdbool.h> #include <string.h> #include <math.h> #include <errno.h> @@ -88,12 +88,12 @@ static const char filename[] = "custom_dir_EXIF_231.tif"; static const char filenameBigTiff[] = "custom_dir_EXIF_231_Big.tif"; #define SPP 3 /* Samples per pixel */ -const uint16 width = 1; -const uint16 length = 1; -const uint16 bps = 8; -const uint16 photometric = PHOTOMETRIC_RGB; -const uint16 rows_per_strip = 1; -const uint16 planarconfig = PLANARCONFIG_CONTIG; +const uint16_t width = 1; +const uint16_t length = 1; +const uint16_t bps = 8; +const uint16_t photometric = PHOTOMETRIC_RGB; +const uint16_t rows_per_strip = 1; +const uint16_t planarconfig = PLANARCONFIG_CONTIG; int @@ -150,9 +150,9 @@ int write_test_tiff(TIFF *tif, const char *filenameRead) { unsigned char buf[SPP] = { 0, 127, 255 }; - uint64 dir_offset = 0; - uint64 dir_offset_GPS = 0, dir_offset_EXIF = 0; - uint64 read_dir_offset = 0; + uint64_t dir_offset = 0; + uint64_t dir_offset_GPS = 0, dir_offset_EXIF = 0; + uint64_t read_dir_offset = 0; /*-- Additional variables --*/ int retCode, retCode2; unsigned char exifVersion[4] = {'0','2','3','1'}; /* EXIF 2.31 version is 4 characters of a string! */ @@ -161,7 +161,7 @@ write_test_tiff(TIFF *tif, const char *filenameRead) float auxFloat = 0.0f; double auxDouble = 0.0; char auxChar = 0; - uint32 auxUint32 = 0; + uint32_t auxUint32 = 0; short auxShort=0; long auxLong = 0; void *pVoid; @@ -200,7 +200,7 @@ write_test_tiff(TIFF *tif, const char *filenameRead) float auxFloatArrayN2[3] = { -1.0f / 7.0f, -61.23456789012345f, -62.3f }; /* -- Variables for reading -- */ - uint16 count16 = 0; + uint16_t count16 = 0; union { long Long; short Short1; @@ -332,7 +332,7 @@ write_test_tiff(TIFF *tif, const char *filenameRead) goto failure; } - /*- Varable Array: TIFF_RATIONAL, 0, TIFF_SETGET_C16_FLOAT */ + /*- Variable Array: TIFF_RATIONAL, 0, TIFF_SETGET_C16_FLOAT */ if (!TIFFSetField(tif, TIFFTAG_BLACKLEVEL, 3, auxFloatArrayN1)) { fprintf(stderr, "Can't set TIFFTAG_BLACKLEVEL tag.\n"); goto failure; @@ -597,6 +597,7 @@ write_test_tiff(TIFF *tif, const char *filenameRead) nTags = tFieldArray->count; for (i=0; i<nTags; i++) { + bool deferredSetField = false; tTag = tFieldArray->fields[i].field_tag; tType = tFieldArray->fields[i].field_type; /* e.g. TIFF_RATIONAL */ tWriteCount = tFieldArray->fields[i].field_writecount; @@ -659,7 +660,7 @@ write_test_tiff(TIFF *tif, const char *filenameRead) /* _Cxx_ just defines the size of the count parameter for the array as C0=char, C16=short or C32=long */ /*-- Check, if it is a single parameter, a fixed array or a variable array */ if (tWriteCount == 1) { - fprintf (stderr, "WriteCount for .set_field_type %d should be -1 or greather than 1! %s\n", tSetFieldType, tFieldArray->fields[i].field_name); + fprintf (stderr, "WriteCount for .set_field_type %d should be -1 or greater than 1! %s\n", tSetFieldType, tFieldArray->fields[i].field_name); } else { /*-- Either fix or variable array --*/ /* For arrays, distinguishing between float or double is essential, even for writing */ @@ -690,46 +691,55 @@ write_test_tiff(TIFF *tif, const char *filenameRead) case TIFF_SETGET_C32_SINT8: /* For arrays, distinguishing between float or double is essential, even for writing */ pVoid = &auxCharArrayW[i]; + deferredSetField = true; + break; case TIFF_SETGET_C0_UINT16: case TIFF_SETGET_C0_SINT16: case TIFF_SETGET_C16_UINT16: case TIFF_SETGET_C16_SINT16: case TIFF_SETGET_C32_UINT16: case TIFF_SETGET_C32_SINT16: - if (pVoid == NULL) pVoid = &auxShortArrayW[i]; + pVoid = &auxShortArrayW[i]; + deferredSetField = true; + break; case TIFF_SETGET_C0_UINT32: case TIFF_SETGET_C0_SINT32: case TIFF_SETGET_C16_UINT32: case TIFF_SETGET_C16_SINT32: case TIFF_SETGET_C32_UINT32: case TIFF_SETGET_C32_SINT32: - if (pVoid == NULL) pVoid = &auxLongArrayW[i]; - /* _Cxx_ just defines the size of the count parameter for the array as C0=char, C16=short or C32=long */ - /*-- Check, if it is a single parameter, a fixed array or a variable array */ - if (tWriteCount == 1) { - fprintf (stderr, "WriteCount for .set_field_type %d should be -1 or greather than 1! %s\n", tSetFieldType, tFieldArray->fields[i].field_name); + pVoid = &auxLongArrayW[i]; + deferredSetField = true; + break; + default: + fprintf (stderr, "SetFieldType %d not defined within writing switch for %s.\n", tSetFieldType, tFieldName); + }; /*-- switch() --*/ + + if (deferredSetField) { + /* _Cxx_ just defines the size of the count parameter for the array as C0=char, C16=short or C32=long */ + /*-- Check, if it is a single parameter, a fixed array or a variable array */ + if (tWriteCount == 1) { + fprintf(stderr, "WriteCount for .set_field_type %d should be -1 or greater than 1! %s\n", + tSetFieldType, tFieldArray->fields[i].field_name); + } else { + /*-- Either fix or variable array --*/ + /* Now decide between fixed or variable array */ + if (tWriteCount > 1) { + /* fixed array with needed arraysize defined in .field_writecount */ + if (!TIFFSetField(tif, tTag, pVoid)) { + fprintf(stderr, "Can't write %s\n", tFieldArray->fields[i].field_name); + goto failure; + } } else { - /*-- Either fix or variable array --*/ - /* Now decide between fixed or variable array */ - if (tWriteCount > 1) { - /* fixed array with needed arraysize defined in .field_writecount */ - if (!TIFFSetField( tif, tTag, pVoid)) { - fprintf (stderr, "Can't write %s\n", tFieldArray->fields[i].field_name); - goto failure; - } - } else { - /* special treatment of variable array */ - /* for test, use always arraysize of VARIABLE_ARRAY_SIZE */ - if (!TIFFSetField( tif, tTag, VARIABLE_ARRAY_SIZE, pVoid)) { - fprintf (stderr, "Can't write %s\n", tFieldArray->fields[i].field_name); - goto failure; - } + /* special treatment of variable array */ + /* for test, use always arraysize of VARIABLE_ARRAY_SIZE */ + if (!TIFFSetField(tif, tTag, VARIABLE_ARRAY_SIZE, pVoid)) { + fprintf(stderr, "Can't write %s\n", tFieldArray->fields[i].field_name); + goto failure; } } - break; - default: - fprintf (stderr, "SetFieldType %d not defined within writing switch for %s.\n", tSetFieldType, tFieldName); - }; /*-- switch() --*/ + } + } } /*-- for() --*/ /*================= EXIF: END Writing arbitrary data to the EXIF fields END END END ==============*/ #endif /*-- WRITE_ALL_EXIF_TAGS --*/ @@ -784,12 +794,12 @@ write_test_tiff(TIFF *tif, const char *filenameRead) retCode = TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &auxUint32 ); if (!retCode) { fprintf(stderr, "Can't read %s\n", "TIFFTAG_IMAGEWIDTH"); } if (auxUint32 != width) { - fprintf (stderr, "Read value of IMAGEWIDTH %d differs from set value %d\n", auxUint32, width); + fprintf (stderr, "Read value of IMAGEWIDTH %"PRIu32" differs from set value %"PRIu16"\n", auxUint32, width); } retCode = TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &auxUint32 ); if (!retCode) { fprintf(stderr, "Can't read %s\n", "TIFFTAG_IMAGELENGTH"); } if (auxUint32 != width) { - fprintf (stderr, "Read value of TIFFTAG_IMAGELENGTH %d differs from set value %d\n", auxUint32, length); + fprintf (stderr, "Read value of TIFFTAG_IMAGELENGTH %"PRIu32" differs from set value %"PRIu16"\n", auxUint32, length); } #ifdef ADDITIONAL_TAGS @@ -956,7 +966,7 @@ write_test_tiff(TIFF *tif, const char *filenameRead) /* New interface allows also double precision for TIFF_RATIONAL */ auxDouble = auxDblUnion.dbl; } else { - /* Old interface reads TIFF_RATIONAL defined as TIFF_SETGET_DOUBLE alwasy as FLOAT */ + /* Old interface reads TIFF_RATIONAL defined as TIFF_SETGET_DOUBLE always as FLOAT */ auxDouble = (double)auxDblUnion.flt1; } /* compare read values with written ones */ @@ -999,7 +1009,7 @@ write_test_tiff(TIFF *tif, const char *filenameRead) /* New interface allows also double precision for TIFF_RATIONAL */ auxDouble = auxDblUnion.dbl; } else { - /* Old interface reads TIFF_RATIONAL defined as TIFF_SETGET_DOUBLE alwasy as FLOAT */ + /* Old interface reads TIFF_RATIONAL defined as TIFF_SETGET_DOUBLE always as FLOAT */ auxDouble = (double)auxDblUnion.flt1; } /* compare read values with written ones */ @@ -1027,7 +1037,7 @@ write_test_tiff(TIFF *tif, const char *filenameRead) /* New interface allows also double precision for TIFF_RATIONAL */ auxDouble = auxDblUnion.dbl; } else { - /* Old interface reads TIFF_RATIONAL defined as TIFF_SETGET_DOUBLE alwasy as FLOAT */ + /* Old interface reads TIFF_RATIONAL defined as TIFF_SETGET_DOUBLE always as FLOAT */ auxDouble = (double)auxDblUnion.flt1; } /* compare read values with written ones */ @@ -1078,6 +1088,7 @@ write_test_tiff(TIFF *tif, const char *filenameRead) } for (i=0; i<nTags; i++) { + bool deferredSetField = false; tTag = tFieldArray->fields[i].field_tag; tType = tFieldArray->fields[i].field_type; /* e.g. TIFF_RATIONAL */ tWriteCount = tFieldArray->fields[i].field_writecount; @@ -1096,7 +1107,8 @@ write_test_tiff(TIFF *tif, const char *filenameRead) break; } /* Save string from temporary buffer and compare with written string. */ - strncpy(auxCharArray, pAscii, sizeof(auxCharArray)); + strncpy(auxCharArray, pAscii, sizeof(auxCharArray) - 1u); + auxCharArray[sizeof(auxCharArray) - 1u] = '\0'; if (tWriteCount > 0) auxLong = tWriteCount-1; else auxLong = (long)strlen(auxCharArray); retCode2 = strncmp(auxCharArray, auxTextArrayW[i], auxLong); if (retCode2 != 0) { @@ -1188,7 +1200,7 @@ write_test_tiff(TIFF *tif, const char *filenameRead) auxDouble = auxDblUnion.dbl; } else { - /* Old interface reads TIFF_RATIONAL defined as TIFF_SETGET_DOUBLE alwasy as FLOAT */ + /* Old interface reads TIFF_RATIONAL defined as TIFF_SETGET_DOUBLE always as FLOAT */ auxDouble = (double)auxDblUnion.flt1; } } @@ -1216,7 +1228,7 @@ write_test_tiff(TIFF *tif, const char *filenameRead) /* _Cxx_ just defines the size of the count parameter for the array as C0=char, C16=short or C32=long */ /*-- Check, if it is a single parameter, a fixed array or a variable array */ if (tWriteCount == 1) { - fprintf (stderr, "Reading: WriteCount for .set_field_type %d should be -1 or greather than 1! %s\n", tSetFieldType, tFieldArray->fields[i].field_name); + fprintf (stderr, "Reading: WriteCount for .set_field_type %d should be -1 or greater than 1! %s\n", tSetFieldType, tFieldArray->fields[i].field_name); } else { /*-- Either fix or variable array --*/ /* For arrays, distinguishing between float or double is essential. */ @@ -1277,99 +1289,113 @@ write_test_tiff(TIFF *tif, const char *filenameRead) case TIFF_SETGET_C32_SINT8: /* For arrays, distinguishing between float or double is essential, even for writing */ pVoid = &auxCharArrayW[i]; - case TIFF_SETGET_C0_UINT16: + deferredSetField = true; + break; + case TIFF_SETGET_C0_UINT16: case TIFF_SETGET_C0_SINT16: case TIFF_SETGET_C16_UINT16: case TIFF_SETGET_C16_SINT16: case TIFF_SETGET_C32_UINT16: case TIFF_SETGET_C32_SINT16: - if (pVoid == NULL) pVoid = &auxShortArrayW[i]; + pVoid = &auxShortArrayW[i]; + deferredSetField = true; +break; case TIFF_SETGET_C0_UINT32: case TIFF_SETGET_C0_SINT32: case TIFF_SETGET_C16_UINT32: case TIFF_SETGET_C16_SINT32: case TIFF_SETGET_C32_UINT32: case TIFF_SETGET_C32_SINT32: - if (pVoid == NULL) pVoid = &auxLongArrayW[i]; - /* _Cxx_ just defines the size of the count parameter for the array as C0=char, C16=short or C32=long */ - /*-- Check, if it is a single parameter, a fixed array or a variable array */ - if (tWriteCount == 1) { - fprintf (stderr, "WriteCount for .set_field_type %d should be -1 or greather than 1! %s\n", tSetFieldType, tFieldArray->fields[i].field_name); + pVoid = &auxLongArrayW[i]; + deferredSetField = true; + break; + default: + fprintf (stderr, "SetFieldType %d not defined within writing switch for %s.\n", tSetFieldType, tFieldName); + GOTOFAILURE + }; /*-- switch() --*/ + + if(deferredSetField) { + /* _Cxx_ just defines the size of the count parameter for the array as C0=char, C16=short or C32=long */ + /*-- Check, if it is a single parameter, a fixed array or a variable array */ + if (tWriteCount == 1) { + fprintf(stderr, "WriteCount for .set_field_type %d should be -1 or greater than 1! %s\n", + tSetFieldType, tFieldArray->fields[i].field_name); + } else { + /*-- Either fix or variable array --*/ + /* Now decide between fixed or variable array */ + if (tWriteCount > 1) { + /* fixed array with needed arraysize defined in .field_writecount */ + if (!TIFFGetField(tif, tTag, &pVoidArray)) { + fprintf(stderr, "Can't read %s\n", tFieldArray->fields[i].field_name); + GOTOFAILURE_ALL_EXIF + break; + } + /* set tWriteCount to number of read samples for next steps */ + auxLong = tWriteCount; } else { - /*-- Either fix or variable array --*/ - /* Now decide between fixed or variable array */ - if (tWriteCount > 1) { - /* fixed array with needed arraysize defined in .field_writecount */ - if (!TIFFGetField( tif, tTag, &pVoidArray)) { - fprintf (stderr, "Can't read %s\n", tFieldArray->fields[i].field_name); - GOTOFAILURE_ALL_EXIF - break; - } - /* set tWriteCount to number of read samples for next steps */ - auxLong = tWriteCount; - } else { - /* special treatment of variable array */ - /* for test, use always arraysize of VARIABLE_ARRAY_SIZE */ - if (!TIFFGetField( tif, tTag, &unionLong, &pVoidArray)) { - fprintf (stderr, "Can't read %s\n", tFieldArray->fields[i].field_name); - GOTOFAILURE_ALL_EXIF - break; - } - /* set tWriteCount to number of read samples for next steps */ - auxLong = unionLong.Short1; + /* special treatment of variable array */ + /* for test, use always arraysize of VARIABLE_ARRAY_SIZE */ + if (!TIFFGetField(tif, tTag, &unionLong, &pVoidArray)) { + fprintf(stderr, "Can't read %s\n", tFieldArray->fields[i].field_name); + GOTOFAILURE_ALL_EXIF + break; } - /* Save values from temporary array */ - if (tSetFieldType == TIFF_SETGET_C0_UINT8 || tSetFieldType == TIFF_SETGET_C0_SINT8 || - tSetFieldType == TIFF_SETGET_C16_UINT8 || tSetFieldType == TIFF_SETGET_C16_SINT8 || - tSetFieldType == TIFF_SETGET_C32_UINT8 || tSetFieldType == TIFF_SETGET_C32_SINT8 ) { - memcpy(&auxCharArray, pVoidArray,(auxLong * sizeof(auxCharArray[0]))); - /* Compare and check values */ - for (j=0; j<auxLong; j++) { - if (tTag == EXIFTAG_EXIFVERSION) { - /*-- Use exifVersion[] instead of auxCharArrayW[] for differently set EXIFVERSION tag */ - if (auxCharArray[j] != exifVersion[j]) { - fprintf(stderr, "Read value %d of %s #%d %d differs from set value %d\n", i, tFieldName, j, auxCharArray[j], auxCharArrayW[i + j]); - GOTOFAILURE_ALL_EXIF - } - } else { - if (auxCharArray[j] != auxCharArrayW[i + j]) { - fprintf(stderr, "Read value %d of %s #%d %d differs from set value %d\n", i, tFieldName, j, auxCharArray[j], auxCharArrayW[i + j]); - GOTOFAILURE_ALL_EXIF - } - } - } - } else if (tSetFieldType == TIFF_SETGET_C0_UINT16 || tSetFieldType == TIFF_SETGET_C0_SINT16 || - tSetFieldType == TIFF_SETGET_C16_UINT16 || tSetFieldType == TIFF_SETGET_C16_SINT16 || - tSetFieldType == TIFF_SETGET_C32_UINT16 || tSetFieldType == TIFF_SETGET_C32_SINT16 ) { - memcpy(&auxShortArray, pVoidArray,(auxLong * sizeof(auxShortArray[0]))); - /* Compare and check values */ - for (j=0; j<auxLong; j++) { - if (auxShortArray[j] != auxShortArrayW[i+j]) { - fprintf (stderr, "Read value %d of %s #%d %d differs from set value %d\n", i, tFieldName, j, auxShortArray[j], auxShortArrayW[i+j]); + /* set tWriteCount to number of read samples for next steps */ + auxLong = unionLong.Short1; + } + /* Save values from temporary array */ + if (tSetFieldType == TIFF_SETGET_C0_UINT8 || tSetFieldType == TIFF_SETGET_C0_SINT8 || + tSetFieldType == TIFF_SETGET_C16_UINT8 || tSetFieldType == TIFF_SETGET_C16_SINT8 || + tSetFieldType == TIFF_SETGET_C32_UINT8 || tSetFieldType == TIFF_SETGET_C32_SINT8) { + memcpy(&auxCharArray, pVoidArray, (auxLong * sizeof(auxCharArray[0]))); + /* Compare and check values */ + for (j = 0; j < auxLong; j++) { + if (tTag == EXIFTAG_EXIFVERSION) { + /*-- Use exifVersion[] instead of auxCharArrayW[] for differently set EXIFVERSION tag */ + if (auxCharArray[j] != exifVersion[j]) { + fprintf(stderr, "Read value %d of %s #%d %d differs from set value %d\n", i, tFieldName, + j, auxCharArray[j], auxCharArrayW[i + j]); GOTOFAILURE_ALL_EXIF } - } - } else if (tSetFieldType == TIFF_SETGET_C0_UINT32 || tSetFieldType == TIFF_SETGET_C0_SINT32 || - tSetFieldType == TIFF_SETGET_C16_UINT32 || tSetFieldType == TIFF_SETGET_C16_SINT32 || - tSetFieldType == TIFF_SETGET_C32_UINT32 || tSetFieldType == TIFF_SETGET_C32_SINT32 ) { - memcpy(&auxLongArray, pVoidArray,(auxLong * sizeof(auxLongArray[0]))); - /* Compare and check values */ - for (j=0; j<auxLong; j++) { - if (auxLongArray[j] != auxLongArrayW[i+j]) { - fprintf (stderr, "Read value %d of %s #%d %ld differs from set value %ld\n", i, tFieldName, j, auxLongArray[j], auxLongArrayW[i+j]); + } else { + if (auxCharArray[j] != auxCharArrayW[i + j]) { + fprintf(stderr, "Read value %d of %s #%d %d differs from set value %d\n", i, tFieldName, + j, auxCharArray[j], auxCharArrayW[i + j]); GOTOFAILURE_ALL_EXIF } } - } else { - fprintf (stderr, "SetFieldType %d not defined within switch case reading for UINT for %s.\n", tSetFieldType, tFieldName); - GOTOFAILURE } + } else if (tSetFieldType == TIFF_SETGET_C0_UINT16 || tSetFieldType == TIFF_SETGET_C0_SINT16 || + tSetFieldType == TIFF_SETGET_C16_UINT16 || tSetFieldType == TIFF_SETGET_C16_SINT16 || + tSetFieldType == TIFF_SETGET_C32_UINT16 || tSetFieldType == TIFF_SETGET_C32_SINT16) { + memcpy(&auxShortArray, pVoidArray, (auxLong * sizeof(auxShortArray[0]))); + /* Compare and check values */ + for (j = 0; j < auxLong; j++) { + if (auxShortArray[j] != auxShortArrayW[i + j]) { + fprintf(stderr, "Read value %d of %s #%d %d differs from set value %d\n", i, tFieldName, j, + auxShortArray[j], auxShortArrayW[i + j]); + GOTOFAILURE_ALL_EXIF + } + } + } else if (tSetFieldType == TIFF_SETGET_C0_UINT32 || tSetFieldType == TIFF_SETGET_C0_SINT32 || + tSetFieldType == TIFF_SETGET_C16_UINT32 || tSetFieldType == TIFF_SETGET_C16_SINT32 || + tSetFieldType == TIFF_SETGET_C32_UINT32 || tSetFieldType == TIFF_SETGET_C32_SINT32) { + memcpy(&auxLongArray, pVoidArray, (auxLong * sizeof(auxLongArray[0]))); + /* Compare and check values */ + for (j = 0; j < auxLong; j++) { + if (auxLongArray[j] != auxLongArrayW[i + j]) { + fprintf(stderr, "Read value %d of %s #%d %ld differs from set value %ld\n", i, tFieldName, + j, auxLongArray[j], auxLongArrayW[i + j]); + GOTOFAILURE_ALL_EXIF + } + } + } else { + fprintf(stderr, "SetFieldType %d not defined within switch case reading for UINT for %s.\n", + tSetFieldType, tFieldName); + GOTOFAILURE } - break; - default: - fprintf (stderr, "SetFieldType %d not defined within writing switch for %s.\n", tSetFieldType, tFieldName); - GOTOFAILURE - }; /*-- switch() --*/ + } + } } /*-- for() --*/ /*================= EXIF: END Reading arbitrary data to the EXIF fields END END END ==============*/ #endif /*-- READ_ALL_EXIF_TAGS --*/ diff --git a/tiff/test/defer_strile_writing.c b/tiff/test/defer_strile_writing.c index 4e358567..b918a228 100644 --- a/tiff/test/defer_strile_writing.c +++ b/tiff/test/defer_strile_writing.c @@ -131,7 +131,7 @@ int test(const char* mode, int tiled, int height) ret = TIFFForceStrileArrayWriting(tif); assert(ret); - /* Now write data on frist directory */ + /* Now write data on first directory */ ret = TIFFSetDirectory( tif, 0 ); assert(ret); diff --git a/tiff/test/long_tag.c b/tiff/test/long_tag.c index 4bfdf805..79f0235c 100644 --- a/tiff/test/long_tag.c +++ b/tiff/test/long_tag.c @@ -37,22 +37,22 @@ #include "tiffio.h" -extern int CheckLongField(TIFF *, ttag_t, uint32); +extern int CheckLongField(TIFF *, ttag_t, uint32_t); const char *filename = "long_test.tiff"; static struct Tags { ttag_t tag; short count; - uint32 value; + uint32_t value; } long_tags[] = { { TIFFTAG_SUBFILETYPE, 1, FILETYPE_REDUCEDIMAGE|FILETYPE_PAGE|FILETYPE_MASK } }; #define NTAGS (sizeof (long_tags) / sizeof (long_tags[0])) -const uint32 width = 1; -const uint32 length = 1; -const uint32 rows_per_strip = 1; +const uint32_t width = 1; +const uint32_t length = 1; +const uint32_t rows_per_strip = 1; int main(int argc, char **argv) diff --git a/tiff/test/rational_precision2double.c b/tiff/test/rational_precision2double.c index e33cc97d..4e5c0bbf 100644 --- a/tiff/test/rational_precision2double.c +++ b/tiff/test/rational_precision2double.c @@ -72,12 +72,12 @@ int write_test_tiff(TIFF *tif, const char *filenameRead, int blnAllCustomTags); #define SPP 3 /* Samples per pixel */ -const uint16 width = 1; -const uint16 length = 1; -const uint16 bps = 8; -const uint16 photometric = PHOTOMETRIC_RGB; -const uint16 rows_per_strip = 1; -const uint16 planarconfig = PLANARCONFIG_CONTIG; +const uint16_t width = 1; +const uint16_t length = 1; +const uint16_t bps = 8; +const uint16_t photometric = PHOTOMETRIC_RGB; +const uint16_t rows_per_strip = 1; +const uint16_t planarconfig = PLANARCONFIG_CONTIG; /*-- Additional custom TIFF tags for testing of Rational2Double precision --*/ #define TIFFTAG_RATIONAL_DOUBLE 60000 @@ -148,11 +148,11 @@ It merges in our new fields and then calls the next extender if there is one in static void _XTIFFDefaultDirectory(TIFF *tif) { - uint32 n, nadded; + uint32_t n, nadded; /* Install the extended Tag field info */ n = N(tifFieldInfo); - //_TIFFMergeFields(tif, const TIFFField info[], uint32 n); + //_TIFFMergeFields(tif, const TIFFField info[], uint32_t n); nadded = _TIFFMergeFields(tif, tifFieldInfo, n); (void)nadded; @@ -261,8 +261,8 @@ write_test_tiff(TIFF* tif, const char* filenameRead, int blnAllCustomTags) { int retCode; float auxFloat = 0.0f; double auxDouble = 0.0; - uint16 auxUint16 = 0; - uint32 auxUint32 = 0; + uint16_t auxUint16 = 0; + uint32_t auxUint32 = 0; long auxLong = 0; void* pVoid; int blnIsRational2Double; @@ -292,7 +292,7 @@ write_test_tiff(TIFF* tif, const char* filenameRead, int blnAllCustomTags) { float auxFloatArrayResolutions[4] = {5.456789f, 6.666666f, 0.0033f, 5.0f / 213.0f}; /* -- Variables for reading -- */ - uint16 count16 = 0; + uint16_t count16 = 0; union { long Long; short Short1; diff --git a/tiff/test/raw_decode.c b/tiff/test/raw_decode.c index a2fca03a..b8d12aa6 100644 --- a/tiff/test/raw_decode.c +++ b/tiff/test/raw_decode.c @@ -59,7 +59,7 @@ "JPEGLib: JPEG parameter struct mismatch: library thinks size is 432, caller expects 464" - For such users we wil fix the problem here. See install.doc file from + For such users we will fix the problem here. See install.doc file from the JPEG library distribution for details. */ @@ -120,24 +120,24 @@ static int check_rgb_pixel( int pixel, return 1; } -static int check_rgba_pixel( int pixel, - int min_red, int max_red, - int min_green, int max_green, - int min_blue, int max_blue, - int min_alpha, int max_alpha, - uint32 *buffer ) { +static int check_rgba_pixel(int pixel, + int min_red, int max_red, + int min_green, int max_green, + int min_blue, int max_blue, + int min_alpha, int max_alpha, + uint32_t *buffer ) { /* RGBA images are upside down - adjust for normal ordering */ int adjusted_pixel = pixel % 128 + (127 - (pixel/128)) * 128; - uint32 rgba = buffer[adjusted_pixel]; - - if( TIFFGetR(rgba) >= (uint32) min_red && - TIFFGetR(rgba) <= (uint32) max_red && - TIFFGetG(rgba) >= (uint32) min_green && - TIFFGetG(rgba) <= (uint32) max_green && - TIFFGetB(rgba) >= (uint32) min_blue && - TIFFGetB(rgba) <= (uint32) max_blue && - TIFFGetA(rgba) >= (uint32) min_alpha && - TIFFGetA(rgba) <= (uint32) max_alpha ) { + uint32_t rgba = buffer[adjusted_pixel]; + + if( TIFFGetR(rgba) >= (uint32_t) min_red && + TIFFGetR(rgba) <= (uint32_t) max_red && + TIFFGetG(rgba) >= (uint32_t) min_green && + TIFFGetG(rgba) <= (uint32_t) max_green && + TIFFGetB(rgba) >= (uint32_t) min_blue && + TIFFGetB(rgba) <= (uint32_t) max_blue && + TIFFGetA(rgba) >= (uint32_t) min_alpha && + TIFFGetA(rgba) <= (uint32_t) max_alpha ) { return 0; } @@ -160,7 +160,7 @@ main(int argc, char **argv) unsigned short h, v; int status; unsigned char *buffer; - uint32 *rgba_buffer; + uint32_t *rgba_buffer; tsize_t sz, szout; unsigned int pixel_status = 0; @@ -261,8 +261,8 @@ main(int argc, char **argv) */ tif = TIFFOpen(srcfile,"r"); - sz = 128 * 128 * sizeof(uint32); - rgba_buffer = (uint32 *) malloc(sz); + sz = 128 * 128 * sizeof(uint32_t); + rgba_buffer = (uint32_t *) malloc(sz); if (!TIFFReadRGBATile( tif, 1*128, 2*128, rgba_buffer )) { fprintf( stderr, "TIFFReadRGBATile() returned failure code.\n" ); @@ -271,7 +271,7 @@ main(int argc, char **argv) /* * Currently TIFFReadRGBATile() just uses JPEGCOLORMODE_RGB so this - * trivally matches the last results. Eventually we should actually + * trivially matches the last results. Eventually we should actually * accomplish it from the YCbCr subsampled buffer ourselves in which * case the results may be subtly different but similar. */ diff --git a/tiff/test/rewrite_tag.c b/tiff/test/rewrite_tag.c index 1708b024..2c988e3b 100644 --- a/tiff/test/rewrite_tag.c +++ b/tiff/test/rewrite_tag.c @@ -39,8 +39,8 @@ #include "tiffio.h" #include "tiffiop.h" -const uint32 length = 40; -const uint32 rows_per_strip = 1; +const uint32_t length = 40; +const uint32_t rows_per_strip = 1; int test_packbits() @@ -49,7 +49,7 @@ int test_packbits() int i; unsigned char buf[10] = {0,0,0,0,0,0,0,0,0,0}; - uint32 width = 10; + uint32_t width = 10; int length = 20; const char *filename = "test_packbits.tif"; @@ -137,16 +137,16 @@ int test_packbits() /************************************************************************/ /* rewrite_test() */ /************************************************************************/ -int rewrite_test( const char *filename, uint32 width, int length, int bigtiff, - uint64 base_value ) +int rewrite_test(const char *filename, uint32_t width, int length, int bigtiff, + uint64_t base_value ) { TIFF *tif; int i; unsigned char *buf; - uint64 *rowoffset, *rowbytes; - uint64 *upd_rowoffset; - uint64 *upd_bytecount; + uint64_t *rowoffset, *rowbytes; + uint64_t *upd_rowoffset = NULL; + uint64_t *upd_bytecount = NULL; buf = calloc(1, width); assert(buf); @@ -223,7 +223,7 @@ int rewrite_test( const char *filename, uint32 width, int length, int bigtiff, goto failure; } - upd_rowoffset = (uint64 *) _TIFFmalloc(sizeof(uint64) * length); + upd_rowoffset = (uint64_t *) _TIFFmalloc(sizeof(uint64_t) * length); for( i = 0; i < length; i++ ) upd_rowoffset[i] = base_value + i*width; @@ -235,8 +235,9 @@ int rewrite_test( const char *filename, uint32 width, int length, int bigtiff, } _TIFFfree( upd_rowoffset ); + upd_rowoffset = NULL; - upd_bytecount = (uint64 *) _TIFFmalloc(sizeof(uint64) * length); + upd_bytecount = (uint64_t *) _TIFFmalloc(sizeof(uint64_t) * length); for( i = 0; i < length; i++ ) upd_bytecount[i] = 100 + i*width; @@ -248,6 +249,7 @@ int rewrite_test( const char *filename, uint32 width, int length, int bigtiff, } _TIFFfree( upd_bytecount ); + upd_bytecount = NULL; TIFFClose(tif); @@ -268,7 +270,7 @@ int rewrite_test( const char *filename, uint32 width, int length, int bigtiff, for( i = 0; i < length; i++ ) { - uint64 expect = base_value + i*width; + uint64_t expect = base_value + i * width; if( rowoffset[i] != expect ) { @@ -291,7 +293,7 @@ int rewrite_test( const char *filename, uint32 width, int length, int bigtiff, for( i = 0; i < length; i++ ) { - uint64 expect = 100 + i*width; + uint64_t expect = 100 + i * width; if( rowbytes[i] != expect ) { @@ -317,6 +319,14 @@ int rewrite_test( const char *filename, uint32 width, int length, int bigtiff, /* Something goes wrong; close file and return unsuccessful status. */ TIFFClose(tif); free(buf); + if( upd_rowoffset != NULL ) + { + _TIFFfree( upd_rowoffset ); + } + if ( upd_bytecount != NULL ) + { + _TIFFfree( upd_bytecount ); + } /* unlink(filename); */ return 1; diff --git a/tiff/test/short_tag.c b/tiff/test/short_tag.c index 75e7f5d5..89197b02 100644 --- a/tiff/test/short_tag.c +++ b/tiff/test/short_tag.c @@ -41,16 +41,16 @@ static const char filename[] = "short_test.tiff"; #define SPP 3 /* Samples per pixel */ -const uint16 width = 1; -const uint16 length = 1; -const uint16 bps = 8; -const uint16 photometric = PHOTOMETRIC_RGB; -const uint16 rows_per_strip = 1; -const uint16 planarconfig = PLANARCONFIG_CONTIG; +const uint16_t width = 1; +const uint16_t length = 1; +const uint16_t bps = 8; +const uint16_t photometric = PHOTOMETRIC_RGB; +const uint16_t rows_per_strip = 1; +const uint16_t planarconfig = PLANARCONFIG_CONTIG; static const struct { const ttag_t tag; - const uint16 value; + const uint16_t value; } short_single_tags[] = { { TIFFTAG_COMPRESSION, COMPRESSION_NONE }, { TIFFTAG_FILLORDER, FILLORDER_MSB2LSB }, @@ -66,7 +66,7 @@ static const struct { static const struct { const ttag_t tag; - const uint16 values[2]; + const uint16_t values[2]; } short_paired_tags[] = { { TIFFTAG_PAGENUMBER, {1, 1} }, { TIFFTAG_HALFTONEHINTS, {0, 255} }, @@ -121,8 +121,8 @@ main() for (i = 0; i < NSINGLETAGS; i++) { if (!TIFFSetField(tif, short_single_tags[i].tag, short_single_tags[i].value)) { - fprintf(stderr, "Can't set tag %lu.\n", - (unsigned long)short_single_tags[i].tag); + fprintf(stderr, "Can't set tag %"PRIu32".\n", + short_single_tags[i].tag); goto failure; } } @@ -131,8 +131,8 @@ main() if (!TIFFSetField(tif, short_paired_tags[i].tag, short_paired_tags[i].values[0], short_paired_tags[i].values[1])) { - fprintf(stderr, "Can't set tag %lu.\n", - (unsigned long)short_paired_tags[i].tag); + fprintf(stderr, "Can't set tag %"PRIu32".\n", + short_paired_tags[i].tag); goto failure; } } diff --git a/tiff/test/strip.c b/tiff/test/strip.c index f2cb7735..004a66a2 100644 --- a/tiff/test/strip.c +++ b/tiff/test/strip.c @@ -57,8 +57,8 @@ write_strips(TIFF *tif, const tdata_t array, const tsize_t size) if (TIFFWriteEncodedStrip(tif, strip, (char *)array + offset, bufsize) != bufsize) { - fprintf (stderr, "Can't write strip %lu.\n", - (unsigned long)strip); + fprintf (stderr, "Can't write strip %"PRIu32".\n", + strip); return -1; } } @@ -97,13 +97,13 @@ read_strips(TIFF *tif, const tdata_t array, const tsize_t size) bufsize = stripsize; if (TIFFReadEncodedStrip(tif, strip, buf, -1) != bufsize) { - fprintf (stderr, "Can't read strip %lu.\n", - (unsigned long)strip); + fprintf (stderr, "Can't read strip %"PRIu32".\n", + strip); return -1; } if (memcmp(buf, (char *)array + offset, bufsize) != 0) { - fprintf (stderr, "Wrong data read for strip %lu.\n", - (unsigned long)strip); + fprintf (stderr, "Wrong data read for strip %"PRIu32".\n", + strip); _TIFFfree(buf); return -1; } @@ -115,11 +115,11 @@ read_strips(TIFF *tif, const tdata_t array, const tsize_t size) } int -create_image_striped(const char *name, uint32 width, uint32 length, - uint32 rowsperstrip, uint16 compression, - uint16 spp, uint16 bps, uint16 photometric, - uint16 sampleformat, uint16 planarconfig, - const tdata_t array, const tsize_t size) +create_image_striped(const char *name, uint32_t width, uint32_t length, + uint32_t rowsperstrip, uint16_t compression, + uint16_t spp, uint16_t bps, uint16_t photometric, + uint16_t sampleformat, uint16_t planarconfig, + const tdata_t array, const tsize_t size) { TIFF *tif; @@ -169,25 +169,25 @@ failure: TIFFClose(tif); openfailure: fprintf (stderr, "Can't create test TIFF file %s:\n" -" ImageWidth=%ld, ImageLength=%ld, RowsPerStrip=%ld, Compression=%d,\n" -" BitsPerSample=%d, SamplesPerPixel=%d, SampleFormat=%d,\n" -" PlanarConfiguration=%d, PhotometricInterpretation=%d.\n", - name, (long) width, (long) length, (long) rowsperstrip, +" ImageWidth=%"PRIu32", ImageLength=%"PRIu32", RowsPerStrip=%"PRIu32", Compression=%"PRIu16",\n" +" BitsPerSample=%"PRIu16", SamplesPerPixel=%"PRIu16", SampleFormat=%"PRIu16",\n" +" PlanarConfiguration=%"PRIu16", PhotometricInterpretation=%"PRIu16".\n", + name, width, length, rowsperstrip, compression, bps, spp, sampleformat, planarconfig, photometric); return -1; } int -read_image_striped(const char *name, uint32 width, uint32 length, - uint32 rowsperstrip, uint16 compression, - uint16 spp, uint16 bps, uint16 photometric, - uint16 sampleformat, uint16 planarconfig, - const tdata_t array, const tsize_t size) +read_image_striped(const char *name, uint32_t width, uint32_t length, + uint32_t rowsperstrip, uint16_t compression, + uint16_t spp, uint16_t bps, uint16_t photometric, + uint16_t sampleformat, uint16_t planarconfig, + const tdata_t array, const tsize_t size) { TIFF *tif; - uint16 value_u16; - uint32 value_u32; + uint16_t value_u16; + uint32_t value_u32; /* Test whether we can read written values. */ tif = TIFFOpen(name, "r"); @@ -247,10 +247,10 @@ failure: TIFFClose(tif); openfailure: fprintf (stderr, "Can't read test TIFF file %s:\n" -" ImageWidth=%ld, ImageLength=%ld, RowsPerStrip=%ld, Compression=%d,\n" -" BitsPerSample=%d, SamplesPerPixel=%d, SampleFormat=%d,\n" -" PlanarConfiguration=%d, PhotometricInterpretation=%d.\n", - name, (long) width, (long) length, (long) rowsperstrip, +" ImageWidth=%"PRIu32", ImageLength=%"PRIu32", RowsPerStrip=%"PRIu32", Compression=%"PRIu16",\n" +" BitsPerSample=%"PRIu16", SamplesPerPixel=%"PRIu16", SampleFormat=%"PRIu16",\n" +" PlanarConfiguration=%"PRIu16", PhotometricInterpretation=%"PRIu16".\n", + name, width, length, rowsperstrip, compression, bps, spp, sampleformat, planarconfig, photometric); return -1; @@ -259,7 +259,7 @@ openfailure: int write_scanlines(TIFF *tif, const tdata_t array, const tsize_t size) { - uint32 length, row; + uint32_t length, row; tsize_t scanlinesize, offset; (void) size; @@ -277,7 +277,7 @@ write_scanlines(TIFF *tif, const tdata_t array, const tsize_t size) for (offset = 0, row = 0; row < length; offset+=scanlinesize, row++) { if (TIFFWriteScanline(tif, (char *)array + offset, row, 0) == -1) { fprintf (stderr, - "Can't write image data at row %lu.\n", (long) row); + "Can't write image data at row %"PRIu32".\n", row); return -1; } } diff --git a/tiff/test/strip_rw.c b/tiff/test/strip_rw.c index bcf7d735..866329b1 100644 --- a/tiff/test/strip_rw.c +++ b/tiff/test/strip_rw.c @@ -39,22 +39,22 @@ #include "test_arrays.h" extern int -create_image_striped(const char *, uint32, uint32, uint32, uint16, uint16, - uint16, uint16, uint16, uint16, const tdata_t, - const tsize_t); +create_image_striped(const char *, uint32_t, uint32_t, uint32_t, uint16_t, uint16_t, + uint16_t, uint16_t, uint16_t, uint16_t, const tdata_t, + const tsize_t); extern int -read_image_striped(const char *, uint32, uint32, uint32, uint16, uint16, - uint16, uint16, uint16, uint16, const tdata_t, - const tsize_t); +read_image_striped(const char *, uint32_t, uint32_t, uint32_t, uint16_t, uint16_t, + uint16_t, uint16_t, uint16_t, uint16_t, const tdata_t, + const tsize_t); const char *filename = "strip_test.tiff"; int main(int argc, char **argv) { - uint32 rowsperstrip; - uint16 compression; - uint16 spp, bps, photometric, sampleformat, planarconfig; + uint32_t rowsperstrip; + uint16_t compression; + uint16_t spp, bps, photometric, sampleformat, planarconfig; (void) argc; (void) argv; diff --git a/tiff/test/testtypes.c b/tiff/test/testtypes.c index a36d21e5..0405b94f 100644 --- a/tiff/test/testtypes.c +++ b/tiff/test/testtypes.c @@ -42,16 +42,15 @@ int main() { - CHECK_TYPE(TIFF_INT8_T, 1) - CHECK_TYPE(TIFF_INT16_T, 2) - CHECK_TYPE(TIFF_INT32_T, 4) - CHECK_TYPE(TIFF_INT64_T, 8) - CHECK_TYPE(TIFF_UINT8_T, 1) - CHECK_TYPE(TIFF_UINT16_T, 2) - CHECK_TYPE(TIFF_UINT32_T, 4) - CHECK_TYPE(TIFF_UINT64_T, 8) - CHECK_TYPE(TIFF_SIZE_T, sizeof(size_t)) - CHECK_TYPE(TIFF_SSIZE_T, sizeof(size_t)) + CHECK_TYPE(int8_t, 1) + CHECK_TYPE(int16_t, 2) + CHECK_TYPE(int32_t, 4) + CHECK_TYPE(int64_t, 8) + CHECK_TYPE(uint8_t, 1) + CHECK_TYPE(uint16_t, 2) + CHECK_TYPE(uint32_t, 4) + CHECK_TYPE(uint64_t, 8) + CHECK_TYPE(tmsize_t , sizeof(size_t)) return 0; } diff --git a/tiff/test/tifftest.h b/tiff/test/tifftest.h index 391b0f64..694f66cc 100644 --- a/tiff/test/tifftest.h +++ b/tiff/test/tifftest.h @@ -32,9 +32,9 @@ #include "tiffio.h" -int CheckShortField(TIFF *, const ttag_t, const uint16); -int CheckShortPairedField(TIFF *, const ttag_t, const uint16*); -int CheckLongField(TIFF *, const ttag_t, const uint32); +int CheckShortField(TIFF *, const ttag_t, const uint16_t); +int CheckShortPairedField(TIFF *, const ttag_t, const uint16_t*); +int CheckLongField(TIFF *, const ttag_t, const uint32_t); #endif /* _TIFFTEST_ */ |