summaryrefslogtreecommitdiff
path: root/compat/mingw.h
diff options
context:
space:
mode:
authorMarius Storm-Olsen <marius.storm-olsen@nokia.com>2009-09-16 10:20:20 +0200
committerJunio C Hamano <gitster@pobox.com>2009-09-18 20:00:42 -0700
commita6ca8c62467570d5d227eba4f2b838ce4b9940e8 (patch)
treef2e77f5142850d4987fb7434b1c0074091184195 /compat/mingw.h
parent3f83bf3784d49e162532212230a271a8cc8edbf0 (diff)
downloadgit-a6ca8c62467570d5d227eba4f2b838ce4b9940e8.tar.gz
Set _O_BINARY as default fmode for both MinGW and MSVC
MinGW set the _CRT_fmode to set both the default fmode and _O_BINARY on stdin/stdout/stderr. Rather use the main() define in mingw.h to set this for both MinGW and MSVC. This will ensure that a MinGW and MSVC build will handle input and output identically. Signed-off-by: Marius Storm-Olsen <mstormo@gmail.com> Acked-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'compat/mingw.h')
-rw-r--r--compat/mingw.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/compat/mingw.h b/compat/mingw.h
index c43917cd6e..bcd23b0a45 100644
--- a/compat/mingw.h
+++ b/compat/mingw.h
@@ -227,12 +227,17 @@ void free_environ(char **env);
/*
* A replacement of main() that ensures that argv[0] has a path
+ * and that default fmode and std(in|out|err) are in binary mode
*/
#define main(c,v) dummy_decl_mingw_main(); \
static int mingw_main(); \
int main(int argc, const char **argv) \
{ \
+ _fmode = _O_BINARY; \
+ _setmode(_fileno(stdin), _O_BINARY); \
+ _setmode(_fileno(stdout), _O_BINARY); \
+ _setmode(_fileno(stderr), _O_BINARY); \
argv[0] = xstrdup(_pgmptr); \
return mingw_main(argc, argv); \
} \