From 8217e459b13d79c1114828a0fc947f705f3e59cc Mon Sep 17 00:00:00 2001 From: Johannes Sixt Date: Wed, 21 Mar 2007 13:45:58 +0100 Subject: [PATCH] Make open(2) a macro that it replaces "/dev/null" by "nul" on MinGW. --- git-compat-util.h | 4 ++++ run-command.c | 4 ---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/git-compat-util.h b/git-compat-util.h index 0d62dc8149..bf9dbe288a 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -397,6 +397,10 @@ static inline int git_unlink(const char *pathname) { } #define unlink git_unlink +#define open(P, F, M...) \ + (__builtin_constant_p(*(P)) && !strcmp(P, "/dev/null") ? \ + open("nul", F, ## M) : open(P, F, ## M)) + #include struct tm *gmtime_r(const time_t *timep, struct tm *result); struct tm *localtime_r(const time_t *timep, struct tm *result); diff --git a/run-command.c b/run-command.c index 79ca6cc9df..0dcbcd2b8a 100644 --- a/run-command.c +++ b/run-command.c @@ -10,11 +10,7 @@ int run_command_v_opt(const char **argv, int flags) int fd_o[2] = { -1, -1 }; if (flags & RUN_COMMAND_NO_STDIN) { -#ifndef __MINGW32__ fd_i[0] = open("/dev/null", O_RDWR); -#else - fd_i[0] = open("nul", O_RDWR); -#endif } if (flags & RUN_COMMAND_STDOUT_TO_STDERR) fd_o[1] = dup(2);