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.
pull/1/head
stijn 2017-08-14 12:01:38 +02:00 committed by Damien George
parent 22131a6738
commit bc86c6252a
2 changed files with 3 additions and 0 deletions

View File

@ -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))

View File

@ -31,6 +31,7 @@
#include <crtdbg.h>
#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() {