summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3f83bf3)
raw | patch | inline | side by side (parent: 3f83bf3)
author | Marius Storm-Olsen <marius.storm-olsen@nokia.com> | |
Wed, 16 Sep 2009 08:20:20 +0000 (10:20 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sat, 19 Sep 2009 03:00:42 +0000 (20:00 -0700) |
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>
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>
compat/mingw.c | patch | blob | history | |
compat/mingw.h | patch | blob | history |
diff --git a/compat/mingw.c b/compat/mingw.c
index 5478b747ceebfd44e9e5b45cda5267244acb8ff6..5a8fae8b315cc5748907465b6b374670579707a7 100644 (file)
--- a/compat/mingw.c
+++ b/compat/mingw.c
#include <conio.h>
#include "../strbuf.h"
-unsigned int _CRT_fmode = _O_BINARY;
-
static int err_win_to_posix(DWORD winerr)
{
int error = ENOSYS;
diff --git a/compat/mingw.h b/compat/mingw.h
index c43917cd6eb266f9455c088baea35e514aa07110..bcd23b0a4570377465e77f30831c9163e9d6bbda 100644 (file)
--- a/compat/mingw.h
+++ b/compat/mingw.h
/*
* 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); \
} \