summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Liu <net147@gmail.com>2010-08-10 19:42:40 +0100
committerAlbert Astals Cid <aacid@kde.org>2010-08-10 19:42:40 +0100
commit213a60ad48684f56b94f6b0eac642e7dfb3b4825 (patch)
tree8ac66424c39e30c416d439d64c5205c44d51ee45
parent37551daff8dc5c3cebd16e8cef4f9e3b6cbffad6 (diff)
Tell windows we are writing/reading binary data
Bug #29329
-rw-r--r--poppler/StdinCachedFile.cc9
-rw-r--r--utils/pdftoppm.cc9
2 files changed, 18 insertions, 0 deletions
diff --git a/poppler/StdinCachedFile.cc b/poppler/StdinCachedFile.cc
index 4bfc31e4..5747572d 100644
--- a/poppler/StdinCachedFile.cc
+++ b/poppler/StdinCachedFile.cc
@@ -6,6 +6,7 @@
//
// Copyright 2010 Hib Eris <hib@hiberis.nl>
// Copyright 2010 Albert Astals Cid <aacid@kde.org>
+// Copyright 2010 Jonathan Liu <net147@gmail.com>
//
//========================================================================
@@ -13,6 +14,10 @@
#include "StdinCachedFile.h"
+#ifdef _WIN32
+#include <fcntl.h> // for O_BINARY
+#include <io.h> // for setmode
+#endif
#include <stdio.h>
size_t StdinCacheLoader::init(GooString *dummy, CachedFile *cachedFile)
@@ -20,6 +25,10 @@ size_t StdinCacheLoader::init(GooString *dummy, CachedFile *cachedFile)
size_t read, size = 0;
char buf[CachedFileChunkSize];
+#if _WIN32
+ setmode(fileno(stdin), O_BINARY);
+#endif
+
CachedFileWriter writer = CachedFileWriter (cachedFile, NULL);
do {
read = fread(buf, 1, CachedFileChunkSize, stdin);
diff --git a/utils/pdftoppm.cc b/utils/pdftoppm.cc
index ed64fea8..14950d01 100644
--- a/utils/pdftoppm.cc
+++ b/utils/pdftoppm.cc
@@ -21,6 +21,7 @@
// Copyright (C) 2009, 2010 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2010 Adrian Johnson <ajohnson@redneon.com>
// Copyright (C) 2010 Hib Eris <hib@hiberis.nl>
+// Copyright (C) 2010 Jonathan Liu <net147@gmail.com>
//
// To see a description of the changes please see the Changelog file that
// came with your tarball or type make ChangeLog if you are building from git
@@ -29,6 +30,10 @@
#include "config.h"
#include <poppler-config.h>
+#ifdef _WIN32
+#include <fcntl.h> // for O_BINARY
+#include <io.h> // for setmode
+#endif
#include <stdio.h>
#include <math.h>
#include "parseargs.h"
@@ -178,6 +183,10 @@ static void savePageSlice(PDFDoc *doc,
bitmap->writePNMFile(ppmFile);
}
} else {
+#if _WIN32
+ setmode(fileno(stdout), O_BINARY);
+#endif
+
if (png) {
bitmap->writeImgFile(splashFormatPng, stdout, x_resolution, y_resolution);
} else if (jpeg) {