[poppler] poppler/StdinCachedFile.cc utils/pdftoppm.cc

Albert Astals Cid aacid at kemper.freedesktop.org
Tue Aug 10 11:44:03 PDT 2010


 poppler/StdinCachedFile.cc |    9 +++++++++
 utils/pdftoppm.cc          |    9 +++++++++
 2 files changed, 18 insertions(+)

New commits:
commit 3bca8ddc10bf4291bf0c0e39c67341a05953e949
Author: Jonathan Liu <net147 at gmail.com>
Date:   Tue Aug 10 19:42:40 2010 +0100

    Tell windows we are writing/reading binary data
    
    Bug #29329

diff --git a/poppler/StdinCachedFile.cc b/poppler/StdinCachedFile.cc
index 4bfc31e..5747572 100644
--- a/poppler/StdinCachedFile.cc
+++ b/poppler/StdinCachedFile.cc
@@ -6,6 +6,7 @@
 //
 // Copyright 2010 Hib Eris <hib at hiberis.nl>
 // Copyright 2010 Albert Astals Cid <aacid at kde.org>
+// Copyright 2010 Jonathan Liu <net147 at 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 ed64fea..14950d0 100644
--- a/utils/pdftoppm.cc
+++ b/utils/pdftoppm.cc
@@ -21,6 +21,7 @@
 // Copyright (C) 2009, 2010 Albert Astals Cid <aacid at kde.org>
 // Copyright (C) 2010 Adrian Johnson <ajohnson at redneon.com>
 // Copyright (C) 2010 Hib Eris <hib at hiberis.nl>
+// Copyright (C) 2010 Jonathan Liu <net147 at 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) {


More information about the poppler mailing list