diff options
author | Guido van Rossum <guido@python.org> | 2000-03-29 01:49:47 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2000-03-29 01:49:47 (GMT) |
commit | e02e48be6f589690e8fe7813203b55999afc7c39 (patch) | |
tree | 232a9750fc14de0264914b988dee883a4fa99561 /PC/getpathp.c | |
parent | 436364c8a0a9bb4c13ca27360c1cee0b17430e04 (diff) | |
download | cpython-e02e48be6f589690e8fe7813203b55999afc7c39.zip cpython-e02e48be6f589690e8fe7813203b55999afc7c39.tar.gz cpython-e02e48be6f589690e8fe7813203b55999afc7c39.tar.bz2 |
Changes to completely ignore the registry when it detects that you are
running out of the build directory. This means that it will no longer
try to use an older version of the library when an older version has
been installed.
Diffstat (limited to 'PC/getpathp.c')
-rw-r--r-- | PC/getpathp.c | 55 |
1 files changed, 30 insertions, 25 deletions
diff --git a/PC/getpathp.c b/PC/getpathp.c index 80865d7..7c4d121 100644 --- a/PC/getpathp.c +++ b/PC/getpathp.c @@ -137,22 +137,30 @@ join(buffer, stuff) static int +gotlandmark(landmark) + char *landmark; +{ + int n, ok; + + n = strlen(prefix); + join(prefix, landmark); + ok = ismodule(prefix); + prefix[n] = '\0'; + return ok; +} + + +static int search_for_prefix(argv0_path, landmark) char *argv0_path; char *landmark; { - int n; - /* Search from argv0_path, until root is found */ + /* Search from argv0_path, until landmark is found */ strcpy(prefix, argv0_path); do { - n = strlen(prefix); - join(prefix, landmark); - if (ismodule(prefix)) { - prefix[n] = '\0'; + if (gotlandmark(landmark)) return 1; - } - prefix[n] = '\0'; reduce(prefix); } while (prefix[0]); return 0; @@ -175,7 +183,7 @@ extern const char *PyWin_DLLVersionString; // a string loaded from the DLL at st */ static char * -getpythonregpath(HKEY keyBase, BOOL bWin32s) +getpythonregpath(HKEY keyBase) { HKEY newKey = 0; DWORD nameSize = 0; @@ -206,11 +214,6 @@ getpythonregpath(HKEY keyBase, BOOL bWin32s) RegQueryInfoKey(newKey, NULL, NULL, NULL, NULL, NULL, NULL, &numEntries, &nameSize, &dataSize, NULL, NULL); } - if (bWin32s && numEntries==0 && dataSize==0) { - /* must hardcode for Win32s */ - numEntries = 1; - dataSize = 511; - } if (numEntries) { /* Loop over all subkeys. */ /* Win32s doesnt know how many subkeys, so we do @@ -225,7 +228,6 @@ getpythonregpath(HKEY keyBase, BOOL bWin32s) if (rc) break; rc = RegQueryValue(newKey, keyBuf, NULL, &reqdSize); if (rc) break; - if (bWin32s && reqdSize==0) reqdSize = 512; dataSize += reqdSize + 1; /* 1 for the ";" */ } dataBuf = malloc(dataSize+1); @@ -333,6 +335,7 @@ calculate_path() char *envpath = getenv("PYTHONPATH"); #ifdef MS_WIN32 + int skiphome = 0; char *machinepath = NULL; char *userpath = NULL; #endif @@ -352,15 +355,11 @@ calculate_path() if (envpath && *envpath == '\0') envpath = NULL; + #ifdef MS_WIN32 - /* Are we running under Windows 3.1(1) Win32s? */ - if (PyWin_IsWin32s()) { - /* Only CLASSES_ROOT is supported */ - machinepath = getpythonregpath(HKEY_CLASSES_ROOT, TRUE); - userpath = NULL; - } else { - machinepath = getpythonregpath(HKEY_LOCAL_MACHINE, FALSE); - userpath = getpythonregpath(HKEY_CURRENT_USER, FALSE); + if (!gotlandmark(BUILD_LANDMARK)) { + machinepath = getpythonregpath(HKEY_LOCAL_MACHINE); + userpath = getpythonregpath(HKEY_CURRENT_USER); } #endif @@ -404,11 +403,11 @@ calculate_path() /* We can't exit, so print a warning and limp along */ fprintf(stderr, "Can't malloc dynamic PYTHONPATH.\n"); if (envpath) { - fprintf(stderr, "Using default static $PYTHONPATH.\n"); + fprintf(stderr, "Using environment $PYTHONPATH.\n"); module_search_path = envpath; } else { - fprintf(stderr, "Using environment $PYTHONPATH.\n"); + fprintf(stderr, "Using default static path.\n"); module_search_path = PYTHONPATH; } #ifdef MS_WIN32 @@ -431,12 +430,18 @@ calculate_path() buf = strchr(buf, '\0'); *buf++ = DELIM; free(userpath); + skiphome = 1; } if (machinepath) { strcpy(buf, machinepath); buf = strchr(buf, '\0'); *buf++ = DELIM; free(machinepath); + skiphome = 1; + } + if (skiphome) { + *buf = 0; + return; } #endif if (pythonhome == NULL) { |