[Python-checkins] CVS: python/dist/src/Python pythonrun.c,2.148,2.149

Guido van Rossum gvanrossum@users.sourceforge.net
2001年10月12日 15:14:28 -0700


Update of /cvsroot/python/python/dist/src/Python
In directory usw-pr-cvs1:/tmp/cvs-serv1850
Modified Files:
	pythonrun.c 
Log Message:
SF patch #467455 : Enhanced environment variables, by Toby Dickenson.
 This patch changes to logic to: 
 if env.var. set and non-empty: 
 if env.var. is an integer: 
 set flag to that integer 
 if flag is zero: # [actually, <= 0 --GvR]
 set flag to 1 
 Under this patch, anyone currently using 
 PYTHONVERBOSE=yes will get the same output as before. 
 PYTHONVERBNOSE=2 will generate more verbosity than 
 before. 
 The only unusual case that the following three are 
 still all equivalent: 
 PYTHONVERBOSE=yespleas 
 PYTHONVERBOSE=1 
 PYTHONVERBOSE=0 
Index: pythonrun.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/pythonrun.c,v
retrieving revision 2.148
retrieving revision 2.149
diff -C2 -d -r2.148 -r2.149
*** pythonrun.c	2001年08月31日 17:40:15	2.148
--- pythonrun.c	2001年10月12日 22:14:26	2.149
***************
*** 88,91 ****
--- 88,102 ----
 */
 
+ static int
+ add_flag(int flag, const char *envs)
+ {
+ 	int env = atoi(envs);
+ 	if (flag < env)
+ 		flag = env;
+ 	if (flag < 1)
+ 		flag = 1;
+ 	return flag;
+ }
+ 
 void
 Py_Initialize(void)
***************
*** 102,110 ****
 	
 	if ((p = Py_GETENV("PYTHONDEBUG")) && *p != '0円')
! 		Py_DebugFlag = Py_DebugFlag ? Py_DebugFlag : 1;
 	if ((p = Py_GETENV("PYTHONVERBOSE")) && *p != '0円')
! 		Py_VerboseFlag = Py_VerboseFlag ? Py_VerboseFlag : 1;
 	if ((p = Py_GETENV("PYTHONOPTIMIZE")) && *p != '0円')
! 		Py_OptimizeFlag = Py_OptimizeFlag ? Py_OptimizeFlag : 1;
 
 	interp = PyInterpreterState_New();
--- 113,121 ----
 	
 	if ((p = Py_GETENV("PYTHONDEBUG")) && *p != '0円')
! 		Py_DebugFlag = add_flag(Py_DebugFlag, p);
 	if ((p = Py_GETENV("PYTHONVERBOSE")) && *p != '0円')
! 		Py_VerboseFlag = add_flag(Py_VerboseFlag, p);
 	if ((p = Py_GETENV("PYTHONOPTIMIZE")) && *p != '0円')
! 		Py_OptimizeFlag = add_flag(Py_OptimizeFlag, p);
 
 	interp = PyInterpreterState_New();

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