diff options
author | Roger Leigh <rleigh@codelibre.net> | 2021-01-30 15:19:45 +0000 |
---|---|---|
committer | Roger Leigh <rleigh@codelibre.net> | 2021-01-30 15:19:45 +0000 |
commit | 8ac5d3bb77f7e9b0325465ba04ad5f5bb9bea925 (patch) | |
tree | e7f2416375b28e0f1f9a20170ffed7433a81058c | |
parent | 2dc866486488253381e7a5f35756dc40731fe9fb (diff) | |
parent | 352cb5a4fb110a01c694616f62b0d5c388a14c16 (diff) | |
download | libtiff-git-8ac5d3bb77f7e9b0325465ba04ad5f5bb9bea925.tar.gz |
Merge branch 'c99-format-strings' into 'master'
C99 format strings
See merge request libtiff/libtiff!211
39 files changed, 930 insertions, 1157 deletions
diff --git a/libtiff/tif_aux.c b/libtiff/tif_aux.c index 96f1f55a..3910e61c 100644 --- a/libtiff/tif_aux.c +++ b/libtiff/tif_aux.c @@ -109,8 +109,8 @@ _TIFFCheckRealloc(TIFF* tif, void* buffer, if (cp == NULL) { TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "Failed to allocate memory for %s " - "(%ld elements of %ld bytes each)", - what,(long) nmemb, (long) elem_size); + "(%"PRId64" elements of %"PRId64" bytes each)", + what, nmemb, elem_size); } return cp; diff --git a/libtiff/tif_codec.c b/libtiff/tif_codec.c index 03fe7930..00963a5b 100644 --- a/libtiff/tif_codec.c +++ b/libtiff/tif_codec.c @@ -110,7 +110,7 @@ _notConfigured(TIFF* tif) const TIFFCodec* c = TIFFFindCODEC(tif->tif_dir.td_compression); char compression_code[20]; - sprintf(compression_code, "%d",tif->tif_dir.td_compression ); + sprintf(compression_code, "%"PRIu16, tif->tif_dir.td_compression ); TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "%s compression support is not configured", c ? c->name : compression_code ); diff --git a/libtiff/tif_compress.c b/libtiff/tif_compress.c index 19a1ff1c..8fcedf45 100644 --- a/libtiff/tif_compress.c +++ b/libtiff/tif_compress.c @@ -40,7 +40,7 @@ TIFFNoEncode(TIFF* tif, const char* method) c->name, method); } else { TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Compression scheme %u %s encoding is not implemented", + "Compression scheme %"PRIu16" %s encoding is not implemented", tif->tif_dir.td_compression, method); } return (-1); @@ -78,7 +78,7 @@ TIFFNoDecode(TIFF* tif, const char* method) c->name, method); else TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Compression scheme %u %s decoding is not implemented", + "Compression scheme %"PRIu16" %s decoding is not implemented", tif->tif_dir.td_compression, method); return (0); } diff --git a/libtiff/tif_dir.c b/libtiff/tif_dir.c index 7ce39d04..a6c254fc 100644 --- a/libtiff/tif_dir.c +++ b/libtiff/tif_dir.c @@ -160,10 +160,10 @@ checkInkNamesString(TIFF* tif, uint32_t slen, const char* s) } bad: TIFFErrorExt(tif->tif_clientdata, "TIFFSetField", - "%s: Invalid InkNames value; expecting %d names, found %d", + "%s: Invalid InkNames value; expecting %"PRIu16" names, found %"PRIu16, tif->tif_name, td->td_samplesperpixel, - td->td_samplesperpixel-i); + (uint16_t)(td->td_samplesperpixel-i)); return (0); } @@ -394,7 +394,7 @@ _TIFFVSetField(TIFF* tif, uint32_t tag, va_list ap) if (tif->tif_mode != O_RDONLY) goto badvalue32; TIFFWarningExt(tif->tif_clientdata, tif->tif_name, - "Nonstandard tile width %u, convert file", v32); + "Nonstandard tile width %"PRIu32", convert file", v32); } td->td_tilewidth = v32; tif->tif_flags |= TIFF_ISTILED; @@ -405,7 +405,7 @@ _TIFFVSetField(TIFF* tif, uint32_t tag, va_list ap) if (tif->tif_mode != O_RDONLY) goto badvalue32; TIFFWarningExt(tif->tif_clientdata, tif->tif_name, - "Nonstandard tile length %u, convert file", v32); + "Nonstandard tile length %"PRIu32", convert file", v32); } td->td_tilelength = v32; tif->tif_flags |= TIFF_ISTILED; @@ -755,7 +755,7 @@ badvalue: { const TIFFField* fip2=TIFFFieldWithTag(tif,tag); TIFFErrorExt(tif->tif_clientdata, module, - "%s: Bad value %u for \"%s\" tag", + "%s: Bad value %"PRIu32" for \"%s\" tag", tif->tif_name, v, fip2 ? fip2->field_name : "Unknown"); va_end(ap); @@ -765,7 +765,7 @@ badvalue32: { const TIFFField* fip2=TIFFFieldWithTag(tif,tag); TIFFErrorExt(tif->tif_clientdata, module, - "%s: Bad value %u for \"%s\" tag", + "%s: Bad value %"PRIu32" for \"%s\" tag", tif->tif_name, v32, fip2 ? fip2->field_name : "Unknown"); va_end(ap); @@ -797,7 +797,7 @@ OkToChangeTag(TIFF* tif, uint32_t tag) { const TIFFField* fip = TIFFFindField(tif, tag, TIFF_ANY); if (!fip) { /* unknown tag */ - TIFFErrorExt(tif->tif_clientdata, "TIFFSetField", "%s: Unknown %stag %u", + TIFFErrorExt(tif->tif_clientdata, "TIFFSetField", "%s: Unknown %stag %"PRIu32, tif->tif_name, isPseudoTag(tag) ? "pseudo-" : "", tag); return (0); } @@ -928,7 +928,7 @@ _TIFFVGetField(TIFF* tif, uint32_t tag, va_list ap) if( val > td->td_samplesperpixel ) { TIFFWarningExt(tif->tif_clientdata,"_TIFFVGetField", - "Truncating NumberOfInks from %u to %u", + "Truncating NumberOfInks from %u to %"PRIu16, val, td->td_samplesperpixel); val = td->td_samplesperpixel; } @@ -1760,7 +1760,7 @@ TIFFUnlinkDirectory(TIFF* tif, uint16_t dirn) } for (n = dirn-1; n > 0; n--) { if (nextdir == 0) { - TIFFErrorExt(tif->tif_clientdata, module, "Directory %d does not exist", dirn); + TIFFErrorExt(tif->tif_clientdata, module, "Directory %"PRIu16" does not exist", dirn); return (0); } if (!TIFFAdvanceDirectory(tif, &nextdir, &off)) diff --git a/libtiff/tif_dirread.c b/libtiff/tif_dirread.c index 9f7a404a..1543c3f4 100644 --- a/libtiff/tif_dirread.c +++ b/libtiff/tif_dirread.c @@ -809,9 +809,9 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryDataAndRealloc( { TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "Failed to allocate memory for %s " - "(%ld elements of %ld bytes each)", + "(%"PRId64" elements of %"PRId64" bytes each)", "TIFFReadDirEntryArray", - (long) 1, (long) (already_read + to_read)); + (tmsize_t) 1, already_read + to_read); return TIFFReadDirEntryErrAlloc; } *pdest = new_dest; @@ -3699,7 +3699,7 @@ TIFFReadDirectory(TIFF* tif) if (fii == FAILED_FII) { TIFFWarningExt(tif->tif_clientdata, module, - "Unknown field with tag %d (0x%x) encountered", + "Unknown field with tag %"PRIu16" (0x%"PRIx16") encountered", dp->tdir_tag,dp->tdir_tag); /* the following knowingly leaks the anonymous field structure */ @@ -3710,7 +3710,7 @@ TIFFReadDirectory(TIFF* tif) 1)) { TIFFWarningExt(tif->tif_clientdata, module, - "Registering anonymous field with tag %d (0x%x) failed", + "Registering anonymous field with tag %"PRIu16" (0x%"PRIx16") failed", dp->tdir_tag, dp->tdir_tag); dp->tdir_ignore = TRUE; @@ -3981,7 +3981,7 @@ TIFFReadDirectory(TIFF* tif) { fip = TIFFFieldWithTag(tif,dp->tdir_tag); TIFFWarningExt(tif->tif_clientdata,module, - "Ignoring %s because BitsPerSample=%d>24", + "Ignoring %s because BitsPerSample=%"PRIu16">24", fip ? fip->field_name : "unknown tagname", tif->tif_dir.td_bitspersample); continue; @@ -4164,7 +4164,8 @@ TIFFReadDirectory(TIFF* tif) new_sampleinfo = (uint16_t*) _TIFFcalloc(tif->tif_dir.td_extrasamples, sizeof(uint16_t)); if (!new_sampleinfo) { TIFFErrorExt(tif->tif_clientdata, module, "Failed to allocate memory for " - "temporary new sampleinfo array (%d 16 bit elements)", + "temporary new sampleinfo array " + "(%"PRIu16" 16 bit elements)", tif->tif_dir.td_extrasamples); goto bad; } @@ -4462,14 +4463,14 @@ TIFFReadCustomDirectory(TIFF* tif, toff_t diroff, if (fii == FAILED_FII) { TIFFWarningExt(tif->tif_clientdata, module, - "Unknown field with tag %d (0x%x) encountered", + "Unknown field with tag %"PRIu16" (0x%"PRIx16") encountered", dp->tdir_tag, dp->tdir_tag); if (!_TIFFMergeFields(tif, _TIFFCreateAnonField(tif, dp->tdir_tag, (TIFFDataType) dp->tdir_type), 1)) { TIFFWarningExt(tif->tif_clientdata, module, - "Registering anonymous field with tag %d (0x%x) failed", + "Registering anonymous field with tag %"PRIu16" (0x%"PRIx16") failed", dp->tdir_tag, dp->tdir_tag); dp->tdir_ignore = TRUE; } else { @@ -4499,7 +4500,7 @@ TIFFReadCustomDirectory(TIFF* tif, toff_t diroff, if (fii==0xFFFF) { TIFFWarningExt(tif->tif_clientdata, module, - "Wrong data type %d for \"%s\"; tag ignored", + "Wrong data type %"PRIu16" for \"%s\"; tag ignored", dp->tdir_type,fip->field_name); dp->tdir_ignore = TRUE; } @@ -4598,7 +4599,7 @@ EstimateStripByteCounts(TIFF* tif, TIFFDirEntry* dir, uint16_t dircount) typewidth = TIFFDataWidth((TIFFDataType) dp->tdir_type); if (typewidth == 0) { TIFFErrorExt(tif->tif_clientdata, module, - "Cannot determine size of unknown tag type %d", + "Cannot determine size of unknown tag type %"PRIu16, dp->tdir_type); return -1; } @@ -4736,14 +4737,14 @@ CheckDirCount(TIFF* tif, TIFFDirEntry* dir, uint32_t count) if ((uint64_t)count > dir->tdir_count) { const TIFFField* fip = TIFFFieldWithTag(tif, dir->tdir_tag); TIFFWarningExt(tif->tif_clientdata, tif->tif_name, - "incorrect count for field \"%s\" (%" PRIu64 ", expecting %u); tag ignored", + "incorrect count for field \"%s\" (%" PRIu64 ", expecting %"PRIu32"); tag ignored", fip ? fip->field_name : "unknown tagname", dir->tdir_count, count); return (0); } else if ((uint64_t)count < dir->tdir_count) { const TIFFField* fip = TIFFFieldWithTag(tif, dir->tdir_tag); TIFFWarningExt(tif->tif_clientdata, tif->tif_name, - "incorrect count for field \"%s\" (%" PRIu64 ", expecting %u); tag trimmed", + "incorrect count for field \"%s\" (%" PRIu64 ", expecting %"PRIu32"); tag trimmed", fip ? fip->field_name : "unknown tagname", dir->tdir_count, count); dir->tdir_count = count; @@ -5026,7 +5027,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) if( fii == FAILED_FII ) { TIFFErrorExt(tif->tif_clientdata, "TIFFFetchNormalTag", - "No definition found for tag %d", + "No definition found for tag %"PRIu16, dp->tdir_tag); return 0; } @@ -5187,8 +5188,8 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) assert(fip->field_passcount==0); if (dp->tdir_count!=2) { TIFFWarningExt(tif->tif_clientdata,module, - "incorrect count for field \"%s\", expected 2, got %d", - fip->field_name,(int)dp->tdir_count); + "incorrect count for field \"%s\", expected 2, got %"PRIu64, + fip->field_name, dp->tdir_count); return(0); } err=TIFFReadDirEntryShortArray(tif,dp,&data); @@ -5210,8 +5211,8 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) assert(fip->field_passcount==0); if (dp->tdir_count!=(uint64_t)fip->field_readcount) { TIFFWarningExt(tif->tif_clientdata,module, - "incorrect count for field \"%s\", expected %d, got %d", - fip->field_name,(int) fip->field_readcount, (int)dp->tdir_count); + "incorrect count for field \"%s\", expected %d, got %"PRIu64, + fip->field_name,(int) fip->field_readcount, dp->tdir_count); return 0; } else diff --git a/libtiff/tif_dirwrite.c b/libtiff/tif_dirwrite.c index 2f469cfd..0a7eb7da 100644 --- a/libtiff/tif_dirwrite.c +++ b/libtiff/tif_dirwrite.c @@ -755,7 +755,7 @@ TIFFWriteDirectorySec(TIFF* tif, int isimage, int imagedone, uint64_t* pdiroff) break; default: TIFFErrorExt(tif->tif_clientdata,module, - "Cannot write tag %d (%s)", + "Cannot write tag %"PRIu32" (%s)", TIFFFieldTag(o), o->field_name ? o->field_name : "unknown"); goto bad; @@ -2710,16 +2710,16 @@ void DoubleToSrational_direct(double value, long *num, long *denom) * using the Euclidean algorithm to find the greatest common divisor (GCD) ------------------------------------------------------------------------*/ static -void ToRationalEuclideanGCD(double value, int blnUseSignedRange, int blnUseSmallRange, unsigned long long *ullNum, unsigned long long *ullDenom) +void ToRationalEuclideanGCD(double value, int blnUseSignedRange, int blnUseSmallRange, uint64_t *ullNum, uint64_t *ullDenom) { /* Internally, the integer variables can be bigger than the external ones, * as long as the result will fit into the external variable size. */ - unsigned long long val, numSum[3] = { 0, 1, 0 }, denomSum[3] = { 1, 0, 0 }; - unsigned long long aux, bigNum, bigDenom; - unsigned long long returnLimit; + uint64_t val, numSum[3] = { 0, 1, 0 }, denomSum[3] = { 1, 0, 0 }; + uint64_t aux, bigNum, bigDenom; + uint64_t returnLimit; int i; - unsigned long long nMax; + uint64_t nMax; double fMax; unsigned long maxDenom; /*-- nMax and fMax defines the initial accuracy of the starting fractional, @@ -2729,7 +2729,7 @@ void ToRationalEuclideanGCD(double value, int blnUseSignedRange, int blnUseSmall * For long long nMax = ((9223372036854775807-1)/2); for long nMax = ((2147483647-1)/2); */ if (blnUseSmallRange) { - nMax = (unsigned long long)((2147483647 - 1) / 2); /* for ULONG range */ + nMax = (uint64_t)((2147483647 - 1) / 2); /* for ULONG range */ } else { nMax = ((9223372036854775807 - 1) / 2); /* for ULLONG range */ @@ -2750,7 +2750,7 @@ void ToRationalEuclideanGCD(double value, int blnUseSignedRange, int blnUseSmall } /*-- First generate a rational fraction (bigNum/bigDenom) which represents the value - * as a rational number with the highest accuracy. Therefore, unsigned long long (uint64_t) is needed. + * as a rational number with the highest accuracy. Therefore, uint64_t (uint64_t) is needed. * This rational fraction is then reduced using the Euclidean algorithm to find the greatest common divisor (GCD). * bigNum = big numinator of value without fraction (or cut residual fraction) * bigDenom = big denominator of value @@ -2762,7 +2762,7 @@ void ToRationalEuclideanGCD(double value, int blnUseSignedRange, int blnUseSmall bigDenom <<= 1; value *= 2; } - bigNum = (unsigned long long)value; + bigNum = (uint64_t)value; /*-- Start Euclidean algorithm to find the greatest common divisor (GCD) -- */ #define MAX_ITERATIONS 64 @@ -2823,7 +2823,7 @@ void DoubleToRational(double value, uint32_t *num, uint32_t *denom) { /*---- UN-SIGNED RATIONAL ---- */ double dblDiff, dblDiff2; - unsigned long long ullNum, ullDenom, ullNum2, ullDenom2; + uint64_t ullNum, ullDenom, ullNum2, ullDenom2; /*-- Check for negative values. If so it is an error. */ /* Test written that way to catch NaN */ @@ -2860,11 +2860,7 @@ void DoubleToRational(double value, uint32_t *num, uint32_t *denom) ToRationalEuclideanGCD(value, FALSE, TRUE, &ullNum2, &ullDenom2); /*-- Double-Check, that returned values fit into ULONG :*/ if (ullNum > 0xFFFFFFFFUL || ullDenom > 0xFFFFFFFFUL || ullNum2 > 0xFFFFFFFFUL || ullDenom2 > 0xFFFFFFFFUL) { -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) - TIFFErrorExt(0, "TIFFLib: DoubleToRational()", " Num or Denom exceeds ULONG: val=%14.6f, num=%I64u, denom=%I64u | num2=%I64u, denom2=%I64u", value, ullNum, ullDenom, ullNum2, ullDenom2); -#else - TIFFErrorExt(0, "TIFFLib: DoubleToRational()", " Num or Denom exceeds ULONG: val=%14.6f, num=%12llu, denom=%12llu | num2=%12llu, denom2=%12llu", value, ullNum, ullDenom, ullNum2, ullDenom2); -#endif + TIFFErrorExt(0, "TIFFLib: DoubleToRational()", " Num or Denom exceeds ULONG: val=%14.6f, num=%12"PRIu64", denom=%12"PRIu64" | num2=%12"PRIu64", denom2=%12"PRIu64"", value, ullNum, ullDenom, ullNum2, ullDenom2); assert(0); } @@ -2892,7 +2888,7 @@ void DoubleToSrational(double value, int32_t *num, int32_t *denom) /*---- SIGNED RATIONAL ----*/ int neg = 1; double dblDiff, dblDiff2; - unsigned long long ullNum, ullDenom, ullNum2, ullDenom2; + uint64_t ullNum, ullDenom, ullNum2, ullDenom2; /*-- Check for negative values and use then the positive one for internal calculations, but take the sign into account before returning. */ if (value < 0) { neg = -1; value = -value; } @@ -2925,11 +2921,7 @@ void DoubleToSrational(double value, int32_t *num, int32_t *denom) ToRationalEuclideanGCD(value, TRUE, TRUE, &ullNum2, &ullDenom2); /*-- Double-Check, that returned values fit into LONG :*/ if (ullNum > 0x7FFFFFFFL || ullDenom > 0x7FFFFFFFL || ullNum2 > 0x7FFFFFFFL || ullDenom2 > 0x7FFFFFFFL) { -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) - TIFFErrorExt(0, "TIFFLib: DoubleToSrational()", " Num or Denom exceeds LONG: val=%14.6f, num=%I64u, denom=%I64u | num2=%I64u, denom2=%I64u", neg*value, ullNum, ullDenom, ullNum2, ullDenom2); -#else - TIFFErrorExt(0, "TIFFLib: DoubleToSrational()", " Num or Denom exceeds LONG: val=%14.6f, num=%12llu, denom=%12llu | num2=%12llu, denom2=%12llu", neg*value, ullNum, ullDenom, ullNum2, ullDenom2); -#endif + TIFFErrorExt(0, "TIFFLib: DoubleToSrational()", " Num or Denom exceeds LONG: val=%14.6f, num=%12"PRIu64", denom=%12"PRIu64" | num2=%12"PRIu64", denom2=%12"PRIu64"", neg*value, ullNum, ullDenom, ullNum2, ullDenom2); assert(0); } @@ -3405,7 +3397,7 @@ _TIFFRewriteField(TIFF* tif, uint16_t tag, TIFFDataType in_datatype, if( entry_tag != tag ) { TIFFErrorExt(tif->tif_clientdata, module, - "%s: Could not find tag %d.", + "%s: Could not find tag %"PRIu16".", tif->tif_name, tag ); return 0; } diff --git a/libtiff/tif_dumpmode.c b/libtiff/tif_dumpmode.c index d739d8d1..8171ac4a 100644 --- a/libtiff/tif_dumpmode.c +++ b/libtiff/tif_dumpmode.c @@ -78,19 +78,11 @@ DumpModeDecode(TIFF* tif, uint8_t* buf, tmsize_t cc, uint16_t s) static const char module[] = "DumpModeDecode"; (void) s; if (tif->tif_rawcc < cc) { -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) TIFFErrorExt(tif->tif_clientdata, module, -"Not enough data for scanline %lu, expected a request for at most %I64d bytes, got a request for %I64d bytes", - (unsigned long) tif->tif_row, - (signed __int64) tif->tif_rawcc, - (signed __int64) cc); -#else - TIFFErrorExt(tif->tif_clientdata, module, -"Not enough data for scanline %lu, expected a request for at most %lld bytes, got a request for %lld bytes", - (unsigned long) tif->tif_row, - (signed long long) tif->tif_rawcc, - (signed long long) cc); -#endif +"Not enough data for scanline %"PRIu32", expected a request for at most %"PRId64" bytes, got a request for %"PRId64" bytes", + tif->tif_row, + tif->tif_rawcc, + cc); return (0); } /* diff --git a/libtiff/tif_fax3.c b/libtiff/tif_fax3.c index cce477cb..49776812 100644 --- a/libtiff/tif_fax3.c +++ b/libtiff/tif_fax3.c @@ -180,7 +180,7 @@ Fax3PreDecode(TIFF* tif, uint16_t s) static void Fax3Unexpected(const char* module, TIFF* tif, uint32_t line, uint32_t a0) { - TIFFErrorExt(tif->tif_clientdata, module, "Bad code word at line %u of %s %u (x %u)", + TIFFErrorExt(tif->tif_clientdata, module, "Bad code word at line %"PRIu32" of %s %"PRIu32" (x %"PRIu32")", line, isTiled(tif) ? "tile" : "strip", (isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip), a0); @@ -191,7 +191,7 @@ static void Fax3Extension(const char* module, TIFF* tif, uint32_t line, uint32_t a0) { TIFFErrorExt(tif->tif_clientdata, module, - "Uncompressed data (not supported) at line %u of %s %u (x %u)", + "Uncompressed data (not supported) at line %"PRIu32" of %s %"PRIu32" (x %"PRIu32")", line, isTiled(tif) ? "tile" : "strip", (isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip), a0); @@ -201,7 +201,7 @@ Fax3Extension(const char* module, TIFF* tif, uint32_t line, uint32_t a0) static void Fax3BadLength(const char* module, TIFF* tif, uint32_t line, uint32_t a0, uint32_t lastx) { - TIFFWarningExt(tif->tif_clientdata, module, "%s at line %u of %s %u (got %u, expected %u)", + TIFFWarningExt(tif->tif_clientdata, module, "%s at line %"PRIu32" of %s %"PRIu32" (got %"PRIu32", expected %"PRIu32")", a0 < lastx ? "Premature EOL" : "Line length mismatch", line, isTiled(tif) ? "tile" : "strip", (isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip), @@ -212,7 +212,7 @@ Fax3BadLength(const char* module, TIFF* tif, uint32_t line, uint32_t a0, uint32_ static void Fax3PrematureEOF(const char* module, TIFF* tif, uint32_t line, uint32_t a0) { - TIFFWarningExt(tif->tif_clientdata, module, "Premature EOF at line %u of %s %u (x %u)", + TIFFWarningExt(tif->tif_clientdata, module, "Premature EOF at line %"PRIu32" of %s %"PRIu32" (x %"PRIu32")", line, isTiled(tif) ? "tile" : "strip", (isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip), a0); @@ -245,8 +245,8 @@ Fax3Decode1D(TIFF* tif, uint8_t* buf, tmsize_t occ, uint16_t s) RunLength = 0; pa = thisrun; #ifdef FAX3_DEBUG - printf("\nBitAcc=%08X, BitsAvail = %d\n", BitAcc, BitsAvail); - printf("-------------------- %d\n", tif->tif_row); + printf("\nBitAcc=%08"PRIX32", BitsAvail = %d\n", BitAcc, BitsAvail); + printf("-------------------- %"PRIu32"\n", tif->tif_row); fflush(stdout); #endif SYNC_EOL(EOF1D); @@ -288,7 +288,7 @@ Fax3Decode2D(TIFF* tif, uint8_t* buf, tmsize_t occ, uint16_t s) RunLength = 0; pa = thisrun = sp->curruns; #ifdef FAX3_DEBUG - printf("\nBitAcc=%08X, BitsAvail = %d EOLcnt = %d", + printf("\nBitAcc=%08"PRIX32", BitsAvail = %d EOLcnt = %d", BitAcc, BitsAvail, EOLcnt); #endif SYNC_EOL(EOF2D); @@ -296,7 +296,7 @@ Fax3Decode2D(TIFF* tif, uint8_t* buf, tmsize_t occ, uint16_t s) is1D = GetBits(1); /* 1D/2D-encoding tag bit */ ClrBits(1); #ifdef FAX3_DEBUG - printf(" %s\n-------------------- %d\n", + printf(" %s\n-------------------- %"PRIu32"\n", is1D ? "1D" : "2D", tif->tif_row); fflush(stdout); #endif @@ -533,7 +533,7 @@ Fax3SetupState(TIFF* tif) } if ((dsp->nruns == 0) || (TIFFSafeMultiply(uint32_t, dsp->nruns, 2) == 0)) { TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Row pixels integer overflow (rowpixels %u)", + "Row pixels integer overflow (rowpixels %"PRIu32")", rowpixels); return (0); } @@ -642,7 +642,7 @@ Fax3PutBits(TIFF* tif, unsigned int bits, unsigned int length) #define DEBUG_COLOR(w) (tab == TIFFFaxWhiteCodes ? w "W" : w "B") #define DEBUG_PRINT(what,len) { \ int t; \ - printf("%08X/%-2d: %s%5d\t", data, bit, DEBUG_COLOR(what), len); \ + printf("%08"PRIX32"/%-2d: %s%5d\t", data, bit, DEBUG_COLOR(what), len); \ for (t = length-1; t >= 0; t--) \ putchar(code & (1<<t) ? '1' : '0'); \ putchar('\n'); \ @@ -1330,7 +1330,7 @@ Fax3PrintDir(TIFF* tif, FILE* fd, long flags) fprintf(fd, " uncorrected errors"); break; } - fprintf(fd, " (%u = 0x%x)\n", + fprintf(fd, " (%"PRIu16" = 0x%"PRIx16")\n", sp->cleanfaxdata, sp->cleanfaxdata); } if (TIFFFieldSet(tif,FIELD_BADFAXLINES)) @@ -1462,7 +1462,7 @@ Fax4Decode(TIFF* tif, uint8_t* buf, tmsize_t occ, uint16_t s) pb = sp->refruns; b1 = *pb++; #ifdef FAX3_DEBUG - printf("\nBitAcc=%08X, BitsAvail = %d\n", BitAcc, BitsAvail); + printf("\nBitAcc=%08"PRIX32", BitsAvail = %d\n", BitAcc, BitsAvail); printf("-------------------- %d\n", tif->tif_row); fflush(stdout); #endif @@ -1472,8 +1472,8 @@ Fax4Decode(TIFF* tif, uint8_t* buf, tmsize_t occ, uint16_t s) if (((lastx + 7) >> 3) > (int)occ) /* check for buffer overrun */ { TIFFErrorExt(tif->tif_clientdata, module, - "Buffer overrun detected : %d bytes available, %d bits needed", - (int)occ, lastx); + "Buffer overrun detected : %"PRId64" bytes available, %d bits needed", + occ, lastx); return -1; } (*sp->fill)(buf, thisrun, pa, lastx); @@ -1494,8 +1494,8 @@ Fax4Decode(TIFF* tif, uint8_t* buf, tmsize_t occ, uint16_t s) if (((lastx + 7) >> 3) > (int)occ) /* check for buffer overrun */ { TIFFErrorExt(tif->tif_clientdata, module, - "Buffer overrun detected : %d bytes available, %d bits needed", - (int)occ, lastx); + "Buffer overrun detected : %"PRId64" bytes available, %d bits needed", + occ, lastx); return -1; } (*sp->fill)(buf, thisrun, pa, lastx); @@ -1600,8 +1600,8 @@ Fax3DecodeRLE(TIFF* tif, uint8_t* buf, tmsize_t occ, uint16_t s) RunLength = 0; pa = thisrun; #ifdef FAX3_DEBUG - printf("\nBitAcc=%08X, BitsAvail = %d\n", BitAcc, BitsAvail); - printf("-------------------- %d\n", tif->tif_row); + printf("\nBitAcc=%08"PRIX32", BitsAvail = %d\n", BitAcc, BitsAvail); + printf("-------------------- %"PRIu32"\n", tif->tif_row); fflush(stdout); #endif EXPAND1D(EOFRLE); diff --git a/libtiff/tif_getimage.c b/libtiff/tif_getimage.c index 04c4cc7b..a1b6570b 100644 --- a/libtiff/tif_getimage.c +++ b/libtiff/tif_getimage.c @@ -90,7 +90,7 @@ TIFFRGBAImageOK(TIFF* tif, char emsg[1024]) case 16: break; default: - sprintf(emsg, "Sorry, can not handle images with %d-bit samples", + sprintf(emsg, "Sorry, can not handle images with %"PRIu16"-bit samples", td->td_bitspersample); return (0); } @@ -120,8 +120,8 @@ TIFFRGBAImageOK(TIFF* tif, char emsg[1024]) && td->td_samplesperpixel != 1 && td->td_bitspersample < 8 ) { sprintf(emsg, - "Sorry, can not handle contiguous data with %s=%d, " - "and %s=%d and Bits/Sample=%d", + "Sorry, can not handle contiguous data with %s=%"PRIu16", " + "and %s=%"PRIu16" and Bits/Sample=%"PRIu16"", photoTag, photometric, "Samples/pixel", td->td_samplesperpixel, td->td_bitspersample); @@ -160,7 +160,7 @@ TIFFRGBAImageOK(TIFF* tif, char emsg[1024]) } if (td->td_samplesperpixel < 4) { sprintf(emsg, - "Sorry, can not handle separated image with %s=%d", + "Sorry, can not handle separated image with %s=%"PRIu16, "Samples/pixel", td->td_samplesperpixel); return 0; } @@ -181,13 +181,13 @@ TIFFRGBAImageOK(TIFF* tif, char emsg[1024]) return (0); } if (td->td_planarconfig != PLANARCONFIG_CONTIG) { - sprintf(emsg, "Sorry, can not handle LogLuv images with %s=%d", + sprintf(emsg, "Sorry, can not handle LogLuv images with %s=%"PRIu16, "Planarconfiguration", td->td_planarconfig); return (0); } if ( td->td_samplesperpixel != 3 || colorchannels != 3 ) { sprintf(emsg, - "Sorry, can not handle image with %s=%d, %s=%d", + "Sorry, can not handle image with %s=%"PRIu16", %s=%d", "Samples/pixel", td->td_samplesperpixel, "colorchannels", colorchannels); return 0; @@ -196,7 +196,7 @@ TIFFRGBAImageOK(TIFF* tif, char emsg[1024]) case PHOTOMETRIC_CIELAB: if ( td->td_samplesperpixel != 3 || colorchannels != 3 || td->td_bitspersample != 8 ) { sprintf(emsg, - "Sorry, can not handle image with %s=%d, %s=%d and %s=%d", + "Sorry, can not handle image with %s=%"PRIu16", %s=%d and %s=%"PRIu16, "Samples/pixel", td->td_samplesperpixel, "colorchannels", colorchannels, "Bits/sample", td->td_bitspersample); @@ -204,7 +204,7 @@ TIFFRGBAImageOK(TIFF* tif, char emsg[1024]) } break; default: - sprintf(emsg, "Sorry, can not handle image with %s=%d", + sprintf(emsg, "Sorry, can not handle image with %s=%"PRIu16, photoTag, photometric); return (0); } @@ -302,7 +302,7 @@ TIFFRGBAImageBegin(TIFFRGBAImage* img, TIFF* tif, int stop, char emsg[1024]) case 16: break; default: - sprintf(emsg, "Sorry, can not handle images with %d-bit samples", + sprintf(emsg, "Sorry, can not handle images with %"PRIu16"-bit samples", img->bitspersample); goto fail_return; } @@ -385,8 +385,8 @@ TIFFRGBAImageBegin(TIFFRGBAImage* img, TIFF* tif, int stop, char emsg[1024]) && img->samplesperpixel != 1 && img->bitspersample < 8 ) { sprintf(emsg, - "Sorry, can not handle contiguous data with %s=%d, " - "and %s=%d and Bits/Sample=%d", + "Sorry, can not handle contiguous data with %s=%"PRIu16", " + "and %s=%"PRIu16" and Bits/Sample=%"PRIu16, photoTag, img->photometric, "Samples/pixel", img->samplesperpixel, img->bitspersample); @@ -431,12 +431,12 @@ TIFFRGBAImageBegin(TIFFRGBAImage* img, TIFF* tif, int stop, char emsg[1024]) uint16_t inkset; TIFFGetFieldDefaulted(tif, TIFFTAG_INKSET, &inkset); if (inkset != INKSET_CMYK) { - sprintf(emsg, "Sorry, can not handle separated image with %s=%d", + sprintf(emsg, "Sorry, can not handle separated image with %s=%"PRIu16, "InkSet", inkset); goto fail_return; } if (img->samplesperpixel < 4) { - sprintf(emsg, "Sorry, can not handle separated image with %s=%d", + sprintf(emsg, "Sorry, can not handle separated image with %s=%"PRIu16, "Samples/pixel", img->samplesperpixel); goto fail_return; } @@ -459,7 +459,7 @@ TIFFRGBAImageBegin(TIFFRGBAImage* img, TIFF* tif, int stop, char emsg[1024]) goto fail_return; } if (planarconfig != PLANARCONFIG_CONTIG) { - sprintf(emsg, "Sorry, can not handle LogLuv images with %s=%d", + sprintf(emsg, "Sorry, can not handle LogLuv images with %s=%"PRIu16, "Planarconfiguration", planarconfig); return (0); } @@ -470,7 +470,7 @@ TIFFRGBAImageBegin(TIFFRGBAImage* img, TIFF* tif, int stop, char emsg[1024]) case PHOTOMETRIC_CIELAB: break; default: - sprintf(emsg, "Sorry, can not handle image with %s=%d", + sprintf(emsg, "Sorry, can not handle image with %s=%"PRIu16, photoTag, img->photometric); goto fail_return; } diff --git a/libtiff/tif_jbig.c b/libtiff/tif_jbig.c index 58ef8fe6..093ff7f0 100644 --- a/libtiff/tif_jbig.c +++ b/libtiff/tif_jbig.c @@ -101,14 +101,14 @@ static int JBIGDecode(TIFF* tif, uint8_t* buffer, tmsize_t size, uint16_t s) if( (tmsize_t)decodedSize < size ) { TIFFWarningExt(tif->tif_clientdata, "JBIG", - "Only decoded %lu bytes, whereas %lu requested", - decodedSize, (unsigned long)size); + "Only decoded %lu bytes, whereas %"PRId64" requested", + decodedSize, size); } else if( (tmsize_t)decodedSize > size ) { TIFFErrorExt(tif->tif_clientdata, "JBIG", - "Decoded %lu bytes, whereas %lu were requested", - decodedSize, (unsigned long)size); + "Decoded %lu bytes, whereas %"PRId64" were requested", + decodedSize, size); jbg_dec_free(&decoder); return 0; } diff --git a/libtiff/tif_jpeg.c b/libtiff/tif_jpeg.c index ae5716e8..6076c117 100644 --- a/libtiff/tif_jpeg.c +++ b/libtiff/tif_jpeg.c @@ -913,10 +913,10 @@ JPEGFixupTagsSubsamplingSec(struct JPEGFixupTagsSubsamplingData* data) if ((ph!=data->tif->tif_dir.td_ycbcrsubsampling[0])||(pv!=data->tif->tif_dir.td_ycbcrsubsampling[1])) { TIFFWarningExt(data->tif->tif_clientdata,module, - "Auto-corrected former TIFF subsampling values [%d,%d] to match subsampling values inside JPEG compressed data [%d,%d]", - (int)data->tif->tif_dir.td_ycbcrsubsampling[0], - (int)data->tif->tif_dir.td_ycbcrsubsampling[1], - (int)ph,(int)pv); + "Auto-corrected former TIFF subsampling values [%"PRIu16",%"PRIu16"] to match subsampling values inside JPEG compressed data [%"PRIu8",%"PRIu8"]", + data->tif->tif_dir.td_ycbcrsubsampling[0], + data->tif->tif_dir.td_ycbcrsubsampling[1], + ph, pv); data->tif->tif_dir.td_ycbcrsubsampling[0]=ph; data->tif->tif_dir.td_ycbcrsubsampling[1]=pv; } @@ -1148,7 +1148,7 @@ JPEGPreDecode(TIFF* tif, uint16_t s) sp->cinfo.d.image_height < segment_height) { TIFFWarningExt(tif->tif_clientdata, module, "Improper JPEG strip/tile size, " - "expected %dx%d, got %dx%d", + "expected %"PRIu32"x%"PRIu32", got %ux%u", segment_width, segment_height, sp->cinfo.d.image_width, sp->cinfo.d.image_height); @@ -1163,7 +1163,7 @@ JPEGPreDecode(TIFF* tif, uint16_t s) /* we can safely recover from that. */ TIFFWarningExt(tif->tif_clientdata, module, "JPEG strip size exceeds expected dimensions," - " expected %dx%d, got %dx%d", + " expected %"PRIu32"x%"PRIu32", got %ux%u", segment_width, segment_height, sp->cinfo.d.image_width, sp->cinfo.d.image_height); } @@ -1177,7 +1177,7 @@ JPEGPreDecode(TIFF* tif, uint16_t s) */ TIFFErrorExt(tif->tif_clientdata, module, "JPEG strip/tile size exceeds expected dimensions," - " expected %dx%d, got %dx%d", + " expected %"PRIu32"x%"PRIu32", got %ux%u", segment_width, segment_height, sp->cinfo.d.image_width, sp->cinfo.d.image_height); return (0); @@ -1231,15 +1231,15 @@ JPEGPreDecode(TIFF* tif, uint16_t s) { TIFFErrorExt(tif->tif_clientdata, module, "Reading this image would require libjpeg to allocate " - "at least %u bytes. " - "This is disabled since above the %u threshold. " + "at least %"PRIu64" bytes. " + "This is disabled since above the %ld threshold. " "You may override this restriction by defining the " "LIBTIFF_ALLOW_LARGE_LIBJPEG_MEM_ALLOC environment variable, " "or setting the JPEGMEM environment variable to a value greater " - "or equal to '%uM'", - (unsigned)(nRequiredMemory), - (unsigned)(sp->cinfo.d.mem->max_memory_to_use), - (unsigned)((nRequiredMemory + 1000000 - 1) / 1000000)); + "or equal to '%"PRIu64"M'", + nRequiredMemory, + sp->cinfo.d.mem->max_memory_to_use, + (nRequiredMemory + 1000000u - 1u) / 1000000u); return 0; } } @@ -1250,7 +1250,7 @@ JPEGPreDecode(TIFF* tif, uint16_t s) sp->cinfo.d.comp_info[0].v_samp_factor != sp->v_sampling) { TIFFErrorExt(tif->tif_clientdata, module, "Improper JPEG sampling factors %d,%d\n" - "Apparently should be %d,%d.", + "Apparently should be %"PRIu16",%"PRIu16".", sp->cinfo.d.comp_info[0].h_samp_factor, sp->cinfo.d.comp_info[0].v_samp_factor, sp->h_sampling, sp->v_sampling); @@ -1784,7 +1784,7 @@ JPEGSetupEncode(TIFF* tif) if( td->td_bitspersample > 16 ) { TIFFErrorExt(tif->tif_clientdata, module, - "BitsPerSample %d not allowed for JPEG", + "BitsPerSample %"PRIu16" not allowed for JPEG", td->td_bitspersample); return (0); } @@ -1814,8 +1814,8 @@ JPEGSetupEncode(TIFF* tif) case PHOTOMETRIC_PALETTE: /* disallowed by Tech Note */ case PHOTOMETRIC_MASK: TIFFErrorExt(tif->tif_clientdata, module, - "PhotometricInterpretation %d not allowed for JPEG", - (int) sp->photometric); + "PhotometricInterpretation %"PRIu16" not allowed for JPEG", + sp->photometric); return (0); default: /* TIFF 6.0 forbids subsampling of all other color spaces */ @@ -1838,8 +1838,8 @@ JPEGSetupEncode(TIFF* tif) if (td->td_bitspersample != BITS_IN_JSAMPLE ) #endif { - TIFFErrorExt(tif->tif_clientdata, module, "BitsPerSample %d not allowed for JPEG", - (int) td->td_bitspersample); + TIFFErrorExt(tif->tif_clientdata, module, "BitsPerSample %"PRIu16" not allowed for JPEG", + td->td_bitspersample); return (0); } sp->cinfo.c.data_precision = td->td_bitspersample; @@ -1849,22 +1849,22 @@ JPEGSetupEncode(TIFF* tif) if (isTiled(tif)) { if ((td->td_tilelength % (sp->v_sampling * DCTSIZE)) != 0) { TIFFErrorExt(tif->tif_clientdata, module, - "JPEG tile height must be multiple of %d", - sp->v_sampling * DCTSIZE); + "JPEG tile height must be multiple of %"PRIu32, + (uint32_t)(sp->v_sampling * DCTSIZE)); return (0); } if ((td->td_tilewidth % (sp->h_sampling * DCTSIZE)) != 0) { TIFFErrorExt(tif->tif_clientdata, module, - "JPEG tile width must be multiple of %d", - sp->h_sampling * DCTSIZE); + "JPEG tile width must be multiple of %"PRIu32, + (uint32_t)(sp->h_sampling * DCTSIZE)); return (0); } } else { if (td->td_rowsperstrip < td->td_imagelength && (td->td_rowsperstrip % (sp->v_sampling * DCTSIZE)) != 0) { TIFFErrorExt(tif->tif_clientdata, module, - "RowsPerStrip must be multiple of %d for JPEG", - sp->v_sampling * DCTSIZE); + "RowsPerStrip must be multiple of %"PRIu32" for JPEG", + (uint32_t)(sp->v_sampling * DCTSIZE)); return (0); } } @@ -2377,8 +2377,8 @@ JPEGPrintDir(TIFF* tif, FILE* fd, long flags) if( sp != NULL ) { if (TIFFFieldSet(tif,FIELD_JPEGTABLES)) - fprintf(fd, " JPEG Tables: (%lu bytes)\n", - (unsigned long) sp->jpegtables_length); + fprintf(fd, " JPEG Tables: (%"PRIu32" bytes)\n", + sp->jpegtables_length); if (sp->printdir) (*sp->printdir)(tif, fd, flags); } diff --git a/libtiff/tif_luv.c b/libtiff/tif_luv.c index d1b9257e..de650b31 100644 --- a/libtiff/tif_luv.c +++ b/libtiff/tif_luv.c @@ -231,17 +231,10 @@ LogL16Decode(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s) } } if (i != npixels) { -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) TIFFErrorExt(tif->tif_clientdata, module, - "Not enough data at row %lu (short %I64d pixels)", - (unsigned long) tif->tif_row, - (unsigned __int64) (npixels - i)); -#else - TIFFErrorExt(tif->tif_clientdata, module, - "Not enough data at row %lu (short %llu pixels)", - (unsigned long) tif->tif_row, - (unsigned long long) (npixels - i)); -#endif + "Not enough data at row %"PRIu32" (short %"PRId64" pixels)", + tif->tif_row, + npixels - i); tif->tif_rawcp = (uint8_t*) bp; tif->tif_rawcc = cc; return (0); @@ -294,17 +287,10 @@ LogLuvDecode24(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s) tif->tif_rawcp = (uint8_t*) bp; tif->tif_rawcc = cc; if (i != npixels) { -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) - TIFFErrorExt(tif->tif_clientdata, module, - "Not enough data at row %lu (short %I64d pixels)", - (unsigned long) tif->tif_row, - (unsigned __int64) (npixels - i)); -#else TIFFErrorExt(tif->tif_clientdata, module, - "Not enough data at row %lu (short %llu pixels)", - (unsigned long) tif->tif_row, - (unsigned long long) (npixels - i)); -#endif + "Not enough data at row %"PRIu32" (short %"PRId64" pixels)", + tif->tif_row, + npixels - i); return (0); } (*sp->tfunc)(sp, op, npixels); @@ -367,17 +353,10 @@ LogLuvDecode32(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s) } } if (i != npixels) { -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) - TIFFErrorExt(tif->tif_clientdata, module, - "Not enough data at row %lu (short %I64d pixels)", - (unsigned long) tif->tif_row, - (unsigned __int64) (npixels - i)); -#else TIFFErrorExt(tif->tif_clientdata, module, - "Not enough data at row %lu (short %llu pixels)", - (unsigned long) tif->tif_row, - (unsigned long long) (npixels - i)); -#endif + "Not enough data at row %"PRIu32" (short %"PRId64" pixels)", + tif->tif_row, + npixels - i); tif->tif_rawcp = (uint8_t*) bp; tif->tif_rawcc = cc; return (0); @@ -1294,7 +1273,7 @@ LogL16InitState(TIFF* tif) if( td->td_samplesperpixel != 1 ) { TIFFErrorExt(tif->tif_clientdata, module, - "Sorry, can not handle LogL image with %s=%d", + "Sorry, can not handle LogL image with %s=%"PRIu16, "Samples/pixel", td->td_samplesperpixel); return 0; } @@ -1495,7 +1474,7 @@ LogLuvSetupDecode(TIFF* tif) return (1); default: TIFFErrorExt(tif->tif_clientdata, module, - "Inappropriate photometric interpretation %d for SGILog compression; %s", + "Inappropriate photometric interpretation %"PRIu16" for SGILog compression; %s", td->td_photometric, "must be either LogLUV or LogL"); break; } @@ -1559,7 +1538,7 @@ LogLuvSetupEncode(TIFF* tif) break; default: TIFFErrorExt(tif->tif_clientdata, module, - "Inappropriate photometric interpretation %d for SGILog compression; %s", + "Inappropriate photometric interpretation %"PRIu16" for SGILog compression; %s", td->td_photometric, "must be either LogLUV or LogL"); return (0); } diff --git a/libtiff/tif_lzma.c b/libtiff/tif_lzma.c index 5bc6846f..a5770569 100644 --- a/libtiff/tif_lzma.c +++ b/libtiff/tif_lzma.c @@ -206,15 +206,15 @@ LZMADecode(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s) } if (ret != LZMA_OK) { TIFFErrorExt(tif->tif_clientdata, module, - "Decoding error at scanline %lu, %s", - (unsigned long) tif->tif_row, LZMAStrerror(ret)); + "Decoding error at scanline %"PRIu32", %s", + tif->tif_row, LZMAStrerror(ret)); break; } } while (sp->stream.avail_out > 0); if (sp->stream.avail_out != 0) { TIFFErrorExt(tif->tif_clientdata, module, - "Not enough data at scanline %lu (short %lu bytes)", - (unsigned long) tif->tif_row, (unsigned long) sp->stream.avail_out); + "Not enough data at scanline %"PRIu32" (short %zu bytes)", + tif->tif_row, sp->stream.avail_out); return 0; } @@ -294,8 +294,8 @@ LZMAEncode(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s) lzma_ret ret = lzma_code(&sp->stream, LZMA_RUN); if (ret != LZMA_OK) { TIFFErrorExt(tif->tif_clientdata, module, - "Encoding error at scanline %lu, %s", - (unsigned long) tif->tif_row, LZMAStrerror(ret)); + "Encoding error at scanline %"PRIu32", %s", + tif->tif_row, LZMAStrerror(ret)); return 0; } if (sp->stream.avail_out == 0) { diff --git a/libtiff/tif_lzw.c b/libtiff/tif_lzw.c index 2f248400..c06aec40 100644 --- a/libtiff/tif_lzw.c +++ b/libtiff/tif_lzw.c @@ -175,7 +175,7 @@ static void cl_hash(LZWCodecState*); #define NextCode(_tif, _sp, _bp, _code, _get) { \ if ((_sp)->dec_bitsleft < (uint64_t)nbits) { \ TIFFWarningExt(_tif->tif_clientdata, module, \ - "LZWDecode: Strip %d not terminated with EOI code", \ + "LZWDecode: Strip %"PRIu32" not terminated with EOI code", \ _tif->tif_curstrip); \ _code = CODE_EOI; \ } else { \ @@ -352,7 +352,7 @@ static void codeLoop(TIFF* tif, const char* module) { TIFFErrorExt(tif->tif_clientdata, module, - "Bogus encoding, loop in the code table; scanline %d", + "Bogus encoding, loop in the code table; scanline %"PRIu32, tif->tif_row); } @@ -454,7 +454,7 @@ LZWDecode(TIFF* tif, uint8_t* op0, tmsize_t occ0, uint16_t s) break; if (code > CODE_CLEAR) { TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "LZWDecode: Corrupted LZW table at scanline %d", + "LZWDecode: Corrupted LZW table at scanline %"PRIu32, tif->tif_row); return (0); } @@ -471,7 +471,7 @@ LZWDecode(TIFF* tif, uint8_t* op0, tmsize_t occ0, uint16_t s) if (free_entp < &sp->dec_codetab[0] || free_entp >= &sp->dec_codetab[CSIZE]) { TIFFErrorExt(tif->tif_clientdata, module, - "Corrupted LZW table at scanline %d", + "Corrupted LZW table at scanline %"PRIu32, tif->tif_row); return (0); } @@ -480,7 +480,7 @@ LZWDecode(TIFF* tif, uint8_t* op0, tmsize_t occ0, uint16_t s) if (free_entp->next < &sp->dec_codetab[0] || free_entp->next >= &sp->dec_codetab[CSIZE]) { TIFFErrorExt(tif->tif_clientdata, module, - "Corrupted LZW table at scanline %d", + "Corrupted LZW table at scanline %"PRIu32, tif->tif_row); return (0); } @@ -503,7 +503,7 @@ LZWDecode(TIFF* tif, uint8_t* op0, tmsize_t occ0, uint16_t s) if(codep->length == 0) { TIFFErrorExt(tif->tif_clientdata, module, "Wrong length of decoded string: " - "data probably corrupted at scanline %d", + "data probably corrupted at scanline %"PRIu32, tif->tif_row); return (0); } @@ -566,15 +566,9 @@ LZWDecode(TIFF* tif, uint8_t* op0, tmsize_t occ0, uint16_t s) sp->dec_maxcodep = maxcodep; if (occ > 0) { -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) TIFFErrorExt(tif->tif_clientdata, module, - "Not enough data at scanline %d (short %I64d bytes)", - tif->tif_row, (unsigned __int64) occ); -#else - TIFFErrorExt(tif->tif_clientdata, module, - "Not enough data at scanline %d (short %llu bytes)", - tif->tif_row, (unsigned long long) occ); -#endif + "Not enough data at scanline %"PRIu32" (short %ld bytes)", + tif->tif_row, occ); return (0); } return (1); @@ -688,7 +682,7 @@ LZWDecodeCompat(TIFF* tif, uint8_t* op0, tmsize_t occ0, uint16_t s) break; if (code > CODE_CLEAR) { TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "LZWDecode: Corrupted LZW table at scanline %d", + "LZWDecode: Corrupted LZW table at scanline %"PRIu32, tif->tif_row); return (0); } @@ -705,7 +699,7 @@ LZWDecodeCompat(TIFF* tif, uint8_t* op0, tmsize_t occ0, uint16_t s) if (free_entp < &sp->dec_codetab[0] || free_entp >= &sp->dec_codetab[CSIZE]) { TIFFErrorExt(tif->tif_clientdata, module, - "Corrupted LZW table at scanline %d", tif->tif_row); + "Corrupted LZW table at scanline %"PRIu32, tif->tif_row); return (0); } @@ -713,7 +707,7 @@ LZWDecodeCompat(TIFF* tif, uint8_t* op0, tmsize_t occ0, uint16_t s) if (free_entp->next < &sp->dec_codetab[0] || free_entp->next >= &sp->dec_codetab[CSIZE]) { TIFFErrorExt(tif->tif_clientdata, module, - "Corrupted LZW table at scanline %d", tif->tif_row); + "Corrupted LZW table at scanline %"PRIu32, tif->tif_row); return (0); } free_entp->firstchar = free_entp->next->firstchar; @@ -735,7 +729,7 @@ LZWDecodeCompat(TIFF* tif, uint8_t* op0, tmsize_t occ0, uint16_t s) if(codep->length == 0) { TIFFErrorExt(tif->tif_clientdata, module, "Wrong length of decoded " - "string: data probably corrupted at scanline %d", + "string: data probably corrupted at scanline %"PRIu32, tif->tif_row); return (0); } @@ -790,15 +784,9 @@ LZWDecodeCompat(TIFF* tif, uint8_t* op0, tmsize_t occ0, uint16_t s) sp->dec_maxcodep = maxcodep; if (occ > 0) { -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) TIFFErrorExt(tif->tif_clientdata, module, - "Not enough data at scanline %d (short %I64d bytes)", - tif->tif_row, (unsigned __int64) occ); -#else - TIFFErrorExt(tif->tif_clientdata, module, - "Not enough data at scanline %d (short %llu bytes)", - tif->tif_row, (unsigned long long) occ); -#endif + "Not enough data at scanline %"PRIu32" (short %ld bytes)", + tif->tif_row, occ); return (0); } return (1); diff --git a/libtiff/tif_next.c b/libtiff/tif_next.c index ef0dc2f9..695fc5d4 100644 --- a/libtiff/tif_next.c +++ b/libtiff/tif_next.c @@ -127,8 +127,8 @@ NeXTDecode(TIFF* tif, uint8_t* buf, tmsize_t occ, uint16_t s) if (npixels >= imagewidth) break; if (op_offset >= scanline ) { - TIFFErrorExt(tif->tif_clientdata, module, "Invalid data for scanline %ld", - (long) tif->tif_row); + TIFFErrorExt(tif->tif_clientdata, module, "Invalid data for scanline %"PRIu32, + tif->tif_row); return (0); } if (cc == 0) @@ -144,8 +144,8 @@ NeXTDecode(TIFF* tif, uint8_t* buf, tmsize_t occ, uint16_t s) tif->tif_rawcc = cc; return (1); bad: - TIFFErrorExt(tif->tif_clientdata, module, "Not enough data for scanline %ld", - (long) tif->tif_row); + TIFFErrorExt(tif->tif_clientdata, module, "Not enough data for scanline %"PRIu32, + tif->tif_row); return (0); } @@ -158,7 +158,7 @@ NeXTPreDecode(TIFF* tif, uint16_t s) if( td->td_bitspersample != 2 ) { - TIFFErrorExt(tif->tif_clientdata, module, "Unsupported BitsPerSample = %d", + TIFFErrorExt(tif->tif_clientdata, module, "Unsupported BitsPerSample = %"PRIu16, td->td_bitspersample); return (0); } diff --git a/libtiff/tif_ojpeg.c b/libtiff/tif_ojpeg.c index 63834e44..66cd275f 100644 --- a/libtiff/tif_ojpeg.c +++ b/libtiff/tif_ojpeg.c @@ -641,9 +641,9 @@ OJPEGPrintDir(TIFF* tif, FILE* fd, long flags) fprintf(fd,"\n"); } if (TIFFFieldSet(tif,FIELD_OJPEG_JPEGPROC)) - fprintf(fd," JpegProc: %u\n",(unsigned int)sp->jpeg_proc); + fprintf(fd," JpegProc: %"PRIu8"\n", sp->jpeg_proc); if (TIFFFieldSet(tif,FIELD_OJPEG_JPEGRESTARTINTERVAL)) - fprintf(fd," JpegRestartInterval: %u\n",(unsigned int)sp->restart_interval); + fprintf(fd," JpegRestartInterval: %"PRIu16"\n", sp->restart_interval); if (sp->printdir) (*sp->printdir)(tif, fd, flags); } @@ -1027,21 +1027,21 @@ OJPEGSubsamplingCorrect(TIFF* tif) if (((sp->subsampling_hor!=mh) || (sp->subsampling_ver!=mv)) && (sp->subsampling_force_desubsampling_inside_decompression==0)) { if (sp->subsampling_tag==0) - TIFFWarningExt(tif->tif_clientdata,module,"Subsampling tag is not set, yet subsampling inside JPEG data [%d,%d] does not match default values [2,2]; assuming subsampling inside JPEG data is correct",sp->subsampling_hor,sp->subsampling_ver); + TIFFWarningExt(tif->tif_clientdata,module,"Subsampling tag is not set, yet subsampling inside JPEG data [%"PRIu8",%"PRIu8"] does not match default values [2,2]; assuming subsampling inside JPEG data is correct",sp->subsampling_hor,sp->subsampling_ver); else - TIFFWarningExt(tif->tif_clientdata,module,"Subsampling inside JPEG data [%d,%d] does not match subsampling tag values [%d,%d]; assuming subsampling inside JPEG data is correct",sp->subsampling_hor,sp->subsampling_ver,mh,mv); + TIFFWarningExt(tif->tif_clientdata,module,"Subsampling inside JPEG data [%"PRIu8",%"PRIu8"] does not match subsampling tag values [%"PRIu8",%"PRIu8"]; assuming subsampling inside JPEG data is correct",sp->subsampling_hor,sp->subsampling_ver,mh,mv); } if (sp->subsampling_force_desubsampling_inside_decompression!=0) { if (sp->subsampling_tag==0) TIFFWarningExt(tif->tif_clientdata,module,"Subsampling tag is not set, yet subsampling inside JPEG data does not match default values [2,2] (nor any other values allowed in TIFF); assuming subsampling inside JPEG data is correct and desubsampling inside JPEG decompression"); else - TIFFWarningExt(tif->tif_clientdata,module,"Subsampling inside JPEG data does not match subsampling tag values [%d,%d] (nor any other values allowed in TIFF); assuming subsampling inside JPEG data is correct and desubsampling inside JPEG decompression",mh,mv); + TIFFWarningExt(tif->tif_clientdata,module,"Subsampling inside JPEG data does not match subsampling tag values [%"PRIu8",%"PRIu8"] (nor any other values allowed in TIFF); assuming subsampling inside JPEG data is correct and desubsampling inside JPEG decompression",mh,mv); } if (sp->subsampling_force_desubsampling_inside_decompression==0) { if (sp->subsampling_hor<sp->subsampling_ver) - TIFFWarningExt(tif->tif_clientdata,module,"Subsampling values [%d,%d] are not allowed in TIFF",sp->subsampling_hor,sp->subsampling_ver); + TIFFWarningExt(tif->tif_clientdata,module,"Subsampling values [%"PRIu8",%"PRIu8"] are not allowed in TIFF",sp->subsampling_hor,sp->subsampling_ver); } } sp->subsamplingcorrect_done=1; @@ -1081,7 +1081,7 @@ OJPEGReadHeaderInfo(TIFF* tif) { if (tif->tif_dir.td_samplesperpixel!=3) { - TIFFErrorExt(tif->tif_clientdata,module,"SamplesPerPixel %d not supported for this compression scheme",sp->samples_per_pixel); + TIFFErrorExt(tif->tif_clientdata,module,"SamplesPerPixel %"PRIu8" not supported for this compression scheme",sp->samples_per_pixel); return(0); } sp->samples_per_pixel=3; @@ -1266,8 +1266,8 @@ OJPEGWriteHeaderInfo(TIFF* tif) return(0); if(sp->libjpeg_jpeg_decompress_struct.image_width != sp->strile_width ) { TIFFErrorExt(tif->tif_clientdata,module, - "jpeg_start_decompress() returned image_width = %d, " - "expected %d", + "jpeg_start_decompress() returned image_width = %u, " + "expected %"PRIu32, sp->libjpeg_jpeg_decompress_struct.image_width, sp->strile_width); return 0; @@ -1276,7 +1276,7 @@ OJPEGWriteHeaderInfo(TIFF* tif) sp->libjpeg_jpeg_decompress_struct.max_v_samp_factor != sp->subsampling_ver) { TIFFErrorExt(tif->tif_clientdata,module, "jpeg_start_decompress() returned max_h_samp_factor = %d " - "and max_v_samp_factor = %d, expected %d and %d", + "and max_v_samp_factor = %d, expected %"PRIu8" and %"PRIu8, sp->libjpeg_jpeg_decompress_struct.max_h_samp_factor, sp->libjpeg_jpeg_decompress_struct.max_v_samp_factor, sp->subsampling_hor, @@ -1401,7 +1401,7 @@ OJPEGReadHeaderInfoSec(TIFF* tif) return(0); break; default: - TIFFErrorExt(tif->tif_clientdata,module,"Unknown marker type %d in JPEG data",m); + TIFFErrorExt(tif->tif_clientdata,module,"Unknown marker type %"PRIu8" in JPEG data", m); return(0); } } while(m!=JPEG_MARKER_SOS); diff --git a/libtiff/tif_open.c b/libtiff/tif_open.c index 7b61d4d3..9724162e 100644 --- a/libtiff/tif_open.c +++ b/libtiff/tif_open.c @@ -373,11 +373,11 @@ TIFFClientOpen( #endif ) { TIFFErrorExt(tif->tif_clientdata, name, - "Not a TIFF or MDI file, bad magic number %d (0x%x)", + "Not a TIFF or MDI file, bad magic number %"PRIu16" (0x%"PRIx16")", #else ) { TIFFErrorExt(tif->tif_clientdata, name, - "Not a TIFF file, bad magic number %d (0x%x)", + "Not a TIFF file, bad magic number %"PRIu16" (0x%"PRIx16")", #endif tif->tif_header.common.tiff_magic, tif->tif_header.common.tiff_magic); @@ -397,7 +397,7 @@ TIFFClientOpen( if ((tif->tif_header.common.tiff_version != TIFF_VERSION_CLASSIC)&& (tif->tif_header.common.tiff_version != TIFF_VERSION_BIG)) { TIFFErrorExt(tif->tif_clientdata, name, - "Not a TIFF file, bad version number %d (0x%x)", + "Not a TIFF file, bad version number %"PRIu16" (0x%"PRIx16")", tif->tif_header.common.tiff_version, tif->tif_header.common.tiff_version); goto bad; @@ -424,7 +424,7 @@ TIFFClientOpen( if (tif->tif_header.big.tiff_offsetsize != 8) { TIFFErrorExt(tif->tif_clientdata, name, - "Not a TIFF file, bad BigTIFF offsetsize %d (0x%x)", + "Not a TIFF file, bad BigTIFF offsetsize %"PRIu16" (0x%"PRIx16")", tif->tif_header.big.tiff_offsetsize, tif->tif_header.big.tiff_offsetsize); goto bad; @@ -432,7 +432,7 @@ TIFFClientOpen( if (tif->tif_header.big.tiff_unused != 0) { TIFFErrorExt(tif->tif_clientdata, name, - "Not a TIFF file, bad BigTIFF unused %d (0x%x)", + "Not a TIFF file, bad BigTIFF unused %"PRIu16" (0x%"PRIx16")", tif->tif_header.big.tiff_unused, tif->tif_header.big.tiff_unused); goto bad; diff --git a/libtiff/tif_packbits.c b/libtiff/tif_packbits.c index 01b6a23c..010c09bf 100644 --- a/libtiff/tif_packbits.c +++ b/libtiff/tif_packbits.c @@ -238,8 +238,8 @@ PackBitsDecode(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s) if( occ < (tmsize_t)n ) { TIFFWarningExt(tif->tif_clientdata, module, - "Discarding %lu bytes to avoid buffer overrun", - (unsigned long) ((tmsize_t)n - occ)); + "Discarding %"PRId64" bytes to avoid buffer overrun", + (tmsize_t)n - occ); n = (long)occ; } if( cc == 0 ) @@ -257,8 +257,8 @@ PackBitsDecode(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s) if (occ < (tmsize_t)(n + 1)) { TIFFWarningExt(tif->tif_clientdata, module, - "Discarding %lu bytes to avoid buffer overrun", - (unsigned long) ((tmsize_t)n - occ + 1)); + "Discarding %"PRId64" bytes to avoid buffer overrun", + (tmsize_t)n - occ + 1); n = (long)occ - 1; } if (cc < (tmsize_t) (n+1)) @@ -276,8 +276,8 @@ PackBitsDecode(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s) tif->tif_rawcc = cc; if (occ > 0) { TIFFErrorExt(tif->tif_clientdata, module, - "Not enough data for scanline %lu", - (unsigned long) tif->tif_row); + "Not enough data for scanline %"PRIu32, + tif->tif_row); return (0); } return (1); diff --git a/libtiff/tif_pixarlog.c b/libtiff/tif_pixarlog.c index a3846aab..9686b7c5 100644 --- a/libtiff/tif_pixarlog.c +++ b/libtiff/tif_pixarlog.c @@ -706,7 +706,7 @@ PixarLogSetupDecode(TIFF* tif) sp->tbuf = NULL; sp->tbuf_size = 0; TIFFErrorExt(tif->tif_clientdata, module, - "PixarLog compression can't handle bits depth/data format combination (depth: %d)", + "PixarLog compression can't handle bits depth/data format combination (depth: %"PRIu16")", td->td_bitspersample); return (0); } @@ -774,7 +774,7 @@ PixarLogDecode(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s) break; default: TIFFErrorExt(tif->tif_clientdata, module, - "%d bit input not supported in PixarLog", + "%"PRIu16" bit input not supported in PixarLog", td->td_bitspersample); return 0; } @@ -811,8 +811,8 @@ PixarLogDecode(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s) } if (state == Z_DATA_ERROR) { TIFFErrorExt(tif->tif_clientdata, module, - "Decoding error at scanline %lu, %s", - (unsigned long) tif->tif_row, sp->stream.msg ? sp->stream.msg : "(null)"); + "Decoding error at scanline %"PRIu32", %s", + tif->tif_row, sp->stream.msg ? sp->stream.msg : "(null)"); return (0); } if (state != Z_OK) { @@ -825,8 +825,8 @@ PixarLogDecode(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s) /* hopefully, we got all the bytes we needed */ if (sp->stream.avail_out != 0) { TIFFErrorExt(tif->tif_clientdata, module, - "Not enough data at scanline %lu (short %" PRIu64 " bytes)", - (unsigned long) tif->tif_row, (uint64_t) sp->stream.avail_out); + "Not enough data at scanline %"PRIu32" (short %u bytes)", + tif->tif_row, sp->stream.avail_out); return (0); } @@ -845,8 +845,8 @@ PixarLogDecode(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s) */ if (nsamples % llen) { TIFFWarningExt(tif->tif_clientdata, module, - "stride %lu is not a multiple of sample count, " - "%lu, data truncated.", (unsigned long) llen, (unsigned long) nsamples); + "stride %d is not a multiple of sample count, " + "%"PRId64", data truncated.", llen, nsamples); nsamples -= nsamples % llen; } @@ -884,7 +884,7 @@ PixarLogDecode(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s) break; default: TIFFErrorExt(tif->tif_clientdata, module, - "Unsupported bits/sample: %d", + "Unsupported bits/sample: %"PRIu16, td->td_bitspersample); return (0); } @@ -917,7 +917,7 @@ PixarLogSetupEncode(TIFF* tif) if (sp->user_datafmt == PIXARLOGDATAFMT_UNKNOWN) sp->user_datafmt = PixarLogGuessDataFmt(td); if (sp->user_datafmt == PIXARLOGDATAFMT_UNKNOWN) { - TIFFErrorExt(tif->tif_clientdata, module, "PixarLog compression can't handle %d bit linear encodings", td->td_bitspersample); + TIFFErrorExt(tif->tif_clientdata, module, "PixarLog compression can't handle %"PRIu16" bit linear encodings", td->td_bitspersample); return (0); } @@ -1140,7 +1140,7 @@ PixarLogEncode(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s) break; default: TIFFErrorExt(tif->tif_clientdata, module, - "%d bit input not supported in PixarLog", + "%"PRIu16" bit input not supported in PixarLog", td->td_bitspersample); return 0; } @@ -1173,7 +1173,7 @@ PixarLogEncode(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s) break; default: TIFFErrorExt(tif->tif_clientdata, module, - "%d bit input not supported in PixarLog", + "%"PRIu16" bit input not supported in PixarLog", td->td_bitspersample); return 0; } diff --git a/libtiff/tif_predict.c b/libtiff/tif_predict.c index 30c674c5..4aa4af69 100644 --- a/libtiff/tif_predict.c +++ b/libtiff/tif_predict.c @@ -66,7 +66,7 @@ PredictorSetup(TIFF* tif) && td->td_bitspersample != 16 && td->td_bitspersample != 32) { TIFFErrorExt(tif->tif_clientdata, module, - "Horizontal differencing \"Predictor\" not supported with %d-bit samples", + "Horizontal differencing \"Predictor\" not supported with %"PRIu16"-bit samples", td->td_bitspersample); return 0; } @@ -74,7 +74,7 @@ PredictorSetup(TIFF* tif) case PREDICTOR_FLOATINGPOINT: if (td->td_sampleformat != SAMPLEFORMAT_IEEEFP) { TIFFErrorExt(tif->tif_clientdata, module, - "Floating point \"Predictor\" not supported with %d data format", + "Floating point \"Predictor\" not supported with %"PRIu16" data format", td->td_sampleformat); return 0; } @@ -83,7 +83,7 @@ PredictorSetup(TIFF* tif) && td->td_bitspersample != 32 && td->td_bitspersample != 64) { /* Should 64 be allowed? */ TIFFErrorExt(tif->tif_clientdata, module, - "Floating point \"Predictor\" not supported with %d-bit samples", + "Floating point \"Predictor\" not supported with %"PRIu16"-bit samples", td->td_bitspersample); return 0; } diff --git a/libtiff/tif_print.c b/libtiff/tif_print.c index 53c87492..347dbdaf 100644 --- a/libtiff/tif_print.c +++ b/libtiff/tif_print.c @@ -73,54 +73,35 @@ _TIFFPrintField(FILE* fd, const TIFFField *fip, for(j = 0; j < value_count; j++) { if(fip->field_type == TIFF_BYTE) - fprintf(fd, "%u", ((uint8_t *) raw_data)[j]); + fprintf(fd, "%"PRIu8, ((uint8_t *) raw_data)[j]); else if(fip->field_type == TIFF_UNDEFINED) - fprintf(fd, "0x%x", - (unsigned int) ((unsigned char *) raw_data)[j]); + fprintf(fd, "0x%"PRIx8, ((uint8_t *) raw_data)[j]); else if(fip->field_type == TIFF_SBYTE) - fprintf(fd, "%d", ((int8_t *) raw_data)[j]); + fprintf(fd, "%"PRId8, ((int8_t *) raw_data)[j]); else if(fip->field_type == TIFF_SHORT) - fprintf(fd, "%u", ((uint16_t *) raw_data)[j]); + fprintf(fd, "%"PRIu16, ((uint16_t *) raw_data)[j]); else if(fip->field_type == TIFF_SSHORT) - fprintf(fd, "%d", ((int16_t *) raw_data)[j]); + fprintf(fd, "%"PRId16, ((int16_t *) raw_data)[j]); else if(fip->field_type == TIFF_LONG) - fprintf(fd, "%lu", - (unsigned long)((uint32_t *) raw_data)[j]); + fprintf(fd, "%"PRIu32, ((uint32_t *) raw_data)[j]); else if(fip->field_type == TIFF_SLONG) - fprintf(fd, "%ld", (long)((int32_t *) raw_data)[j]); + fprintf(fd, "%"PRId32, ((int32_t *) raw_data)[j]); else if(fip->field_type == TIFF_IFD) - fprintf(fd, "0x%lx", - (unsigned long)((uint32_t *) raw_data)[j]); + fprintf(fd, "0x%"PRIx32, ((uint32_t *) raw_data)[j]); else if(fip->field_type == TIFF_RATIONAL || fip->field_type == TIFF_SRATIONAL || fip->field_type == TIFF_FLOAT) fprintf(fd, "%f", ((float *) raw_data)[j]); else if(fip->field_type == TIFF_LONG8) -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) - fprintf(fd, "%I64u", - (unsigned __int64)((uint64_t *) raw_data)[j]); -#else - fprintf(fd, "%llu", - (unsigned long long)((uint64_t *) raw_data)[j]); -#endif + fprintf(fd, "%"PRIu64, ((uint64_t *) raw_data)[j]); else if(fip->field_type == TIFF_SLONG8) -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) - fprintf(fd, "%I64d", (__int64)((int64_t *) raw_data)[j]); -#else - fprintf(fd, "%lld", (long long)((int64_t *) raw_data)[j]); -#endif + fprintf(fd, "%"PRId64, ((int64_t *) raw_data)[j]); else if(fip->field_type == TIFF_IFD8) -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) - fprintf(fd, "0x%I64x", - (unsigned __int64)((uint64_t *) raw_data)[j]); -#else - fprintf(fd, "0x%llx", - (unsigned long long)((uint64_t *) raw_data)[j]); -#endif + fprintf(fd, "0x%"PRIx64, ((uint64_t *) raw_data)[j]); else if(fip->field_type == TIFF_FLOAT) fprintf(fd, "%f", ((float *)raw_data)[j]); else if(fip->field_type == TIFF_DOUBLE) - fprintf(fd, "%f", ((double *) raw_data)[j]); + fprintf(fd, "%lf", ((double *) raw_data)[j]); else if(fip->field_type == TIFF_ASCII) { fprintf(fd, "%s", (char *) raw_data); break; @@ -158,7 +139,7 @@ _TIFFPrettyPrintField(TIFF* tif, const TIFFField *fip, FILE* fd, uint32_t tag, fprintf(fd, "CMYK\n"); break; default: - fprintf(fd, "%u (0x%x)\n", + fprintf(fd, "%"PRIu16" (0x%"PRIx16")\n", *((uint16_t*)raw_data), *((uint16_t*)raw_data)); break; @@ -169,7 +150,7 @@ _TIFFPrettyPrintField(TIFF* tif, const TIFFField *fip, FILE* fd, uint32_t tag, case TIFFTAG_DOTRANGE: if (value_count == 2 && fip->field_type == TIFF_SHORT) { - fprintf(fd, " Dot Range: %u-%u\n", + fprintf(fd, " Dot Range: %"PRIu16"-%"PRIu16"\n", ((uint16_t*)raw_data)[0], ((uint16_t*)raw_data)[1]); return 1; } @@ -199,18 +180,18 @@ _TIFFPrettyPrintField(TIFF* tif, const TIFFField *fip, FILE* fd, uint32_t tag, * defined as array of LONG values. */ fprintf(fd, - " RichTIFFIPTC Data: <present>, %lu bytes\n", - (unsigned long) value_count * 4); + " RichTIFFIPTC Data: <present>, %"PRIu32" bytes\n", + value_count * 4u); return 1; case TIFFTAG_PHOTOSHOP: - fprintf(fd, " Photoshop Data: <present>, %lu bytes\n", - (unsigned long) value_count); + fprintf(fd, " Photoshop Data: <present>, %"PRIu32" bytes\n", + value_count); return 1; case TIFFTAG_ICCPROFILE: - fprintf(fd, " ICC Profile: <present>, %lu bytes\n", - (unsigned long) value_count); + fprintf(fd, " ICC Profile: <present>, %"PRIu32" bytes\n", + value_count); return 1; case TIFFTAG_STONITS: @@ -237,15 +218,9 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) char *sep; long l, n; -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) - fprintf(fd, "TIFF Directory at offset 0x%I64x (%I64u)\n", - (unsigned __int64) tif->tif_diroff, - (unsigned __int64) tif->tif_diroff); -#else - fprintf(fd, "TIFF Directory at offset 0x%llx (%llu)\n", - (unsigned long long) tif->tif_diroff, - (unsigned long long) tif->tif_diroff); -#endif + fprintf(fd, "TIFF Directory at offset 0x%"PRIu64" (%"PRIx64")\n", + tif->tif_diroff, + tif->tif_diroff); if (TIFFFieldSet(tif,FIELD_SUBFILETYPE)) { fprintf(fd, " Subfile Type:"); sep = " "; @@ -259,23 +234,23 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) } if (td->td_subfiletype & FILETYPE_MASK) fprintf(fd, "%stransparency mask", sep); - fprintf(fd, " (%lu = 0x%lx)\n", - (unsigned long) td->td_subfiletype, (long) td->td_subfiletype); + fprintf(fd, " (%"PRIu32" = 0x%"PRIx32")\n", + td->td_subfiletype, td->td_subfiletype); } if (TIFFFieldSet(tif,FIELD_IMAGEDIMENSIONS)) { - fprintf(fd, " Image Width: %lu Image Length: %lu", - (unsigned long) td->td_imagewidth, (unsigned long) td->td_imagelength); + fprintf(fd, " Image Width: %"PRIu32" Image Length: %"PRIu32, + td->td_imagewidth, td->td_imagelength); if (TIFFFieldSet(tif,FIELD_IMAGEDEPTH)) - fprintf(fd, " Image Depth: %lu", - (unsigned long) td->td_imagedepth); + fprintf(fd, " Image Depth: %"PRIu32, + td->td_imagedepth); fprintf(fd, "\n"); } if (TIFFFieldSet(tif,FIELD_TILEDIMENSIONS)) { - fprintf(fd, " Tile Width: %lu Tile Length: %lu", - (unsigned long) td->td_tilewidth, (unsigned long) td->td_tilelength); + fprintf(fd, " Tile Width: %"PRIu32" Tile Length: %"PRIu32, + td->td_tilewidth, td->td_tilelength); if (TIFFFieldSet(tif,FIELD_TILEDEPTH)) - fprintf(fd, " Tile Depth: %lu", - (unsigned long) td->td_tiledepth); + fprintf(fd, " Tile Depth: %"PRIu32, + td->td_tiledepth); fprintf(fd, "\n"); } if (TIFFFieldSet(tif,FIELD_RESOLUTION)) { @@ -293,7 +268,7 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) fprintf(fd, " pixels/cm"); break; default: - fprintf(fd, " (unit %u = 0x%x)", + fprintf(fd, " (unit %"PRIu16" = 0x%"PRIx16")", td->td_resolutionunit, td->td_resolutionunit); break; @@ -305,7 +280,7 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) fprintf(fd, " Position: %g, %g\n", td->td_xposition, td->td_yposition); if (TIFFFieldSet(tif,FIELD_BITSPERSAMPLE)) - fprintf(fd, " Bits/Sample: %u\n", td->td_bitspersample); + fprintf(fd, " Bits/Sample: %"PRIu16"\n", td->td_bitspersample); if (TIFFFieldSet(tif,FIELD_SAMPLEFORMAT)) { fprintf(fd, " Sample Format: "); switch (td->td_sampleformat) { @@ -328,7 +303,7 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) fprintf(fd, "complex IEEE floating point\n"); break; default: - fprintf(fd, "%u (0x%x)\n", + fprintf(fd, "%"PRIu16" (0x%"PRIx16")\n", td->td_sampleformat, td->td_sampleformat); break; } @@ -339,7 +314,7 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) if (c) fprintf(fd, "%s\n", c->name); else - fprintf(fd, "%u (0x%x)\n", + fprintf(fd, "%"PRIu16" (0x%"PRIx16")\n", td->td_compression, td->td_compression); } if (TIFFFieldSet(tif,FIELD_PHOTOMETRIC)) { @@ -355,7 +330,7 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) fprintf(fd, "CIE Log2(L) (u',v')\n"); break; default: - fprintf(fd, "%u (0x%x)\n", + fprintf(fd, "%"PRIu16" (0x%"PRIx16")\n", td->td_photometric, td->td_photometric); break; } @@ -363,7 +338,7 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) } if (TIFFFieldSet(tif,FIELD_EXTRASAMPLES) && td->td_extrasamples) { uint16_t i; - fprintf(fd, " Extra Samples: %u<", td->td_extrasamples); + fprintf(fd, " Extra Samples: %"PRIu16"<", td->td_extrasamples); sep = ""; for (i = 0; i < td->td_extrasamples; i++) { switch (td->td_sampleinfo[i]) { @@ -377,7 +352,7 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) fprintf(fd, "%sunassoc-alpha", sep); break; default: - fprintf(fd, "%s%u (0x%x)", sep, + fprintf(fd, "%s%"PRIu16" (0x%"PRIx16")", sep, td->td_sampleinfo[i], td->td_sampleinfo[i]); break; } @@ -415,7 +390,7 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) fprintf(fd, "error diffused\n"); break; default: - fprintf(fd, "%u (0x%x)\n", + fprintf(fd, "%"PRIu16" (0x%"PRIx16")\n", td->td_threshholding, td->td_threshholding); break; } @@ -430,14 +405,14 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) fprintf(fd, "lsb-to-msb\n"); break; default: - fprintf(fd, "%u (0x%x)\n", + fprintf(fd, "%"PRIu16" (0x%"PRIx16")\n", td->td_fillorder, td->td_fillorder); break; } } if (TIFFFieldSet(tif,FIELD_YCBCRSUBSAMPLING)) { - fprintf(fd, " YCbCr Subsampling: %u, %u\n", + fprintf(fd, " YCbCr Subsampling: %"PRIu16", %"PRIu16"\n", td->td_ycbcrsubsampling[0], td->td_ycbcrsubsampling[1] ); } if (TIFFFieldSet(tif,FIELD_YCBCRPOSITIONING)) { @@ -450,35 +425,35 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) fprintf(fd, "cosited\n"); break; default: - fprintf(fd, "%u (0x%x)\n", + fprintf(fd, "%"PRIu16" (0x%"PRIx16")\n", td->td_ycbcrpositioning, td->td_ycbcrpositioning); break; } } if (TIFFFieldSet(tif,FIELD_HALFTONEHINTS)) - fprintf(fd, " Halftone Hints: light %u dark %u\n", + fprintf(fd, " Halftone Hints: light %"PRIu16" dark %"PRIu16"\n", td->td_halftonehints[0], td->td_halftonehints[1]); if (TIFFFieldSet(tif,FIELD_ORIENTATION)) { fprintf(fd, " Orientation: "); if (td->td_orientation < NORIENTNAMES) fprintf(fd, "%s\n", orientNames[td->td_orientation]); else - fprintf(fd, "%u (0x%x)\n", + fprintf(fd, "%"PRIu16" (0x%"PRIx16")\n", td->td_orientation, td->td_orientation); } if (TIFFFieldSet(tif,FIELD_SAMPLESPERPIXEL)) - fprintf(fd, " Samples/Pixel: %u\n", td->td_samplesperpixel); + fprintf(fd, " Samples/Pixel: %"PRIx16"\n", td->td_samplesperpixel); if (TIFFFieldSet(tif,FIELD_ROWSPERSTRIP)) { fprintf(fd, " Rows/Strip: "); if (td->td_rowsperstrip == (uint32_t) -1) fprintf(fd, "(infinite)\n"); else - fprintf(fd, "%lu\n", (unsigned long) td->td_rowsperstrip); + fprintf(fd, "%"PRIu32"\n", td->td_rowsperstrip); } if (TIFFFieldSet(tif,FIELD_MINSAMPLEVALUE)) - fprintf(fd, " Min Sample Value: %u\n", td->td_minsamplevalue); + fprintf(fd, " Min Sample Value: %"PRIu16"\n", td->td_minsamplevalue); if (TIFFFieldSet(tif,FIELD_MAXSAMPLEVALUE)) - fprintf(fd, " Max Sample Value: %u\n", td->td_maxsamplevalue); + fprintf(fd, " Max Sample Value: %"PRIu16"\n", td->td_maxsamplevalue); if (TIFFFieldSet(tif,FIELD_SMINSAMPLEVALUE)) { int i; int count = (tif->tif_flags & TIFF_PERSAMPLE) ? td->td_samplesperpixel : 1; @@ -505,13 +480,13 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) fprintf(fd, "separate image planes\n"); break; default: - fprintf(fd, "%u (0x%x)\n", + fprintf(fd, "%"PRIu16" (0x%"PRIx16")\n", td->td_planarconfig, td->td_planarconfig); break; } } if (TIFFFieldSet(tif,FIELD_PAGENUMBER)) - fprintf(fd, " Page Number: %u-%u\n", + fprintf(fd, " Page Number: %"PRIu16"-%"PRIu16"\n", td->td_pagenumber[0], td->td_pagenumber[1]); if (TIFFFieldSet(tif,FIELD_COLORMAP)) { fprintf(fd, " Color Map: "); @@ -519,7 +494,7 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) fprintf(fd, "\n"); n = 1L<<td->td_bitspersample; for (l = 0; l < n; l++) - fprintf(fd, " %5ld: %5u %5u %5u\n", + fprintf(fd, " %5ld: %5"PRIu16" %5"PRIu16" %5"PRIu16"\n", l, td->td_colormap[0][l], td->td_colormap[1][l], @@ -542,10 +517,10 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) n = 1L<<td->td_bitspersample; for (l = 0; l < n; l++) { uint16_t i; - fprintf(fd, " %2ld: %5u", + fprintf(fd, " %2ld: %5"PRIu16, l, td->td_transferfunction[0][l]); for (i = 1; i < td->td_samplesperpixel - td->td_extrasamples && i < 3; i++) - fprintf(fd, " %5u", + fprintf(fd, " %5"PRIu16, td->td_transferfunction[i][l]); fputc('\n', fd); } @@ -556,13 +531,8 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) uint16_t i; fprintf(fd, " SubIFD Offsets:"); for (i = 0; i < td->td_nsubifd; i++) -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) - fprintf(fd, " %5I64u", - (unsigned __int64) td->td_subifd[i]); -#else - fprintf(fd, " %5llu", - (unsigned long long) td->td_subifd[i]); -#endif + fprintf(fd, " %5"PRIu64, + td->td_subifd[i]); fputc('\n', fd); } @@ -656,21 +626,14 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) TIFFFieldSet(tif,FIELD_STRIPOFFSETS)) { uint32_t s; - fprintf(fd, " %lu %s:\n", - (unsigned long) td->td_nstrips, + fprintf(fd, " %"PRIu32" %s:\n", + td->td_nstrips, isTiled(tif) ? "Tiles" : "Strips"); for (s = 0; s < td->td_nstrips; s++) -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) - fprintf(fd, " %3lu: [%8I64u, %8I64u]\n", - (unsigned long) s, - (unsigned __int64) TIFFGetStrileOffset(tif, s), - (unsigned __int64) TIFFGetStrileByteCount(tif, s)); -#else - fprintf(fd, " %3lu: [%8llu, %8llu]\n", - (unsigned long) s, - (unsigned long long) TIFFGetStrileOffset(tif, s), - (unsigned long long) TIFFGetStrileByteCount(tif, s)); -#endif + fprintf(fd, " %3"PRIu32": [%8"PRIu64", %8"PRIu64"]\n", + s, + TIFFGetStrileOffset(tif, s), + TIFFGetStrileByteCount(tif, s)); } } diff --git a/libtiff/tif_read.c b/libtiff/tif_read.c index 748fb2d5..8b174d9a 100644 --- a/libtiff/tif_read.c +++ b/libtiff/tif_read.c @@ -109,8 +109,8 @@ static int TIFFReadAndRealloc(TIFF* tif, tmsize_t size, if( new_rawdata == 0 ) { TIFFErrorExt(tif->tif_clientdata, module, - "No space for data buffer at scanline %lu", - (unsigned long) tif->tif_row); + "No space for data buffer at scanline %"PRIu32, + tif->tif_row); _TIFFfree(tif->tif_rawdata); tif->tif_rawdata = 0; tif->tif_rawdatasize = 0; @@ -130,49 +130,26 @@ static int TIFFReadAndRealloc(TIFF* tif, tmsize_t size, if (bytes_read != to_read) { memset( tif->tif_rawdata + rawdata_offset + already_read, 0, tif->tif_rawdatasize - rawdata_offset - already_read ); -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) if( is_strip ) { TIFFErrorExt(tif->tif_clientdata, module, - "Read error at scanline %lu; got %I64u bytes, " - "expected %I64u", - (unsigned long) tif->tif_row, - (unsigned __int64) already_read, - (unsigned __int64) size); + "Read error at scanline %"PRIu32"; got %"PRId64" bytes, " + "expected %"PRId64, + tif->tif_row, + already_read, + size); } else { TIFFErrorExt(tif->tif_clientdata, module, - "Read error at row %lu, col %lu, tile %lu; " - "got %I64u bytes, expected %I64u", - (unsigned long) tif->tif_row, - (unsigned long) tif->tif_col, - (unsigned long) strip_or_tile, - (unsigned __int64) already_read, - (unsigned __int64) size); + "Read error at row %"PRIu32", col %"PRIu32", tile %"PRIu32"; " + "got %"PRId64" bytes, expected %"PRId64"", + tif->tif_row, + tif->tif_col, + strip_or_tile, + already_read, + size); } -#else - if( is_strip ) - { - TIFFErrorExt(tif->tif_clientdata, module, - "Read error at scanline %lu; got %llu bytes, " - "expected %llu", - (unsigned long) tif->tif_row, - (unsigned long long) already_read, - (unsigned long long) size); - } - else - { - TIFFErrorExt(tif->tif_clientdata, module, - "Read error at row %lu, col %lu, tile %lu; " - "got %llu bytes, expected %llu", - (unsigned long) tif->tif_row, - (unsigned long) tif->tif_col, - (unsigned long) strip_or_tile, - (unsigned long long) already_read, - (unsigned long long) size); - } -#endif return 0; } } @@ -211,8 +188,8 @@ TIFFFillStripPartial( TIFF *tif, int strip, tmsize_t read_ahead, int restart ) tif->tif_curstrip = NOSTRIP; if ((tif->tif_flags & TIFF_MYBUFFER) == 0) { TIFFErrorExt(tif->tif_clientdata, module, - "Data buffer too small to hold part of strip %lu", - (unsigned long) strip); + "Data buffer too small to hold part of strip %d", + strip); return (0); } } @@ -246,8 +223,8 @@ TIFFFillStripPartial( TIFF *tif, int strip, tmsize_t read_ahead, int restart ) if (!SeekOK(tif, read_offset)) { TIFFErrorExt(tif->tif_clientdata, module, - "Seek error at scanline %lu, strip %lu", - (unsigned long) tif->tif_row, (unsigned long) strip); + "Seek error at scanline %"PRIu32", strip %d", + tif->tif_row, strip); return 0; } @@ -338,16 +315,16 @@ TIFFSeek(TIFF* tif, uint32_t row, uint16_t sample ) */ if (row >= td->td_imagelength) { /* out of range */ TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "%lu: Row out of range, max %lu", - (unsigned long) row, - (unsigned long) td->td_imagelength); + "%"PRIu32": Row out of range, max %"PRIu32"", + row, + td->td_imagelength); return (0); } if (td->td_planarconfig == PLANARCONFIG_SEPARATE) { if (sample >= td->td_samplesperpixel) { TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "%lu: Sample out of range, max %lu", - (unsigned long) sample, (unsigned long) td->td_samplesperpixel); + "%"PRIu16": Sample out of range, max %"PRIu16"", + sample, td->td_samplesperpixel); return (0); } strip = (uint32_t)sample * td->td_stripsperimage + row / td->td_rowsperstrip; @@ -499,8 +476,8 @@ static tmsize_t TIFFReadEncodedStripGetStripSize(TIFF* tif, uint32_t strip, uint if (strip>=td->td_nstrips) { TIFFErrorExt(tif->tif_clientdata,module, - "%lu: Strip out of range, max %lu",(unsigned long)strip, - (unsigned long)td->td_nstrips); + "%"PRIu32": Strip out of range, max %"PRIu32, strip, + td->td_nstrips); return((tmsize_t)(-1)); } @@ -615,25 +592,17 @@ TIFFReadRawStrip1(TIFF* tif, uint32_t strip, void* buf, tmsize_t size, if (!SeekOK(tif, TIFFGetStrileOffset(tif, strip))) { TIFFErrorExt(tif->tif_clientdata, module, - "Seek error at scanline %lu, strip %lu", - (unsigned long) tif->tif_row, (unsigned long) strip); + "Seek error at scanline %"PRIu32", strip %"PRIu32, + tif->tif_row, strip); return ((tmsize_t)(-1)); } cc = TIFFReadFile(tif, buf, size); if (cc != size) { -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) - TIFFErrorExt(tif->tif_clientdata, module, - "Read error at scanline %lu; got %I64u bytes, expected %I64u", - (unsigned long) tif->tif_row, - (unsigned __int64) cc, - (unsigned __int64) size); -#else TIFFErrorExt(tif->tif_clientdata, module, - "Read error at scanline %lu; got %llu bytes, expected %llu", - (unsigned long) tif->tif_row, - (unsigned long long) cc, - (unsigned long long) size); -#endif + "Read error at scanline %"PRIu32"; got %"PRId64" bytes, expected %"PRId64, + tif->tif_row, + cc, + size); return ((tmsize_t)(-1)); } } else { @@ -657,21 +626,12 @@ TIFFReadRawStrip1(TIFF* tif, uint32_t strip, void* buf, tmsize_t size, n=size; } if (n!=size) { -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) TIFFErrorExt(tif->tif_clientdata, module, - "Read error at scanline %lu, strip %lu; got %I64u bytes, expected %I64u", - (unsigned long) tif->tif_row, - (unsigned long) strip, - (unsigned __int64) n, - (unsigned __int64) size); -#else - TIFFErrorExt(tif->tif_clientdata, module, - "Read error at scanline %lu, strip %lu; got %llu bytes, expected %llu", - (unsigned long) tif->tif_row, - (unsigned long) strip, - (unsigned long long) n, - (unsigned long long) size); -#endif + "Read error at scanline %"PRIu32", strip %"PRIu32"; got %"PRId64" bytes, expected %"PRId64, + tif->tif_row, + strip, + n, + size); return ((tmsize_t)(-1)); } _TIFFmemcpy(buf, tif->tif_base + ma, @@ -691,17 +651,17 @@ TIFFReadRawStripOrTile2(TIFF* tif, uint32_t strip_or_tile, int is_strip, if( is_strip ) { TIFFErrorExt(tif->tif_clientdata, module, - "Seek error at scanline %lu, strip %lu", - (unsigned long) tif->tif_row, - (unsigned long) strip_or_tile); + "Seek error at scanline %"PRIu32", strip %"PRIu32, + tif->tif_row, + strip_or_tile); } else { TIFFErrorExt(tif->tif_clientdata, module, - "Seek error at row %lu, col %lu, tile %lu", - (unsigned long) tif->tif_row, - (unsigned long) tif->tif_col, - (unsigned long) strip_or_tile); + "Seek error at row %"PRIu32", col %"PRIu32", tile %"PRIu32, + tif->tif_row, + tif->tif_col, + strip_or_tile); } return ((tmsize_t)(-1)); } @@ -730,9 +690,9 @@ TIFFReadRawStrip(TIFF* tif, uint32_t strip, void* buf, tmsize_t size) return ((tmsize_t)(-1)); if (strip >= td->td_nstrips) { TIFFErrorExt(tif->tif_clientdata, module, - "%lu: Strip out of range, max %lu", - (unsigned long) strip, - (unsigned long) td->td_nstrips); + "%"PRIu32": Strip out of range, max %"PRIu32, + strip, + td->td_nstrips); return ((tmsize_t)(-1)); } if (tif->tif_flags&TIFF_NOREADRAW) @@ -772,17 +732,10 @@ TIFFFillStrip(TIFF* tif, uint32_t strip) { uint64_t bytecount = TIFFGetStrileByteCount(tif, strip); if( bytecount == 0 || bytecount > (uint64_t)TIFF_INT64_MAX ) { -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) - TIFFErrorExt(tif->tif_clientdata, module, - "Invalid strip byte count %I64u, strip %lu", - (unsigned __int64) bytecount, - (unsigned long) strip); -#else TIFFErrorExt(tif->tif_clientdata, module, - "Invalid strip byte count %llu, strip %lu", - (unsigned long long) bytecount, - (unsigned long) strip); -#endif + "Invalid strip byte count %"PRIu64", strip %"PRIu32, + bytecount, + strip); return (0); } @@ -800,19 +753,11 @@ TIFFFillStrip(TIFF* tif, uint32_t strip) uint64_t newbytecount = (uint64_t)stripsize * 10 + 4096; if( newbytecount == 0 || newbytecount > (uint64_t)TIFF_INT64_MAX ) { -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) - TIFFWarningExt(tif->tif_clientdata, module, - "Too large strip byte count %I64u, strip %lu. Limiting to %I64u", - (unsigned __int64) bytecount, - (unsigned long) strip, - (unsigned __int64) newbytecount); -#else TIFFErrorExt(tif->tif_clientdata, module, - "Too large strip byte count %llu, strip %lu. Limiting to %llu", - (unsigned long long) bytecount, - (unsigned long) strip, - (unsigned long long) newbytecount); -#endif + "Too large strip byte count %"PRIu64", strip %"PRIu32". Limiting to %"PRIu64, + bytecount, + strip, + newbytecount); bytecount = newbytecount; } } @@ -835,23 +780,13 @@ TIFFFillStrip(TIFF* tif, uint32_t strip) * it's what would happen if a read were done * instead. */ -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) TIFFErrorExt(tif->tif_clientdata, module, - "Read error on strip %lu; " - "got %I64u bytes, expected %I64u", - (unsigned long) strip, - (unsigned __int64) NoSanitizeSubUInt64(tif->tif_size, TIFFGetStrileOffset(tif, strip)), - (unsigned __int64) bytecount); -#else - TIFFErrorExt(tif->tif_clientdata, module, - - "Read error on strip %lu; " - "got %llu bytes, expected %llu", - (unsigned long) strip, - (unsigned long long) NoSanitizeSubUInt64(tif->tif_size, TIFFGetStrileOffset(tif, strip)), - (unsigned long long) bytecount); -#endif + "Read error on strip %"PRIu32"; " + "got %"PRIu64" bytes, expected %"PRIu64, + strip, + NoSanitizeSubUInt64(tif->tif_size, TIFFGetStrileOffset(tif, strip)), + bytecount); tif->tif_curstrip = NOSTRIP; return (0); } @@ -906,8 +841,8 @@ TIFFFillStrip(TIFF* tif, uint32_t strip) tif->tif_curstrip = NOSTRIP; if ((tif->tif_flags & TIFF_MYBUFFER) == 0) { TIFFErrorExt(tif->tif_clientdata, module, - "Data buffer too small to hold strip %lu", - (unsigned long) strip); + "Data buffer too small to hold strip %"PRIu32, + strip); return (0); } } @@ -985,8 +920,8 @@ TIFFReadEncodedTile(TIFF* tif, uint32_t tile, void* buf, tmsize_t size) return ((tmsize_t)(-1)); if (tile >= td->td_nstrips) { TIFFErrorExt(tif->tif_clientdata, module, - "%lu: Tile out of range, max %lu", - (unsigned long) tile, (unsigned long) td->td_nstrips); + "%"PRIu32": Tile out of range, max %"PRIu32, + tile, td->td_nstrips); return ((tmsize_t)(-1)); } @@ -1062,8 +997,8 @@ _TIFFReadEncodedTileAndAllocBuffer(TIFF* tif, uint32_t tile, return ((tmsize_t)(-1)); if (tile >= td->td_nstrips) { TIFFErrorExt(tif->tif_clientdata, module, - "%lu: Tile out of range, max %lu", - (unsigned long) tile, (unsigned long) td->td_nstrips); + "%"PRIu32": Tile out of range, max %"PRIu32, + tile, td->td_nstrips); return ((tmsize_t)(-1)); } @@ -1099,29 +1034,20 @@ TIFFReadRawTile1(TIFF* tif, uint32_t tile, void* buf, tmsize_t size, const char* if (!SeekOK(tif, TIFFGetStrileOffset(tif, tile))) { TIFFErrorExt(tif->tif_clientdata, module, - "Seek error at row %lu, col %lu, tile %lu", - (unsigned long) tif->tif_row, - (unsigned long) tif->tif_col, - (unsigned long) tile); + "Seek error at row %"PRIu32", col %"PRIu32", tile %"PRIu32, + tif->tif_row, + tif->tif_col, + tile); return ((tmsize_t)(-1)); } cc = TIFFReadFile(tif, buf, size); if (cc != size) { -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) - TIFFErrorExt(tif->tif_clientdata, module, - "Read error at row %lu, col %lu; got %I64u bytes, expected %I64u", - (unsigned long) tif->tif_row, - (unsigned long) tif->tif_col, - (unsigned __int64) cc, - (unsigned __int64) size); -#else TIFFErrorExt(tif->tif_clientdata, module, - "Read error at row %lu, col %lu; got %llu bytes, expected %llu", - (unsigned long) tif->tif_row, - (unsigned long) tif->tif_col, - (unsigned long long) cc, - (unsigned long long) size); -#endif + "Read error at row %"PRIu32", col %"PRIu32"; got %"PRId64" bytes, expected %"PRId64, + tif->tif_row, + tif->tif_col, + cc, + size); return ((tmsize_t)(-1)); } } else { @@ -1136,23 +1062,13 @@ TIFFReadRawTile1(TIFF* tif, uint32_t tile, void* buf, tmsize_t size, const char* else n=size; if (n!=size) { -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) - TIFFErrorExt(tif->tif_clientdata, module, -"Read error at row %lu, col %lu, tile %lu; got %I64u bytes, expected %I64u", - (unsigned long) tif->tif_row, - (unsigned long) tif->tif_col, - (unsigned long) tile, - (unsigned __int64) n, - (unsigned __int64) size); -#else TIFFErrorExt(tif->tif_clientdata, module, -"Read error at row %lu, col %lu, tile %lu; got %llu bytes, expected %llu", - (unsigned long) tif->tif_row, - (unsigned long) tif->tif_col, - (unsigned long) tile, - (unsigned long long) n, - (unsigned long long) size); -#endif +"Read error at row %"PRIu32", col %"PRIu32", tile %"PRIu32"; got %"PRId64" bytes, expected %"PRId64, + tif->tif_row, + tif->tif_col, + tile, + n, + size); return ((tmsize_t)(-1)); } _TIFFmemcpy(buf, tif->tif_base + ma, size); @@ -1175,8 +1091,8 @@ TIFFReadRawTile(TIFF* tif, uint32_t tile, void* buf, tmsize_t size) return ((tmsize_t)(-1)); if (tile >= td->td_nstrips) { TIFFErrorExt(tif->tif_clientdata, module, - "%lu: Tile out of range, max %lu", - (unsigned long) tile, (unsigned long) td->td_nstrips); + "%"PRIu32": Tile out of range, max %"PRIu32, + tile, td->td_nstrips); return ((tmsize_t)(-1)); } if (tif->tif_flags&TIFF_NOREADRAW) @@ -1210,17 +1126,10 @@ TIFFFillTile(TIFF* tif, uint32_t tile) { uint64_t bytecount = TIFFGetStrileByteCount(tif, tile); if( bytecount == 0 || bytecount > (uint64_t)TIFF_INT64_MAX ) { -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) TIFFErrorExt(tif->tif_clientdata, module, - "%I64u: Invalid tile byte count, tile %lu", - (unsigned __int64) bytecount, - (unsigned long) tile); -#else - TIFFErrorExt(tif->tif_clientdata, module, - "%llu: Invalid tile byte count, tile %lu", - (unsigned long long) bytecount, - (unsigned long) tile); -#endif + "%"PRIu64": Invalid tile byte count, tile %"PRIu32, + bytecount, + tile); return (0); } @@ -1238,19 +1147,11 @@ TIFFFillTile(TIFF* tif, uint32_t tile) uint64_t newbytecount = (uint64_t)stripsize * 10 + 4096; if( newbytecount == 0 || newbytecount > (uint64_t)TIFF_INT64_MAX ) { -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) - TIFFWarningExt(tif->tif_clientdata, module, - "Too large tile byte count %I64u, tile %lu. Limiting to %I64u", - (unsigned __int64) bytecount, - (unsigned long) tile, - (unsigned __int64) newbytecount); -#else TIFFErrorExt(tif->tif_clientdata, module, - "Too large tile byte count %llu, tile %lu. Limiting to %llu", - (unsigned long long) bytecount, - (unsigned long) tile, - (unsigned long long) newbytecount); -#endif + "Too large tile byte count %"PRIu64", tile %"PRIu32". Limiting to %"PRIu64, + bytecount, + tile, + newbytecount); bytecount = newbytecount; } } @@ -1317,8 +1218,8 @@ TIFFFillTile(TIFF* tif, uint32_t tile) tif->tif_curtile = NOTILE; if ((tif->tif_flags & TIFF_MYBUFFER) == 0) { TIFFErrorExt(tif->tif_clientdata, module, - "Data buffer too small to hold tile %lu", - (unsigned long) tile); + "Data buffer too small to hold tile %"PRIu32, + tile); return (0); } } @@ -1406,8 +1307,8 @@ TIFFReadBufferSetup(TIFF* tif, void* bp, tmsize_t size) } if (tif->tif_rawdata == NULL) { TIFFErrorExt(tif->tif_clientdata, module, - "No space for data buffer at scanline %lu", - (unsigned long) tif->tif_row); + "No space for data buffer at scanline %"PRIu32, + tif->tif_row); tif->tif_rawdatasize = 0; return (0); } diff --git a/test/ascii_tag.c b/test/ascii_tag.c index 9a56d31d..944dd57c 100644 --- a/test/ascii_tag.c +++ b/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/test/check_tag.c b/test/check_tag.c index afbb5ce0..63554866 100644 --- a/test/check_tag.c +++ b/test/check_tag.c @@ -35,13 +35,13 @@ CheckShortField(TIFF *tif, const ttag_t field, const uint16_t value) 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; } @@ -54,13 +54,13 @@ CheckShortPairedField(TIFF *tif, const ttag_t field, const uint16_t *values) 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; } @@ -73,13 +73,13 @@ CheckLongField(TIFF *tif, const ttag_t field, const uint32_t value) 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/test/custom_dir_EXIF_231.c b/test/custom_dir_EXIF_231.c index 94ba6809..a0d78fa1 100644 --- a/test/custom_dir_EXIF_231.c +++ b/test/custom_dir_EXIF_231.c @@ -783,12 +783,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 diff --git a/test/short_tag.c b/test/short_tag.c index feab3b66..89197b02 100644 --- a/test/short_tag.c +++ b/test/short_tag.c @@ -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/test/strip.c b/test/strip.c index 91c34bc1..004a66a2 100644 --- a/test/strip.c +++ b/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; } @@ -169,10 +169,10 @@ 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; @@ -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; @@ -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/tools/fax2tiff.c b/tools/fax2tiff.c index c0a4fec0..f6e433d6 100644 --- a/tools/fax2tiff.c +++ b/tools/fax2tiff.c @@ -336,9 +336,9 @@ main(int argc, char* argv[]) if (verbose) { fprintf(stderr, "%s:\n", argv[optind]); fprintf(stderr, "%d rows in input\n", rows); - fprintf(stderr, "%ld total bad rows\n", - (long) badfaxlines); - fprintf(stderr, "%d max consecutive bad rows\n", badfaxrun); + fprintf(stderr, "%"PRIu32" total bad rows\n", + badfaxlines); + fprintf(stderr, "%"PRIu16" max consecutive bad rows\n", badfaxrun); } if (compression_out == COMPRESSION_CCITTFAX3 && mode == FAXMODE_CLASSF) { @@ -406,15 +406,15 @@ copyFaxFile(TIFF* tifin, TIFF* tifout) tifin->tif_row++; if (TIFFWriteScanline(tifout, rowbuf, row, 0) < 0) { - fprintf(stderr, "%s: Write error at row %ld.\n", - tifout->tif_name, (long) row); + fprintf(stderr, "%s: Write error at row %"PRIu32".\n", + tifout->tif_name, row); break; } row++; if (stretch) { if (TIFFWriteScanline(tifout, rowbuf, row, 0) < 0) { - fprintf(stderr, "%s: Write error at row %ld.\n", - tifout->tif_name, (long) row); + fprintf(stderr, "%s: Write error at row %"PRIu32".\n", + tifout->tif_name, row); break; } row++; diff --git a/tools/ppm2tiff.c b/tools/ppm2tiff.c index 3ca19e8e..976b3d34 100644 --- a/tools/ppm2tiff.c +++ b/tools/ppm2tiff.c @@ -403,8 +403,8 @@ main(int argc, char* argv[]) } for (row = 0; row < h; row++) { if (fread(buf, linebytes, 1, in) != 1) { - fprintf(stderr, "%s: scanline %lu: Read error.\n", - infile, (unsigned long) row); + fprintf(stderr, "%s: scanline %u: Read error.\n", + infile, row); break; } pack_func (buf, w * spp, bpp); diff --git a/tools/raw2tiff.c b/tools/raw2tiff.c index a5ef5b96..11fc96b7 100644 --- a/tools/raw2tiff.c +++ b/tools/raw2tiff.c @@ -292,16 +292,14 @@ main(int argc, char* argv[]) hdr_size + (length*band+row)*linebytes, SEEK_SET) == (_TIFF_off_t)-1) { fprintf(stderr, - "%s: %s: scanline %lu: seek error.\n", - argv[0], argv[optind], - (unsigned long) row); + "%s: %s: scanline %"PRIu32": seek error.\n", + argv[0], argv[optind], row); break; } if (read(fd, buf, linebytes) < 0) { fprintf(stderr, - "%s: %s: scanline %lu: Read error.\n", - argv[0], argv[optind], - (unsigned long) row); + "%s: %s: scanline %"PRIu32": Read error.\n", + argv[0], argv[optind], row); break; } if (swab) /* Swap bytes if needed */ @@ -315,9 +313,8 @@ main(int argc, char* argv[]) default: if (read(fd, buf1, bufsize) < 0) { fprintf(stderr, - "%s: %s: scanline %lu: Read error.\n", - argv[0], argv[optind], - (unsigned long) row); + "%s: %s: scanline %"PRIu32": Read error.\n", + argv[0], argv[optind], row); break; } if (swab) /* Swap bytes if needed */ @@ -326,8 +323,8 @@ main(int argc, char* argv[]) } if (TIFFWriteScanline(out, buf1, row, 0) < 0) { - fprintf(stderr, "%s: %s: scanline %lu: Write error.\n", - argv[0], outfilename, (unsigned long) row); + fprintf(stderr, "%s: %s: scanline %"PRIu32": Write error.\n", + argv[0], outfilename, row); break; } } @@ -391,8 +388,8 @@ guessSize(int fd, TIFFDataType dtype, _TIFF_off_t hdr_size, uint32_t nbands, *length = imagesize / *width; - fprintf(stderr, "Height is guessed as %lu.\n", - (unsigned long)*length); + fprintf(stderr, "Height is guessed as %"PRIu32".\n", + *length); return 1; } else if (*width == 0 && *length != 0) { @@ -400,8 +397,8 @@ guessSize(int fd, TIFFDataType dtype, _TIFF_off_t hdr_size, uint32_t nbands, *width = imagesize / *length; - fprintf(stderr, "Width is guessed as %lu.\n", - (unsigned long)*width); + fprintf(stderr, "Width is guessed as %"PRIu32".\n", + *width); return 1; } else if (*width == 0 && *length == 0) { @@ -473,8 +470,8 @@ guessSize(int fd, TIFFDataType dtype, _TIFF_off_t hdr_size, uint32_t nbands, } fprintf(stderr, - "Width is guessed as %lu, height is guessed as %lu.\n", - (unsigned long)*width, (unsigned long)*length); + "Width is guessed as %"PRIu32", height is guessed as %"PRIu32".\n", + *width, *length); return 1; } else { diff --git a/tools/rgb2ycbcr.c b/tools/rgb2ycbcr.c index 84e6f57a..de23594b 100644 --- a/tools/rgb2ycbcr.c +++ b/tools/rgb2ycbcr.c @@ -304,8 +304,8 @@ tiffcvt(TIFF* in, TIFF* out) if (!width || !height || pixel_count / width != height) { TIFFError(TIFFFileName(in), "Malformed input file; " - "can't allocate buffer for raster of %lux%lu size", - (unsigned long)width, (unsigned long)height); + "can't allocate buffer for raster of %"PRIu32"x%"PRIu32" size", + width, height); return 0; } @@ -313,9 +313,9 @@ tiffcvt(TIFF* in, TIFF* out) "raster buffer"); if (raster == 0) { TIFFError(TIFFFileName(in), - "Failed to allocate buffer (%lu elements of %lu each)", - (unsigned long)pixel_count, - (unsigned long)sizeof(uint32_t)); + "Failed to allocate buffer (%zu elements of %zu each)", + pixel_count, + sizeof(uint32_t)); return (0); } diff --git a/tools/tiff2pdf.c b/tools/tiff2pdf.c index 2a4e40f1..2f3317e2 100644 --- a/tools/tiff2pdf.c +++ b/tools/tiff2pdf.c @@ -956,8 +956,8 @@ T2P* t2p_init() if(t2p==NULL){ TIFFError( TIFF2PDF_MODULE, - "Can't allocate %lu bytes of memory for t2p_init", - (unsigned long) sizeof(T2P)); + "Can't allocate %zu bytes of memory for t2p_init", + sizeof(T2P)); return( (T2P*) NULL ); } _TIFFmemset(t2p, 0x00, sizeof(T2P)); @@ -1037,7 +1037,7 @@ void t2p_validate(T2P* t2p){ t2p->pdf_defaultcompressionquality*=100; TIFFError( TIFF2PDF_MODULE, - "PNG Group predictor differencing not implemented, assuming compression quality %u", + "PNG Group predictor differencing not implemented, assuming compression quality %"PRIu16, t2p->pdf_defaultcompressionquality); } t2p->pdf_defaultcompressionquality%=100; @@ -1081,7 +1081,7 @@ void t2p_read_tiff_init(T2P* t2p, TIFF* input){ TIFFError( TIFF2PDF_MODULE, "Can't allocate %zu bytes of memory for tiff_pages array, %s", - (size_t) directorycount * sizeof(T2P_PAGE), + sizeof(T2P_PAGE) * directorycount, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return; @@ -1091,8 +1091,8 @@ 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", - (size_t) directorycount * sizeof(T2P_TILES), + "Can't allocate %zu bytes of memory for tiff_tiles array, %s", + sizeof(T2P_TILES) * directorycount, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return; @@ -1104,7 +1104,7 @@ void t2p_read_tiff_init(T2P* t2p, TIFF* input){ if(!TIFFSetDirectory(input, i)){ TIFFError( TIFF2PDF_MODULE, - "Can't set directory %u of input file %s", + "Can't set directory %"PRIu16" of input file %s", i, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; @@ -1193,7 +1193,7 @@ void t2p_read_tiff_init(T2P* t2p, TIFF* input){ if (tiff_transferfunctioncount != t2p->tiff_transferfunctioncount){ TIFFError( TIFF2PDF_MODULE, - "Different transfer function on page %d", + "Different transfer function on page %"PRIu16, i); t2p->t2p_error = T2P_ERR_ERROR; return; @@ -1264,8 +1264,8 @@ 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", - (size_t) t2p->tiff_tiles[i].tiles_tilecount * sizeof(T2P_TILE), + "Can't allocate %zu 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; return; @@ -1354,7 +1354,7 @@ void t2p_read_tiff_data(T2P* t2p, TIFF* input){ if( TIFFIsCODECConfigured(t2p->tiff_compression) == 0){ TIFFError( TIFF2PDF_MODULE, - "No support for %s with compression type %u: not configured", + "No support for %s with compression type %"PRIu16": not configured", TIFFFileName(input), t2p->tiff_compression ); @@ -1380,7 +1380,7 @@ void t2p_read_tiff_data(T2P* t2p, TIFF* input){ default: TIFFError( TIFF2PDF_MODULE, - "No support for %s with %u bits per sample", + "No support for %s with %"PRIu16" bits per sample", TIFFFileName(input), t2p->tiff_bitspersample); t2p->t2p_error = T2P_ERR_ERROR; @@ -1391,7 +1391,7 @@ void t2p_read_tiff_data(T2P* t2p, TIFF* input){ if(t2p->tiff_samplesperpixel>4){ TIFFError( TIFF2PDF_MODULE, - "No support for %s with %u samples per pixel", + "No support for %s with %"PRIu16" samples per pixel", TIFFFileName(input), t2p->tiff_samplesperpixel); t2p->t2p_error = T2P_ERR_ERROR; @@ -1414,7 +1414,7 @@ void t2p_read_tiff_data(T2P* t2p, TIFF* input){ default: TIFFError( TIFF2PDF_MODULE, - "No support for %s with sample format %u", + "No support for %s with sample format %"PRIu16, TIFFFileName(input), xuint16); t2p->t2p_error = T2P_ERR_ERROR; @@ -1471,7 +1471,7 @@ void t2p_read_tiff_data(T2P* t2p, TIFF* input){ { TIFFError( TIFF2PDF_MODULE, - "No support for BitsPerSample=%d for RGBA", + "No support for BitsPerSample=%"PRIu16" for RGBA", t2p->tiff_bitspersample); t2p->t2p_error = T2P_ERR_ERROR; return; @@ -1484,7 +1484,7 @@ void t2p_read_tiff_data(T2P* t2p, TIFF* input){ { TIFFError( TIFF2PDF_MODULE, - "No support for BitsPerSample=%d for RGBA", + "No support for BitsPerSample=%"PRIu16" for RGBA", t2p->tiff_bitspersample); t2p->t2p_error = T2P_ERR_ERROR; return; @@ -1508,7 +1508,7 @@ void t2p_read_tiff_data(T2P* t2p, TIFF* input){ } else { TIFFError( TIFF2PDF_MODULE, - "No support for RGB image %s with %u samples per pixel", + "No support for RGB image %s with %"PRIu16" samples per pixel", TIFFFileName(input), t2p->tiff_samplesperpixel); t2p->t2p_error = T2P_ERR_ERROR; @@ -1517,7 +1517,7 @@ void t2p_read_tiff_data(T2P* t2p, TIFF* input){ } else { TIFFError( TIFF2PDF_MODULE, - "No support for RGB image %s with %u samples per pixel", + "No support for RGB image %s with %"PRIu16" samples per pixel", TIFFFileName(input), t2p->tiff_samplesperpixel); t2p->t2p_error = T2P_ERR_ERROR; @@ -1559,7 +1559,7 @@ void t2p_read_tiff_data(T2P* t2p, TIFF* input){ if(t2p->pdf_palette==NULL){ TIFFError( TIFF2PDF_MODULE, - "Can't allocate %u bytes of memory for t2p_read_tiff_image, %s", + "Can't allocate %"PRIu16" bytes of memory for t2p_read_tiff_image, %s", t2p->pdf_palettesize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; @@ -1593,7 +1593,7 @@ void t2p_read_tiff_data(T2P* t2p, TIFF* input){ } else { TIFFError( TIFF2PDF_MODULE, - "No support for %s because it has %u samples per pixel", + "No support for %s because it has %"PRIu16" samples per pixel", TIFFFileName(input), t2p->tiff_samplesperpixel); t2p->t2p_error = T2P_ERR_ERROR; @@ -1635,7 +1635,7 @@ void t2p_read_tiff_data(T2P* t2p, TIFF* input){ if(t2p->pdf_palette==NULL){ TIFFError( TIFF2PDF_MODULE, - "Can't allocate %u bytes of memory for t2p_read_tiff_image, %s", + "Can't allocate %"PRIu16" bytes of memory for t2p_read_tiff_image, %s", t2p->pdf_palettesize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; @@ -1667,7 +1667,7 @@ void t2p_read_tiff_data(T2P* t2p, TIFF* input){ if( t2p->tiff_samplesperpixel != 3){ TIFFError( TIFF2PDF_MODULE, - "Unsupported samplesperpixel = %d for CIELAB", + "Unsupported samplesperpixel = %"PRIu16" for CIELAB", t2p->tiff_samplesperpixel); t2p->t2p_error = T2P_ERR_ERROR; return; @@ -1675,7 +1675,7 @@ void t2p_read_tiff_data(T2P* t2p, TIFF* input){ if( t2p->tiff_bitspersample != 8){ TIFFError( TIFF2PDF_MODULE, - "Invalid bitspersample = %d for CIELAB", + "Invalid bitspersample = %"PRIu16" for CIELAB", t2p->tiff_bitspersample); t2p->t2p_error = T2P_ERR_ERROR; return; @@ -1698,7 +1698,7 @@ void t2p_read_tiff_data(T2P* t2p, TIFF* input){ if( t2p->tiff_samplesperpixel != 3){ TIFFError( TIFF2PDF_MODULE, - "Unsupported samplesperpixel = %d for ITULAB", + "Unsupported samplesperpixel = %"PRIu16" for ITULAB", t2p->tiff_samplesperpixel); t2p->t2p_error = T2P_ERR_ERROR; return; @@ -1706,7 +1706,7 @@ void t2p_read_tiff_data(T2P* t2p, TIFF* input){ if( t2p->tiff_bitspersample != 8){ TIFFError( TIFF2PDF_MODULE, - "Invalid bitspersample = %d for ITULAB", + "Invalid bitspersample = %"PRIu16" for ITULAB", t2p->tiff_bitspersample); t2p->t2p_error = T2P_ERR_ERROR; return; @@ -1729,7 +1729,7 @@ void t2p_read_tiff_data(T2P* t2p, TIFF* input){ default: TIFFError( TIFF2PDF_MODULE, - "No support for %s with photometric interpretation %u", + "No support for %s with photometric interpretation %"PRIu16, TIFFFileName(input), t2p->tiff_photometric); t2p->t2p_error = T2P_ERR_ERROR; @@ -1751,7 +1751,7 @@ void t2p_read_tiff_data(T2P* t2p, TIFF* input){ if(t2p->tiff_bitspersample!=8){ TIFFError( TIFF2PDF_MODULE, - "No support for %s with separated planar configuration and %u bits per sample", + "No support for %s with separated planar configuration and %"PRIu16" bits per sample", TIFFFileName(input), t2p->tiff_bitspersample); t2p->t2p_error = T2P_ERR_ERROR; @@ -1761,7 +1761,7 @@ void t2p_read_tiff_data(T2P* t2p, TIFF* input){ default: TIFFError( TIFF2PDF_MODULE, - "No support for %s with planar configuration %u", + "No support for %s with planar configuration %"PRIu16, TIFFFileName(input), t2p->tiff_planar); t2p->t2p_error = T2P_ERR_ERROR; @@ -1773,7 +1773,7 @@ void t2p_read_tiff_data(T2P* t2p, TIFF* input){ &(t2p->tiff_orientation)); if(t2p->tiff_orientation>8){ TIFFWarning(TIFF2PDF_MODULE, - "Image %s has orientation %u, assuming 0", + "Image %s has orientation %"PRIu16", assuming 0", TIFFFileName(input), t2p->tiff_orientation); t2p->tiff_orientation=0; } @@ -2262,9 +2262,9 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ _TIFFmalloc(t2p->tiff_datasize); if (buffer == NULL) { TIFFError(TIFF2PDF_MODULE, - "Can't allocate %lu bytes of memory for " + "Can't allocate %"PRId64" bytes of memory for " "t2p_readwrite_pdf_image, %s", - (unsigned long) t2p->tiff_datasize, + t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return(0); @@ -2297,8 +2297,8 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ _TIFFmalloc(t2p->tiff_datasize); if(buffer == NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %lu bytes of memory for t2p_readwrite_pdf_image, %s", - (unsigned long) t2p->tiff_datasize, + "Can't allocate %"PRId64" bytes of memory for t2p_readwrite_pdf_image, %s", + t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return(0); @@ -2329,8 +2329,8 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ _TIFFmalloc(t2p->tiff_datasize); if(buffer == NULL) { TIFFError(TIFF2PDF_MODULE, - "Can't allocate %lu bytes of memory for t2p_readwrite_pdf_image, %s", - (unsigned long) t2p->tiff_datasize, + "Can't allocate %"PRId64" bytes of memory for t2p_readwrite_pdf_image, %s", + t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return(0); @@ -2405,8 +2405,8 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ _TIFFmalloc(t2p->tiff_datasize); if(buffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %lu bytes of memory for t2p_readwrite_pdf_image, %s", - (unsigned long) t2p->tiff_datasize, + "Can't allocate %"PRId64" bytes of memory for t2p_readwrite_pdf_image, %s", + t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return(0); @@ -2461,8 +2461,8 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ _TIFFmalloc(t2p->tiff_datasize); if(buffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %lu bytes of memory for t2p_readwrite_pdf_image, %s", - (unsigned long) t2p->tiff_datasize, + "Can't allocate %"PRId64" bytes of memory for t2p_readwrite_pdf_image, %s", + t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return(0); @@ -2483,7 +2483,7 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ _TIFFmalloc(max_striplength); if(stripbuffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %u bytes of memory for t2p_readwrite_pdf_image, %s", + "Can't allocate %"PRId32" bytes of memory for t2p_readwrite_pdf_image, %s", max_striplength, TIFFFileName(input)); _TIFFfree(buffer); @@ -2531,8 +2531,8 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ buffer = (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); if(buffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %lu bytes of memory for t2p_readwrite_pdf_image, %s", - (unsigned long) t2p->tiff_datasize, + "Can't allocate %"PRId64" bytes of memory for t2p_readwrite_pdf_image, %s", + t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return(0); @@ -2548,7 +2548,7 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ TIFFmin(stripsize, t2p->tiff_datasize - bufferoffset)); if(read==-1){ TIFFError(TIFF2PDF_MODULE, - "Error on decoding strip %u of %s", + "Error on decoding strip %"PRIu32" of %s", i, TIFFFileName(input)); _TIFFfree(buffer); @@ -2569,8 +2569,8 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ buffer = (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); if(buffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %lu bytes of memory for t2p_readwrite_pdf_image, %s", - (unsigned long) t2p->tiff_datasize, + "Can't allocate %"PRId64" bytes of memory for t2p_readwrite_pdf_image, %s", + t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return(0); @@ -2579,8 +2579,8 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ samplebuffer = (unsigned char*) _TIFFmalloc(stripsize); if(samplebuffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %lu bytes of memory for t2p_readwrite_pdf_image, %s", - (unsigned long) t2p->tiff_datasize, + "Can't allocate %"PRId64" bytes of memory for t2p_readwrite_pdf_image, %s", + t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; _TIFFfree(buffer); @@ -2596,7 +2596,7 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ TIFFmin(sepstripsize, stripsize - samplebufferoffset)); if(read==-1){ TIFFError(TIFF2PDF_MODULE, - "Error on decoding strip %u of %s", + "Error on decoding strip %"PRIu32" of %s", i + j*stripcount, TIFFFileName(input)); _TIFFfree(buffer); @@ -2619,8 +2619,8 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ buffer = (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); if(buffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %lu bytes of memory for t2p_readwrite_pdf_image, %s", - (unsigned long) t2p->tiff_datasize, + "Can't allocate %"PRId64" bytes of memory for t2p_readwrite_pdf_image, %s", + t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return(0); @@ -2636,7 +2636,7 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ TIFFmin(stripsize, t2p->tiff_datasize - bufferoffset)); if(read==-1){ TIFFError(TIFF2PDF_MODULE, - "Error on decoding strip %u of %s", + "Error on decoding strip %"PRIu32" of %s", i, TIFFFileName(input)); _TIFFfree(samplebuffer); @@ -2654,8 +2654,8 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ t2p->tiff_datasize * t2p->tiff_samplesperpixel); if(samplebuffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %lu bytes of memory for t2p_readwrite_pdf_image, %s", - (unsigned long) t2p->tiff_datasize, + "Can't allocate %"PRId64" bytes of memory for t2p_readwrite_pdf_image, %s", + t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; _TIFFfree(buffer); @@ -2685,8 +2685,8 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ t2p->tiff_width*t2p->tiff_length*4); if(samplebuffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %lu bytes of memory for t2p_readwrite_pdf_image, %s", - (unsigned long) t2p->tiff_datasize, + "Can't allocate %"PRId64" bytes of memory for t2p_readwrite_pdf_image, %s", + t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; _TIFFfree(buffer); @@ -2882,9 +2882,9 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_ buffer= (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); if(buffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %lu bytes of memory " + "Can't allocate %"PRId64" bytes of memory " "for t2p_readwrite_pdf_image_tile, %s", - (unsigned long) t2p->tiff_datasize, + t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return(0); @@ -2910,9 +2910,9 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_ buffer= (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); if(buffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %lu bytes of memory " + "Can't allocate %"PRId64" bytes of memory " "for t2p_readwrite_pdf_image_tile, %s", - (unsigned long) t2p->tiff_datasize, + t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return(0); @@ -2947,9 +2947,9 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_ buffer=(unsigned char*) _TIFFmalloc(t2p->tiff_datasize); if(buffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %lu bytes of memory " + "Can't allocate %"PRId64" bytes of memory " "for t2p_readwrite_pdf_image, %s", - (unsigned long) t2p->tiff_datasize, + t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return(0); @@ -2995,9 +2995,9 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_ buffer= (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); if(buffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %zu bytes of memory " + "Can't allocate %"PRId64" bytes of memory " "for t2p_readwrite_pdf_image_tile, %s", - (size_t) t2p->tiff_datasize, + t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return(0); @@ -3044,9 +3044,9 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_ buffer = (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); if(buffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %lu bytes of memory for " + "Can't allocate %"PRId64" bytes of memory for " "t2p_readwrite_pdf_image_tile, %s", - (unsigned long) t2p->tiff_datasize, + t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return(0); @@ -3060,7 +3060,7 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_ t2p->tiff_datasize); if(read==-1){ TIFFError(TIFF2PDF_MODULE, - "Error on decoding tile %u of %s", + "Error on decoding tile %"PRIu32" of %s", tile, TIFFFileName(input)); _TIFFfree(buffer); @@ -3078,9 +3078,9 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_ buffer = (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); if(buffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %lu bytes of memory " + "Can't allocate %"PRId64" bytes of memory " "for t2p_readwrite_pdf_image_tile, %s", - (unsigned long) t2p->tiff_datasize, + t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return(0); @@ -3089,9 +3089,9 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_ samplebuffer = (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); if(samplebuffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %lu bytes of memory " + "Can't allocate %"PRId64" bytes of memory " "for t2p_readwrite_pdf_image_tile, %s", - (unsigned long) t2p->tiff_datasize, + t2p->tiff_datasize, TIFFFileName(input)); _TIFFfree(buffer); t2p->t2p_error = T2P_ERR_ERROR; @@ -3107,7 +3107,7 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_ septilesize); if(read==-1){ TIFFError(TIFF2PDF_MODULE, - "Error on decoding tile %u of %s", + "Error on decoding tile %"PRIu32" of %s", tile + i*tilecount, TIFFFileName(input)); _TIFFfree(samplebuffer); @@ -3130,9 +3130,9 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_ buffer = (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); if(buffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %lu bytes of memory " + "Can't allocate %"PRId64" bytes of memory " "for t2p_readwrite_pdf_image_tile, %s", - (unsigned long) t2p->tiff_datasize, + t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return(0); @@ -3145,7 +3145,7 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_ t2p->tiff_datasize); if(read==-1){ TIFFError(TIFF2PDF_MODULE, - "Error on decoding tile %u of %s", + "Error on decoding tile %"PRIu32" of %s", tile, TIFFFileName(input)); _TIFFfree(buffer); @@ -3426,7 +3426,7 @@ int t2p_process_ojpeg_tables(T2P* t2p, TIFF* input){ if(t2p->pdf_ojpegdata == NULL){ TIFFError(TIFF2PDF_MODULE, "Can't allocate %u bytes of memory for t2p_process_ojpeg_tables, %s", - 2048, + 2048u, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return(0); @@ -3915,9 +3915,9 @@ tsize_t t2p_write_pdf_header(T2P* t2p, TIFF* output){ char buffer[16]; int buflen=0; - buflen = snprintf(buffer, sizeof(buffer), "%%PDF-%u.%u ", - t2p->pdf_majorversion&0xff, - t2p->pdf_minorversion&0xff); + buflen = snprintf(buffer, sizeof(buffer), "%%PDF-%"PRIu16".%"PRIu16" ", + (uint16_t) (t2p->pdf_majorversion&0xff), + (uint16_t) (t2p->pdf_minorversion&0xff)); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t)"\n%\342\343\317\323\n", 7); @@ -3935,7 +3935,7 @@ tsize_t t2p_write_pdf_obj_start(uint32_t number, TIFF* output){ char buffer[32]; int buflen=0; - buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)number); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu32, number); check_snprintf_ret((T2P*)NULL, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen ); written += t2pWriteFile(output, (tdata_t) " 0 obj\n", 7); @@ -4161,7 +4161,7 @@ tsize_t t2p_write_pdf_stream_dict(tsize_t len, uint32_t number, TIFF* output){ if(len!=0){ written += t2p_write_pdf_stream_length(len, output); } else { - buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)number); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu32, number); check_snprintf_ret((T2P*)NULL, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) " 0 R \n", 6); @@ -4206,7 +4206,7 @@ tsize_t t2p_write_pdf_stream_length(tsize_t len, TIFF* output){ char buffer[32]; int buflen=0; - buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)len); + buflen=snprintf(buffer, sizeof(buffer), "%"PRId64, len); check_snprintf_ret((T2P*)NULL, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) "\n", 1); @@ -4227,7 +4227,7 @@ tsize_t t2p_write_pdf_catalog(T2P* t2p, TIFF* output) written += t2pWriteFile(output, (tdata_t)"<< \n/Type /Catalog \n/Pages ", 27); - buflen = snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)t2p->pdf_pages); + buflen = snprintf(buffer, sizeof(buffer), "%"PRIu32, t2p->pdf_pages); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, TIFFmin((size_t)buflen, sizeof(buffer) - 1)); @@ -4416,7 +4416,7 @@ tsize_t t2p_write_pdf_pages(T2P* t2p, TIFF* output) } } written += t2pWriteFile(output, (tdata_t) "] \n/Count ", 10); - buflen=snprintf(buffer, sizeof(buffer), "%d", t2p->tiff_pagecount); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu16, t2p->tiff_pagecount); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) " \n>> \n", 6); @@ -4436,7 +4436,7 @@ tsize_t t2p_write_pdf_page(uint32_t object, T2P* t2p, TIFF* output){ int buflen=0; written += t2pWriteFile(output, (tdata_t) "<<\n/Type /Page \n/Parent ", 24); - buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)t2p->pdf_pages); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu32, t2p->pdf_pages); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) " 0 R \n", 6); @@ -4458,7 +4458,7 @@ tsize_t t2p_write_pdf_page(uint32_t object, T2P* t2p, TIFF* output){ written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) "] \n", 3); written += t2pWriteFile(output, (tdata_t) "/Contents ", 10); - buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)(object + 1)); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu32, object + 1u); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) " 0 R \n", 6); @@ -4467,16 +4467,16 @@ tsize_t t2p_write_pdf_page(uint32_t object, T2P* t2p, TIFF* output){ written += t2pWriteFile(output, (tdata_t) "/XObject <<\n", 12); for(i=0;i<t2p->tiff_tiles[t2p->pdf_page].tiles_tilecount;i++){ written += t2pWriteFile(output, (tdata_t) "/Im", 3); - buflen = snprintf(buffer, sizeof(buffer), "%u", t2p->pdf_page+1); + buflen = snprintf(buffer, sizeof(buffer), "%"PRIu16, (uint16_t)(t2p->pdf_page+1u)); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) "_", 1); - buflen = snprintf(buffer, sizeof(buffer), "%u", i+1); + buflen = snprintf(buffer, sizeof(buffer), "%u", i+1u); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) " ", 1); - buflen = snprintf(buffer, sizeof(buffer), "%lu", - (unsigned long)(object+3+(2*i)+t2p->tiff_pages[t2p->pdf_page].page_extra)); + buflen = snprintf(buffer, sizeof(buffer), "%"PRIu32, + object+3u+(2u*i)+t2p->tiff_pages[t2p->pdf_page].page_extra); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) " 0 R ", 5); @@ -4488,12 +4488,12 @@ tsize_t t2p_write_pdf_page(uint32_t object, T2P* t2p, TIFF* output){ } else { written += t2pWriteFile(output, (tdata_t) "/XObject <<\n", 12); written += t2pWriteFile(output, (tdata_t) "/Im", 3); - buflen = snprintf(buffer, sizeof(buffer), "%u", t2p->pdf_page+1); + buflen = snprintf(buffer, sizeof(buffer), "%"PRIu16, (uint16_t)(t2p->pdf_page+1u)); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) " ", 1); - buflen = snprintf(buffer, sizeof(buffer), "%lu", - (unsigned long)(object+3+(2*i)+t2p->tiff_pages[t2p->pdf_page].page_extra)); + buflen = snprintf(buffer, sizeof(buffer), "%"PRIu32, + object+3u+(2u*i)+t2p->tiff_pages[t2p->pdf_page].page_extra); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) " 0 R ", 5); @@ -4502,8 +4502,8 @@ tsize_t t2p_write_pdf_page(uint32_t object, T2P* t2p, TIFF* output){ if(t2p->tiff_transferfunctioncount != 0) { written += t2pWriteFile(output, (tdata_t) "/ExtGState <<", 13); t2pWriteFile(output, (tdata_t) "/GS1 ", 5); - buflen = snprintf(buffer, sizeof(buffer), "%lu", - (unsigned long)(object + 3)); + buflen = snprintf(buffer, sizeof(buffer), "%"PRIu32, + object + 3u); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) " 0 R ", 5); @@ -4886,7 +4886,7 @@ tsize_t t2p_write_pdf_page_content_stream(T2P* t2p, TIFF* output){ for(i=0;i<t2p->tiff_tiles[t2p->pdf_page].tiles_tilecount; i++){ box=t2p->tiff_tiles[t2p->pdf_page].tiles_tiles[i].tile_box; buflen=snprintf(buffer, sizeof(buffer), - "q %s %.4f %.4f %.4f %.4f %.4f %.4f cm /Im%d_%ld Do Q\n", + "q %s %.4f %.4f %.4f %.4f %.4f %.4f cm /Im%"PRIu16"_%"PRIu32" Do Q\n", t2p->tiff_transferfunctioncount?"/GS1 gs ":"", box.mat[0], box.mat[1], @@ -4894,15 +4894,15 @@ tsize_t t2p_write_pdf_page_content_stream(T2P* t2p, TIFF* output){ box.mat[4], box.mat[6], box.mat[7], - t2p->pdf_page + 1, - (long)(i + 1)); + (uint16_t)(t2p->pdf_page + 1u), + i + 1u); check_snprintf_ret(t2p, buflen, buffer); written += t2p_write_pdf_stream(buffer, buflen, output); } } else { box=t2p->pdf_imagebox; buflen=snprintf(buffer, sizeof(buffer), - "q %s %.4f %.4f %.4f %.4f %.4f %.4f cm /Im%d Do Q\n", + "q %s %.4f %.4f %.4f %.4f %.4f %.4f cm /Im%"PRIu16" Do Q\n", t2p->tiff_transferfunctioncount?"/GS1 gs ":"", box.mat[0], box.mat[1], @@ -4910,7 +4910,7 @@ tsize_t t2p_write_pdf_page_content_stream(T2P* t2p, TIFF* output){ box.mat[4], box.mat[6], box.mat[7], - t2p->pdf_page+1); + (uint16_t)(t2p->pdf_page+1u)); check_snprintf_ret(t2p, buflen, buffer); written += t2p_write_pdf_stream(buffer, buflen, output); } @@ -4934,45 +4934,45 @@ tsize_t t2p_write_pdf_xobject_stream_dict(ttile_t tile, written += t2pWriteFile(output, (tdata_t) "/Type /XObject \n/Subtype /Image \n/Name /Im", 42); - buflen=snprintf(buffer, sizeof(buffer), "%u", t2p->pdf_page+1); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu16, (uint16_t)(t2p->pdf_page+1u)); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); if(tile != 0){ written += t2pWriteFile(output, (tdata_t) "_", 1); - buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)tile); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu32, tile); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); } written += t2pWriteFile(output, (tdata_t) "\n/Width ", 8); if(tile==0){ - buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)t2p->tiff_width); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu32, t2p->tiff_width); } else { if(t2p_tile_is_right_edge(t2p->tiff_tiles[t2p->pdf_page], tile-1)!=0){ - buflen=snprintf(buffer, sizeof(buffer), "%lu", - (unsigned long)t2p->tiff_tiles[t2p->pdf_page].tiles_edgetilewidth); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu32, + t2p->tiff_tiles[t2p->pdf_page].tiles_edgetilewidth); } else { - buflen=snprintf(buffer, sizeof(buffer), "%lu", - (unsigned long)t2p->tiff_tiles[t2p->pdf_page].tiles_tilewidth); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu32, + t2p->tiff_tiles[t2p->pdf_page].tiles_tilewidth); } } check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) "\n/Height ", 9); if(tile==0){ - buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)t2p->tiff_length); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu32, t2p->tiff_length); } else { if(t2p_tile_is_bottom_edge(t2p->tiff_tiles[t2p->pdf_page], tile-1)!=0){ - buflen=snprintf(buffer, sizeof(buffer), "%lu", - (unsigned long)t2p->tiff_tiles[t2p->pdf_page].tiles_edgetilelength); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu32, + t2p->tiff_tiles[t2p->pdf_page].tiles_edgetilelength); } else { - buflen=snprintf(buffer, sizeof(buffer), "%lu", - (unsigned long)t2p->tiff_tiles[t2p->pdf_page].tiles_tilelength); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu32, + t2p->tiff_tiles[t2p->pdf_page].tiles_tilelength); } } check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) "\n/BitsPerComponent ", 19); - buflen=snprintf(buffer, sizeof(buffer), "%u", t2p->tiff_bitspersample); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu16, t2p->tiff_bitspersample); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) "\n/ColorSpace ", 13); @@ -5027,11 +5027,11 @@ tsize_t t2p_write_pdf_xobject_cs(T2P* t2p, TIFF* output){ t2p->pdf_colorspace ^= T2P_CS_PALETTE; written += t2p_write_pdf_xobject_cs(t2p, output); t2p->pdf_colorspace |= T2P_CS_PALETTE; - buflen=snprintf(buffer, sizeof(buffer), "%u", (0x0001 << t2p->tiff_bitspersample)-1 ); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu32, (uint32_t)(0x1u << t2p->tiff_bitspersample)-1u ); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) " ", 1); - buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)t2p->pdf_palettecs ); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu32, t2p->pdf_palettecs ); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) " 0 R ]\n", 7); @@ -5090,25 +5090,25 @@ tsize_t t2p_write_pdf_transfer(T2P* t2p, TIFF* output){ written += t2pWriteFile(output, (tdata_t) "<< /Type /ExtGState \n/TR ", 25); if(t2p->tiff_transferfunctioncount == 1){ - buflen=snprintf(buffer, sizeof(buffer), "%lu", - (unsigned long)(t2p->pdf_xrefcount + 1)); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu32, + t2p->pdf_xrefcount + 1u); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) " 0 R ", 5); } else { written += t2pWriteFile(output, (tdata_t) "[ ", 2); - buflen=snprintf(buffer, sizeof(buffer), "%lu", - (unsigned long)(t2p->pdf_xrefcount + 1)); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu32, + t2p->pdf_xrefcount + 1u); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) " 0 R ", 5); - buflen=snprintf(buffer, sizeof(buffer), "%lu", - (unsigned long)(t2p->pdf_xrefcount + 2)); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu32, + t2p->pdf_xrefcount + 2u); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) " 0 R ", 5); - buflen=snprintf(buffer, sizeof(buffer), "%lu", - (unsigned long)(t2p->pdf_xrefcount + 3)); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu32, + t2p->pdf_xrefcount + 3u); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) " 0 R ", 5); @@ -5130,7 +5130,7 @@ tsize_t t2p_write_pdf_transfer_dict(T2P* t2p, TIFF* output, uint16_t i){ written += t2pWriteFile(output, (tdata_t) "/FunctionType 0 \n", 17); written += t2pWriteFile(output, (tdata_t) "/Domain [0.0 1.0] \n", 19); written += t2pWriteFile(output, (tdata_t) "/Range [0.0 1.0] \n", 18); - buflen=snprintf(buffer, sizeof(buffer), "/Size [%u] \n", (1<<t2p->tiff_bitspersample)); + buflen=snprintf(buffer, sizeof(buffer), "/Size [%"PRIu16"] \n", (uint16_t)(1u<<t2p->tiff_bitspersample)); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) "/BitsPerSample 16 \n", 19); @@ -5257,7 +5257,7 @@ tsize_t t2p_write_pdf_xobject_icccs(T2P* t2p, TIFF* output){ int buflen=0; written += t2pWriteFile(output, (tdata_t) "[/ICCBased ", 11); - buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)t2p->pdf_icccs); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu32, t2p->pdf_icccs); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) " 0 R] \n", 7); @@ -5272,7 +5272,7 @@ tsize_t t2p_write_pdf_xobject_icccs_dict(T2P* t2p, TIFF* output){ int buflen=0; written += t2pWriteFile(output, (tdata_t) "/N ", 3); - buflen=snprintf(buffer, sizeof(buffer), "%u \n", t2p->tiff_samplesperpixel); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu16" \n", t2p->tiff_samplesperpixel); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) "/Alternate ", 11); @@ -5353,39 +5353,39 @@ tsize_t t2p_write_pdf_xobject_stream_filter(ttile_t tile, T2P* t2p, TIFF* output written += t2pWriteFile(output, (tdata_t) "<< /K -1 ", 9); if(tile==0){ written += t2pWriteFile(output, (tdata_t) "/Columns ", 9); - buflen=snprintf(buffer, sizeof(buffer), "%lu", - (unsigned long)t2p->tiff_width); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu32, + t2p->tiff_width); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) " /Rows ", 7); - buflen=snprintf(buffer, sizeof(buffer), "%lu", - (unsigned long)t2p->tiff_length); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu32, + t2p->tiff_length); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); } else { if(t2p_tile_is_right_edge(t2p->tiff_tiles[t2p->pdf_page], tile-1)==0){ written += t2pWriteFile(output, (tdata_t) "/Columns ", 9); - buflen=snprintf(buffer, sizeof(buffer), "%lu", - (unsigned long)t2p->tiff_tiles[t2p->pdf_page].tiles_tilewidth); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu32, + t2p->tiff_tiles[t2p->pdf_page].tiles_tilewidth); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); } else { written += t2pWriteFile(output, (tdata_t) "/Columns ", 9); - buflen=snprintf(buffer, sizeof(buffer), "%lu", - (unsigned long)t2p->tiff_tiles[t2p->pdf_page].tiles_edgetilewidth); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu32, + t2p->tiff_tiles[t2p->pdf_page].tiles_edgetilewidth); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); } if(t2p_tile_is_bottom_edge(t2p->tiff_tiles[t2p->pdf_page], tile-1)==0){ written += t2pWriteFile(output, (tdata_t) " /Rows ", 7); - buflen=snprintf(buffer, sizeof(buffer), "%lu", - (unsigned long)t2p->tiff_tiles[t2p->pdf_page].tiles_tilelength); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu32, + t2p->tiff_tiles[t2p->pdf_page].tiles_tilelength); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); } else { written += t2pWriteFile(output, (tdata_t) " /Rows ", 7); - buflen=snprintf(buffer, sizeof(buffer), "%lu", - (unsigned long)t2p->tiff_tiles[t2p->pdf_page].tiles_edgetilelength); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu32, + t2p->tiff_tiles[t2p->pdf_page].tiles_edgetilelength); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); } @@ -5412,20 +5412,20 @@ tsize_t t2p_write_pdf_xobject_stream_filter(ttile_t tile, T2P* t2p, TIFF* output if(t2p->pdf_compressionquality%100){ written += t2pWriteFile(output, (tdata_t) "/DecodeParms ", 13); written += t2pWriteFile(output, (tdata_t) "<< /Predictor ", 14); - buflen=snprintf(buffer, sizeof(buffer), "%u", t2p->pdf_compressionquality%100); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu16, (uint16_t)(t2p->pdf_compressionquality % 100u)); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) " /Columns ", 10); - buflen = snprintf(buffer, sizeof(buffer), "%lu", - (unsigned long)t2p->tiff_width); + buflen = snprintf(buffer, sizeof(buffer), "%"PRIu32, + t2p->tiff_width); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) " /Colors ", 9); - buflen=snprintf(buffer, sizeof(buffer), "%u", t2p->tiff_samplesperpixel); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu16, t2p->tiff_samplesperpixel); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) " /BitsPerComponent ", 19); - buflen=snprintf(buffer, sizeof(buffer), "%u", t2p->tiff_bitspersample); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu16, t2p->tiff_bitspersample); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) ">>\n", 3); @@ -5451,7 +5451,7 @@ tsize_t t2p_write_pdf_xreftable(T2P* t2p, TIFF* output){ uint32_t i=0; written += t2pWriteFile(output, (tdata_t) "xref\n0 ", 7); - buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)(t2p->pdf_xrefcount + 1)); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu32, t2p->pdf_xrefcount + 1u); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) " \n0000000000 65535 f \n", 22); @@ -5480,15 +5480,15 @@ tsize_t t2p_write_pdf_trailer(T2P* t2p, TIFF* output) snprintf(t2p->pdf_fileid + i, 9, "%.8X", rand()); written += t2pWriteFile(output, (tdata_t) "trailer\n<<\n/Size ", 17); - buflen = snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)(t2p->pdf_xrefcount+1)); + buflen = snprintf(buffer, sizeof(buffer), "%"PRIu32, t2p->pdf_xrefcount+1u); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) "\n/Root ", 7); - buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)t2p->pdf_catalog); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu32, t2p->pdf_catalog); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) " 0 R \n/Info ", 12); - buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)t2p->pdf_info); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu32, t2p->pdf_info); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) " 0 R \n/ID[<", 11); @@ -5498,7 +5498,7 @@ tsize_t t2p_write_pdf_trailer(T2P* t2p, TIFF* output) written += t2pWriteFile(output, (tdata_t) t2p->pdf_fileid, sizeof(t2p->pdf_fileid) - 1); written += t2pWriteFile(output, (tdata_t) ">]\n>>\nstartxref\n", 16); - buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)t2p->pdf_startxref); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu32, t2p->pdf_startxref); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) "\n%%EOF\n", 7); @@ -5559,8 +5559,8 @@ tsize_t t2p_write_pdf(T2P* t2p, TIFF* input, TIFF* output){ if(t2p->pdf_xrefoffsets==NULL){ TIFFError( TIFF2PDF_MODULE, - "Can't allocate %u bytes of memory for t2p_write_pdf", - (unsigned int) (t2p->pdf_xrefcount * sizeof(uint32_t)) ); + "Can't allocate %zu 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/tiff2ps.c b/tools/tiff2ps.c index 4bbd7d90..3a653072 100644 --- a/tools/tiff2ps.c +++ b/tools/tiff2ps.c @@ -170,9 +170,6 @@ #define EXP_ASCII85ENCODER -/* - * NB: this code assumes uint32_t works with printf's %l[ud]. - */ #ifndef TRUE #define TRUE 1 #define FALSE 0 @@ -250,8 +247,8 @@ static void usage(int); static void* limitMalloc(tmsize_t s) { if (maxMalloc && (s > maxMalloc)) { - fprintf(stderr, "MemoryLimitError: allocation of %" PRIu64 " bytes is forbidden. Limit is %" PRIu64 ".\n", - (uint64_t)s, (uint64_t)maxMalloc); + fprintf(stderr, "MemoryLimitError: allocation of %" PRId64 " bytes is forbidden. Limit is %" PRId64 ".\n", + s, maxMalloc); fprintf(stderr, " use -M option to change limit.\n"); return NULL; } @@ -549,7 +546,7 @@ checkImage(TIFF* tif) case PHOTOMETRIC_RGB: if (alpha && bitspersample != 8) { TIFFError(filename, - "Can not handle %d-bit/sample RGB image with alpha", + "Can not handle %"PRIu16"-bit/sample RGB image with alpha", bitspersample); return (0); } @@ -580,7 +577,7 @@ checkImage(TIFF* tif) /* fall through... */ default: TIFFError(filename, - "Can not handle image with PhotometricInterpretation=%d", + "Can not handle image with PhotometricInterpretation=%"PRIu16, photometric); return (0); } @@ -590,7 +587,7 @@ checkImage(TIFF* tif) case 16: break; default: - TIFFError(filename, "Can not handle %d-bit/sample image", + TIFFError(filename, "Can not handle %"PRIu16"-bit/sample image", bitspersample); return (0); } @@ -634,8 +631,8 @@ static const char RGBcolorimage[] = "\ static void PhotoshopBanner(FILE* fd, uint32_t w, uint32_t h, int bs, int nc, char* startline) { - fprintf(fd, "%%ImageData: %ld %ld %d %d 0 %d 2 \"", - (long) w, (long) h, bitspersample, nc, bs); + fprintf(fd, "%%ImageData: %"PRIu32" %"PRIu32" %"PRIu16" %d 0 %d 2 \"", + w, h, bitspersample, nc, bs); fprintf(fd, startline, nc); fprintf(fd, "\"\n"); } @@ -1127,7 +1124,7 @@ int psPageSize (FILE * fd, int rotation, double pgwidth, double pgheight, fprintf (fd, "%%%%PageOrientation: %s\n", pageOrientation); else fprintf (fd, "%%%%PageOrientation: %s\n", (new_width > new_height) ? "Landscape" : "Portrait"); - fprintf (fd, "%%%%PageBoundingBox: 0 0 %ld %ld\n", (long)new_width, (long)new_height); + fprintf (fd, "%%%%PageBoundingBox: 0 0 %"PRId32" %"PRId32"\n", (int32_t)new_width, (int32_t)new_height); fprintf (fd, "1 dict begin /PageSize [ %f %f ] def currentdict end setpagedevice\n", new_width, new_height); } @@ -1139,7 +1136,7 @@ int psPageSize (FILE * fd, int rotation, double pgwidth, double pgheight, fprintf (fd, "%%%%PageOrientation: %s\n", pageOrientation); else fprintf (fd, "%%%%PageOrientation: %s\n", (pswidth > psheight) ? "Landscape" : "Portrait"); - fprintf (fd, "%%%%PageBoundingBox: 0 0 %ld %ld\n", (long)pswidth, (long)psheight); + fprintf (fd, "%%%%PageBoundingBox: 0 0 %"PRId32" %"PRId32"\n", (int32_t)pswidth, (int32_t)psheight); fprintf(fd, "1 dict begin /PageSize [ %f %f ] def currentdict end setpagedevice\n", pswidth, psheight); } @@ -1149,7 +1146,7 @@ int psPageSize (FILE * fd, int rotation, double pgwidth, double pgheight, fprintf (fd, "%%%%PageOrientation: %s\n", pageOrientation); else fprintf (fd, "%%%%PageOrientation: %s\n", (reqwidth > reqheight) ? "Landscape" : "Portrait"); - fprintf (fd, "%%%%PageBoundingBox: 0 0 %ld %ld\n", (long)reqwidth, (long)reqheight); + fprintf (fd, "%%%%PageBoundingBox: 0 0 %"PRId32" %"PRId32"\n", (int32_t)reqwidth, (int32_t)reqheight); fprintf(fd, "1 dict begin /PageSize [ %f %f ] def currentdict end setpagedevice\n", reqwidth, reqheight); } @@ -1171,7 +1168,7 @@ int psPageSize (FILE * fd, int rotation, double pgwidth, double pgheight, fprintf (fd, "%%%%PageOrientation: %s\n", pageOrientation); else fprintf (fd, "%%%%PageOrientation: %s\n", (new_width > new_height) ? "Landscape" : "Portrait"); - fprintf (fd, "%%%%PageBoundingBox: 0 0 %ld %ld\n", (long)new_width, (long)new_height); + fprintf (fd, "%%%%PageBoundingBox: 0 0 %"PRId32" %"PRId32"\n", (int32_t)new_width, (int32_t)new_height); fprintf (fd, "1 dict begin /PageSize [ %f %f ] def currentdict end setpagedevice\n", new_width, new_height); } @@ -1183,7 +1180,7 @@ int psPageSize (FILE * fd, int rotation, double pgwidth, double pgheight, fprintf (fd, "%%%%PageOrientation: %s\n", pageOrientation); else fprintf (fd, "%%%%PageOrientation: %s\n", (psheight > pswidth) ? "Landscape" : "Portrait"); - fprintf (fd, "%%%%PageBoundingBox: 0 0 %ld %ld\n", (long)psheight, (long)pswidth); + fprintf (fd, "%%%%PageBoundingBox: 0 0 %"PRId32" %"PRId32"\n", (int32_t)psheight, (int32_t)pswidth); fprintf(fd, "1 dict begin /PageSize [ %f %f ] def currentdict end setpagedevice\n", psheight, pswidth); } @@ -1193,7 +1190,7 @@ int psPageSize (FILE * fd, int rotation, double pgwidth, double pgheight, fprintf (fd, "%%%%PageOrientation: %s\n", pageOrientation); else fprintf (fd, "%%%%PageOrientation: %s\n", (reqwidth > reqheight) ? "Landscape" : "Portrait"); - fprintf (fd, "%%%%PageBoundingBox: 0 0 %ld %ld\n", (long)reqwidth, (long)reqheight); + fprintf (fd, "%%%%PageBoundingBox: 0 0 %"PRId32" %"PRId32"\n", (int32_t)reqwidth, (int32_t)reqheight); fprintf(fd, "1 dict begin /PageSize [ %f %f ] def currentdict end setpagedevice\n", reqwidth, reqheight); } @@ -1696,9 +1693,9 @@ PSHead(FILE *fd, double pagewidth, double pageheight, double xoff, double yoff) /* NB: should use PageBoundingBox for each page instead of BoundingBox * * PageBoundingBox DSC added in PSPageSize function, R Nolde 09-01-2010 */ - fprintf(fd, "%%%%Origin: %ld %ld\n", (long) xoff, (long) yoff); - fprintf(fd, "%%%%BoundingBox: 0 0 %ld %ld\n", - (long) ceil(pagewidth), (long) ceil(pageheight)); + fprintf(fd, "%%%%Origin: %"PRId32" %"PRId32"\n", (int32_t) xoff, (int32_t) yoff); + fprintf(fd, "%%%%BoundingBox: 0 0 %"PRId32" %"PRId32"\n", + (int32_t) ceil(pagewidth), (int32_t) ceil(pageheight)); fprintf(fd, "%%%%LanguageLevel: %d\n", (level3 ? 3 : (level2 ? 2 : 1))); if (generateEPSF == TRUE) @@ -1808,7 +1805,7 @@ PS_Lvl2colorspace(FILE* fd, TIFF* tif) Ascii85Put((unsigned char)bmap[i], fd); } else { fputs((i % 8) ? " " : "\n ", fd); - fprintf(fd, "%02x%02x%02x", + fprintf(fd, "%02"PRIx16"%02"PRIx16"%02"PRIx16"", rmap[i], gmap[i], bmap[i]); } } @@ -1833,8 +1830,8 @@ PS_Lvl2ImageDict(FILE* fd, TIFF* tif, uint32_t w, uint32_t h) imageOp = "imagemask"; (void)strcpy(im_x, "0"); - (void)snprintf(im_y, sizeof(im_y), "%lu", (long) h); - (void)snprintf(im_h, sizeof(im_h), "%lu", (long) h); + (void)snprintf(im_y, sizeof(im_y), "%"PRIu32, h); + (void)snprintf(im_h, sizeof(im_h), "%"PRIu32, h); tile_width = w; tile_height = h; if (TIFFIsTiled(tif)) { @@ -1855,7 +1852,7 @@ PS_Lvl2ImageDict(FILE* fd, TIFF* tif, uint32_t w, uint32_t h) } if (tile_height < h) { fputs("/im_y 0 def\n", fd); - (void)snprintf(im_y, sizeof(im_y), "%lu im_y sub", (unsigned long) h); + (void)snprintf(im_y, sizeof(im_y), "%"PRIu32" im_y sub", h); } } else { repeat_count = tf_numberstrips; @@ -1864,10 +1861,9 @@ PS_Lvl2ImageDict(FILE* fd, TIFF* tif, uint32_t w, uint32_t h) tile_height = h; if (repeat_count > 1) { fputs("/im_y 0 def\n", fd); - fprintf(fd, "/im_h %lu def\n", - (unsigned long) tile_height); + fprintf(fd, "/im_h %"PRIu32" def\n", tile_height); (void)strcpy(im_h, "im_h"); - (void)snprintf(im_y, sizeof(im_y), "%lu im_y sub", (unsigned long) h); + (void)snprintf(im_y, sizeof(im_y), "%"PRIu32" im_y sub", h); } } @@ -1877,7 +1873,7 @@ PS_Lvl2ImageDict(FILE* fd, TIFF* tif, uint32_t w, uint32_t h) fputs("{ % exec\n", fd); if (repeat_count > 1) - fprintf(fd, "%u { %% repeat\n", repeat_count); + fprintf(fd, "%"PRIu32" { %% repeat\n", repeat_count); /* * Output filter options and image dictionary. @@ -1887,7 +1883,7 @@ PS_Lvl2ImageDict(FILE* fd, TIFF* tif, uint32_t w, uint32_t h) fd); fputs(" <<\n", fd); fputs(" /ImageType 1\n", fd); - fprintf(fd, " /Width %lu\n", (unsigned long) tile_width); + fprintf(fd, " /Width %"PRIu32"\n", tile_width); /* * Workaround for some software that may crash when last strip * of image contains fewer number of scanlines than specified @@ -1899,15 +1895,15 @@ PS_Lvl2ImageDict(FILE* fd, TIFF* tif, uint32_t w, uint32_t h) * one-stripped image). */ if (TIFFIsTiled(tif) || tf_numberstrips == 1) - fprintf(fd, " /Height %lu\n", (unsigned long) tile_height); + fprintf(fd, " /Height %"PRIu32"\n", tile_height); else fprintf(fd, " /Height im_h\n"); if (planarconfiguration == PLANARCONFIG_SEPARATE && samplesperpixel > 1) fputs(" /MultipleDataSources true\n", fd); - fprintf(fd, " /ImageMatrix [ %lu 0 0 %ld %s %s ]\n", - (unsigned long) w, - (long)h, im_x, im_y); - fprintf(fd, " /BitsPerComponent %d\n", bitspersample); + fprintf(fd, " /ImageMatrix [ %"PRIu32" 0 0 %"PRId32" %s %s ]\n", + w, - (int32_t)h, im_x, im_y); + fprintf(fd, " /BitsPerComponent %"PRIu16"\n", bitspersample); fprintf(fd, " /Interpolate %s\n", interpolate ? "true" : "false"); switch (samplesperpixel - extrasamples) { @@ -1941,7 +1937,7 @@ PS_Lvl2ImageDict(FILE* fd, TIFF* tif, uint32_t w, uint32_t h) &minsamplevalue); TIFFGetFieldDefaulted(tif, TIFFTAG_MAXSAMPLEVALUE, &maxsamplevalue); - fprintf(fd, " /Decode [%u %u]\n", + fprintf(fd, " /Decode [%"PRIu16" %"PRIu16"]\n", minsamplevalue, maxsamplevalue); break; default: @@ -2017,8 +2013,8 @@ PS_Lvl2ImageDict(FILE* fd, TIFF* tif, uint32_t w, uint32_t h) fputs("\t /Uncompressed true\n", fd); } if (!(tile_width == w && w == 1728U)) - fprintf(fd, "\t /Columns %lu\n", - (unsigned long) tile_width); + fprintf(fd, "\t /Columns %"PRIu32"\n", + tile_width); fprintf(fd, "\t /Rows %s\n", im_h); if (compression == COMPRESSION_CCITTRLE || compression == COMPRESSION_CCITTRLEW) { @@ -2033,11 +2029,11 @@ PS_Lvl2ImageDict(FILE* fd, TIFF* tif, uint32_t w, uint32_t h) TIFFGetFieldDefaulted(tif, TIFFTAG_PREDICTOR, &predictor); if (predictor == 2) { fputs("\n\t<<\n", fd); - fprintf(fd, "\t /Predictor %u\n", predictor); - fprintf(fd, "\t /Columns %lu\n", - (unsigned long) tile_width); - fprintf(fd, "\t /Colors %u\n", samplesperpixel); - fprintf(fd, "\t /BitsPerComponent %u\n", + fprintf(fd, "\t /Predictor %"PRIu16"\n", predictor); + fprintf(fd, "\t /Columns %"PRIu32"\n", + tile_width); + fprintf(fd, "\t /Colors %"PRIu16"\n", samplesperpixel); + fprintf(fd, "\t /BitsPerComponent %"PRIu16"\n", bitspersample); fputs("\t>>", fd); } @@ -2050,11 +2046,11 @@ PS_Lvl2ImageDict(FILE* fd, TIFF* tif, uint32_t w, uint32_t h) if (predictor > 1) { fprintf(fd, "\t %% PostScript Level 3 only."); fputs("\n\t<<\n", fd); - fprintf(fd, "\t /Predictor %u\n", predictor); - fprintf(fd, "\t /Columns %lu\n", - (unsigned long) tile_width); - fprintf(fd, "\t /Colors %u\n", samplesperpixel); - fprintf(fd, "\t /BitsPerComponent %u\n", + fprintf(fd, "\t /Predictor %"PRIu16"\n", predictor); + fprintf(fd, "\t /Columns %"PRIu32"\n", + tile_width); + fprintf(fd, "\t /Colors %"PRIu16"\n", samplesperpixel); + fprintf(fd, "\t /BitsPerComponent %"PRIu16"\n", bitspersample); fputs("\t>>", fd); } @@ -2113,28 +2109,28 @@ PS_Lvl2ImageDict(FILE* fd, TIFF* tif, uint32_t w, uint32_t h) fputs(" im_stream status { im_stream flushfile } if\n", fd); if (repeat_count > 1) { if (tile_width < w) { - fprintf(fd, " /im_x im_x %lu add def\n", - (unsigned long) tile_width); + fprintf(fd, " /im_x im_x %"PRIu32" add def\n", + tile_width); if (tile_height < h) { - fprintf(fd, " im_x %lu ge {\n", - (unsigned long) w); + fprintf(fd, " im_x %"PRIu32" ge {\n", + w); fputs(" /im_x 0 def\n", fd); - fprintf(fd, " /im_y im_y %lu add def\n", - (unsigned long) tile_height); + fprintf(fd, " /im_y im_y %"PRIu32" add def\n", + tile_height); fputs(" } if\n", fd); } } if (tile_height < h) { if (tile_width >= w) { - fprintf(fd, " /im_y im_y %lu add def\n", - (unsigned long) tile_height); + fprintf(fd, " /im_y im_y %"PRIu32" add def\n", + tile_height); if (!TIFFIsTiled(tif)) { - fprintf(fd, " /im_h %lu im_y sub", - (unsigned long) h); - fprintf(fd, " dup %lu gt { pop", - (unsigned long) tile_height); - fprintf(fd, " %lu } if def\n", - (unsigned long) tile_height); + fprintf(fd, " /im_h %"PRIu32" im_y sub", + h); + fprintf(fd, " dup %"PRIu32" gt { pop", + tile_height); + fprintf(fd, " %"PRIu32" } if def\n", + tile_height); } } } @@ -2216,8 +2212,8 @@ PS_Lvl2page(FILE* fd, TIFF* tif, uint32_t w, uint32_t h) } buf_data = (unsigned char *)limitMalloc(chunk_size); if (!buf_data) { - TIFFError(filename, "Can't alloc %lu bytes for %s.", - (unsigned long) chunk_size, tiled_image ? "tiles" : "strips"); + TIFFError(filename, "Can't alloc %"PRId64" bytes for %s.", + chunk_size, tiled_image ? "tiles" : "strips"); return(FALSE); } @@ -2269,7 +2265,7 @@ PS_Lvl2page(FILE* fd, TIFF* tif, uint32_t w, uint32_t h) chunk_size); } if (byte_count < 0) { - TIFFError(filename, "Can't read %s %d.", + TIFFError(filename, "Can't read %s %"PRIu32".", tiled_image ? "tile" : "strip", chunk_no); if (ascii85) Ascii85Put('\0', fd); @@ -2394,12 +2390,12 @@ PSpage(FILE* fd, TIFF* tif, uint32_t w, uint32_t h) case PHOTOMETRIC_PALETTE: fprintf(fd, "%s", RGBcolorimage); PhotoshopBanner(fd, w, h, 1, 3, "false 3 colorimage"); - fprintf(fd, "/scanLine %ld string def\n", - (long) ps_bytesperrow * 3L); - fprintf(fd, "%lu %lu 8\n", - (unsigned long) w, (unsigned long) h); - fprintf(fd, "[%lu 0 0 -%lu 0 %lu]\n", - (unsigned long) w, (unsigned long) h, (unsigned long) h); + fprintf(fd, "/scanLine %"PRId64" string def\n", + ps_bytesperrow * 3L); + fprintf(fd, "%"PRIu32" %"PRIu32" 8\n", + w, h); + fprintf(fd, "[%"PRIu32" 0 0 -%"PRIu32" 0 %"PRIu32"]\n", + w, h, h); fprintf(fd, "{currentfile scanLine readhexstring pop} bind\n"); fprintf(fd, "false 3 colorimage\n"); PSDataPalette(fd, tif, w, h); @@ -2407,12 +2403,12 @@ PSpage(FILE* fd, TIFF* tif, uint32_t w, uint32_t h) case PHOTOMETRIC_MINISBLACK: case PHOTOMETRIC_MINISWHITE: PhotoshopBanner(fd, w, h, 1, 1, imageOp); - fprintf(fd, "/scanLine %ld string def\n", - (long) ps_bytesperrow); - fprintf(fd, "%lu %lu %d\n", - (unsigned long) w, (unsigned long) h, bitspersample); - fprintf(fd, "[%lu 0 0 -%lu 0 %lu]\n", - (unsigned long) w, (unsigned long) h, (unsigned long) h); + fprintf(fd, "/scanLine %"PRId64" string def\n", + ps_bytesperrow); + fprintf(fd, "%"PRIu32" %"PRIu32" %"PRIu16"\n", + w, h, bitspersample); + fprintf(fd, "[%"PRIu32" 0 0 -%"PRIu32" 0 %"PRIu32"]\n", + w, h, h); fprintf(fd, "{currentfile scanLine readhexstring pop} bind\n"); fprintf(fd, "%s\n", imageOp); @@ -2427,11 +2423,11 @@ PSColorContigPreamble(FILE* fd, uint32_t w, uint32_t h, int nc) { ps_bytesperrow = nc * (tf_bytesperrow / samplesperpixel); PhotoshopBanner(fd, w, h, 1, nc, "false %d colorimage"); - fprintf(fd, "/line %ld string def\n", (long) ps_bytesperrow); - fprintf(fd, "%lu %lu %d\n", - (unsigned long) w, (unsigned long) h, bitspersample); - fprintf(fd, "[%lu 0 0 -%lu 0 %lu]\n", - (unsigned long) w, (unsigned long) h, (unsigned long) h); + fprintf(fd, "/line %"PRId64" string def\n", ps_bytesperrow); + fprintf(fd, "%"PRIu32" %"PRIu32" %"PRIu16"\n", + w, h, bitspersample); + fprintf(fd, "[%"PRIu32" 0 0 -%"PRIu32" 0 %"PRIu32"]\n", + w, h, h); fprintf(fd, "{currentfile line readhexstring pop} bind\n"); fprintf(fd, "false %d colorimage\n", nc); } @@ -2443,12 +2439,12 @@ PSColorSeparatePreamble(FILE* fd, uint32_t w, uint32_t h, int nc) PhotoshopBanner(fd, w, h, ps_bytesperrow, nc, "true %d colorimage"); for (i = 0; i < nc; i++) - fprintf(fd, "/line%d %ld string def\n", - i, (long) ps_bytesperrow); - fprintf(fd, "%lu %lu %d\n", - (unsigned long) w, (unsigned long) h, bitspersample); - fprintf(fd, "[%lu 0 0 -%lu 0 %lu] \n", - (unsigned long) w, (unsigned long) h, (unsigned long) h); + fprintf(fd, "/line%d %"PRId64" string def\n", + i, ps_bytesperrow); + fprintf(fd, "%"PRIu32" %"PRIu32" %"PRIu16"\n", + w, h, bitspersample); + fprintf(fd, "[%"PRIu32" 0 0 -%"PRIu32" 0 %"PRIu32"] \n", + w, h, h); for (i = 0; i < nc; i++) fprintf(fd, "{currentfile line%d readhexstring pop}bind\n", i); fprintf(fd, "true %d colorimage\n", nc); @@ -2473,7 +2469,7 @@ PSDataColorContig(FILE* fd, TIFF* tif, uint32_t w, uint32_t h, int nc) (void) w; if( es < 0 ) { - TIFFError(filename, "Inconsistent value of es: %d (samplesperpixel=%u, nc=%d)", es, samplesperpixel, nc); + TIFFError(filename, "Inconsistent value of es: %d (samplesperpixel=%"PRIu16", nc=%d)", es, samplesperpixel, nc); return; } tf_buf = (unsigned char *) limitMalloc(tf_bytesperrow); @@ -2587,7 +2583,7 @@ PSDataPalette(FILE* fd, TIFF* tif, uint32_t w, uint32_t h) case 8: case 4: case 2: case 1: break; default: - TIFFError(filename, "Depth %d not supported", bitspersample); + TIFFError(filename, "Depth %"PRIu16" not supported", bitspersample); return; } nc = 3 * (8 / bitspersample); diff --git a/tools/tiff2rgba.c b/tools/tiff2rgba.c index d8ba5990..e6202d69 100644 --- a/tools/tiff2rgba.c +++ b/tools/tiff2rgba.c @@ -405,14 +405,14 @@ cvt_whole_image( TIFF *in, TIFF *out ) /* XXX: Check the integer overflow. */ if (!width || !height || pixel_count / width != height) { TIFFError(TIFFFileName(in), - "Malformed input file; can't allocate buffer for raster of %lux%lu size", - (unsigned long)width, (unsigned long)height); + "Malformed input file; can't allocate buffer for raster of %"PRIu32"x%"PRIu32" size", + width, height); return 0; } if (maxMalloc != 0 && (tmsize_t)pixel_count * (tmsize_t)sizeof(uint32_t) > maxMalloc) { TIFFError(TIFFFileName(in), - "Raster size %" PRIu64 " over memory limit (%" PRIu64 "), try -b option.", - (uint64_t)pixel_count * sizeof(uint32_t), (uint64_t)maxMalloc); + "Raster size %zu over memory limit (%" PRId64 "), try -b option.", + pixel_count * sizeof(uint32_t), maxMalloc); return 0; } @@ -421,8 +421,8 @@ 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 (%lu elements of %lu each)", - (unsigned long)pixel_count, (unsigned long)sizeof(uint32_t)); + TIFFError(TIFFFileName(in), "Failed to allocate buffer (%zu elements of %zu each)", + pixel_count, sizeof(uint32_t)); return (0); } @@ -543,8 +543,8 @@ tiffcvt(TIFF* in, TIFF* out) if (maxMalloc != 0 && TIFFStripSize(in) > maxMalloc) { TIFFError(TIFFFileName(in), - "Strip Size %" PRIu64 " over memory limit (%" PRIu64 ")", - (uint64_t)TIFFStripSize(in), (uint64_t)maxMalloc); + "Strip Size %" PRId64 " over memory limit (%" PRId64 ")", + TIFFStripSize(in), maxMalloc); return 0; } if( process_by_block && TIFFIsTiled( in ) ) diff --git a/tools/tiffcmp.c b/tools/tiffcmp.c index 51374a1f..c895b374 100644 --- a/tools/tiffcmp.c +++ b/tools/tiffcmp.c @@ -417,13 +417,13 @@ ContigCompare(int sample, uint32_t row, } } } else { - fprintf(stderr, "Sample format %d is not supported.\n", + fprintf(stderr, "Sample format %"PRIu16" is not supported.\n", sampleformat); return -1; } break; default: - fprintf(stderr, "Bit depth %d is not supported.\n", bitspersample); + fprintf(stderr, "Bit depth %"PRIu16" is not supported.\n", bitspersample); return -1; } @@ -450,12 +450,12 @@ PrintIntDiff(uint32_t row, int sample, uint32_t pix, uint32_t w1, uint32_t w2) mask2 >>= bitspersample, s -= bitspersample, pix++) { if ((w1 & mask2) ^ (w2 & mask2)) { printf( - "Scanline %lu, pixel %lu, sample %d: %01x %01x\n", - (unsigned long) row, - (unsigned long) pix, + "Scanline %"PRIu32", pixel %"PRIu32", sample %d: %01"PRIx32" %01"PRIx32"\n", + row, + pix, sample, - (unsigned int)((w1 >> s) & mask1), - (unsigned int)((w2 >> s) & mask1)); + (w1 >> s) & mask1, + (w2 >> s) & mask1); if (--stopondiff == 0) exit(1); } @@ -463,23 +463,23 @@ PrintIntDiff(uint32_t row, int sample, uint32_t pix, uint32_t w1, uint32_t w2) break; } case 8: - printf("Scanline %lu, pixel %lu, sample %d: %02x %02x\n", - (unsigned long) row, (unsigned long) pix, sample, - (unsigned int) w1, (unsigned int) w2); + printf("Scanline %"PRIu32", pixel %"PRIu32", sample %d: %02"PRIx32" %02"PRIx32"\n", + row, pix, sample, + w1, w2); if (--stopondiff == 0) exit(1); break; case 16: - printf("Scanline %lu, pixel %lu, sample %d: %04x %04x\n", - (unsigned long) row, (unsigned long) pix, sample, - (unsigned int) w1, (unsigned int) w2); + printf("Scanline %"PRIu32", pixel %"PRIu32", sample %d: %04"PRIx32" %04"PRIx32"\n", + row, pix, sample, + w1, w2); if (--stopondiff == 0) exit(1); break; case 32: - printf("Scanline %lu, pixel %lu, sample %d: %08x %08x\n", - (unsigned long) row, (unsigned long) pix, sample, - (unsigned int) w1, (unsigned int) w2); + printf("Scanline %"PRIu32", pixel %"PRIu32", sample %d: %08"PRIx32" %08"PRIx32"\n", + row, pix, sample, + w1, w2); if (--stopondiff == 0) exit(1); break; @@ -495,8 +495,8 @@ PrintFloatDiff(uint32_t row, int sample, uint32_t pix, double w1, double w2) sample = 0; switch (bitspersample) { case 32: - printf("Scanline %lu, pixel %lu, sample %d: %g %g\n", - (long) row, (long) pix, sample, w1, w2); + printf("Scanline %"PRIu32", pixel %"PRIu32", sample %d: %g %g\n", + row, pix, sample, w1, w2); if (--stopondiff == 0) exit(1); break; @@ -515,8 +515,8 @@ SeparateCompare(int reversed, int sample, uint32_t row, cp1 += sample; for (pixel = 0; npixels-- > 0; pixel++, cp1 += samplesperpixel, p2++) { if (*cp1 != *p2) { - printf("Scanline %lu, pixel %lu, sample %ld: ", - (long) row, (long) pixel, (long) sample); + printf("Scanline %"PRIu32", pixel %"PRIu32", sample %d: ", + row, pixel, sample); if (reversed) printf("%02x %02x\n", *p2, *cp1); else @@ -560,7 +560,7 @@ static int CheckShortTag(TIFF* tif1, TIFF* tif2, int tag, char* name) { uint16_t v1, v2; - CHECK(v1 == v2, "%s: %u %u\n"); + CHECK(v1 == v2, "%s: %"PRIu16" %"PRIu16"\n"); } static int @@ -576,7 +576,7 @@ CheckShort2Tag(TIFF* tif1, TIFF* tif2, int tag, char* name) } if (v11 == v21 && v12 == v22) return (1); - printf("%s: <%u,%u> <%u,%u>\n", name, v11, v12, v21, v22); + printf("%s: <%"PRIu16",%"PRIu16"> <%"PRIu16",%"PRIu16">\n", name, v11, v12, v21, v22); } else if (TIFFGetField(tif2, tag, &v21, &v22)) printf("%s tag appears only in %s\n", name, TIFFFileName(tif2)); else @@ -602,17 +602,17 @@ CheckShortArrayTag(TIFF* tif1, TIFF* tif2, int tag, char* name) if (memcmp(a1, a2, n1 * sizeof(uint16_t)) == 0) return (1); - printf("%s: value mismatch, <%u:", name, n1); + printf("%s: value mismatch, <%"PRIu16":", name, n1); sep = ""; for (i = 0; i < n1; i++) - printf("%s%u", sep, a1[i]), sep = ","; - printf("> and <%u: ", n2); + printf("%s%"PRIu16, sep, a1[i]), sep = ","; + printf("> and <%"PRIu16": ", n2); sep = ""; for (i = 0; i < n2; i++) - printf("%s%u", sep, a2[i]), sep = ","; + printf("%s%"PRIu16, sep, a2[i]), sep = ","; printf(">\n"); } else - printf("%s: %u items in %s, %u items in %s", name, + printf("%s: %"PRIu16" items in %s, %"PRIu16" items in %s", name, n1, TIFFFileName(tif1), n2, TIFFFileName(tif2) ); @@ -627,7 +627,7 @@ static int CheckLongTag(TIFF* tif1, TIFF* tif2, int tag, char* name) { uint32_t v1, v2; - CHECK(v1 == v2, "%s: %u %u\n"); + CHECK(v1 == v2, "%s: %"PRIu32" %"PRIu32"\n"); } static int @@ -648,7 +648,7 @@ static void leof(const char* name, uint32_t row, int s) { - printf("%s: EOF at scanline %lu", name, (unsigned long)row); + printf("%s: EOF at scanline %"PRIu32, name, row); if (s >= 0) printf(", sample %d", s); printf("\n"); diff --git a/tools/tiffcp.c b/tools/tiffcp.c index dd9ee768..f6b44813 100644 --- a/tools/tiffcp.c +++ b/tools/tiffcp.c @@ -107,8 +107,8 @@ static int pageInSeq = 0; static void* limitMalloc(tmsize_t s) { if (maxMalloc && (s > maxMalloc)) { - fprintf(stderr, "MemoryLimitError: allocation of %" PRIu64 " bytes is forbidden. Limit is %" PRIu64 ".\n", - (uint64_t)s, (uint64_t)maxMalloc); + fprintf(stderr, "MemoryLimitError: allocation of %" PRId64 " bytes is forbidden. Limit is %" PRId64 ".\n", + s, maxMalloc); fprintf(stderr, " use -m option to change limit.\n"); return NULL; } @@ -139,8 +139,8 @@ static int nextSrcImage (TIFF *tif, char **imageSpec) } } if (TIFFSetDirectory (tif, nextImage)) return 1; - fprintf (stderr, "%s%c%d not found!\n", - TIFFFileName(tif), comma, (int) nextImage); + fprintf (stderr, "%s%c%"PRIu16" not found!\n", + TIFFFileName(tif), comma, nextImage); } return 0; } @@ -604,7 +604,7 @@ cpTag(TIFF* in, TIFF* out, uint16_t tag, uint16_t count, TIFFDataType type) break; default: TIFFError(TIFFFileName(in), - "Data type %d is not supported, tag %d skipped.", + "Data type %"PRIu16" is not supported, tag %d skipped.", tag, type); } } @@ -941,14 +941,14 @@ DECLAREcpFunc(cpContig2ContigByRow) for (row = 0; row < imagelength; row++) { if (TIFFReadScanline(in, buf, row, 0) < 0 && !ignore) { TIFFError(TIFFFileName(in), - "Error, can't read scanline %lu", - (unsigned long) row); + "Error, can't read scanline %"PRIu32, + row); goto bad; } if (TIFFWriteScanline(out, buf, row, 0) < 0) { TIFFError(TIFFFileName(out), - "Error, can't write scanline %lu", - (unsigned long) row); + "Error, can't write scanline %"PRIu32, + row); goto bad; } } @@ -1013,22 +1013,22 @@ DECLAREcpFunc(cpBiasedContig2Contig) if (TIFFReadScanline(in, buf, row, 0) < 0 && !ignore) { TIFFError(TIFFFileName(in), - "Error, can't read scanline %lu", - (unsigned long) row); + "Error, can't read scanline %"PRIu32, + row); goto bad; } if (TIFFReadScanline(bias, biasBuf, row, 0) < 0 && !ignore) { TIFFError(TIFFFileName(in), - "Error, can't read biased scanline %lu", - (unsigned long) row); + "Error, can't read biased scanline %"PRIu32, + row); goto bad; } subtractLine (buf, biasBuf, imagewidth); if (TIFFWriteScanline(out, buf, row, 0) < 0) { TIFFError(TIFFFileName(out), - "Error, can't write scanline %lu", - (unsigned long) row); + "Error, can't write scanline %"PRIu32, + row); goto bad; } } @@ -1044,19 +1044,19 @@ bad: return 0; } else { TIFFError(TIFFFileName(in), - "No support for biasing %d bit pixels\n", + "No support for biasing %"PRIu16" bit pixels\n", sampleBits); return 0; } } TIFFError(TIFFFileName(in), - "Bias image %s,%d\nis not the same size as %s,%d\n", + "Bias image %s,%"PRIu16"\nis not the same size as %s,%"PRIu16"\n", TIFFFileName(bias), TIFFCurrentDirectory(bias), TIFFFileName(in), TIFFCurrentDirectory(in)); return 0; } else { TIFFError(TIFFFileName(in), - "Can't bias %s,%d as it has >1 Sample/Pixel\n", + "Can't bias %s,%"PRIu16" as it has >1 Sample/Pixel\n", TIFFFileName(in), TIFFCurrentDirectory(in)); return 0; } @@ -1083,14 +1083,14 @@ DECLAREcpFunc(cpDecodedStrips) if (TIFFReadEncodedStrip(in, s, buf, cc) < 0 && !ignore) { TIFFError(TIFFFileName(in), - "Error, can't read strip %lu", - (unsigned long) s); + "Error, can't read strip %"PRIu32, + s); goto bad; } if (TIFFWriteEncodedStrip(out, s, buf, cc) < 0) { TIFFError(TIFFFileName(out), - "Error, can't write strip %lu", - (unsigned long) s); + "Error, can't write strip %"PRIu32, + s); goto bad; } row += rowsperstrip; @@ -1099,8 +1099,8 @@ DECLAREcpFunc(cpDecodedStrips) return 1; } else { TIFFError(TIFFFileName(in), - "Error, can't allocate memory buffer of size %lu " - "to read strips", (unsigned long) stripsize); + "Error, can't allocate memory buffer of size %"PRId64 + " to read strips", stripsize); return 0; } @@ -1128,14 +1128,14 @@ DECLAREcpFunc(cpSeparate2SeparateByRow) for (row = 0; row < imagelength; row++) { if (TIFFReadScanline(in, buf, row, s) < 0 && !ignore) { TIFFError(TIFFFileName(in), - "Error, can't read scanline %lu", - (unsigned long) row); + "Error, can't read scanline %"PRIu32, + row); goto bad; } if (TIFFWriteScanline(out, buf, row, s) < 0) { TIFFError(TIFFFileName(out), - "Error, can't write scanline %lu", - (unsigned long) row); + "Error, can't write scanline %"PRIu32, + row); goto bad; } } @@ -1183,8 +1183,8 @@ DECLAREcpFunc(cpContig2SeparateByRow) if (TIFFReadScanline(in, inbuf, row, 0) < 0 && !ignore) { TIFFError(TIFFFileName(in), - "Error, can't read scanline %lu", - (unsigned long) row); + "Error, can't read scanline %"PRIu32, + row); goto bad; } inp = ((uint8_t*)inbuf) + s; @@ -1195,8 +1195,8 @@ DECLAREcpFunc(cpContig2SeparateByRow) } if (TIFFWriteScanline(out, outbuf, row, s) < 0) { TIFFError(TIFFFileName(out), - "Error, can't write scanline %lu", - (unsigned long) row); + "Error, can't write scanline %"PRIu32, + row); goto bad; } } @@ -1246,8 +1246,8 @@ DECLAREcpFunc(cpSeparate2ContigByRow) if (TIFFReadScanline(in, inbuf, row, s) < 0 && !ignore) { TIFFError(TIFFFileName(in), - "Error, can't read scanline %lu", - (unsigned long) row); + "Error, can't read scanline %"PRIu32, + row); goto bad; } inp = (uint8_t*)inbuf; @@ -1259,8 +1259,8 @@ DECLAREcpFunc(cpSeparate2ContigByRow) } if (TIFFWriteScanline(out, outbuf, row, 0) < 0) { TIFFError(TIFFFileName(out), - "Error, can't write scanline %lu", - (unsigned long) row); + "Error, can't write scanline %"PRIu32, + row); goto bad; } } @@ -1371,8 +1371,8 @@ DECLAREreadFunc(readContigStripsIntoBuffer) if (TIFFReadScanline(in, (tdata_t) bufp, row, 0) < 0 && !ignore) { TIFFError(TIFFFileName(in), - "Error, can't read scanline %lu", - (unsigned long) row); + "Error, can't read scanline %"PRIu32, + row); return 0; } bufp += scanlinesize; @@ -1408,8 +1408,8 @@ DECLAREreadFunc(readSeparateStripsIntoBuffer) if (TIFFReadScanline(in, scanline, row, s) < 0 && !ignore) { TIFFError(TIFFFileName(in), - "Error, can't read scanline %lu", - (unsigned long) row); + "Error, can't read scanline %"PRIu32, + row); status = 0; goto done; } @@ -1454,9 +1454,8 @@ DECLAREreadFunc(readContigTilesIntoBuffer) if (TIFFReadTile(in, tilebuf, col, row, 0, 0) < 0 && !ignore) { TIFFError(TIFFFileName(in), - "Error, can't read tile at %lu %lu", - (unsigned long) col, - (unsigned long) row); + "Error, can't read tile at %"PRIu32" %"PRIu32, + col, row); status = 0; goto done; } @@ -1531,11 +1530,9 @@ DECLAREreadFunc(readSeparateTilesIntoBuffer) if (TIFFReadTile(in, tilebuf, col, row, 0, s) < 0 && !ignore) { TIFFError(TIFFFileName(in), - "Error, can't read tile at %lu %lu, " - "sample %lu", - (unsigned long) col, - (unsigned long) row, - (unsigned long) s); + "Error, can't read tile at %"PRIu32" %"PRIu32", " + "sample %"PRIu16, + col, row, s); status = 0; goto done; } @@ -1582,7 +1579,7 @@ DECLAREwriteFunc(writeBufferToContigStrips) tsize_t stripsize = TIFFVStripSize(out, nrows); if (TIFFWriteEncodedStrip(out, strip++, buf, stripsize) < 0) { TIFFError(TIFFFileName(out), - "Error, can't write strip %u", strip - 1); + "Error, can't write strip %"PRIu32, strip - 1u); return 0; } buf += stripsize; @@ -1616,8 +1613,8 @@ DECLAREwriteFunc(writeBufferToSeparateStrips) nrows, imagewidth, 0, 0, spp, 1); if (TIFFWriteEncodedStrip(out, strip++, obuf, stripsize) < 0) { TIFFError(TIFFFileName(out), - "Error, can't write strip %u", - strip - 1); + "Error, can't write strip %"PRIu32, + strip - 1u); _TIFFfree(obuf); return 0; } @@ -1667,9 +1664,8 @@ DECLAREwriteFunc(writeBufferToContigTiles) 0, iskew); if (TIFFWriteTile(out, obuf, col, row, 0, 0) < 0) { TIFFError(TIFFFileName(out), - "Error, can't write tile at %lu %lu", - (unsigned long) col, - (unsigned long) row); + "Error, can't write tile at %"PRIu32" %"PRIu32, + col, row); _TIFFfree(obuf); return 0; } @@ -1744,11 +1740,9 @@ DECLAREwriteFunc(writeBufferToSeparateTiles) bytes_per_sample); if (TIFFWriteTile(out, obuf, col, row, 0, s) < 0) { TIFFError(TIFFFileName(out), - "Error, can't write tile at %lu %lu " - "sample %lu", - (unsigned long) col, - (unsigned long) row, - (unsigned long) s); + "Error, can't write tile at %"PRIu32" %"PRIu32 + " sample %"PRIu16, + col, row, s); _TIFFfree(obuf); return 0; } diff --git a/tools/tiffcrop.c b/tools/tiffcrop.c index 83af4c1a..7751e866 100644 --- a/tools/tiffcrop.c +++ b/tools/tiffcrop.c @@ -831,7 +831,7 @@ static int readContigTilesIntoBuffer (TIFF* in, uint8_t* buf, { #ifdef DEBUG2 TIFFError("readContigTilesIntoBuffer", - "Tilesize %lu is too small, using alternate calculation %u", + "Tilesize %"PRId64" is too small, using alternate calculation %"PRIu64, tilesize, tl * tile_rowsize); #endif tile_buffsize = tl * tile_rowsize; @@ -865,9 +865,8 @@ static int readContigTilesIntoBuffer (TIFF* in, uint8_t* buf, if (tbytes < tilesize && !ignore) { TIFFError(TIFFFileName(in), - "Error, can't read tile at row %lu col %lu, Read %lu bytes of %lu", - (unsigned long) col, (unsigned long) row, (unsigned long)tbytes, - (unsigned long)tilesize); + "Error, can't read tile at row %"PRIu32" col %"PRIu32", Read %"PRId64" bytes of %"PRId64, + col, row, tbytes, tilesize); status = 0; _TIFFfree(tilebuf); return status; @@ -916,8 +915,8 @@ static int readContigTilesIntoBuffer (TIFF* in, uint8_t* buf, spp, bps, count, 0, ncol)) { TIFFError("readContigTilesIntoBuffer", - "Unable to extract row %d from tile %lu", - row, (unsigned long)TIFFCurrentTile(in)); + "Unable to extract row %"PRIu32" from tile %"PRIu32, + row, TIFFCurrentTile(in)); return 1; } break; @@ -930,8 +929,8 @@ static int readContigTilesIntoBuffer (TIFF* in, uint8_t* buf, prev_trailing_bits)) { TIFFError("readContigTilesIntoBuffer", - "Unable to extract row %d from tile %lu", - row, (unsigned long)TIFFCurrentTile(in)); + "Unable to extract row %"PRIu32" from tile %"PRIu32, + row, TIFFCurrentTile(in)); return 1; } break; @@ -944,8 +943,8 @@ static int readContigTilesIntoBuffer (TIFF* in, uint8_t* buf, prev_trailing_bits)) { TIFFError("readContigTilesIntoBuffer", - "Unable to extract row %d from tile %lu", - row, (unsigned long)TIFFCurrentTile(in)); + "Unable to extract row %"PRIu32" from tile %"PRIu32, + row, TIFFCurrentTile(in)); return 1; } break; @@ -956,8 +955,8 @@ static int readContigTilesIntoBuffer (TIFF* in, uint8_t* buf, prev_trailing_bits)) { TIFFError("readContigTilesIntoBuffer", - "Unable to extract row %d from tile %lu", - row, (unsigned long)TIFFCurrentTile(in)); + "Unable to extract row %"PRIu32" from tile %"PRIu32, + row, TIFFCurrentTile(in)); return 1; } break; @@ -970,12 +969,12 @@ static int readContigTilesIntoBuffer (TIFF* in, uint8_t* buf, prev_trailing_bits)) { TIFFError("readContigTilesIntoBuffer", - "Unable to extract row %d from tile %lu", - row, (unsigned long)TIFFCurrentTile(in)); + "Unable to extract row %"PRIu32" from tile %"PRIu32, + row, TIFFCurrentTile(in)); return 1; } break; - default: TIFFError("readContigTilesIntoBuffer", "Unsupported bit depth %d", bps); + default: TIFFError("readContigTilesIntoBuffer", "Unsupported bit depth %"PRIu16, bps); return 1; } } @@ -1037,10 +1036,9 @@ static int readSeparateTilesIntoBuffer (TIFF* in, uint8_t *obuf, if (tbytes < 0 && !ignore) { TIFFError(TIFFFileName(in), - "Error, can't read tile for row %lu col %lu, " - "sample %lu", - (unsigned long) col, (unsigned long) row, - (unsigned long) s); + "Error, can't read tile for row %"PRIu32" col %"PRIu32", " + "sample %"PRIu16, + col, row, s); status = 0; for (sample = 0; (sample < spp) && (sample < MAX_SAMPLES); sample++) { @@ -1119,7 +1117,7 @@ static int readSeparateTilesIntoBuffer (TIFF* in, uint8_t *obuf, break; } break; - default: TIFFError ("readSeparateTilesIntoBuffer", "Unsupported bit depth: %d", bps); + default: TIFFError ("readSeparateTilesIntoBuffer", "Unsupported bit depth: %"PRIu16, bps); status = 0; break; } @@ -1151,7 +1149,7 @@ static int writeBufferToContigStrips(TIFF* out, uint8_t* buf, uint32_t imageleng stripsize = TIFFVStripSize(out, nrows); if (TIFFWriteEncodedStrip(out, strip++, buf, stripsize) < 0) { - TIFFError(TIFFFileName(out), "Error, can't write strip %u", strip - 1); + TIFFError(TIFFFileName(out), "Error, can't write strip %"PRIu32, strip - 1); return 1; } buf += stripsize; @@ -1236,7 +1234,7 @@ writeBufferToSeparateStrips (TIFF* out, uint8_t* buf, if (TIFFWriteEncodedStrip(out, strip++, obuf, stripsize) < 0) { - TIFFError(TIFFFileName(out), "Error, can't write strip %u", strip - 1); + TIFFError(TIFFFileName(out), "Error, can't write strip %"PRIu32, strip - 1); _TIFFfree(obuf); return 1; } @@ -1280,7 +1278,7 @@ static int writeBufferToContigTiles (TIFF* out, uint8_t* buf, uint32_t imageleng { #ifdef DEBUG2 TIFFError("writeBufferToContigTiles", - "Tilesize %lu is too small, using alternate calculation %u", + "Tilesize %"PRId64" is too small, using alternate calculation %"PRIu32, tilesize, tl * tile_rowsize); #endif tile_buffsize = tl * tile_rowsize; @@ -1321,8 +1319,8 @@ static int writeBufferToContigTiles (TIFF* out, uint8_t* buf, uint32_t imageleng tw, 0, spp, spp, bps, dump) > 0) { TIFFError("writeBufferToContigTiles", - "Unable to extract data to tile for row %lu, col %lu", - (unsigned long) row, (unsigned long)col); + "Unable to extract data to tile for row %"PRIu32", col %"PRIu32, + row, col); _TIFFfree(tilebuf); return 1; } @@ -1330,8 +1328,8 @@ static int writeBufferToContigTiles (TIFF* out, uint8_t* buf, uint32_t imageleng if (TIFFWriteTile(out, tilebuf, col, row, 0, 0) < 0) { TIFFError("writeBufferToContigTiles", - "Cannot write tile at %lu %lu", - (unsigned long) col, (unsigned long) row); + "Cannot write tile at %"PRIu32" %"PRIu32, + col, row); _TIFFfree(tilebuf); return 1; } @@ -1396,8 +1394,8 @@ static int writeBufferToSeparateTiles (TIFF* out, uint8_t* buf, uint32_t imagele tw, s, 1, spp, bps, dump) > 0) { TIFFError("writeBufferToSeparateTiles", - "Unable to extract data to tile for row %lu, col %lu sample %d", - (unsigned long) row, (unsigned long)col, (int)s); + "Unable to extract data to tile for row %"PRIu32", col %"PRIu32" sample %"PRIu16, + row, col, s); _TIFFfree(obuf); return 1; } @@ -1405,9 +1403,8 @@ static int writeBufferToSeparateTiles (TIFF* out, uint8_t* buf, uint32_t imagele if (TIFFWriteTile(out, obuf, col, row, 0, s) < 0) { TIFFError("writeBufferToseparateTiles", - "Cannot write tile at %lu %lu sample %lu", - (unsigned long) col, (unsigned long) row, - (unsigned long) s); + "Cannot write tile at %"PRIu32" %"PRIu32" sample %"PRIu16, + col, row, s); _TIFFfree(obuf); return 1; } @@ -1568,7 +1565,7 @@ cpTag(TIFF* in, TIFF* out, uint16_t tag, uint16_t count, TIFFDataType type) break; default: TIFFError(TIFFFileName(in), - "Data type %d is not supported, tag %d skipped", + "Data type %"PRIu16" is not supported, tag %d skipped", tag, type); } } @@ -1745,7 +1742,7 @@ void process_command_opts (int argc, char *argv[], char *mp, char *mode, uint32 &crop_data->corners[i].X1, &crop_data->corners[i].Y1, &crop_data->corners[i].X2, &crop_data->corners[i].Y2) != 4) { - TIFFError ("Unable to parse coordinates for region", "%d %s", i, optarg); + TIFFError ("Unable to parse coordinates for region", "%u %s", i, optarg); TIFFError ("For valid options type", "tiffcrop -h"); exit (EXIT_FAILURE); } @@ -2301,8 +2298,8 @@ main(int argc, char* argv[]) if (dirnum > (total_images)) { TIFFError (TIFFFileName(in), - "Invalid image number %d, File contains only %d images", - (int)dirnum + 1, total_images); + "Invalid image number %"PRIu32", File contains only %"PRIu32" images", + dirnum + 1u, total_images); if (out != NULL) (void) TIFFClose(out); return (1); @@ -2310,7 +2307,7 @@ main(int argc, char* argv[]) if (dirnum != 0 && !TIFFSetDirectory(in, (tdir_t)dirnum)) { - TIFFError(TIFFFileName(in),"Error, setting subdirectory at %d", dirnum); + TIFFError(TIFFFileName(in),"Error, setting subdirectory at %"PRIu32, dirnum); if (out != NULL) (void) TIFFClose(out); return (1); @@ -2348,7 +2345,7 @@ main(int argc, char* argv[]) TIFFError ("Unable to open dump file for writing", "%s", temp_filename); exit (EXIT_FAILURE); } - dump_info(dump.infile, dump.format, "Reading image","%d from %s", + dump_info(dump.infile, dump.format, "Reading image","%u from %s", dump_images, TIFFFileName(in)); } length = strlen(dump.outfilename); @@ -2367,7 +2364,7 @@ main(int argc, char* argv[]) TIFFError ("Unable to open dump file for writing", "%s", temp_filename); exit (EXIT_FAILURE); } - dump_info(dump.outfile, dump.format, "Writing image","%d from %s", + dump_info(dump.outfile, dump.format, "Writing image","%u from %s", dump_images, TIFFFileName(in)); } } @@ -2727,8 +2724,8 @@ static int dump_buffer (FILE* dumpfile, int format, uint32_t rows, uint32_t widt dump_ptr = buff + (i * width); if (format == DUMP_TEXT) dump_info (dumpfile, format, "", - "Row %4d, %d bytes at offset %d", - row + i + 1, width, row * width); + "Row %4"PRIu32", %"PRIu32" bytes at offset %"PRIu32, + row + i + 1u, width, row * width); for (j = 0, k = width; k >= 10; j += 10, k -= 10, dump_ptr += 10) dump_data (dumpfile, format, "", dump_ptr, 10); @@ -2764,13 +2761,13 @@ extractContigSamplesBytes (uint8_t *in, uint8_t *out, uint32_t cols, if ((start > end) || (start > cols)) { TIFFError ("extractContigSamplesBytes", - "Invalid start column value %d ignored", start); + "Invalid start column value %"PRIu32" ignored", start); start = 0; } if ((end == 0) || (end > cols)) { TIFFError ("extractContigSamplesBytes", - "Invalid end column value %d ignored", end); + "Invalid end column value %"PRIu32" ignored", end); end = cols; } @@ -2831,13 +2828,13 @@ extractContigSamples8bits (uint8_t *in, uint8_t *out, uint32_t cols, if ((start > end) || (start > cols)) { TIFFError ("extractContigSamples8bits", - "Invalid start column value %d ignored", start); + "Invalid start column value %"PRIu32" ignored", start); start = 0; } if ((end == 0) || (end > cols)) { TIFFError ("extractContigSamples8bits", - "Invalid end column value %d ignored", end); + "Invalid end column value %"PRIu32" ignored", end); end = cols; } @@ -2909,13 +2906,13 @@ extractContigSamples16bits (uint8_t *in, uint8_t *out, uint32_t cols, if ((start > end) || (start > cols)) { TIFFError ("extractContigSamples16bits", - "Invalid start column value %d ignored", start); + "Invalid start column value %"PRIu32" ignored", start); start = 0; } if ((end == 0) || (end > cols)) { TIFFError ("extractContigSamples16bits", - "Invalid end column value %d ignored", end); + "Invalid end column value %"PRIu32" ignored", end); end = cols; } @@ -2998,13 +2995,13 @@ extractContigSamples24bits (uint8_t *in, uint8_t *out, uint32_t cols, if ((start > end) || (start > cols)) { TIFFError ("extractContigSamples24bits", - "Invalid start column value %d ignored", start); + "Invalid start column value %"PRIu32" ignored", start); start = 0; } if ((end == 0) || (end > cols)) { TIFFError ("extractContigSamples24bits", - "Invalid end column value %d ignored", end); + "Invalid end column value %"PRIu32" ignored", end); end = cols; } @@ -3109,13 +3106,13 @@ extractContigSamples32bits (uint8_t *in, uint8_t *out, uint32_t cols, if ((start > end) || (start > cols)) { TIFFError ("extractContigSamples32bits", - "Invalid start column value %d ignored", start); + "Invalid start column value %"PRIu32" ignored", start); start = 0; } if ((end == 0) || (end > cols)) { TIFFError ("extractContigSamples32bits", - "Invalid end column value %d ignored", end); + "Invalid end column value %"PRIu32" ignored", end); end = cols; } @@ -3212,13 +3209,13 @@ extractContigSamplesShifted8bits (uint8_t *in, uint8_t *out, uint32_t cols, if ((start > end) || (start > cols)) { TIFFError ("extractContigSamplesShifted8bits", - "Invalid start column value %d ignored", start); + "Invalid start column value %"PRIu32" ignored", start); start = 0; } if ((end == 0) || (end > cols)) { TIFFError ("extractContigSamplesShifted8bits", - "Invalid end column value %d ignored", end); + "Invalid end column value %"PRIu32" ignored", end); end = cols; } @@ -3293,13 +3290,13 @@ extractContigSamplesShifted16bits (uint8_t *in, uint8_t *out, uint32_t cols, if ((start > end) || (start > cols)) { TIFFError ("extractContigSamplesShifted16bits", - "Invalid start column value %d ignored", start); + "Invalid start column value %"PRIu32" ignored", start); start = 0; } if ((end == 0) || (end > cols)) { TIFFError ("extractContigSamplesShifted16bits", - "Invalid end column value %d ignored", end); + "Invalid end column value %"PRIu32" ignored", end); end = cols; } @@ -3383,13 +3380,13 @@ extractContigSamplesShifted24bits (uint8_t *in, uint8_t *out, uint32_t cols, if ((start > end) || (start > cols)) { TIFFError ("extractContigSamplesShifted24bits", - "Invalid start column value %d ignored", start); + "Invalid start column value %"PRIu32" ignored", start); start = 0; } if ((end == 0) || (end > cols)) { TIFFError ("extractContigSamplesShifted24bits", - "Invalid end column value %d ignored", end); + "Invalid end column value %"PRIu32" ignored", end); end = cols; } @@ -3483,13 +3480,13 @@ extractContigSamplesShifted32bits (uint8_t *in, uint8_t *out, uint32_t cols, if ((start > end) || (start > cols)) { TIFFError ("extractContigSamplesShifted32bits", - "Invalid start column value %d ignored", start); + "Invalid start column value %"PRIu32" ignored", start); start = 0; } if ((end == 0) || (end > cols)) { TIFFError ("extractContigSamplesShifted32bits", - "Invalid end column value %d ignored", end); + "Invalid end column value %"PRIu32" ignored", end); end = cols; } @@ -3594,7 +3591,7 @@ extractContigSamplesToBuffer(uint8_t *out, uint8_t *in, uint32_t rows, uint32_t if ((dump->outfile != NULL) && (dump->level == 4)) { dump_info (dump->outfile, dump->format, "extractContigSamplesToBuffer", - "Sample %d, %d rows", sample + 1, rows + 1); + "Sample %"PRIu32", %"PRIu32" rows", sample + 1u, rows + 1u); } for (row = 0; row < rows; row++) { @@ -3632,7 +3629,7 @@ extractContigSamplesToBuffer(uint8_t *out, uint8_t *in, uint32_t rows, uint32_t spp, bps, count, first_col, cols)) return (1); break; - default: TIFFError ("extractContigSamplesToBuffer", "Unsupported bit depth: %d", bps); + default: TIFFError ("extractContigSamplesToBuffer", "Unsupported bit depth: %"PRIu16, bps); return (1); } if ((dump->outfile != NULL) && (dump->level == 4)) @@ -3667,7 +3664,7 @@ extractContigSamplesToTileBuffer(uint8_t *out, uint8_t *in, uint32_t rows, uint3 if ((dump->outfile != NULL) && (dump->level == 4)) { dump_info (dump->outfile, dump->format, "extractContigSamplesToTileBuffer", - "Sample %d, %d rows", sample + 1, rows + 1); + "Sample %"PRIu32", %"PRIu32" rows", sample + 1u, rows + 1u); } src_rowsize = ((bps * spp * imagewidth) + 7) / 8; @@ -3709,7 +3706,7 @@ extractContigSamplesToTileBuffer(uint8_t *out, uint8_t *in, uint32_t rows, uint3 spp, bps, count, 0, cols)) return (1); break; - default: TIFFError ("extractContigSamplesToTileBuffer", "Unsupported bit depth: %d", bps); + default: TIFFError ("extractContigSamplesToTileBuffer", "Unsupported bit depth: %"PRIu16, bps); return (1); } if ((dump->outfile != NULL) && (dump->level == 4)) @@ -3738,13 +3735,12 @@ static int readContigStripsIntoBuffer (TIFF* in, uint8_t* buf) bytes_read = TIFFReadEncodedStrip (in, strip, bufp, -1); rows = bytes_read / scanline_size; if ((strip < (nstrips - 1)) && (bytes_read != (int32_t)stripsize)) - TIFFError("", "Strip %d: read %lu bytes, strip size %lu", - (int)strip + 1, (unsigned long) bytes_read, - (unsigned long)stripsize); + TIFFError("", "Strip %"PRIu32": read %"PRId32" bytes, strip size %"PRIu32, + strip + 1, bytes_read, stripsize); if (bytes_read < 0 && !ignore) { - TIFFError("", "Error reading strip %lu after %lu rows", - (unsigned long) strip, (unsigned long)rows); + TIFFError("", "Error reading strip %"PRIu32" after %"PRIu32" rows", + strip, rows); return 0; } bufp += stripsize; @@ -3782,7 +3778,7 @@ combineSeparateSamplesBytes (unsigned char *srcbuffs[], unsigned char *out, { for (s = 0; s < spp; s++) { - dump_info (dumpfile, format, "combineSeparateSamplesBytes","Input data, Sample %d", s); + dump_info (dumpfile, format, "combineSeparateSamplesBytes","Input data, Sample %"PRIu16, s); dump_buffer(dumpfile, format, 1, cols, row, srcbuffs[s] + (row * src_rowsize)); } } @@ -3877,8 +3873,8 @@ combineSeparateSamples8bits (uint8_t *in[], uint8_t *out, uint32_t cols, if ((dumpfile != NULL) && (level == 3)) { dump_info (dumpfile, format, "", - "Row %3d, Col %3d, Samples %d, Src byte offset %3d bit offset %2d Dst offset %3d", - row + 1, col + 1, s, src_byte, src_bit, dst - out); + "Row %3"PRIu32", Col %3"PRIu32", Samples %"PRIu16", Src byte offset %3"PRIu32" bit offset %2"PRIu32" Dst offset %3td", + row + 1u, col + 1u, s, src_byte, src_bit, dst - out); dump_byte (dumpfile, format, "Match bits", matchbits); dump_byte (dumpfile, format, "Src bits", *src); dump_byte (dumpfile, format, "Buff1 bits", buff1); @@ -3895,8 +3891,8 @@ combineSeparateSamples8bits (uint8_t *in[], uint8_t *out, uint32_t cols, if ((dumpfile != NULL) && (level == 3)) { dump_info (dumpfile, format, "", - "Row %3d, Col %3d, Src byte offset %3d bit offset %2d Dst offset %3d", - row + 1, col + 1, src_byte, src_bit, dst - out); + "Row %3"PRIu32", Col %3"PRIu32", Src byte offset %3"PRIu32" bit offset %2"PRIu32" Dst offset %3td", + row + 1u, col + 1u, src_byte, src_bit, dst - out); dump_byte (dumpfile, format, "Final bits", buff1); } } @@ -3984,8 +3980,8 @@ combineSeparateSamples16bits (uint8_t *in[], uint8_t *out, uint32_t cols, if ((dumpfile != NULL) && (level == 3)) { dump_info (dumpfile, format, "", - "Row %3d, Col %3d, Samples %d, Src byte offset %3d bit offset %2d Dst offset %3d", - row + 1, col + 1, s, src_byte, src_bit, dst - out); + "Row %3"PRIu32", Col %3"PRIu32", Samples %"PRIu16", Src byte offset %3"PRIu32" bit offset %2"PRIu32" Dst offset %3td", + row + 1u, col + 1u, s, src_byte, src_bit, dst - out); dump_short (dumpfile, format, "Match bits", matchbits); dump_data (dumpfile, format, "Src bits", src, 2); @@ -4096,8 +4092,8 @@ combineSeparateSamples24bits (uint8_t *in[], uint8_t *out, uint32_t cols, if ((dumpfile != NULL) && (level == 3)) { dump_info (dumpfile, format, "", - "Row %3d, Col %3d, Samples %d, Src byte offset %3d bit offset %2d Dst offset %3d", - row + 1, col + 1, s, src_byte, src_bit, dst - out); + "Row %3"PRIu32", Col %3"PRIu32", Samples %"PRIu16", Src byte offset %3"PRIu32" bit offset %2"PRIu32" Dst offset %3td", + row + 1u, col + 1u, s, src_byte, src_bit, dst - out); dump_long (dumpfile, format, "Match bits ", matchbits); dump_data (dumpfile, format, "Src bits ", src, 4); dump_long (dumpfile, format, "Buff1 bits ", buff1); @@ -4233,8 +4229,8 @@ combineSeparateSamples32bits (uint8_t *in[], uint8_t *out, uint32_t cols, if ((dumpfile != NULL) && (level == 3)) { dump_info (dumpfile, format, "", - "Row %3d, Col %3d, Sample %d, Src byte offset %3d bit offset %2d Dst offset %3d", - row + 1, col + 1, s, src_byte, src_bit, dst - out); + "Row %3"PRIu32", Col %3"PRIu32", Sample %"PRIu16", Src byte offset %3"PRIu32" bit offset %2"PRIu32" Dst offset %3td", + row + 1u, col + 1u, s, src_byte, src_bit, dst - out); dump_wide (dumpfile, format, "Match bits ", matchbits); dump_data (dumpfile, format, "Src bits ", src, 8); dump_wide (dumpfile, format, "Buff1 bits ", buff1); @@ -4305,7 +4301,7 @@ combineSeparateTileSamplesBytes (unsigned char *srcbuffs[], unsigned char *out, { for (s = 0; s < spp; s++) { - dump_info (dumpfile, format, "combineSeparateTileSamplesBytes","Input data, Sample %d", s); + dump_info (dumpfile, format, "combineSeparateTileSamplesBytes","Input data, Sample %"PRIu16, s); dump_buffer(dumpfile, format, 1, cols, row, srcbuffs[s] + (row * src_rowsize)); } } @@ -4402,8 +4398,8 @@ combineSeparateTileSamples8bits (uint8_t *in[], uint8_t *out, uint32_t cols, if ((dumpfile != NULL) && (level == 3)) { dump_info (dumpfile, format, "", - "Row %3d, Col %3d, Samples %d, Src byte offset %3d bit offset %2d Dst offset %3d", - row + 1, col + 1, s, src_byte, src_bit, dst - out); + "Row %3"PRIu32", Col %3"PRIu32", Samples %"PRIu16", Src byte offset %3"PRIu32" bit offset %2"PRIu32" Dst offset %3td", + row + 1u, col + 1u, s, src_byte, src_bit, dst - out); dump_byte (dumpfile, format, "Match bits", matchbits); dump_byte (dumpfile, format, "Src bits", *src); dump_byte (dumpfile, format, "Buff1 bits", buff1); @@ -4508,8 +4504,8 @@ combineSeparateTileSamples16bits (uint8_t *in[], uint8_t *out, uint32_t cols, if ((dumpfile != NULL) && (level == 3)) { dump_info (dumpfile, format, "", - "Row %3d, Col %3d, Samples %d, Src byte offset %3d bit offset %2d Dst offset %3d", - row + 1, col + 1, s, src_byte, src_bit, dst - out); + "Row %3"PRIu32", Col %3"PRIu32", Samples %"PRIu16", Src byte offset %3"PRIu32" bit offset %2"PRIu32" Dst offset %3td", + row + 1u, col + 1u, s, src_byte, src_bit, dst - out); dump_short (dumpfile, format, "Match bits", matchbits); dump_data (dumpfile, format, "Src bits", src, 2); @@ -4620,8 +4616,8 @@ combineSeparateTileSamples24bits (uint8_t *in[], uint8_t *out, uint32_t cols, if ((dumpfile != NULL) && (level == 3)) { dump_info (dumpfile, format, "", - "Row %3d, Col %3d, Samples %d, Src byte offset %3d bit offset %2d Dst offset %3d", - row + 1, col + 1, s, src_byte, src_bit, dst - out); + "Row %3"PRIu32", Col %3"PRIu32", Samples %"PRIu16", Src byte offset %3"PRIu32" bit offset %2"PRIu32" Dst offset %3td", + row + 1u, col + 1u, s, src_byte, src_bit, dst - out); dump_long (dumpfile, format, "Match bits ", matchbits); dump_data (dumpfile, format, "Src bits ", src, 4); dump_long (dumpfile, format, "Buff1 bits ", buff1); @@ -4758,8 +4754,8 @@ combineSeparateTileSamples32bits (uint8_t *in[], uint8_t *out, uint32_t cols, if ((dumpfile != NULL) && (level == 3)) { dump_info (dumpfile, format, "", - "Row %3d, Col %3d, Sample %d, Src byte offset %3d bit offset %2d Dst offset %3d", - row + 1, col + 1, s, src_byte, src_bit, dst - out); + "Row %3"PRIu32", Col %3"PRIu32", Sample %"PRIu16", Src byte offset %3"PRIu32" bit offset %2"PRIu32" Dst offset %3td", + row + 1u, col + 1u, s, src_byte, src_bit, dst - out); dump_wide (dumpfile, format, "Match bits ", matchbits); dump_data (dumpfile, format, "Src bits ", src, 8); dump_wide (dumpfile, format, "Buff1 bits ", buff1); @@ -4849,10 +4845,10 @@ static int readSeparateStripsIntoBuffer (TIFF *in, uint8_t *obuf, uint32_t lengt if ((dump->infile != NULL) && (dump->level == 3)) { dump_info (dump->infile, dump->format, "", - "Image width %d, length %d, Scanline size, %4d bytes", + "Image width %"PRIu32", length %"PRIu32", Scanline size, %4"PRId64" bytes", width, length, scanlinesize); dump_info (dump->infile, dump->format, "", - "Bits per sample %d, Samples per pixel %d, Shift width %d", + "Bits per sample %"PRIu16", Samples per pixel %"PRIu16", Shift width %d", bps, spp, shift_width); } @@ -4878,7 +4874,7 @@ static int readSeparateStripsIntoBuffer (TIFF *in, uint8_t *obuf, uint32_t lengt if (!buff) { TIFFError ("readSeparateStripsIntoBuffer", - "Unable to allocate strip read buffer for sample %d", s); + "Unable to allocate strip read buffer for sample %"PRIu16, s); for (i = 0; i < s; i++) _TIFFfree (srcbuffs[i]); return 0; @@ -4901,13 +4897,13 @@ static int readSeparateStripsIntoBuffer (TIFF *in, uint8_t *obuf, uint32_t lengt if (bytes_read < 0 && !ignore) { TIFFError(TIFFFileName(in), - "Error, can't read strip %lu for sample %d", - (unsigned long) strip, s + 1); + "Error, can't read strip %"PRIu32" for sample %"PRIu32, + strip, s + 1u); result = 0; break; } #ifdef DEVELMODE - TIFFError("", "Strip %2d, read %5d bytes for %4d scanlines, shift width %d", + TIFFError("", "Strip %2"PRIu32", read %5"PRId32" bytes for %4"PRIu32" scanlines, shift width %d", strip, bytes_read, rows_this_strip, shift_width); #endif } @@ -4965,7 +4961,7 @@ static int readSeparateStripsIntoBuffer (TIFF *in, uint8_t *obuf, uint32_t lengt break; } break; - default: TIFFError ("readSeparateStripsIntoBuffer", "Unsupported bit depth: %d", bps); + default: TIFFError ("readSeparateStripsIntoBuffer", "Unsupported bit depth: %"PRIu16, bps); result = 0; break; } @@ -5464,9 +5460,9 @@ getCropOffsets(struct image_data *image, struct crop_mask *crop, struct dump_opt if (dump->outfile != NULL) { - dump_info (dump->outfile, dump->format, "", "Margins: Top: %d Left: %d Bottom: %d Right: %d", + dump_info (dump->outfile, dump->format, "", "Margins: Top: %"PRIu32" Left: %"PRIu32" Bottom: %"PRIu32" Right: %"PRIu32, offsets.tmargin, offsets.lmargin, offsets.bmargin, offsets.rmargin); - dump_info (dump->outfile, dump->format, "", "Crop region within margins: Adjusted Width: %6d Length: %6d", + dump_info (dump->outfile, dump->format, "", "Crop region within margins: Adjusted Width: %6"PRIu32" Length: %6"PRIu32, offsets.crop_width, offsets.crop_length); } @@ -5621,8 +5617,8 @@ getCropOffsets(struct image_data *image, struct crop_mask *crop, struct dump_opt if (dump->outfile != NULL) - dump_info (dump->outfile, dump->format, "", "Zone %d, width: %4d, length: %4d, x1: %4d x2: %4d y1: %4d y2: %4d", - i + 1, (uint32_t)zwidth, (uint32_t)zlength, + dump_info (dump->outfile, dump->format, "", "Zone %d, width: %4"PRIu32", length: %4"PRIu32", x1: %4"PRIu32" x2: %4"PRIu32" y1: %4"PRIu32" y2: %4"PRIu32, + i + 1, zwidth, zlength, crop->regionlist[i].x1, crop->regionlist[i].x2, crop->regionlist[i].y1, crop->regionlist[i].y2); } @@ -5705,7 +5701,7 @@ computeOutputPixelOffsets (struct crop_mask *crop, struct image_data *image, "Hmargin: %3.2f, Vmargin: %3.2f", page->name, page->vres, page->hres, page->hmargin, page->vmargin); - TIFFError("", "Res_unit: %d, Scale: %3.2f, Page width: %3.2f, length: %3.2f", + TIFFError("", "Res_unit: %"PRIu16", Scale: %3.2f, Page width: %3.2f, length: %3.2f", page->res_unit, scale, pwidth, plength); } @@ -6061,7 +6057,7 @@ loadImage(TIFF* in, struct image_data *image, struct dump_opts *dump, unsigned c if ((bps == 0) || (spp == 0)) { - TIFFError("loadImage", "Invalid samples per pixel (%d) or bits per sample (%d)", + TIFFError("loadImage", "Invalid samples per pixel (%"PRIu16") or bits per sample (%"PRIu16")", spp, bps); return (-1); } @@ -6098,14 +6094,14 @@ loadImage(TIFF* in, struct image_data *image, struct dump_opts *dump, unsigned c #ifdef DEBUG2 TIFFError("loadImage", - "Tilesize %u is too small, using ntiles * tilelength * tilerowsize %lu", - tlsize, (unsigned long)buffsize); + "Tilesize %"PRIu32" is too small, using ntiles * tilelength * tilerowsize %"PRIu32, + tlsize, buffsize); #endif } if (dump->infile != NULL) dump_info (dump->infile, dump->format, "", - "Tilesize: %u, Number of Tiles: %u, Tile row size: %u", + "Tilesize: %"PRIu32", Number of Tiles: %"PRIu32", Tile row size: %"PRIu32, tlsize, ntiles, tile_rowsize); } else @@ -6138,14 +6134,14 @@ loadImage(TIFF* in, struct image_data *image, struct dump_opts *dump, unsigned c buffsize = ((length * width * spp * bps) + 7) / 8; #ifdef DEBUG2 TIFFError("loadImage", - "Stripsize %u is too small, using imagelength * width * spp * bps / 8 = %lu", + "Stripsize %"PRIu32" is too small, using imagelength * width * spp * bps / 8 = %"PRIu32, stsize, (unsigned long)buffsize); #endif } if (dump->infile != NULL) dump_info (dump->infile, dump->format, "", - "Stripsize: %u, Number of Strips: %u, Rows per Strip: %u, Scanline size: %u", + "Stripsize: %"PRIu32", Number of Strips: %"PRIu32", Rows per Strip: %"PRIu32", Scanline size: %"PRIu32, stsize, nstrips, rowsperstrip, scanlinesize); } @@ -6164,7 +6160,7 @@ loadImage(TIFF* in, struct image_data *image, struct dump_opts *dump, unsigned c if (subsampling_horiz != 1 || subsampling_vert != 1) { TIFFError("loadImage", - "Can't copy/convert subsampled image with subsampling %d horiz %d vert", + "Can't copy/convert subsampled image with subsampling %"PRIu16" horiz %"PRIu16" vert", subsampling_horiz, subsampling_vert); return (-1); } @@ -6264,10 +6260,10 @@ loadImage(TIFF* in, struct image_data *image, struct dump_opts *dump, unsigned c if ((dump->infile != NULL) && (dump->level == 2)) { dump_info (dump->infile, dump->format, "loadImage", - "Image width %d, length %d, Raw image data, %4d bytes", + "Image width %"PRIu32", length %"PRIu32", Raw image data, %4"PRIu32" bytes", width, length, buffsize); dump_info (dump->infile, dump->format, "", - "Bits per sample %d, Samples per pixel %d", bps, spp); + "Bits per sample %"PRIu16", Samples per pixel %"PRIu16, bps, spp); for (i = 0; i < length; i++) dump_buffer(dump->infile, dump->format, 1, scanlinesize, @@ -6311,8 +6307,8 @@ static int correct_orientation(struct image_data *image, unsigned char **work_b rotation = (uint16_t) 270; else { - TIFFError ("correct_orientation", "Invalid rotation value: %d", - image->adjustments & ROTATE_ANY); + TIFFError ("correct_orientation", "Invalid rotation value: %"PRIu16, + (uint16_t) (image->adjustments & ROTATE_ANY)); return (-1); } @@ -6417,7 +6413,7 @@ extractCompositeRegions(struct image_data *image, struct crop_mask *crop, last_col + 1)) { TIFFError("extractCompositeRegions", - "Unable to extract row %d", row); + "Unable to extract row %"PRIu32, row); return (1); } break; @@ -6429,7 +6425,7 @@ extractCompositeRegions(struct image_data *image, struct crop_mask *crop, prev_trailing_bits)) { TIFFError("extractCompositeRegions", - "Unable to extract row %d", row); + "Unable to extract row %"PRIu32, row); return (1); } break; @@ -6441,7 +6437,7 @@ extractCompositeRegions(struct image_data *image, struct crop_mask *crop, prev_trailing_bits)) { TIFFError("extractCompositeRegions", - "Unable to extract row %d", row); + "Unable to extract row %"PRIu32, row); return (1); } break; @@ -6451,7 +6447,7 @@ extractCompositeRegions(struct image_data *image, struct crop_mask *crop, prev_trailing_bits)) { TIFFError("extractCompositeRegions", - "Unable to extract row %d", row); + "Unable to extract row %"PRIu32, row); return (1); } break; @@ -6463,11 +6459,11 @@ extractCompositeRegions(struct image_data *image, struct crop_mask *crop, prev_trailing_bits)) { TIFFError("extractCompositeRegions", - "Unable to extract row %d", row); + "Unable to extract row %"PRIu32, row); return (1); } break; - default: TIFFError("extractCompositeRegions", "Unsupported bit depth %d", bps); + default: TIFFError("extractCompositeRegions", "Unsupported bit depth %"PRIu16, bps); return (1); } } @@ -6499,7 +6495,7 @@ extractCompositeRegions(struct image_data *image, struct crop_mask *crop, first_col, last_col + 1)) { TIFFError("extractCompositeRegions", - "Unable to extract row %d", row); + "Unable to extract row %"PRIu32, row); return (1); } break; @@ -6511,7 +6507,7 @@ extractCompositeRegions(struct image_data *image, struct crop_mask *crop, prev_trailing_bits)) { TIFFError("extractCompositeRegions", - "Unable to extract row %d", row); + "Unable to extract row %"PRIu32, row); return (1); } break; @@ -6523,7 +6519,7 @@ extractCompositeRegions(struct image_data *image, struct crop_mask *crop, prev_trailing_bits)) { TIFFError("extractCompositeRegions", - "Unable to extract row %d", row); + "Unable to extract row %"PRIu32, row); return (1); } break; @@ -6533,7 +6529,7 @@ extractCompositeRegions(struct image_data *image, struct crop_mask *crop, prev_trailing_bits)) { TIFFError("extractCompositeRegions", - "Unable to extract row %d", row); + "Unable to extract row %"PRIu32, row); return (1); } break; @@ -6545,11 +6541,11 @@ extractCompositeRegions(struct image_data *image, struct crop_mask *crop, prev_trailing_bits)) { TIFFError("extractCompositeRegions", - "Unable to extract row %d", row); + "Unable to extract row %"PRIu32, row); return (1); } break; - default: TIFFError("extractCompositeRegions", "Unsupported bit depth %d", bps); + default: TIFFError("extractCompositeRegions", "Unsupported bit depth %"PRIu16, bps); return (1); } } @@ -6642,7 +6638,7 @@ extractSeparateRegion(struct image_data *image, struct crop_mask *crop, last_col + 1)) { TIFFError("extractSeparateRegion", - "Unable to extract row %d", row); + "Unable to extract row %"PRIu32, row); return (1); } break; @@ -6654,7 +6650,7 @@ extractSeparateRegion(struct image_data *image, struct crop_mask *crop, prev_trailing_bits)) { TIFFError("extractSeparateRegion", - "Unable to extract row %d", row); + "Unable to extract row %"PRIu32, row); return (1); } break; @@ -6666,7 +6662,7 @@ extractSeparateRegion(struct image_data *image, struct crop_mask *crop, prev_trailing_bits)) { TIFFError("extractSeparateRegion", - "Unable to extract row %d", row); + "Unable to extract row %"PRIu32, row); return (1); } break; @@ -6676,7 +6672,7 @@ extractSeparateRegion(struct image_data *image, struct crop_mask *crop, prev_trailing_bits)) { TIFFError("extractSeparateRegion", - "Unable to extract row %d", row); + "Unable to extract row %"PRIu32, row); return (1); } break; @@ -6688,11 +6684,11 @@ extractSeparateRegion(struct image_data *image, struct crop_mask *crop, prev_trailing_bits)) { TIFFError("extractSeparateRegion", - "Unable to extract row %d", row); + "Unable to extract row %"PRIu32, row); return (1); } break; - default: TIFFError("extractSeparateRegion", "Unsupported bit depth %d", bps); + default: TIFFError("extractSeparateRegion", "Unsupported bit depth %"PRIu16, bps); return (1); } } @@ -6769,11 +6765,11 @@ extractImageSection(struct image_data *image, struct pageseg *section, trailing_bits = (sect_width * bps) % 8; #ifdef DEVELMODE - TIFFError ("", "First row: %d, last row: %d, First col: %d, last col: %d\n", + TIFFError ("", "First row: %"PRIu32", last row: %"PRIu32", First col: %"PRIu32", last col: %"PRIu32"\n", first_row, last_row, first_col, last_col); - TIFFError ("", "Image width: %d, Image length: %d, bps: %d, spp: %d\n", + TIFFError ("", "Image width: %"PRIu32", Image length: %"PRIu32", bps: %"PRIu16", spp: %"PRIu16"\n", img_width, img_length, bps, spp); - TIFFError ("", "Sect width: %d, Sect length: %d, full bytes: %d trailing bits %d\n", + TIFFError ("", "Sect width: %"PRIu32", Sect length: %"PRIu32", full bytes: %"PRIu32" trailing bits %"PRIu32"\n", sect_width, sect_length, full_bytes, trailing_bits); #endif @@ -6787,7 +6783,7 @@ extractImageSection(struct image_data *image, struct pageseg *section, src_offset = row_offset + col_offset; #ifdef DEVELMODE - TIFFError ("", "Src offset: %8d, Dst offset: %8d", src_offset, dst_offset); + TIFFError ("", "Src offset: %8"PRIu32", Dst offset: %8"PRIu32, src_offset, dst_offset); #endif _TIFFmemcpy (sect_buff + dst_offset, src_buff + src_offset, full_bytes); dst_offset += full_bytes; @@ -6818,7 +6814,7 @@ extractImageSection(struct image_data *image, struct pageseg *section, sprintf(&bitarray[j], (bitset) ? "1" : "0"); } bitarray[18] = '\0'; - TIFFError ("", "Row: %3d Offset1: %d, Shift1: %d, Offset2: %d, Shift2: %d\n", + TIFFError ("", "Row: %3d Offset1: %"PRIu32", Shift1: %"PRIu32", Offset2: %"PRIu32", Shift2: %"PRIu32"\n", row, offset1, shift1, offset2, shift2); #endif @@ -6828,7 +6824,7 @@ extractImageSection(struct image_data *image, struct pageseg *section, _TIFFmemcpy (sect_buff + dst_offset, src_buff + offset1, full_bytes); #ifdef DEVELMODE - TIFFError ("", " Aligned data src offset1: %8d, Dst offset: %8d\n", offset1, dst_offset); + TIFFError ("", " Aligned data src offset1: %8"PRIu32", Dst offset: %8"PRIu32"\n", offset1, dst_offset); sprintf(&bitarray[18], "\n"); sprintf(&bitarray[19], "\t"); for (j = 20, k = 7; j < 28; j++, k--) @@ -6846,7 +6842,7 @@ extractImageSection(struct image_data *image, struct pageseg *section, bytebuff2 = src_buff[offset2] & ((unsigned char)255 << (7 - shift2)); sect_buff[dst_offset] = bytebuff2; #ifdef DEVELMODE - TIFFError ("", " Trailing bits src offset: %8d, Dst offset: %8d\n", + TIFFError ("", " Trailing bits src offset: %8"PRIu32", Dst offset: %8"PRIu32"\n", offset2, dst_offset); for (j = 30, k = 7; j < 38; j++, k--) { @@ -6862,7 +6858,7 @@ extractImageSection(struct image_data *image, struct pageseg *section, else /* each destination byte will have to be built from two source bytes*/ { #ifdef DEVELMODE - TIFFError ("", " Unalligned data src offset: %8d, Dst offset: %8d\n", offset1 , dst_offset); + TIFFError ("", " Unalligned data src offset: %8"PRIu32", Dst offset: %8"PRIu32"\n", offset1 , dst_offset); #endif for (j = 0; j <= full_bytes; j++) { @@ -6886,7 +6882,7 @@ extractImageSection(struct image_data *image, struct pageseg *section, if (trailing_bits != 0) { #ifdef DEVELMODE - TIFFError ("", " Trailing bits src offset: %8d, Dst offset: %8d\n", offset1 + full_bytes, dst_offset); + TIFFError ("", " Trailing bits src offset: %8"PRIu32", Dst offset: %8"PRIu32"\n", offset1 + full_bytes, dst_offset); #endif if (shift2 > shift1) { @@ -7056,7 +7052,7 @@ writeImageSections(TIFF *in, TIFF *out, struct image_data *image, if ((k < 1) || (k > MAX_SECTIONS)) { TIFFError("writeImageSections", - "%d Rows and Columns exceed maximum sections\nIncrease resolution or reduce sections", k); + "%"PRIu32" Rows and Columns exceed maximum sections\nIncrease resolution or reduce sections", k); return (-1); } @@ -7518,7 +7514,7 @@ processCropSelections(struct image_data *image, struct crop_mask *crop, &crop->combined_length, &crop_buff)) { TIFFError("processCropSelections", - "Failed to rotate composite regions by %d degrees", crop->rotation); + "Failed to rotate composite regions by %"PRIu32" degrees", crop->rotation); return (-1); } seg_buffs[0].buffer = crop_buff; @@ -7624,7 +7620,7 @@ processCropSelections(struct image_data *image, struct crop_mask *crop, &crop->regionlist[i].length, &crop_buff)) { TIFFError("processCropSelections", - "Failed to rotate crop region by %d degrees", crop->rotation); + "Failed to rotate crop region by %"PRIu16" degrees", crop->rotation); return (-1); } total_width += crop->regionlist[i].width; @@ -7752,7 +7748,7 @@ createCroppedImage(struct image_data *image, struct crop_mask *crop, &crop->combined_length, crop_buff_ptr)) { TIFFError("createCroppedImage", - "Failed to rotate image or cropped selection by %d degrees", crop->rotation); + "Failed to rotate image or cropped selection by %"PRIu16" degrees", crop->rotation); return (-1); } } @@ -8096,7 +8092,7 @@ rotateContigSamples8bits(uint16_t rotation, uint16_t spp, uint16_t bps, uint32_t break; case 270: next = src + src_byte + (row * rowsize); break; - default: TIFFError("rotateContigSamples8bits", "Invalid rotation %d", rotation); + default: TIFFError("rotateContigSamples8bits", "Invalid rotation %"PRIu16, rotation); return (1); } matchbits = maskbits << (8 - src_bit - bps); @@ -8172,7 +8168,7 @@ rotateContigSamples16bits(uint16_t rotation, uint16_t spp, uint16_t bps, uint32_ break; case 270: next = src + src_byte + (row * rowsize); break; - default: TIFFError("rotateContigSamples8bits", "Invalid rotation %d", rotation); + default: TIFFError("rotateContigSamples8bits", "Invalid rotation %"PRIu16, rotation); return (1); } matchbits = maskbits << (16 - src_bit - bps); @@ -8256,7 +8252,7 @@ rotateContigSamples24bits(uint16_t rotation, uint16_t spp, uint16_t bps, uint32_ break; case 270: next = src + src_byte + (row * rowsize); break; - default: TIFFError("rotateContigSamples8bits", "Invalid rotation %d", rotation); + default: TIFFError("rotateContigSamples8bits", "Invalid rotation %"PRIu16, rotation); return (1); } matchbits = maskbits << (32 - src_bit - bps); @@ -8356,7 +8352,7 @@ rotateContigSamples32bits(uint16_t rotation, uint16_t spp, uint16_t bps, uint32_ break; case 270: next = src + src_byte + (row * rowsize); break; - default: TIFFError("rotateContigSamples8bits", "Invalid rotation %d", rotation); + default: TIFFError("rotateContigSamples8bits", "Invalid rotation %"PRIu16, rotation); return (1); } matchbits = maskbits << (64 - src_bit - bps); @@ -8452,7 +8448,7 @@ rotateImage(uint16_t rotation, struct image_data *image, uint32_t *img_width, case 90: case 180: case 270: break; - default: TIFFError("rotateImage", "Invalid rotation angle %d", rotation); + default: TIFFError("rotateImage", "Invalid rotation angle %"PRIu16, rotation); return (-1); } @@ -8522,7 +8518,7 @@ rotateImage(uint16_t rotation, struct image_data *image, uint32_t *img_width, return (-1); } break; - default: TIFFError("rotateImage","Unsupported bit depth %d", bps); + default: TIFFError("rotateImage","Unsupported bit depth %"PRIu16, bps); _TIFFfree(rbuff); return (-1); } @@ -8591,7 +8587,7 @@ rotateImage(uint16_t rotation, struct image_data *image, uint32_t *img_width, return (-1); } break; - default: TIFFError("rotateImage","Unsupported bit depth %d", bps); + default: TIFFError("rotateImage","Unsupported bit depth %"PRIu16, bps); _TIFFfree(rbuff); return (-1); } @@ -8668,7 +8664,7 @@ rotateImage(uint16_t rotation, struct image_data *image, uint32_t *img_width, return (-1); } break; - default: TIFFError("rotateImage","Unsupported bit depth %d", bps); + default: TIFFError("rotateImage","Unsupported bit depth %"PRIu16, bps); _TIFFfree(rbuff); return (-1); } @@ -9062,7 +9058,7 @@ reverseSamplesBytes (uint16_t spp, uint16_t bps, uint32_t width, dst -= spp; } break; - default: TIFFError("reverseSamplesBytes","Unsupported bit depth %d", bps); + default: TIFFError("reverseSamplesBytes","Unsupported bit depth %"PRIu16, bps); return (1); } return (0); @@ -9165,7 +9161,7 @@ mirrorImage(uint16_t spp, uint16_t bps, uint16_t mirror, uint32_t width, uint32_ } _TIFFmemcpy (src, line_buff, rowsize); break; - default: TIFFError("mirrorImage","Unsupported bit depth %d", bps); + default: TIFFError("mirrorImage","Unsupported bit depth %"PRIu16, bps); _TIFFfree(line_buff); return (-1); } @@ -9175,7 +9171,7 @@ mirrorImage(uint16_t spp, uint16_t bps, uint16_t mirror, uint32_t width, uint32_ } break; - default: TIFFError ("mirrorImage", "Invalid mirror axis %d", mirror); + default: TIFFError ("mirrorImage", "Invalid mirror axis %"PRIu16, mirror); return (-1); break; } @@ -9239,7 +9235,7 @@ invertImage(uint16_t photometric, uint16_t spp, uint16_t bps, uint32_t width, ui src++; } break; - default: TIFFError("invertImage", "Unsupported bit depth %d", bps); + default: TIFFError("invertImage", "Unsupported bit depth %"PRIu16, bps); return (-1); } diff --git a/tools/tiffdump.c b/tools/tiffdump.c index b0f05650..74a76603 100644 --- a/tools/tiffdump.c +++ b/tools/tiffdump.c @@ -73,26 +73,20 @@ static int bigendian; static int bigtiff; static uint32_t maxitems = 24; /* maximum indirect data items to print */ -static const char bytefmt[] = "%s%#02x"; /* BYTE */ -static const char sbytefmt[] = "%s%d"; /* SBYTE */ -static const char shortfmtd[] = "%s%u"; /* SHORT */ -static const char shortfmth[] = "%s%#x"; -static const char sshortfmtd[] = "%s%d"; /* SSHORT */ -static const char sshortfmth[] = "%s%#x"; -static const char longfmtd[] = "%s%lu"; /* LONG */ -static const char longfmth[] = "%s%#lx"; -static const char slongfmtd[] = "%s%ld"; /* SLONG */ -static const char slongfmth[] = "%s%#lx"; -static const char ifdfmt[] = "%s%#04lx"; /* IFD offset */ -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) -static const char long8fmt[] = "%s%I64u"; /* LONG8 */ -static const char slong8fmt[] = "%s%I64d"; /* SLONG8 */ -static const char ifd8fmt[] = "%s%#08I64x"; /* IFD offset8*/ -#else -static const char long8fmt[] = "%s%llu"; /* LONG8 */ -static const char slong8fmt[] = "%s%lld"; /* SLONG8 */ -static const char ifd8fmt[] = "%s%#08llx"; /* IFD offset8 */ -#endif +static const char bytefmt[] = "%s%#02" PRIx8; /* BYTE */ +static const char sbytefmt[] = "%s%" PRId8; /* SBYTE */ +static const char shortfmtd[] = "%s%" PRIu16; /* SHORT */ +static const char shortfmth[] = "%s%#" PRIx16; +static const char sshortfmtd[] = "%s%" PRId16; /* SSHORT */ +static const char sshortfmth[] = "%s%#" PRIx16; +static const char longfmtd[] = "%s%" PRIu32; /* LONG */ +static const char longfmth[] = "%s%#" PRIx32; +static const char slongfmtd[] = "%s%" PRId32; /* SLONG */ +static const char slongfmth[] = "%s%#" PRIx32; +static const char ifdfmt[] = "%s%#04" PRIx32; /* IFD offset */ +static const char long8fmt[] = "%s%" PRIu64; /* LONG8 */ +static const char slong8fmt[] = "%s%" PRId64; /* SLONG8 */ +static const char ifd8fmt[] = "%s%#08" PRIx64; /* IFD offset8 */ static const char rationalfmt[] = "%s%g"; /* RATIONAL */ static const char srationalfmt[] = "%s%g"; /* SRATIONAL */ static const char floatfmt[] = "%s%g"; /* FLOAT */ @@ -347,13 +341,8 @@ ReadDirectory(int fd, unsigned int ix, uint64_t off) if (n != dircount*direntrysize) { n /= direntrysize; Error( -#if defined(__WIN32__) && defined(_MSC_VER) - "Could only read %lu of %u entries in directory at offset %#I64x", - (unsigned long)n, dircount, (unsigned __int64) off); -#else - "Could only read %lu of %u entries in directory at offset %#llx", - (unsigned long)n, dircount, (unsigned long long) off); -#endif + "Could only read %" PRIu32 " of %" PRIu16 " entries in directory at offset %#" PRIu64, + n, dircount, off); dircount = n; nextdiroff = 0; } else { @@ -371,15 +360,8 @@ ReadDirectory(int fd, unsigned int ix, uint64_t off) TIFFSwabLong8(&nextdiroff); } } -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) - printf("Directory %u: offset %I64u (%#I64x) next %I64u (%#I64x)\n", ix, - (unsigned __int64)off, (unsigned __int64)off, - (unsigned __int64)nextdiroff, (unsigned __int64)nextdiroff); -#else - printf("Directory %u: offset %llu (%#llx) next %llu (%#llx)\n", ix, - (unsigned long long)off, (unsigned long long)off, - (unsigned long long)nextdiroff, (unsigned long long)nextdiroff); -#endif + printf("Directory %u: offset %" PRIu64 " (%#" PRIx64 ") next %" PRIu64 " (%#" PRIx64 ")\n", + ix, off, off, nextdiroff, nextdiroff); for (dp = (uint8_t*)dirmem, n = dircount; n > 0; n--) { uint16_t tag; uint16_t type; @@ -420,11 +402,7 @@ ReadDirectory(int fd, unsigned int ix, uint64_t off) TIFFSwabLong8(&count); dp += sizeof(uint64_t); } -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) - printf("%I64u<", (unsigned __int64)count); -#else - printf("%llu<", (unsigned long long)count); -#endif + printf("%" PRIu64 "<", count); if (type >= NWIDTHS) typewidth = 0; else @@ -749,7 +727,7 @@ PrintData(FILE* fd, uint16_t type, uint32_t count, unsigned char* data) case TIFF_LONG: { uint32_t *lp = (uint32_t*)data; while (count-- > 0) { - fprintf(fd, hex_mode ? longfmth : longfmtd, sep, (unsigned long) *lp++); + fprintf(fd, hex_mode ? longfmth : longfmtd, sep, *lp++); sep = " "; } break; @@ -757,7 +735,7 @@ PrintData(FILE* fd, uint16_t type, uint32_t count, unsigned char* data) case TIFF_SLONG: { int32_t *lp = (int32_t*)data; while (count-- > 0) - fprintf(fd, hex_mode ? slongfmth : slongfmtd, sep, (long) *lp++), sep = " "; + fprintf(fd, hex_mode ? slongfmth : slongfmtd, sep, *lp++), sep = " "; break; } case TIFF_LONG8: { @@ -766,7 +744,7 @@ PrintData(FILE* fd, uint16_t type, uint32_t count, unsigned char* data) uint64_t val; memcpy(&val, llp, sizeof(uint64_t)); llp ++; - fprintf(fd, long8fmt, sep, (unsigned long long) val); + fprintf(fd, long8fmt, sep, val); sep = " "; } break; @@ -777,7 +755,7 @@ PrintData(FILE* fd, uint16_t type, uint32_t count, unsigned char* data) int64_t val; memcpy(&val, llp, sizeof(int64_t)); llp ++; - fprintf(fd, slong8fmt, sep, (long long) val); + fprintf(fd, slong8fmt, sep, val); sep = " "; } break; @@ -786,9 +764,8 @@ PrintData(FILE* fd, uint16_t type, uint32_t count, unsigned char* data) uint32_t *lp = (uint32_t*)data; while (count-- > 0) { if (lp[1] == 0) - fprintf(fd, "%sNan (%lu/%lu)", sep, - (unsigned long) lp[0], - (unsigned long) lp[1]); + fprintf(fd, "%sNan (%"PRIu32"/%"PRIu32")", sep, + lp[0], lp[1]); else fprintf(fd, rationalfmt, sep, (double)lp[0] / (double)lp[1]); @@ -801,8 +778,8 @@ PrintData(FILE* fd, uint16_t type, uint32_t count, unsigned char* data) int32_t *lp = (int32_t*)data; while (count-- > 0) { if (lp[1] == 0) - fprintf(fd, "%sNan (%ld/%ld)", sep, - (long) lp[0], (long) lp[1]); + fprintf(fd, "%sNan (%"PRId32"/%"PRId32")", sep, + lp[0], lp[1]); else fprintf(fd, srationalfmt, sep, (double)lp[0] / (double)lp[1]); @@ -826,7 +803,7 @@ PrintData(FILE* fd, uint16_t type, uint32_t count, unsigned char* data) case TIFF_IFD: { uint32_t *lp = (uint32_t*)data; while (count-- > 0) { - fprintf(fd, ifdfmt, sep, (unsigned long) *lp++); + fprintf(fd, ifdfmt, sep, *lp++); sep = " "; } break; @@ -834,11 +811,8 @@ PrintData(FILE* fd, uint16_t type, uint32_t count, unsigned char* data) case TIFF_IFD8: { uint64_t *llp = (uint64_t*)data; while (count-- > 0) { -#if defined(__WIN32__) && defined(_MSC_VER) - fprintf(fd, ifd8fmt, sep, (unsigned __int64) *llp++); -#else - fprintf(fd, ifd8fmt, sep, (unsigned long long) *llp++); -#endif + fprintf(fd, ifd8fmt, sep, *llp++); + sep = " "; sep = " "; } break; diff --git a/tools/tiffinfo.c b/tools/tiffinfo.c index f61142ad..329c0d31 100644 --- a/tools/tiffinfo.c +++ b/tools/tiffinfo.c @@ -202,7 +202,7 @@ ShowStrip(tstrip_t strip, unsigned char* pp, uint32_t nrow, tsize_t scanline) { register tsize_t cc; - printf("Strip %lu:\n", (unsigned long) strip); + printf("Strip %"PRIu32":\n", strip); while (nrow-- > 0) { for (cc = 0; cc < scanline; cc++) { printf(" %02x", *pp++); @@ -277,9 +277,9 @@ ShowTile(uint32_t row, uint32_t col, tsample_t sample, { uint32_t cc; - printf("Tile (%lu,%lu", (unsigned long) row, (unsigned long) col); + printf("Tile (%" PRIu32 ",%" PRIu32 "", row, col); if (sample != (tsample_t) -1) - printf(",%u", sample); + printf(",%" PRIu16, sample); printf("):\n"); while (nrow-- > 0) { for (cc = 0; cc < (uint32_t) rowsize; cc++) { @@ -403,7 +403,7 @@ ShowRawWords(uint16_t* pp, uint32_t n) uint32_t i; for (i = 0; i < n; i++) { - printf(" %04x", *pp++); + printf(" %04" PRIx16, *pp++); if (((i+1) % 15) == 0) printf("\n "); } @@ -430,23 +430,23 @@ TIFFReadRawDataStriped(TIFF* tif, int bitrev) } if (buf == NULL) { fprintf(stderr, - "Cannot allocate buffer to read strip %lu\n", - (unsigned long) s); + "Cannot allocate buffer to read strip %"PRIu32"\n", + s); break; } if (TIFFReadRawStrip(tif, s, buf, (tmsize_t) stripbc[s]) < 0) { - fprintf(stderr, "Error reading strip %lu\n", - (unsigned long) s); + fprintf(stderr, "Error reading strip %"PRIu32"\n", + s); if (stoponerr) break; } else if (showdata) { if (bitrev) { TIFFReverseBits(buf, (tmsize_t)stripbc[s]); - printf("%s %lu: (bit reversed)\n ", - what, (unsigned long) s); + printf("%s %"PRIu32": (bit reversed)\n ", + what, s); } else - printf("%s %lu:\n ", what, - (unsigned long) s); + printf("%s %"PRIu32":\n ", what, + s); if (showwords) ShowRawWords((uint16_t*) buf, (uint32_t) stripbc[s] >> 1); else @@ -478,23 +478,23 @@ TIFFReadRawDataTiled(TIFF* tif, int bitrev) } if (buf == NULL) { fprintf(stderr, - "Cannot allocate buffer to read tile %lu\n", - (unsigned long) t); + "Cannot allocate buffer to read tile %"PRIu32"\n", + t); break; } if (TIFFReadRawTile(tif, t, buf, (tmsize_t)tilebc[t]) < 0) { - fprintf(stderr, "Error reading tile %lu\n", - (unsigned long) t); + fprintf(stderr, "Error reading tile %"PRIu32"\n", + t); if (stoponerr) break; } else if (showdata) { if (bitrev) { TIFFReverseBits(buf, (tmsize_t)tilebc[t]); - printf("%s %lu: (bit reversed)\n ", - what, (unsigned long) t); + printf("%s %"PRIu32": (bit reversed)\n ", + what, t); } else { - printf("%s %lu:\n ", what, - (unsigned long) t); + printf("%s %"PRIu32":\n ", what, + t); } if (showwords) { ShowRawWords((uint16_t*) buf, (uint32_t)(tilebc[t] >> 1)); |