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

Tim Peters python-dev@python.org
Mon, 3 Jul 2000 16:51:19 -0700


Update of /cvsroot/python/python/dist/src/PC
In directory slayer.i.sourceforge.net:/tmp/cvs-serv16659/python/dist/src/PC
Modified Files:
	import_nt.c 
Log Message:
Squash signed-vs-unsigned warning. Also edits to bring into line
with Python coding stds (max line length, C-style comments).
Index: import_nt.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/PC/import_nt.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -r1.12 -r1.13
*** import_nt.c	2000年06月28日 22:20:06	1.12
--- import_nt.c	2000年07月03日 23:51:17	1.13
***************
*** 9,19 ****
 #include "Python.h"
 #include "osdefs.h"
 #include <windows.h>
 #include "importdl.h"
! #include "malloc.h" // for alloca
 
! extern const char *PyWin_DLLVersionString; // a string loaded from the DLL at startup.
 
! FILE *PyWin_FindRegisteredModule( const char *moduleName, struct filedescr **ppFileDesc, char *pathBuf, int pathLen)
 {
 	char *moduleKey;
--- 9,24 ----
 #include "Python.h"
 #include "osdefs.h"
+ #include <assert.h>
 #include <windows.h>
 #include "importdl.h"
! #include "malloc.h" /* for alloca */
 
! /* a string loaded from the DLL at startup */
! extern const char *PyWin_DLLVersionString;
 
! FILE *PyWin_FindRegisteredModule(const char *moduleName,
! 				 struct filedescr **ppFileDesc,
! 				 char *pathBuf,
! 				 int pathLen)
 {
 	char *moduleKey;
***************
*** 21,25 ****
 	const char keySuffix[] = "\\Modules\\";
 #ifdef _DEBUG
! 	// In debugging builds, we _must_ have the debug version registered.
 	const char debugString[] = "\\Debug";
 #else
--- 26,32 ----
 	const char keySuffix[] = "\\Modules\\";
 #ifdef _DEBUG
! 	/* In debugging builds, we _must_ have the debug version
! 	 * registered.
! 	 */
 	const char debugString[] = "\\Debug";
 #else
***************
*** 32,53 ****
 	long regStat;
 
! 	// Calculate the size for the sprintf buffer.
! 	// Get the size of the chars only, plus 1 NULL.
! 	size_t bufSize = sizeof(keyPrefix)-1 + strlen(PyWin_DLLVersionString) + sizeof(keySuffix) + strlen(moduleName) + sizeof(debugString) - 1;
! 	// alloca == no free required, but memory only local to fn, also no heap fragmentation!
 	moduleKey = alloca(bufSize); 
! 	sprintf(moduleKey, "Software\\Python\\PythonCore\\%s\\Modules\\%s%s", PyWin_DLLVersionString, moduleName, debugString);
 
 	modNameSize = pathLen;
 	regStat = RegQueryValue(keyBase, moduleKey, pathBuf, &modNameSize);
! 	if (regStat!=ERROR_SUCCESS)
 		return NULL;
! 	// use the file extension to locate the type entry.
 	for (fdp = _PyImport_Filetab; fdp->suffix != NULL; fdp++) {
 		size_t extLen = strlen(fdp->suffix);
! 		if (modNameSize>extLen && strnicmp(pathBuf+(modNameSize-extLen-1),fdp->suffix,extLen)==0)
 			break;
 	}
! 	if (fdp->suffix==NULL)
 		return NULL;
 	fp = fopen(pathBuf, fdp->mode);
--- 39,73 ----
 	long regStat;
 
! 	/* Calculate the size for the sprintf buffer.
! 	 * Get the size of the chars only, plus 1 NULL.
! 	 */
! 	size_t bufSize = sizeof(keyPrefix)-1 +
! 	 strlen(PyWin_DLLVersionString) +
! 	 sizeof(keySuffix) +
! 	 strlen(moduleName) +
! 	 sizeof(debugString) - 1;
! 	/* alloca == no free required, but memory only local to fn,
! 	 * also no heap fragmentation!
! 	 */
 	moduleKey = alloca(bufSize); 
! 	sprintf(moduleKey,
! 		"Software\\Python\\PythonCore\\%s\\Modules\\%s%s",
! 	 PyWin_DLLVersionString, moduleName, debugString);
 
 	modNameSize = pathLen;
 	regStat = RegQueryValue(keyBase, moduleKey, pathBuf, &modNameSize);
! 	if (regStat != ERROR_SUCCESS)
 		return NULL;
! 	/* use the file extension to locate the type entry. */
 	for (fdp = _PyImport_Filetab; fdp->suffix != NULL; fdp++) {
 		size_t extLen = strlen(fdp->suffix);
! 		assert(modNameSize >= 0); /* else cast to size_t is wrong */
! 		if ((size_t)modNameSize > extLen &&
! 		 strnicmp(pathBuf + ((size_t)modNameSize-extLen-1),
! 		 fdp->suffix,
! 		 extLen) == 0)
 			break;
 	}
! 	if (fdp->suffix == NULL)
 		return NULL;
 	fp = fopen(pathBuf, fdp->mode);
***************
*** 56,58 ****
 	return fp;
 }
- 
--- 76,77 ----

AltStyle によって変換されたページ (->オリジナル) /