Commit 0802ba275f589520988ea9af6c434af6b78add41

Authored by Jay Berkenbilt
1 parent f60bb8e0

Visual C++ and mingw32 fixes for large files

config-mingw32
1 #!/bin/sh 1 #!/bin/sh
2 ./configure --disable-test-compare-images --enable-external-libs --with-windows-wordsize=32 --with-buildrules=mingw 2 ./configure --disable-test-compare-images --enable-external-libs --with-windows-wordsize=32 --with-buildrules=mingw
  3 +# As of autoconf 2.69 and gcc 4.6, autoconf's configure fails to
  4 +# recognize that defining _FILE_OFFSET_BITS works with mingw32.
  5 +# Append to qpdf-config.h rather than passing CPPFLAGS on the
  6 +# commandline. This way we don't defeat the fact that test_large_file
  7 +# and other things that only use the public interface can be built
  8 +# without any special flags.
  9 +cat >> libqpdf/qpdf/qpdf-config.h <<EOF
  10 +#ifndef _FILE_OFFSET_BITS
  11 +# define _FILE_OFFSET_BITS 64
  12 +#endif
  13 +EOF
configure.ac
@@ -64,6 +64,7 @@ AC_ARG_WITH(large-file-test-path, @@ -64,6 +64,7 @@ AC_ARG_WITH(large-file-test-path,
64 64
65 AC_SYS_LARGEFILE 65 AC_SYS_LARGEFILE
66 AC_FUNC_FSEEKO 66 AC_FUNC_FSEEKO
  67 +AC_CHECK_FUNCS([fseeko64])
67 AC_TYPE_UINT16_T 68 AC_TYPE_UINT16_T
68 AC_TYPE_UINT32_T 69 AC_TYPE_UINT32_T
69 70
libqpdf/QUtil.cc
@@ -126,8 +126,14 @@ QUtil::fseek_off_t(FILE* stream, qpdf_offset_t offset, int whence) @@ -126,8 +126,14 @@ QUtil::fseek_off_t(FILE* stream, qpdf_offset_t offset, int whence)
126 { 126 {
127 #if HAVE_FSEEKO 127 #if HAVE_FSEEKO
128 return fseeko(stream, (off_t)offset, whence); 128 return fseeko(stream, (off_t)offset, whence);
  129 +#elif HAVE_FSEEKO64
  130 + return fseeko64(stream, offset, whence);
129 #else 131 #else
  132 +# ifdef _MSC_VER
  133 + return _fseeki64(stream, offset, whence);
  134 +# else
130 return fseek(stream, (long)offset, whence); 135 return fseek(stream, (long)offset, whence);
  136 +# endif
131 #endif 137 #endif
132 } 138 }
133 139
@@ -136,8 +142,14 @@ QUtil::ftell_off_t(FILE* stream) @@ -136,8 +142,14 @@ QUtil::ftell_off_t(FILE* stream)
136 { 142 {
137 #if HAVE_FSEEKO 143 #if HAVE_FSEEKO
138 return (qpdf_offset_t)ftello(stream); 144 return (qpdf_offset_t)ftello(stream);
  145 +#elif HAVE_FSEEKO64
  146 + return (qpdf_offset_t)ftello64(stream);
139 #else 147 #else
  148 +# ifdef _MSC_VER
  149 + return _ftelli64(stream);
  150 +# else
140 return (qpdf_offset_t)ftell(stream); 151 return (qpdf_offset_t)ftell(stream);
  152 +# endif
141 #endif 153 #endif
142 } 154 }
143 155