summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Leigh <rleigh@codelibre.net>2021-02-03 10:41:47 +0000
committerRoger Leigh <rleigh@codelibre.net>2021-02-04 18:09:03 +0000
commit39fa8a04ee96853ab4cc8e51ca14bec7dfb570fb (patch)
tree768cf5c022a729fa21ca5c360fa97b7ee628c542
parentc5820961e65b5dd54777c97c4b2a2347d6515570 (diff)
downloadlibtiff-git-39fa8a04ee96853ab4cc8e51ca14bec7dfb570fb.tar.gz
Add TIFF_SIZE_FORMAT for portable use of %z
MinGW64 does support %z, but it issues a compiler warning.
-rw-r--r--libtiff/tif_config.h.cmake.in9
-rw-r--r--libtiff/tif_config.h.in11
-rw-r--r--libtiff/tif_lzma.c2
-rw-r--r--libtiff/tif_webp.c2
-rw-r--r--tools/rgb2ycbcr.c2
-rw-r--r--tools/tiff2pdf.c10
-rw-r--r--tools/tiff2rgba.c4
7 files changed, 29 insertions, 11 deletions
diff --git a/libtiff/tif_config.h.cmake.in b/libtiff/tif_config.h.cmake.in
index 2b65d243..44d1240f 100644
--- a/libtiff/tif_config.h.cmake.in
+++ b/libtiff/tif_config.h.cmake.in
@@ -134,10 +134,19 @@
# endif
#endif
+#if !defined(__MINGW32__)
+# define TIFF_SIZE_FORMAT "zu"
+#endif
#if SIZEOF_SIZE_T == 8
# define TIFF_SSIZE_FORMAT PRId64
+# if defined(__MINGW32__)
+# define TIFF_SIZE_FORMAT PRIu64
+# endif
#elif SIZEOF_SIZE_T == 4
# define TIFF_SSIZE_FORMAT PRId32
+# if defined(__MINGW32__)
+# define TIFF_SIZE_FORMAT PRIu32
+# endif
#else
# error "Unsupported size_t size; please submit a bug report"
#endif
diff --git a/libtiff/tif_config.h.in b/libtiff/tif_config.h.in
index 6a543463..b15b2b04 100644
--- a/libtiff/tif_config.h.in
+++ b/libtiff/tif_config.h.in
@@ -150,10 +150,19 @@
/* Define for large files, on AIX-style hosts. */
#undef _LARGE_FILES
+#if !defined(__MINGW32__)
+# define TIFF_SIZE_FORMAT "zu"
+#endif
#if SIZEOF_SIZE_T == 8
# define TIFF_SSIZE_FORMAT PRId64
+# if defined(__MINGW32__)
+# define TIFF_SIZE_FORMAT PRIu64
+# endif
#elif SIZEOF_SIZE_T == 4
# define TIFF_SSIZE_FORMAT PRId32
+# if defined(__MINGW32__)
+# define TIFF_SIZE_FORMAT PRIu32
+# endif
#else
# error "Unsupported size_t size; please submit a bug report"
-#endif \ No newline at end of file
+#endif
diff --git a/libtiff/tif_lzma.c b/libtiff/tif_lzma.c
index a5770569..fc046475 100644
--- a/libtiff/tif_lzma.c
+++ b/libtiff/tif_lzma.c
@@ -213,7 +213,7 @@ LZMADecode(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s)
} while (sp->stream.avail_out > 0);
if (sp->stream.avail_out != 0) {
TIFFErrorExt(tif->tif_clientdata, module,
- "Not enough data at scanline %"PRIu32" (short %zu bytes)",
+ "Not enough data at scanline %"PRIu32" (short %"TIFF_SIZE_FORMAT" bytes)",
tif->tif_row, sp->stream.avail_out);
return 0;
}
diff --git a/libtiff/tif_webp.c b/libtiff/tif_webp.c
index 31412c84..50ffdce6 100644
--- a/libtiff/tif_webp.c
+++ b/libtiff/tif_webp.c
@@ -79,7 +79,7 @@ int TWebPDatasetWriter(const uint8_t* data, size_t data_size,
if ( (tif->tif_rawcc + (tmsize_t)data_size) > tif->tif_rawdatasize ) {
TIFFErrorExt(tif->tif_clientdata, module,
- "Buffer too small by %zu bytes.",
+ "Buffer too small by %"TIFF_SIZE_FORMAT" bytes.",
(size_t) (tif->tif_rawcc + data_size - tif->tif_rawdatasize));
return 0;
} else {
diff --git a/tools/rgb2ycbcr.c b/tools/rgb2ycbcr.c
index de23594b..0407cd69 100644
--- a/tools/rgb2ycbcr.c
+++ b/tools/rgb2ycbcr.c
@@ -313,7 +313,7 @@ tiffcvt(TIFF* in, TIFF* out)
"raster buffer");
if (raster == 0) {
TIFFError(TIFFFileName(in),
- "Failed to allocate buffer (%zu elements of %zu each)",
+ "Failed to allocate buffer (%"TIFF_SIZE_FORMAT" elements of %"TIFF_SIZE_FORMAT" each)",
pixel_count,
sizeof(uint32_t));
return (0);
diff --git a/tools/tiff2pdf.c b/tools/tiff2pdf.c
index 4cdf0f90..7d0ab678 100644
--- a/tools/tiff2pdf.c
+++ b/tools/tiff2pdf.c
@@ -955,7 +955,7 @@ T2P* t2p_init()
if(t2p==NULL){
TIFFError(
TIFF2PDF_MODULE,
- "Can't allocate %zu bytes of memory for t2p_init",
+ "Can't allocate %"TIFF_SIZE_FORMAT" bytes of memory for t2p_init",
sizeof(T2P));
return( (T2P*) NULL );
}
@@ -1079,7 +1079,7 @@ void t2p_read_tiff_init(T2P* t2p, TIFF* input){
if(t2p->tiff_pages==NULL){
TIFFError(
TIFF2PDF_MODULE,
- "Can't allocate %zu bytes of memory for tiff_pages array, %s",
+ "Can't allocate %"TIFF_SIZE_FORMAT" bytes of memory for tiff_pages array, %s",
sizeof(T2P_PAGE) * directorycount,
TIFFFileName(input));
t2p->t2p_error = T2P_ERR_ERROR;
@@ -1090,7 +1090,7 @@ void t2p_read_tiff_init(T2P* t2p, TIFF* input){
if(t2p->tiff_tiles==NULL){
TIFFError(
TIFF2PDF_MODULE,
- "Can't allocate %zu bytes of memory for tiff_tiles array, %s",
+ "Can't allocate %"TIFF_SIZE_FORMAT" bytes of memory for tiff_tiles array, %s",
sizeof(T2P_TILES) * directorycount,
TIFFFileName(input));
t2p->t2p_error = T2P_ERR_ERROR;
@@ -1263,7 +1263,7 @@ void t2p_read_tiff_init(T2P* t2p, TIFF* input){
if( t2p->tiff_tiles[i].tiles_tiles == NULL){
TIFFError(
TIFF2PDF_MODULE,
- "Can't allocate %zu bytes of memory for t2p_read_tiff_init, %s",
+ "Can't allocate %"TIFF_SIZE_FORMAT" bytes of memory for t2p_read_tiff_init, %s",
sizeof(T2P_TILE) * t2p->tiff_tiles[i].tiles_tilecount,
TIFFFileName(input));
t2p->t2p_error = T2P_ERR_ERROR;
@@ -5558,7 +5558,7 @@ tsize_t t2p_write_pdf(T2P* t2p, TIFF* input, TIFF* output){
if(t2p->pdf_xrefoffsets==NULL){
TIFFError(
TIFF2PDF_MODULE,
- "Can't allocate %zu bytes of memory for t2p_write_pdf",
+ "Can't allocate %"TIFF_SIZE_FORMAT" bytes of memory for t2p_write_pdf",
sizeof(uint32_t) * t2p->pdf_xrefcount);
t2p->t2p_error = T2P_ERR_ERROR;
return(written);
diff --git a/tools/tiff2rgba.c b/tools/tiff2rgba.c
index e0dbcc45..e1495f14 100644
--- a/tools/tiff2rgba.c
+++ b/tools/tiff2rgba.c
@@ -411,7 +411,7 @@ cvt_whole_image( TIFF *in, TIFF *out )
}
if (maxMalloc != 0 && (tmsize_t)pixel_count * (tmsize_t)sizeof(uint32_t) > maxMalloc) {
TIFFError(TIFFFileName(in),
- "Raster size %zu over memory limit (%" TIFF_SSIZE_FORMAT "), try -b option.",
+ "Raster size %"TIFF_SIZE_FORMAT" over memory limit (%" TIFF_SSIZE_FORMAT "), try -b option.",
pixel_count * sizeof(uint32_t), maxMalloc);
return 0;
}
@@ -421,7 +421,7 @@ cvt_whole_image( TIFF *in, TIFF *out )
raster = (uint32_t*)_TIFFCheckMalloc(in, pixel_count, sizeof(uint32_t), "raster buffer");
if (raster == 0) {
- TIFFError(TIFFFileName(in), "Failed to allocate buffer (%zu elements of %zu each)",
+ TIFFError(TIFFFileName(in), "Failed to allocate buffer (%"TIFF_SIZE_FORMAT" elements of %"TIFF_SIZE_FORMAT" each)",
pixel_count, sizeof(uint32_t));
return (0);
}