Make open(2) a macro that it replaces "/dev/null" by "nul" on MinGW.

This commit is contained in:
Johannes Sixt
2007-03-21 13:45:58 +01:00
parent 103ca38f10
commit 8217e459b1
2 changed files with 4 additions and 4 deletions

View File

@@ -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 <time.h>
struct tm *gmtime_r(const time_t *timep, struct tm *result);
struct tm *localtime_r(const time_t *timep, struct tm *result);

View File

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