summaryrefslogtreecommitdiffstats
path: root/PC/getpathp.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1998-08-08 19:58:59 (GMT)
committerGuido van Rossum <guido@python.org>1998-08-08 19:58:59 (GMT)
commit67ab67218bb8c5f45f57ed8f8f5a5eec61a68c7c (patch)
treeb1152cda11c5ddb8aa85007b6c08c7959576062e /PC/getpathp.c
parente2d81cd4d7f151d07278fc0adfa556a3aa9a957f (diff)
downloadcpython-67ab67218bb8c5f45f57ed8f8f5a5eec61a68c7c.zip
cpython-67ab67218bb8c5f45f57ed8f8f5a5eec61a68c7c.tar.gz
cpython-67ab67218bb8c5f45f57ed8f8f5a5eec61a68c7c.tar.bz2
Different version games:
- MS_DLL_ID is now set to "1.5" instead of "1.5.x" so Mark Hammond's extensions won't have to be changed. - FILEVERSION and PRODUCTVERSION are set to 1,5,2,1. (The last number could be the build# or the alpha release# or so.)
Diffstat (limited to 'PC/getpathp.c')
-rw-r--r--PC/getpathp.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/PC/getpathp.c b/PC/getpathp.c
index f0714b5..5ff4101 100644
--- a/PC/getpathp.c
+++ b/PC/getpathp.c
@@ -352,6 +352,7 @@ calculate_path()
/* We need to construct a path from the following parts:
(1) the PYTHONPATH environment variable, if set;
(2) for Win32, the machinepath and userpath, if set;
+ The following only if neither machinepath nor userpath is set:
(3) the PYTHONPATH config macro, with the leading "."
of each component replaced with pythonhome, if set;
(4) the directory containing the executable (argv0_path).
@@ -371,15 +372,17 @@ calculate_path()
else
bufsz = 0;
bufsz += strlen(PYTHONPATH) + 1;
- if (envpath != NULL)
- bufsz += strlen(envpath) + 1;
bufsz += strlen(argv0_path) + 1;
#ifdef MS_WIN32
- if (machinepath)
- bufsz += strlen(machinepath) + 1;
+ if (userpath || machinepath)
+ bufsz = 0; /* Reset! */
if (userpath)
bufsz += strlen(userpath) + 1;
+ if (machinepath)
+ bufsz += strlen(machinepath) + 1;
#endif
+ if (envpath != NULL)
+ bufsz += strlen(envpath) + 1;
module_search_path = buf = malloc(bufsz);
if (buf == NULL) {
@@ -408,17 +411,21 @@ calculate_path()
*buf++ = DELIM;
}
#ifdef MS_WIN32
+ if (userpath) {
+ strcpy(buf, userpath);
+ buf = strchr(buf, '\0');
+ *buf++ = DELIM;
+ free(userpath);
+ }
if (machinepath) {
strcpy(buf, machinepath);
buf = strchr(buf, '\0');
*buf++ = DELIM;
free(machinepath);
}
- if (userpath) {
- strcpy(buf, userpath);
- buf = strchr(buf, '\0');
- *buf++ = DELIM;
- free(userpath);
+ if (userpath || machinepath) {
+ buf[-1] = '\0';
+ return;
}
#endif
if (pythonhome == NULL) {