diff options
Diffstat (limited to 'libqpdf')
-rw-r--r-- | libqpdf/QPDF.cc | 2 | ||||
-rw-r--r-- | libqpdf/QPDFWriter.cc | 2 | ||||
-rw-r--r-- | libqpdf/QPDF_encryption.cc | 2 | ||||
-rw-r--r-- | libqpdf/QPDF_linearization.cc | 2 | ||||
-rw-r--r-- | libqpdf/QUtil.cc | 26 | ||||
-rw-r--r-- | libqpdf/qpdf/PCRE.hh | 3 |
6 files changed, 33 insertions, 4 deletions
diff --git a/libqpdf/QPDF.cc b/libqpdf/QPDF.cc index bcee47a4..0385828d 100644 --- a/libqpdf/QPDF.cc +++ b/libqpdf/QPDF.cc @@ -241,7 +241,7 @@ QPDF::ObjGen::ObjGen(int o = 0, int g = 0) : } bool -QPDF::ObjGen::ObjGen::operator<(ObjGen const& rhs) const +QPDF::ObjGen::operator<(ObjGen const& rhs) const { return ((this->obj < rhs.obj) || ((this->obj == rhs.obj) && (this->gen < rhs.gen))); diff --git a/libqpdf/QPDFWriter.cc b/libqpdf/QPDFWriter.cc index acaf52a8..eb146bd2 100644 --- a/libqpdf/QPDFWriter.cc +++ b/libqpdf/QPDFWriter.cc @@ -1110,7 +1110,7 @@ QPDFWriter::generateID() // the file yet. This scheme should be fine though. std::string seed; - seed += QUtil::int_to_string((int)time(0)); + seed += QUtil::int_to_string((int)QUtil::get_current_time()); seed += " QPDF "; seed += filename; seed += " "; diff --git a/libqpdf/QPDF_encryption.cc b/libqpdf/QPDF_encryption.cc index 39b34070..bd7ef7a6 100644 --- a/libqpdf/QPDF_encryption.cc +++ b/libqpdf/QPDF_encryption.cc @@ -45,7 +45,7 @@ QPDF::trim_user_password(std::string& user_password) return; } - char* p = 0; + char const* p = 0; while ((p = strchr(cstr, '\x28')) != 0) { if (memcmp(p, padding_string, len - (p - cstr)) == 0) diff --git a/libqpdf/QPDF_linearization.cc b/libqpdf/QPDF_linearization.cc index 9a1c7b05..5739b3a9 100644 --- a/libqpdf/QPDF_linearization.cc +++ b/libqpdf/QPDF_linearization.cc @@ -624,7 +624,7 @@ QPDF::maxEnd(ObjUser const& ou) assert(this->obj_user_to_objects.count(ou) > 0); std::set<ObjGen> const& ogs = this->obj_user_to_objects[ou]; int end = 0; - for (std::set<ObjGen>::iterator iter = ogs.begin(); + for (std::set<ObjGen>::const_iterator iter = ogs.begin(); iter != ogs.end(); ++iter) { ObjGen const& og = *iter; diff --git a/libqpdf/QUtil.cc b/libqpdf/QUtil.cc index 0ffc6e26..3ac467d4 100644 --- a/libqpdf/QUtil.cc +++ b/libqpdf/QUtil.cc @@ -141,6 +141,32 @@ QUtil::get_env(std::string const& var, std::string* value) #endif } +time_t +QUtil::get_current_time() +{ +#ifdef _WIN32 + // The procedure to get local time at this resolution comes from + // the Microsoft documentation. It says to convert a SYSTEMTIME + // to a FILETIME, and to copy the FILETIME to a ULARGE_INTEGER. + // The resulting number is the number of 100-nanosecond intervals + // between January 1, 1601 and now. POSIX threads wants a time + // based on January 1, 1970, so we adjust by subtracting the + // number of seconds in that time period from the result we get + // here. + SYSTEMTIME sysnow; + GetSystemTime(&sysnow); + FILETIME filenow; + SystemTimeToFileTime(&sysnow, &filenow); + ULARGE_INTEGER uinow; + uinow.LowPart = filenow.dwLowDateTime; + uinow.HighPart = filenow.dwHighDateTime; + ULONGLONG now = uinow.QuadPart; + return ((now / 10000000LL) - 11644473600LL); +#else + return time(0); +#endif +} + std::string QUtil::toUTF8(unsigned long uval) { diff --git a/libqpdf/qpdf/PCRE.hh b/libqpdf/qpdf/PCRE.hh index a226aa19..deba8733 100644 --- a/libqpdf/qpdf/PCRE.hh +++ b/libqpdf/qpdf/PCRE.hh @@ -5,6 +5,9 @@ #ifndef __PCRE_HH__ #define __PCRE_HH__ +#ifdef _WIN32 +# define PCRE_STATIC +#endif #include <pcre.h> #include <string> |