From 1ee2d140b6f76115822f45376c19c6861d2f6fa0 Mon Sep 17 00:00:00 2001 From: Luca Bacci Date: Tue, 4 Feb 2025 11:30:03 +0100 Subject: [PATCH] Boilerplate: Open pipe in binary mode on Windows Avoids a translation from LF to CRLF, which messes up the expected byte counts. Note that popen() on GLibc does not support the 'b' mode, so this change is for Windows only. From the POSIX.2024 spec: > The behavior of popen() is specified for values of mode of "r", > "w", "re", and "we". Other modes such as "rb" and "wb" might be > supported by specific implementations, but these would not be > portable features. --- boilerplate/cairo-boilerplate.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c index a3e710f08..5f68216fd 100644 --- a/boilerplate/cairo-boilerplate.c +++ b/boilerplate/cairo-boilerplate.c @@ -945,7 +945,11 @@ POPEN: *close_cb = pclose; sprintf (command, "%s %s %d", any2ppm, filename, page); +#ifndef _WIN32 return popen (command, "r"); +#else + return popen (command, "rb"); +#endif } static cairo_bool_t