Re: [PATCH 08/14] help.c: Fix detection of custom merge strategy on cygwin
- From
Ramsay Jones <ramsay@ramsay1.demon.co.uk>
- Date
- Dec 16, 2010, 21:03 UTC
- Message-ID
- <4D0A7E87.3020203@ramsay1.demon.co.uk>
- In-Reply-To
- <AANLkTimt3w9GVCXa_n1_HXivyRmnRyUhhdSArrHOT6fs@mail.gmail.com>
Erik Faye-Lund wrote:
Show 17 quoted lines
>> diff --git a/help.c b/help.c >> index 7f4928e..eabadc9 100644 >> --- a/help.c >> +++ b/help.c >> @@ -126,7 +126,10 @@ static int is_executable(const char *name) >> !S_ISREG(st.st_mode)) >> return 0; >> >> -#ifdef WIN32 >> +#if defined(WIN32) || defined(__CYGWIN__) >> +#if defined(__CYGWIN__) >> +if ((st.st_mode & S_IXUSR) == 0) >> +#endif > > Perhaps the first check should simply be changed to check for _WIN32 > instead of WIN32? IIRC _WIN32 is set on Cygwin, but I could be > mistaken...
No, neither WIN32 or _WIN32 will be defined here (and they should not be). It's actually quite tricky, particularly when #including <windows.h>, viz:
$ cat -n test.c
1 #include <stdio.h>
2
3 #ifdef IW
4 # include <windows.h>
5 #endif
6
7 int main(int argc, char *argv[])
8 {
9 #ifdef WIN32
10 printf("WIN32 ");
11 #endif
12 #ifdef _WIN32
13 printf("_WIN32 ");
14 #endif
15 #ifdef __CYGWIN__
16 printf("__CYGWIN__ ");
17 #endif
18 #ifdef __MINGW32__
19 printf("__MINGW32__ ");
20 #endif
21 printf("\n");
22 return 0;
23 } $ gcc -o test test.c
$ ./test
__CYGWIN__ $ gcc -o test -DIW test.c
$ ./test
WIN32 _WIN32 __CYGWIN__ $ gcc -o test -mno-cygwin test.c
$ ./test
WIN32 _WIN32 __MINGW32__ ATB, Ramsay Jones