From 92d9b89d59e627ba46fbb175b1d8f9aebbd1aac7 Mon Sep 17 00:00:00 2001 From: Petri Lehtinen Date: Tue, 1 Nov 2011 19:52:20 +0200 Subject: [PATCH] Fix test file comparisons on MinGW Don't output any DOS line terminators from json_process. Issue GH-39. --- test/bin/json_process.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/bin/json_process.c b/test/bin/json_process.c index 66c34d1..4ec22e6 100644 --- a/test/bin/json_process.c +++ b/test/bin/json_process.c @@ -19,6 +19,11 @@ #include #endif +#if _WIN32 +#include /* for _setmode() */ +#include /* for _O_BINARY */ +#endif + static int getenv_int(const char *name) { char *value, *end; @@ -72,6 +77,13 @@ int main(int argc, char *argv[]) return 2; } +#ifdef _WIN32 + /* On Windows, set stdout and stderr to binary mode to avoid + outputting DOS line terminators */ + _setmode(_fileno(stdout), _O_BINARY); + _setmode(_fileno(stderr), _O_BINARY); +#endif + indent = getenv_int("JSON_INDENT"); if(indent < 0 || indent > 255) { fprintf(stderr, "invalid value for JSON_INDENT: %d\n", indent); -- 2.1.4