diff options
author | Guido van Rossum <guido@python.org> | 1997-05-12 20:49:39 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1997-05-12 20:49:39 (GMT) |
commit | 573a24a4f7e2bf22eddd4a12d8985a4f14b69b90 (patch) | |
tree | 4087959c1fdac30d228070f039447c361c2560df /Modules | |
parent | 4a807f59391b497730342cf4cd07207ef50cfb51 (diff) | |
download | cpython-573a24a4f7e2bf22eddd4a12d8985a4f14b69b90.zip cpython-573a24a4f7e2bf22eddd4a12d8985a4f14b69b90.tar.gz cpython-573a24a4f7e2bf22eddd4a12d8985a4f14b69b90.tar.bz2 |
Fix problem reported by Donn Cave: if VPATH is an absolute path, it
would always be a hit. Prevent this by only using VPATH if we know
we are in the build directory.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/getpath.c | 43 |
1 files changed, 25 insertions, 18 deletions
diff --git a/Modules/getpath.c b/Modules/getpath.c index e2a87bf..d888df2 100644 --- a/Modules/getpath.c +++ b/Modules/getpath.c @@ -209,25 +209,30 @@ search_for_prefix(argv0_path, home) int i, n; char *vpath; - /* Check VPATH to see if argv0_path is in the build directory. - * Complication: the VPATH passed in is relative to the - * Modules build directory and points to the Modules source - * directory; we need it relative to the build tree and - * pointing to the source tree. Solution: chop off a leading - * ".." (but only if it's there -- it could be an absolute - * path) and chop off the final component (assuming it's - * "Modules"). - */ - vpath = VPATH; - if (vpath[0] == '.' && vpath[1] == '.' && vpath[2] == '/') - vpath += 3; + /* Check to see if argv[0] is in the build directory */ strcpy(prefix, argv0_path); - join(prefix, vpath); - reduce(prefix); - join(prefix, "Lib"); - join(prefix, LANDMARK); - if (exists(prefix)) - return -1; + join(prefix, "Modules/Setup"); + if (exists(prefix)) { + /* Check VPATH to see if argv0_path is in the build directory. + * Complication: the VPATH passed in is relative to the + * Modules build directory and points to the Modules source + * directory; we need it relative to the build tree and + * pointing to the source tree. Solution: chop off a leading + * ".." (but only if it's there -- it could be an absolute + * path) and chop off the final component (assuming it's + * "Modules"). + */ + vpath = VPATH; + if (vpath[0] == '.' && vpath[1] == '.' && vpath[2] == '/') + vpath += 3; + strcpy(prefix, argv0_path); + join(prefix, vpath); + reduce(prefix); + join(prefix, "Lib"); + join(prefix, LANDMARK); + if (exists(prefix)) + return -1; + } if (home) { /* Check $PYTHONHOME */ @@ -474,6 +479,8 @@ calculate_path() strcpy(buf, rtpypath); strcat(buf, delimiter); } + else + buf[0] = '\0'; /* Next goes merge of compile-time $PYTHONPATH with * dynamically located prefix. |