From 519b72700430b84c99db73a832c4c58f3e52ebcd Mon Sep 17 00:00:00 2001 From: Bob Friesenhahn Date: Sat, 2 Apr 2011 20:54:08 +0000 Subject: [PATCH] * configure.ac: Support configuring TIFF_INT64_FORMAT and TIFF_UINT64_FORMAT appropriately for MinGW32. * tools/tiffdump.c (ReadDirectory): MinGW32 needs to use WIN32 printf conventions for 64-bit types because it uses the WIN32 CRT. * libtiff/{tif_dumpmode.c,tif_luv.c,tif_lzw.c,tif_print.c, tif_read.c,tif_strip.c,tif_thunder.c}: MinGW32 needs to use WIN32 printf conventions for 64-bit types because it uses the WIN32 CRT. * tools/tiff2pdf.c (t2p_write_pdf_string): Fix printf syntax not understood by WIN32 CRT. --- ChangeLog | 13 +++++++++++++ configure | 27 ++++++++++++++++++++------- configure.ac | 22 ++++++++++++++++++++-- libtiff/tif_dumpmode.c | 4 ++-- libtiff/tif_luv.c | 8 ++++---- libtiff/tif_lzw.c | 6 +++--- libtiff/tif_print.c | 14 +++++++------- libtiff/tif_read.c | 20 ++++++++++---------- libtiff/tif_strip.c | 4 ++-- libtiff/tif_thunder.c | 4 ++-- tools/tiff2pdf.c | 4 ++-- tools/tiffdump.c | 8 ++++---- 12 files changed, 89 insertions(+), 45 deletions(-) diff --git a/ChangeLog b/ChangeLog index 370f9a2b..f81550aa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,18 @@ 2011-04-02 Bob Friesenhahn + * configure.ac: Support configuring TIFF_INT64_FORMAT and + TIFF_UINT64_FORMAT appropriately for MinGW32. + + * tools/tiffdump.c (ReadDirectory): MinGW32 needs to use WIN32 + printf conventions for 64-bit types because it uses the WIN32 CRT. + + * libtiff/{tif_dumpmode.c,tif_luv.c,tif_lzw.c,tif_print.c, + tif_read.c,tif_strip.c,tif_thunder.c}: MinGW32 needs to use WIN32 + printf conventions for 64-bit types because it uses the WIN32 CRT. + + * tools/tiff2pdf.c (t2p_write_pdf_string): Fix printf syntax not + understood by WIN32 CRT. + * libtiff/tif_ojpeg.c: Fixes to compile with MinGW32 GCC. * tools/fax2ps.c (main): Use tmpfile() rather than mkstemp() since diff --git a/configure b/configure index 09893036..f92db4e3 100755 --- a/configure +++ b/configure @@ -784,7 +784,6 @@ enable_fast_install with_gnu_ld with_sysroot enable_libtool_lock -with_gnu_ld enable_silent_rules enable_rpath enable_largefile @@ -831,12 +830,8 @@ LDFLAGS LIBS CPPFLAGS CPP -CPPFLAGS CXX CXXFLAGS -LDFLAGS -LIBS -CPPFLAGS CCC CXXCPP XMKMF' @@ -16924,9 +16919,19 @@ then INT64_FORMAT='"%ld"' elif test $ac_cv_sizeof_signed_long_long -eq 8 then - INT64_FORMAT='"%lld"' INT64_T='signed long long' + case "${host_os}" in + mingw32*) + # MinGW32 understands 'long long', but uses printf from WIN32 CRT + INT64_FORMAT='"%I64d"' + ;; + *) + INT64_FORMAT='"%lld"' + ;; + esac fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INT64_T" >&5 $as_echo "$INT64_T" >&6; } @@ -16951,7 +16956,15 @@ then elif test $ac_cv_sizeof_unsigned_long_long -eq 8 then UINT64_T='unsigned long long' - UINT64_FORMAT='"%llu"' + case "${host_os}" in + mingw32*) + # MinGW32 understands 'unsigned long long', but uses printf from WIN32 CRT + UINT64_FORMAT='"%I64u"' + ;; + *) + UINT64_FORMAT='"%llu"' + ;; + esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $UINT64_T" >&5 $as_echo "$UINT64_T" >&6; } diff --git a/configure.ac b/configure.ac index c8140868..71004707 100644 --- a/configure.ac +++ b/configure.ac @@ -248,9 +248,19 @@ then INT64_FORMAT='"%ld"' elif test $ac_cv_sizeof_signed_long_long -eq 8 then - INT64_FORMAT='"%lld"' INT64_T='signed long long' + case "${host_os}" in + mingw32*) + # MinGW32 understands 'long long', but uses printf from WIN32 CRT + INT64_FORMAT='"%I64d"' + ;; + *) + INT64_FORMAT='"%lld"' + ;; + esac fi + + AC_MSG_RESULT($INT64_T) AC_DEFINE_UNQUOTED(TIFF_INT64_T,$INT64_T,[Signed 64-bit type]) AC_DEFINE_UNQUOTED(TIFF_INT64_FORMAT,$INT64_FORMAT,[Signed 64-bit type formatter]) @@ -265,7 +275,15 @@ then elif test $ac_cv_sizeof_unsigned_long_long -eq 8 then UINT64_T='unsigned long long' - UINT64_FORMAT='"%llu"' + case "${host_os}" in + mingw32*) + # MinGW32 understands 'unsigned long long', but uses printf from WIN32 CRT + UINT64_FORMAT='"%I64u"' + ;; + *) + UINT64_FORMAT='"%llu"' + ;; + esac fi AC_MSG_RESULT($UINT64_T) AC_DEFINE_UNQUOTED(TIFF_UINT64_T,$UINT64_T,[Unsigned 64-bit type]) diff --git a/libtiff/tif_dumpmode.c b/libtiff/tif_dumpmode.c index c668964f..a94cf0b3 100644 --- a/libtiff/tif_dumpmode.c +++ b/libtiff/tif_dumpmode.c @@ -1,4 +1,4 @@ -/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_dumpmode.c,v 1.13 2010-03-10 18:56:48 bfriesen Exp $ */ +/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_dumpmode.c,v 1.14 2011-04-02 20:54:09 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -80,7 +80,7 @@ DumpModeDecode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) static const char module[] = "DumpModeDecode"; (void) s; if (tif->tif_rawcc < cc) { -#if defined(__WIN32__) && defined(_MSC_VER) +#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, diff --git a/libtiff/tif_luv.c b/libtiff/tif_luv.c index 5253c6b1..eba6c08e 100644 --- a/libtiff/tif_luv.c +++ b/libtiff/tif_luv.c @@ -1,4 +1,4 @@ -/* $Id: tif_luv.c,v 1.34 2010-03-10 18:56:48 bfriesen Exp $ */ +/* $Id: tif_luv.c,v 1.35 2011-04-02 20:54:09 bfriesen Exp $ */ /* * Copyright (c) 1997 Greg Ward Larson @@ -224,7 +224,7 @@ LogL16Decode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) tp[i++] |= (int16)*bp++ << shft; } if (i != npixels) { -#if defined(__WIN32__) && defined(_MSC_VER) +#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, @@ -282,7 +282,7 @@ LogLuvDecode24(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) tif->tif_rawcp = (uint8*) bp; tif->tif_rawcc = cc; if (i != npixels) { -#if defined(__WIN32__) && defined(_MSC_VER) +#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, @@ -347,7 +347,7 @@ LogLuvDecode32(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) tp[i++] |= (uint32)*bp++ << shft; } if (i != npixels) { -#if defined(__WIN32__) && defined(_MSC_VER) +#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, diff --git a/libtiff/tif_lzw.c b/libtiff/tif_lzw.c index e89ce2c3..fd9c7a0a 100644 --- a/libtiff/tif_lzw.c +++ b/libtiff/tif_lzw.c @@ -1,4 +1,4 @@ -/* $Id: tif_lzw.c,v 1.44 2010-03-30 17:02:57 fwarmerdam Exp $ */ +/* $Id: tif_lzw.c,v 1.45 2011-04-02 20:54:09 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -549,7 +549,7 @@ LZWDecode(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s) sp->dec_maxcodep = maxcodep; if (occ > 0) { -#if defined(__WIN32__) && defined(_MSC_VER) +#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); @@ -753,7 +753,7 @@ LZWDecodeCompat(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s) sp->dec_maxcodep = maxcodep; if (occ > 0) { -#if defined(__WIN32__) && defined(_MSC_VER) +#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); diff --git a/libtiff/tif_print.c b/libtiff/tif_print.c index a98c6d65..9481eb62 100644 --- a/libtiff/tif_print.c +++ b/libtiff/tif_print.c @@ -1,4 +1,4 @@ -/* $Id: tif_print.c,v 1.53 2011-02-18 20:53:04 fwarmerdam Exp $ */ +/* $Id: tif_print.c,v 1.54 2011-04-02 20:54:09 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -93,7 +93,7 @@ _TIFFPrintField(FILE* fd, const TIFFField *fip, || 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) +#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) fprintf(fd, "%I64u", (unsigned __int64)((uint64 *) raw_data)[j]); #else @@ -101,13 +101,13 @@ _TIFFPrintField(FILE* fd, const TIFFField *fip, (unsigned long long)((uint64 *) raw_data)[j]); #endif else if(fip->field_type == TIFF_SLONG8) -#if defined(__WIN32__) && defined(_MSC_VER) +#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) fprintf(fd, "%I64d", (__int64)((int64 *) raw_data)[j]); #else fprintf(fd, "%lld", (long long)((int64 *) raw_data)[j]); #endif else if(fip->field_type == TIFF_IFD8) -#if defined(__WIN32__) && defined(_MSC_VER) +#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) fprintf(fd, "0x%I64x", (unsigned __int64)((uint64 *) raw_data)[j]); #else @@ -212,7 +212,7 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) uint16 i; long l, n; -#if defined(__WIN32__) && defined(_MSC_VER) +#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); @@ -518,7 +518,7 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) if (TIFFFieldSet(tif, FIELD_SUBIFD) && (td->td_subifd)) { fprintf(fd, " SubIFD Offsets:"); for (i = 0; i < td->td_nsubifd; i++) -#if defined(__WIN32__) && defined(_MSC_VER) +#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) fprintf(fd, " %5I64u", (unsigned __int64) td->td_subifd[i]); #else @@ -631,7 +631,7 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) (long) td->td_nstrips, isTiled(tif) ? "Tiles" : "Strips"); for (s = 0; s < td->td_nstrips; s++) -#if defined(__WIN32__) && defined(_MSC_VER) +#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) fprintf(fd, " %3lu: [%8I64u, %8I64u]\n", (unsigned long) s, (unsigned __int64) td->td_stripoffset[s], diff --git a/libtiff/tif_read.c b/libtiff/tif_read.c index 643c7736..9f7641a6 100644 --- a/libtiff/tif_read.c +++ b/libtiff/tif_read.c @@ -1,4 +1,4 @@ -/* $Id: tif_read.c,v 1.36 2011-02-18 22:20:59 fwarmerdam Exp $ */ +/* $Id: tif_read.c,v 1.37 2011-04-02 20:54:09 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -122,7 +122,7 @@ TIFFFillStripPartial( TIFF *tif, int strip, tmsize_t read_ahead, int restart ) cc = TIFFReadFile(tif, tif->tif_rawdata + unused_data, to_read); if (cc != to_read) { -#if defined(__WIN32__) && defined(_MSC_VER) +#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, @@ -374,7 +374,7 @@ TIFFReadRawStrip1(TIFF* tif, uint32 strip, void* buf, tmsize_t size, } cc = TIFFReadFile(tif, buf, size); if (cc != size) { -#if defined(__WIN32__) && defined(_MSC_VER) +#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, @@ -401,7 +401,7 @@ TIFFReadRawStrip1(TIFF* tif, uint32 strip, void* buf, tmsize_t size, else n=size; if (n!=size) { -#if defined(__WIN32__) && defined(_MSC_VER) +#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, @@ -452,7 +452,7 @@ TIFFReadRawStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size) } bytecount = td->td_stripbytecount[strip]; if (bytecount <= 0) { -#if defined(__WIN32__) && defined(_MSC_VER) +#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) TIFFErrorExt(tif->tif_clientdata, module, "%I64u: Invalid strip byte count, strip %lu", (unsigned __int64) bytecount, @@ -491,7 +491,7 @@ TIFFFillStrip(TIFF* tif, uint32 strip) { uint64 bytecount = td->td_stripbytecount[strip]; if (bytecount <= 0) { -#if defined(__WIN32__) && defined(_MSC_VER) +#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) TIFFErrorExt(tif->tif_clientdata, module, "Invalid strip byte count %I64u, strip %lu", (unsigned __int64) bytecount, @@ -537,7 +537,7 @@ TIFFFillStrip(TIFF* tif, uint32 strip) * it's what would happen if a read were done * instead. */ -#if defined(__WIN32__) && defined(_MSC_VER) +#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) TIFFErrorExt(tif->tif_clientdata, module, "Read error on strip %lu; " @@ -670,7 +670,7 @@ TIFFReadRawTile1(TIFF* tif, uint32 tile, void* buf, tmsize_t size, const char* m } cc = TIFFReadFile(tif, buf, size); if (cc != size) { -#if defined(__WIN32__) && defined(_MSC_VER) +#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, @@ -699,7 +699,7 @@ TIFFReadRawTile1(TIFF* tif, uint32 tile, void* buf, tmsize_t size, const char* m else n=size; if (n!=size) { -#if defined(__WIN32__) && defined(_MSC_VER) +#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, @@ -776,7 +776,7 @@ TIFFFillTile(TIFF* tif, uint32 tile) { uint64 bytecount = td->td_stripbytecount[tile]; if (bytecount <= 0) { -#if defined(__WIN32__) && defined(_MSC_VER) +#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) TIFFErrorExt(tif->tif_clientdata, module, "%I64u: Invalid tile byte count, tile %lu", (unsigned __int64) bytecount, diff --git a/libtiff/tif_strip.c b/libtiff/tif_strip.c index bddb6c51..3ced5a8d 100644 --- a/libtiff/tif_strip.c +++ b/libtiff/tif_strip.c @@ -1,4 +1,4 @@ -/* $Id: tif_strip.c,v 1.33 2010-07-01 15:33:28 dron Exp $ */ +/* $Id: tif_strip.c,v 1.34 2011-04-02 20:54:09 bfriesen Exp $ */ /* * Copyright (c) 1991-1997 Sam Leffler @@ -152,7 +152,7 @@ TIFFRawStripSize64(TIFF* tif, uint32 strip) if (bytecount == 0) { -#if defined(__WIN32__) && defined(_MSC_VER) +#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) TIFFErrorExt(tif->tif_clientdata, module, "%I64u: Invalid strip byte count, strip %lu", (unsigned __int64) bytecount, diff --git a/libtiff/tif_thunder.c b/libtiff/tif_thunder.c index 5f3257fb..390891c9 100644 --- a/libtiff/tif_thunder.c +++ b/libtiff/tif_thunder.c @@ -1,4 +1,4 @@ -/* $Id: tif_thunder.c,v 1.11 2011-03-21 16:02:27 fwarmerdam Exp $ */ +/* $Id: tif_thunder.c,v 1.12 2011-04-02 20:54:09 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -143,7 +143,7 @@ ThunderDecode(TIFF* tif, uint8* op, tmsize_t maxpixels) tif->tif_rawcp = (uint8*) bp; tif->tif_rawcc = cc; if (npixels != maxpixels) { -#if defined(__WIN32__) && defined(_MSC_VER) +#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) TIFFErrorExt(tif->tif_clientdata, module, "%s data at scanline %lu (%I64u != %I64u)", npixels < maxpixels ? "Not enough" : "Too much", diff --git a/tools/tiff2pdf.c b/tools/tiff2pdf.c index 7d2635b1..9875bf76 100644 --- a/tools/tiff2pdf.c +++ b/tools/tiff2pdf.c @@ -1,4 +1,4 @@ -/* $Id: tiff2pdf.c,v 1.62 2010-12-13 05:41:38 faxguy Exp $ +/* $Id: tiff2pdf.c,v 1.63 2011-04-02 20:54:09 bfriesen Exp $ * * tiff2pdf - converts a TIFF image to a PDF document * @@ -3678,7 +3678,7 @@ tsize_t t2p_write_pdf_string(char* pdfstr, TIFF* output) written += t2pWriteFile(output, (tdata_t) "(", 1); for (i=0; i