summaryrefslogtreecommitdiffstats
path: root/qpdf
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2009-07-15 05:47:44 +0200
committerJay Berkenbilt <ejb@ql.org>2009-07-15 05:47:44 +0200
commita1c0aaf03adf0344b34dd591f9103479f249e965 (patch)
treeb7d801e15d733791b47328349abd86f0317ce207 /qpdf
parent7acc0498ebfe13c48ecbaee718537a4c088cca5e (diff)
downloadqpdf-a1c0aaf03adf0344b34dd591f9103479f249e965.tar.zst
windows fixes
git-svn-id: svn+q:///qpdf/trunk@684 71b93d88-0707-0410-a8cf-f5a4172ac649
Diffstat (limited to 'qpdf')
-rw-r--r--qpdf/qpdf.cc22
-rw-r--r--qpdf/qtest/qpdf.test9
-rw-r--r--qpdf/test_driver.cc4
3 files changed, 30 insertions, 5 deletions
diff --git a/qpdf/qpdf.cc b/qpdf/qpdf.cc
index 90025f46..7bf41936 100644
--- a/qpdf/qpdf.cc
+++ b/qpdf/qpdf.cc
@@ -2,6 +2,11 @@
#include <iostream>
#include <string.h>
#include <stdlib.h>
+#include <fcntl.h>
+
+#ifdef _WIN32
+# include <io.h>
+#endif
#include <qpdf/QUtil.hh>
#include <qpdf/QTC.hh>
@@ -15,7 +20,7 @@
static int const EXIT_ERROR = 2;
static int const EXIT_WARNING = 3;
-static char const* whoami = 0;
+static char* whoami = 0;
// Note: let's not be too noisy about documenting the fact that this
// software purposely fails to enforce the distinction between user
@@ -429,7 +434,12 @@ parse_encrypt_options(
int main(int argc, char* argv[])
{
- if ((whoami = strrchr(argv[0], '/')) == NULL)
+#ifdef _WIN32
+ char pathsep = '\\';
+#else
+ char pathsep = '/';
+#endif
+ if ((whoami = strrchr(argv[0], pathsep)) == NULL)
{
whoami = argv[0];
}
@@ -437,6 +447,13 @@ int main(int argc, char* argv[])
{
++whoami;
}
+#ifdef _WIN32
+ if ((strlen(whoami) > 4) &&
+ (strcmp(whoami + strlen(whoami) - 4, ".exe") == 0))
+ {
+ whoami[strlen(whoami) - 4] = '\0';
+ }
+#endif
// For libtool's sake....
if (strncmp(whoami, "lt-", 3) == 0)
{
@@ -790,6 +807,7 @@ int main(int argc, char* argv[])
}
else
{
+ QUtil::binary_stdout();
Pl_StdioFile out("stdout", stdout);
obj.pipeStreamData(&out, filter, normalize, false);
}
diff --git a/qpdf/qtest/qpdf.test b/qpdf/qtest/qpdf.test
index 55f7c594..508f1dd0 100644
--- a/qpdf/qtest/qpdf.test
+++ b/qpdf/qtest/qpdf.test
@@ -267,7 +267,8 @@ for (my $i = 1; $i <= scalar(@goodfiles); ++$i)
$td->runtest("$goodfiles[$i-1]",
{$td->COMMAND => "test_driver $n good$i.pdf"},
{$td->FILE => "good$i.out",
- $td->EXIT_STATUS => 0});
+ $td->EXIT_STATUS => 0},
+ $td->NORMALIZE_NEWLINES);
my $xflags = $goodtest_flags{$i} || '';
check_pdf("create qdf",
"qpdf --static-id -qdf $xflags good$i.pdf",
@@ -461,7 +462,8 @@ $td->runtest("unfilterable stream data",
{$td->COMMAND => "qpdf encrypted-with-images.pdf" .
" --show-object=8 --filtered-stream-data"},
{$td->FILE => "show-unfilterable.out",
- $td->EXIT_STATUS => 2});
+ $td->EXIT_STATUS => 2},
+ $td->NORMALIZE_NEWLINES);
$td->runtest("show-xref-by-id",
{$td->COMMAND => "qpdf encrypted-with-images.pdf" .
@@ -837,7 +839,8 @@ foreach my $file (@files)
$td->runtest("check status",
{$td->COMMAND => "qpdf --check a.pdf"},
{$td->FILE => "$base.$n.check",
- $td->EXIT_STATUS => 0});
+ $td->EXIT_STATUS => 0},
+ $td->NORMALIZE_NEWLINES);
compare_pdfs($file, "a.pdf");
diff --git a/qpdf/test_driver.cc b/qpdf/test_driver.cc
index cdaa4cc5..192577c5 100644
--- a/qpdf/test_driver.cc
+++ b/qpdf/test_driver.cc
@@ -126,6 +126,7 @@ void runtest(int n, char const* filename)
std::cout << "Raw stream data:" << std::endl;
std::cout.flush();
+ QUtil::binary_stdout();
PointerHolder<Pl_StdioFile> out = new Pl_StdioFile("raw", stdout);
qtest.pipeStreamData(out.getPointer(), false, false, false);
@@ -133,6 +134,7 @@ void runtest(int n, char const* filename)
if (qtest.pipeStreamData(0, true, false, false))
{
std::cout.flush();
+ QUtil::binary_stdout();
out = new Pl_StdioFile("filtered", stdout);
qtest.pipeStreamData(out.getPointer(), true, false, false);
std::cout << std::endl << "End of stream data" << std::endl;
@@ -172,6 +174,7 @@ void runtest(int n, char const* filename)
QPDFObjectHandle kids = pages.getKey("/Kids");
QPDFObjectHandle page = kids.getArrayItem(1); // second page
QPDFObjectHandle contents = page.getKey("/Contents");
+ QUtil::binary_stdout();
PointerHolder<Pl_StdioFile> out = new Pl_StdioFile("filtered", stdout);
contents.pipeStreamData(out.getPointer(), true, false, false);
}
@@ -183,6 +186,7 @@ void runtest(int n, char const* filename)
QPDFObjectHandle stream = streams.getArrayItem(i);
std::cout << "-- stream " << i << " --" << std::endl;
std::cout.flush();
+ QUtil::binary_stdout();
PointerHolder<Pl_StdioFile> out =
new Pl_StdioFile("tokenized stream", stdout);
stream.pipeStreamData(out.getPointer(), true, true, false);