From a7eef33859223cc6e8d7ae058db8d991e3c9b9f6 Mon Sep 17 00:00:00 2001 From: "Avi Halachmi (:avih)" Date: Tue, 25 Jun 2019 15:43:24 +0300 Subject: [PATCH] configure: conftest win32: don't translate LF to CRLF This removes a spurious \r at $gcc_{major,minor} in configure on cygwin. Details: The EOL output of conftest.exe for windows was \r\n . Now it's only \n . The output of conftest is used with sh command substitutions which trim trailing newlines, but not all windows shells consider \r\n as newline. E.g. msys2 and busybox (for windows) were designed for tight integration with windows apps and their shells do trim \r\n, but cygwin sh is closer to POSIX and trims only \n - leaving \r at the string. --- conftest.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/conftest.c b/conftest.c index 2824cc89..c7bc7831 100644 --- a/conftest.c +++ b/conftest.c @@ -1,5 +1,9 @@ #include +#if defined(_WIN32) +#include +#endif + /* Define architecture */ #if defined(__i386__) || defined _M_IX86 # define TRIPLET_ARCH "i386" @@ -49,6 +53,9 @@ int _CRT_glob = 0; int main(int argc, char *argv[]) { +#if defined(_WIN32) + _setmode(_fileno(stdout), _O_BINARY); /* don't translate \n to \r\n */ +#endif switch(argc == 2 ? argv[1][0] : 0) { case 'b': {