From 26a40d0e114c5f9025718b511d45f2da09259c1c Mon Sep 17 00:00:00 2001 From: Tim Pambor Date: Mon, 5 Aug 2019 11:51:03 +0200 Subject: Fix piping on windows On windows stdin and stdout have to be set to binary as otherwise windows treats it as text and converts occurences of CRLF to LF --- iceprog/iceprog.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'iceprog/iceprog.c') diff --git a/iceprog/iceprog.c b/iceprog/iceprog.c index bae9e71..aaba285 100644 --- a/iceprog/iceprog.c +++ b/iceprog/iceprog.c @@ -35,6 +35,11 @@ #include #include +#ifdef _WIN32 +#include /* _setmode() */ +#include /* _O_BINARY */ +#endif + #include "mpsse.h" static bool verbose = false; @@ -523,6 +528,11 @@ int main(int argc, char **argv) const char *devstr = NULL; int ifnum = 0; +#ifdef _WIN32 + _setmode(_fileno(stdin), _O_BINARY); + _setmode(_fileno(stdout), _O_BINARY); +#endif + static struct option long_options[] = { {"help", no_argument, NULL, -2}, {NULL, 0, NULL, 0} -- cgit v1.2.3