summaryrefslogtreecommitdiff
path: root/samples/pdfium_test.cc
diff options
context:
space:
mode:
authorJohn Abd-El-Malek <jam@chromium.org>2014-06-26 10:18:11 -0700
committerJohn Abd-El-Malek <jam@chromium.org>2014-06-26 10:18:11 -0700
commita548d30f8126d167210fdc26783454b0b3752004 (patch)
tree27f1cd9eb73bb3bfb27370f7efb8419d4ddd9d0e /samples/pdfium_test.cc
parent9a52eb09edf2f5001f33f2227cc3888ef2e8c338 (diff)
downloadpdfium-a548d30f8126d167210fdc26783454b0b3752004.tar.xz
Explicitly use binary mode when opening files in the pdfium_test sample.
This patch adds the 'b' (binary mode) flag to the fopen calls. Before the fix the PPM images written with --write_images were corrupted under Windows because on this platform in text mode all occurrences of the byte 0xa (line feed) are replaced with the bytes 0x0d (carriage return) and 0x0a (line feed). On UNIX platforms the 'b' flag is supported but ignored, because no translation of the line feed character takes place. BUG=18 R=jam@chromium.org Original patch by Michael Doppler <m.doppler@gmail.com> Review URL: https://codereview.chromium.org/343303004
Diffstat (limited to 'samples/pdfium_test.cc')
-rw-r--r--samples/pdfium_test.cc8
1 files changed, 2 insertions, 6 deletions
diff --git a/samples/pdfium_test.cc b/samples/pdfium_test.cc
index 0c641498fe..c504bf4823 100644
--- a/samples/pdfium_test.cc
+++ b/samples/pdfium_test.cc
@@ -20,10 +20,6 @@
#ifdef _WIN32
#define snprintf _snprintf
- /* in Windows, rb for open and read binary file */
- #define FOPEN_READ "rb"
-#else
- #define FOPEN_READ "r"
#endif
static void WritePpm(const char* pdf_name, int num,
@@ -39,7 +35,7 @@ static void WritePpm(const char* pdf_name, int num,
char filename[256];
snprintf(filename, sizeof(filename), "%s.%d.ppm", pdf_name, num);
- FILE* fp = fopen(filename, "w");
+ FILE* fp = fopen(filename, "wb");
if (!fp)
return;
fprintf(fp, "P6\n# PDF test render\n%d %d\n255\n", width, height);
@@ -283,7 +279,7 @@ int main(int argc, const char* argv[]) {
while (!files.empty()) {
const char* filename = files.front();
files.pop_front();
- FILE* file = fopen(filename, FOPEN_READ);
+ FILE* file = fopen(filename, "rb");
if (!file) {
fprintf(stderr, "Failed to open: %s\n", filename);
continue;