aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/qpdf/QUtil.hh2
-rw-r--r--libqpdf/QPDF.cc2
-rw-r--r--libqpdf/QPDFWriter.cc2
-rw-r--r--libqpdf/QPDF_encryption.cc2
-rw-r--r--libqpdf/QPDF_linearization.cc2
-rw-r--r--libqpdf/QUtil.cc26
-rw-r--r--libqpdf/qpdf/PCRE.hh3
-rw-r--r--libtests/ascii85.cc2
-rw-r--r--libtests/hex.cc2
-rw-r--r--libtests/lzw.cc24
-rw-r--r--libtests/qtest/ascii85.test3
-rw-r--r--libtests/qtest/bits.test3
-rw-r--r--libtests/qtest/buffer.test3
-rw-r--r--libtests/qtest/lzw.test4
-rw-r--r--libtests/qtest/md5.test3
-rw-r--r--libtests/qtest/pcre.test2
-rw-r--r--libtests/qtest/ph.test3
-rw-r--r--libtests/qtest/qutil.test3
-rw-r--r--qpdf/qpdf.cc2
19 files changed, 73 insertions, 20 deletions
diff --git a/include/qpdf/QUtil.hh b/include/qpdf/QUtil.hh
index 7a1a0576..ffa7dda5 100644
--- a/include/qpdf/QUtil.hh
+++ b/include/qpdf/QUtil.hh
@@ -37,6 +37,8 @@ namespace QUtil
// non-null, initializes it with the value of the variable.
bool get_env(std::string const& var, std::string* value = 0);
+ time_t get_current_time();
+
// Return a string containing the byte representation of the UTF-8
// encoding for the unicode value passed in.
std::string toUTF8(unsigned long uval);
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>
diff --git a/libtests/ascii85.cc b/libtests/ascii85.cc
index 8be7175d..497df79a 100644
--- a/libtests/ascii85.cc
+++ b/libtests/ascii85.cc
@@ -15,7 +15,7 @@ int main()
bool done = false;
while (! done)
{
- int len = read(0, buf, sizeof(buf));
+ int len = fread(buf, 1, sizeof(buf), stdin);
if (len <= 0)
{
done = true;
diff --git a/libtests/hex.cc b/libtests/hex.cc
index 5278f95f..0a08fcb8 100644
--- a/libtests/hex.cc
+++ b/libtests/hex.cc
@@ -15,7 +15,7 @@ int main()
bool done = false;
while (! done)
{
- int len = read(0, buf, sizeof(buf));
+ int len = fread(buf, 1, sizeof(buf), stdin);
if (len <= 0)
{
done = true;
diff --git a/libtests/lzw.cc b/libtests/lzw.cc
index 034c0bb9..5bfdbbd5 100644
--- a/libtests/lzw.cc
+++ b/libtests/lzw.cc
@@ -1,6 +1,7 @@
#include <qpdf/Pl_LZWDecoder.hh>
#include <qpdf/Pl_StdioFile.hh>
+#include <qpdf/QUtil.hh>
#include <iostream>
#include <stdlib.h>
#include <string.h>
@@ -8,21 +9,36 @@
int main(int argc, char* argv[])
{
bool early_code_change = true;
- if ((argc == 2) && (strcmp(argv[1], "--no-early-code-change") == 0))
+ if ((argc == 4) && (strcmp(argv[3], "--no-early-code-change") == 0))
{
early_code_change = false;
}
- Pl_StdioFile out("stdout", stdout);
- Pl_LZWDecoder decode("decode", &out, early_code_change);
+ if (argc < 3)
+ {
+ std::cerr << "Usage: lzw infile outfile [ --no-early-code-change ]"
+ << std::endl;
+ exit(2);
+ }
try
{
+ char* infilename = argv[1];
+ char* outfilename = argv[2];
+
+ FILE* infile = QUtil::fopen_wrapper("open input file",
+ fopen(infilename, "rb"));
+ FILE* outfile = QUtil::fopen_wrapper("open output file",
+ fopen(outfilename, "wb"));
+
+ Pl_StdioFile out("output", outfile);
+ Pl_LZWDecoder decode("decode", &out, early_code_change);
+
unsigned char buf[10000];
bool done = false;
while (! done)
{
- int len = read(0, buf, sizeof(buf));
+ int len = fread(buf, 1, sizeof(buf), infile);
if (len <= 0)
{
done = true;
diff --git a/libtests/qtest/ascii85.test b/libtests/qtest/ascii85.test
index 07551bd1..7ea3ee42 100644
--- a/libtests/qtest/ascii85.test
+++ b/libtests/qtest/ascii85.test
@@ -17,6 +17,7 @@ $td->runtest("decode",
$td->runtest("partial decode",
{$td->COMMAND => "echo '\@<5skEHbu7\$3~>' | ascii85"},
{$td->STRING => "asdfqwer\n",
- $td->EXIT_STATUS => 0});
+ $td->EXIT_STATUS => 0},
+ $td->NORMALIZE_NEWLINES);
$td->report(2);
diff --git a/libtests/qtest/bits.test b/libtests/qtest/bits.test
index f5dac7b5..08bee707 100644
--- a/libtests/qtest/bits.test
+++ b/libtests/qtest/bits.test
@@ -12,6 +12,7 @@ my $td = new TestDriver('bits');
$td->runtest("bits",
{$td->COMMAND => "bits"},
{$td->FILE => "bits.out",
- $td->EXIT_STATUS => 0});
+ $td->EXIT_STATUS => 0},
+ $td->NORMALIZE_NEWLINES);
$td->report(1);
diff --git a/libtests/qtest/buffer.test b/libtests/qtest/buffer.test
index 83ce4643..38da9fc3 100644
--- a/libtests/qtest/buffer.test
+++ b/libtests/qtest/buffer.test
@@ -12,6 +12,7 @@ my $td = new TestDriver('buffer');
$td->runtest("buffer",
{$td->COMMAND => "buffer"},
{$td->FILE => "buffer.out",
- $td->EXIT_STATUS => 0});
+ $td->EXIT_STATUS => 0},
+ $td->NORMALIZE_NEWLINES);
$td->report(1);
diff --git a/libtests/qtest/lzw.test b/libtests/qtest/lzw.test
index 649cd330..e6142115 100644
--- a/libtests/qtest/lzw.test
+++ b/libtests/qtest/lzw.test
@@ -12,7 +12,7 @@ my $td = new TestDriver('lzw');
cleanup();
$td->runtest("decode: early code change",
- {$td->COMMAND => "lzw < lzw1.in > tmp"},
+ {$td->COMMAND => "lzw lzw1.in tmp"},
{$td->STRING => "",
$td->EXIT_STATUS => 0});
@@ -21,7 +21,7 @@ $td->runtest("check output",
{$td->FILE => "lzw1.out"});
$td->runtest("decode: no early code change",
- {$td->COMMAND => "lzw --no-early-code-change < lzw2.in > tmp"},
+ {$td->COMMAND => "lzw lzw2.in tmp --no-early-code-change"},
{$td->STRING => "",
$td->EXIT_STATUS => 0});
diff --git a/libtests/qtest/md5.test b/libtests/qtest/md5.test
index 4c0685cd..076a37ec 100644
--- a/libtests/qtest/md5.test
+++ b/libtests/qtest/md5.test
@@ -12,6 +12,7 @@ my $td = new TestDriver('md5');
$td->runtest("md5",
{$td->COMMAND => "md5"},
{$td->FILE => "md5.out",
- $td->EXIT_STATUS => 0});
+ $td->EXIT_STATUS => 0},
+ $td->NORMALIZE_NEWLINES);
$td->report(1);
diff --git a/libtests/qtest/pcre.test b/libtests/qtest/pcre.test
index cf0418da..89a1d83c 100644
--- a/libtests/qtest/pcre.test
+++ b/libtests/qtest/pcre.test
@@ -16,7 +16,7 @@ $td->runtest("PCRE",
$td->NORMALIZE_NEWLINES);
chop(my $supported = `pcre --unicode-classes-supported`);
-if ($supported)
+if ($supported =~ m/^1/)
{
$td->runtest("unicode character classes",
{$td->COMMAND => "pcre --unicode-classes"},
diff --git a/libtests/qtest/ph.test b/libtests/qtest/ph.test
index 8e70efd5..9c0ffb8e 100644
--- a/libtests/qtest/ph.test
+++ b/libtests/qtest/ph.test
@@ -12,6 +12,7 @@ my $td = new TestDriver('ph');
$td->runtest("PointerHolder",
{$td->COMMAND => "pointer_holder"},
{$td->FILE => "ph.out",
- $td->EXIT_STATUS => 0});
+ $td->EXIT_STATUS => 0},
+ $td->NORMALIZE_NEWLINES);
$td->report(1);
diff --git a/libtests/qtest/qutil.test b/libtests/qtest/qutil.test
index e90692f8..9c0410e5 100644
--- a/libtests/qtest/qutil.test
+++ b/libtests/qtest/qutil.test
@@ -12,6 +12,7 @@ my $td = new TestDriver('qutil');
$td->runtest("QUtil",
{$td->COMMAND => "qutil"},
{$td->FILE => "qutil.out",
- $td->EXIT_STATUS => 0});
+ $td->EXIT_STATUS => 0},
+ $td->NORMALIZE_NEWLINES);
$td->report(1);
diff --git a/qpdf/qpdf.cc b/qpdf/qpdf.cc
index 8335ad8f..90025f46 100644
--- a/qpdf/qpdf.cc
+++ b/qpdf/qpdf.cc
@@ -532,7 +532,7 @@ int main(int argc, char* argv[])
// Be lax about -arg vs --arg
++arg;
}
- char* parameter = strchr(arg, '=');
+ char* parameter = (char*)strchr(arg, '=');
if (parameter)
{
*parameter++ = 0;