NON-WORKING python with an older version of the MinGW patch.
[fedora-mingw.git] / python / python-2.4.1-canonicalize.patch
1 --- Python-2.4.1/pyconfig.h.in.canonicalize     2004-10-13 11:30:55.000000000 -0400
2 +++ Python-2.4.1/pyconfig.h.in  2005-10-06 14:04:06.000000000 -0400
3 @@ -58,6 +58,9 @@
4  /* Define if pthread_sigmask() does not work on your system. */
5  #undef HAVE_BROKEN_PTHREAD_SIGMASK
6  
7 +/* Define to 1 if you have the `canonicalize_file_name' function. */
8 +#undef HAVE_CANONICALIZE_FILE_NAME
9 +
10  /* Define to 1 if you have the `chown' function. */
11  #undef HAVE_CHOWN
12  
13 --- Python-2.4.1/Python/sysmodule.c.canonicalize        2005-01-27 13:58:30.000000000 -0500
14 +++ Python-2.4.1/Python/sysmodule.c     2005-10-06 14:56:37.000000000 -0400
15 @@ -1168,11 +1168,13 @@
16  void
17  PySys_SetArgv(int argc, char **argv)
18  {
19 +#ifndef HAVE_CANONICALIZE_FILE_NAME
20  #if defined(HAVE_REALPATH)
21         char fullpath[MAXPATHLEN];
22  #elif defined(MS_WINDOWS)
23         char fullpath[MAX_PATH];
24  #endif
25 +#endif
26         PyObject *av = makeargvobject(argc, argv);
27         PyObject *path = PySys_GetObject("path");
28         if (av == NULL)
29 @@ -1184,6 +1186,64 @@
30                 char *p = NULL;
31                 int n = 0;
32                 PyObject *a;
33 +#ifdef HAVE_CANONICALIZE_FILE_NAME
34 +               char *link = NULL, *argv0copy = NULL;
35 +                
36 +                if (argc > 0 && argv0 != NULL) {
37 +                       
38 +                       link = canonicalize_file_name(argv0);
39 +                       if (link == NULL) {
40 +                               link = strdup(argv0);
41 +                               if (!link)
42 +                                       Py_FatalError("no mem for sys.argv");
43 +                       }
44 +               }
45 +               if (link) {
46 +                       if (link[0] == SEP) /* Link to absolute path */
47 +                               argv0 = link;
48 +                       else if (strchr(link, SEP) == NULL) {
49 +                               /* Link without path */
50 +                               /* strdup argv0 so we can free it 
51 +                                  unconditionally */
52 +                               argv0 = strdup(argv0);
53 +                               if (!argv0)
54 +                                       Py_FatalError("no mem for sys.argv");
55 +                               free(link);
56 +                       } else {
57 +                               /* Must join(dirname(argv0), link) */
58 +                               char *q = strrchr(argv0, SEP);
59 +                               if (q == NULL) /* argv0 without path */
60 +                                       argv0 = link;
61 +                               else {
62 +                                       /* Must make a copy */
63 +                                       argv0copy = calloc(
64 +                                                strlen(link) + strlen(q) +1,
65 +                                                sizeof (char));
66 +                                       if (!argv0copy)
67 +                                               Py_FatalError("no mem for sys.argv");
68 +                                       strcpy(argv0copy, argv0);
69 +                                       q = strrchr(argv0copy, SEP);
70 +                                       strcpy(argv0copy+1, link);
71 +                                       argv0 = argv0copy;
72 +                                       p = NULL;
73 +                                       free(link);
74 +                               }
75 +                       }
76 +               }
77 +               if (argc > 0 && argv0 != NULL) {
78 +                       char *q;
79 +                       p = strrchr(argv0, SEP);
80 +                       /* Test for alternate separator */
81 +                       q = strrchr(p ? p : argv0, '/');
82 +                       if (q != NULL)
83 +                               p = q;
84 +                       if (p != NULL) {
85 +                               n = p + 1 - argv0;
86 +                               if (n > 1 && p[-1] != ':')
87 +                                       n--; /* Drop trailing separator */
88 +                       }
89 +               }
90 +#else /* ! HAVE_CANONICALIZE_FILE_NAME */
91  #ifdef HAVE_READLINK
92                 char link[MAXPATHLEN+1];
93                 char argv0copy[2*MAXPATHLEN+1];
94 @@ -1256,9 +1316,14 @@
95  #endif /* Unix */
96                 }
97  #endif /* All others */
98 +#endif /* ! HAVE_CANONICALIZE_FILE_NAME */
99                 a = PyString_FromStringAndSize(argv0, n);
100                 if (a == NULL)
101                         Py_FatalError("no mem for sys.path insertion");
102 +#ifdef HAVE_CANONICALIZE_FILE_NAME
103 +               if (argc > 0 && argv0 != NULL)
104 +                       free(argv0);
105 +#endif /* HAVE_CANONICALIZE_FILE_NAME */
106                 if (PyList_Insert(path, 0, a) < 0)
107                         Py_FatalError("sys.path.insert(0) failed");
108                 Py_DECREF(a);
109 --- Python-2.4.1/configure.in.canonicalize      2005-03-28 18:23:34.000000000 -0500
110 +++ Python-2.4.1/configure.in   2005-10-06 14:04:06.000000000 -0400
111 @@ -2096,8 +2096,8 @@
112  AC_MSG_RESULT(MACHDEP_OBJS)
113  
114  # checks for library functions
115 -AC_CHECK_FUNCS(alarm bind_textdomain_codeset chown clock confstr ctermid \
116 - execv fork fpathconf ftime ftruncate \
117 +AC_CHECK_FUNCS(alarm bind_textdomain_codeset canonicalize_file_name chown \
118 + clock confstr ctermid execv fork fpathconf ftime ftruncate \
119   gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \
120   getpriority getpwent getsid getwd \
121   kill killpg lchown lstat mkfifo mknod mktime \