Fixup fromcvs/togit conversion
[minix-pkgsrc.git] / lang / python27 / patches / patch-Modules_getpath.c
blob316e8e1e9fa8d70c918ae8c5f696aaafa3509ea7
1 $NetBSD$
3 * from cygport 2.7.3-getpath-exe-extension.patch
5 --- Modules/getpath.c.orig 2013-04-06 14:02:37.000000000 +0000
6 +++ Modules/getpath.c
7 @@ -436,6 +436,28 @@ calculate_path(void)
8 if (isxfile(progpath))
9 break;
11 +#ifdef __CYGWIN__
12 + /*
13 + * Cygwin automatically removes the ".exe" extension from argv[0]
14 + * to make programs feel like they are in a more Unix-like
15 + * environment. Unfortunately, this can make it problemmatic for
16 + * Cygwin to distinguish between a directory and an executable with
17 + * the same name excluding the ".exe" extension. For example, the
18 + * Cygwin Python build directory has a "Python" directory and a
19 + * "python.exe" executable. This causes isxfile() to erroneously
20 + * return false. If isdir() returns true and there is enough space
21 + * to append the ".exe" extension, then we try again with the
22 + * extension appended.
23 + */
24 +#define EXE ".exe"
25 + if (isdir(progpath) && strlen(progpath) + strlen(EXE) <= MAXPATHLEN)
26 + {
27 + strcat(progpath, EXE);
28 + if (isxfile(progpath))
29 + break;
30 + }
31 +#endif /* __CYGWIN__ */
33 if (!delim) {
34 progpath[0] = '\0';
35 break;