diff options
author | Jay Berkenbilt <ejb@ql.org> | 2012-06-20 17:20:57 +0200 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2012-06-20 21:20:26 +0200 |
commit | 5d4cad9c02e9d4f31477fed0e3b20b35c83936f8 (patch) | |
tree | 38768f5e4a797e09de304b1e184021f5b280da29 /libqpdf/QUtil.cc | |
parent | 24e2b2b76f1f0051f240c8371b2352c4cde85bf9 (diff) | |
download | qpdf-5d4cad9c02e9d4f31477fed0e3b20b35c83936f8.tar.zst |
ABI change: fix use of off_t, size_t, and integer types
Significantly improve the code's use of off_t for file offsets, size_t
for memory sizes, and integer types in cases where there has to be
compatibility with external interfaces. Rework sections of the code
that would have prevented qpdf from working on files larger than 2 (or
maybe 4) GB in size.
Diffstat (limited to 'libqpdf/QUtil.cc')
-rw-r--r-- | libqpdf/QUtil.cc | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/libqpdf/QUtil.cc b/libqpdf/QUtil.cc index 1bdae0fe..e1071940 100644 --- a/libqpdf/QUtil.cc +++ b/libqpdf/QUtil.cc @@ -1,4 +1,5 @@ #include <qpdf/QUtil.hh> +#include <qpdf/qpdf-config.h> #include <stdio.h> #include <errno.h> #include <ctype.h> @@ -14,7 +15,7 @@ #endif std::string -QUtil::int_to_string(int num, int fullpad) +QUtil::int_to_string(long long num, int fullpad) { // This routine will need to be recompiled if an int can be longer than // 49 digits. @@ -28,14 +29,20 @@ QUtil::int_to_string(int num, int fullpad) "limit"); } +#ifdef HAVE_PRINTF_LL +# define PRINTF_LL "ll" +#else +# define PRINTF_LL "l" +#endif if (fullpad) { - sprintf(t, "%0*d", fullpad, num); + sprintf(t, "%0*" PRINTF_LL "d", fullpad, num); } else { - sprintf(t, "%d", num); + sprintf(t, "%" PRINTF_LL "d", num); } +#undef PRINTF_LL return std::string(t); } @@ -101,6 +108,26 @@ QUtil::fopen_wrapper(std::string const& description, FILE* f) return f; } +int +QUtil::fseek_off_t(FILE* stream, off_t offset, int whence) +{ +#if HAVE_FSEEKO + return fseeko(stream, offset, whence); +#else + return fseek(stream, offset, whence); +#endif +} + +off_t +QUtil::ftell_off_t(FILE* stream) +{ +#if HAVE_FSEEKO + return ftello(stream); +#else + return ftell(stream); +#endif +} + char* QUtil::copy_string(std::string const& str) { |