[Python-checkins] CVS: python/dist/src/PC getpathp.c,1.11,1.12

Guido van Rossum python-dev@python.org
Tue, 28 Mar 2000 20:49:49 -0500 (EST)


Update of /projects/cvsroot/python/dist/src/PC
In directory eric:/home/guido/hp/mal/py-patched/PC

Modified Files:
	getpathp.c 
Log Message:
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.


Index: getpathp.c
===================================================================
RCS file: /projects/cvsroot/python/dist/src/PC/getpathp.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -r1.11 -r1.12
*** getpathp.c	1998/08/11 20:35:56	1.11
--- getpathp.c	2000/03/29 01:49:47	1.12
***************
*** 138,157 ****
  
  static int
  search_for_prefix(argv0_path, landmark)
  	char *argv0_path;
  	char *landmark;
  {
- 	int n;
  
! 	/* Search from argv0_path, until root is found */
  	strcpy(prefix, argv0_path);
  	do {
! 		n = strlen(prefix);
! 		join(prefix, landmark);
! 		if (ismodule(prefix)) {
! 			prefix[n] = '\0';
  			return 1;
- 		}
- 		prefix[n] = '\0';
  		reduce(prefix);
  	} while (prefix[0]);
--- 138,165 ----
  
  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;
  {
  
! 	/* Search from argv0_path, until landmark is found */
  	strcpy(prefix, argv0_path);
  	do {
! 		if (gotlandmark(landmark))
  			return 1;
  		reduce(prefix);
  	} while (prefix[0]);
***************
*** 176,180 ****
  
  static char *
! getpythonregpath(HKEY keyBase, BOOL bWin32s)
  {
  	HKEY newKey = 0;
--- 184,188 ----
  
  static char *
! getpythonregpath(HKEY keyBase)
  {
  	HKEY newKey = 0;
***************
*** 207,215 ****
  		                &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. */
--- 215,218 ----
***************
*** 226,230 ****
  			rc = RegQueryValue(newKey, keyBuf, NULL, &reqdSize);
  			if (rc) break;
- 			if (bWin32s && reqdSize==0) reqdSize = 512;
  			dataSize += reqdSize + 1; /* 1 for the ";" */
  		}
--- 229,232 ----
***************
*** 334,337 ****
--- 336,340 ----
  
  #ifdef MS_WIN32
+ 	int skiphome = 0;
  	char *machinepath = NULL;
  	char *userpath = NULL;
***************
*** 353,365 ****
  		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);
  	}
  #endif
--- 356,364 ----
  		envpath = NULL;
  
+ 
  #ifdef MS_WIN32
! 	if (!gotlandmark(BUILD_LANDMARK)) {
! 		machinepath = getpythonregpath(HKEY_LOCAL_MACHINE);
! 		userpath = getpythonregpath(HKEY_CURRENT_USER);
  	}
  #endif
***************
*** 405,413 ****
  		fprintf(stderr, "Can't malloc dynamic PYTHONPATH.\n");
  		if (envpath) {
! 			fprintf(stderr, "Using default static $PYTHONPATH.\n");
  			module_search_path = envpath;
  		}
  		else {
! 			fprintf(stderr, "Using environment $PYTHONPATH.\n");
  			module_search_path = PYTHONPATH;
  		}
--- 404,412 ----
  		fprintf(stderr, "Can't malloc dynamic PYTHONPATH.\n");
  		if (envpath) {
! 			fprintf(stderr, "Using environment $PYTHONPATH.\n");
  			module_search_path = envpath;
  		}
  		else {
! 			fprintf(stderr, "Using default static path.\n");
  			module_search_path = PYTHONPATH;
  		}
***************
*** 432,435 ****
--- 431,435 ----
  		*buf++ = DELIM;
  		free(userpath);
+ 		skiphome = 1;
  	}
  	if (machinepath) {
***************
*** 438,441 ****
--- 438,446 ----
  		*buf++ = DELIM;
  		free(machinepath);
+ 		skiphome = 1;
+ 	}
+ 	if (skiphome) {
+ 		*buf = 0;
+ 		return;
  	}
  #endif