From bc86c6252ab1b9a9ee47a44d7ccc9e1a9d74f207 Mon Sep 17 00:00:00 2001 From: stijn Date: Mon, 14 Aug 2017 12:01:38 +0200 Subject: [PATCH] windows: Default to binary mode for files. If this is not set it might default to calls to open() to use text mode which is usually not wanted, and even wrong and leading to incorrect results when loading binary .mpy files. This also means that text files written and read will not have line-ending translation from \n to \r\n and vice-versa anymore. This shouldn't be much of a problem though since most tools dealing with text files adapt automatically to any of the 2 formats. --- ports/windows/Makefile | 1 + ports/windows/init.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/ports/windows/Makefile b/ports/windows/Makefile index e65c09c53a..af815383c7 100644 --- a/ports/windows/Makefile +++ b/ports/windows/Makefile @@ -40,6 +40,7 @@ SRC_C = \ realpath.c \ init.c \ sleep.c \ + fmode.c \ $(SRC_MOD) OBJ = $(PY_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o)) diff --git a/ports/windows/init.c b/ports/windows/init.c index 09fa10417b..73ab713752 100644 --- a/ports/windows/init.c +++ b/ports/windows/init.c @@ -31,6 +31,7 @@ #include #endif #include "sleep.h" +#include "fmode.h" extern BOOL WINAPI console_sighandler(DWORD evt); @@ -61,6 +62,7 @@ void init() { // https://msdn.microsoft.com/en-us/library/bb531344(v=vs.140).aspx _set_output_format(_TWO_DIGIT_EXPONENT); #endif + set_fmode_binary(); } void deinit() {