[Python-checkins] CVS: python/dist/src/Python future.c,2.10,2.10.2.1

Guido van Rossum gvanrossum@users.sourceforge.net
Mon, 20 Aug 2001 20:25:17 -0700


Update of /cvsroot/python/python/dist/src/Python
In directory usw-pr-cvs1:/tmp/cvs-serv1851/branch/Python

Modified Files:
      Tag: r22a2-branch
	future.c 
Log Message:
Merge trunk->branch

Index: future.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/future.c,v
retrieving revision 2.10
retrieving revision 2.10.2.1
diff -C2 -d -r2.10 -r2.10.2.1
*** future.c	2001/08/10 21:41:33	2.10
--- future.c	2001/08/21 03:25:15	2.10.2.1
***************
*** 9,12 ****
--- 9,15 ----
  #define FUTURE_IMPORT_STAR "future statement does not support import *"
  
+ /* FUTURE_POSSIBLE() is provided to accomodate doc strings, which is
+    the only statement that can occur before a future statement.
+ */
  #define FUTURE_POSSIBLE(FF) ((FF)->ff_last_lineno == -1)
  
***************
*** 58,62 ****
  			"beginning of the file");
  	PyErr_SyntaxLocation(filename, n->n_lineno);
- 	/* XXX set filename and lineno */
  }
  
--- 61,64 ----
***************
*** 76,80 ****
  */
  
! /* future_parse() return values:
     -1 indicates an error occurred, e.g. unknown feature name
     0 indicates no feature was found
--- 78,87 ----
  */
  
! /* future_parse() finds future statements at the beginnning of a
!    module.  The function calls itself recursively, rather than
!    factoring out logic for different kinds of statements into
!    different routines.
! 
!    Return values:
     -1 indicates an error occurred, e.g. unknown feature name
     0 indicates no feature was found
***************
*** 98,106 ****
  
  	case file_input:
  		for (i = 0; i < NCH(n); i++) {
  			node *ch = CHILD(n, i);
  			if (TYPE(ch) == stmt) {
  				r = future_parse(ff, ch, filename);
! 				if (!FUTURE_POSSIBLE(ff))
  					return r;
  			}
--- 105,121 ----
  
  	case file_input:
+ 		/* Check each statement in the file, starting with the
+ 		   first, and continuing until the first statement
+ 		   that isn't a future statement.
+ 		*/
  		for (i = 0; i < NCH(n); i++) {
  			node *ch = CHILD(n, i);
  			if (TYPE(ch) == stmt) {
  				r = future_parse(ff, ch, filename);
! 				/* Need to check both conditions below
! 				   to accomodate doc strings, which
! 				   causes r < 0.
! 				*/
! 				if (r < 1 && !FUTURE_POSSIBLE(ff))
  					return r;
  			}