[Python-checkins] python/dist/src/Python newcompile.c,1.1.2.35,1.1.2.36

tim_one@users.sourceforge.net tim_one@users.sourceforge.net
2003年3月25日 13:01:29 -0800


Update of /cvsroot/python/python/dist/src/Python
In directory sc8-pr-cvs1:/tmp/cvs-serv22227/Python
Modified Files:
 Tag: ast-branch
	newcompile.c 
Log Message:
Compiling a two-branch if/else got into an infinite loop. Repaired.
Index: newcompile.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/Attic/newcompile.c,v
retrieving revision 1.1.2.35
retrieving revision 1.1.2.36
diff -C2 -d -r1.1.2.35 -r1.1.2.36
*** newcompile.c	25 Mar 2003 20:53:22 -0000	1.1.2.35
--- newcompile.c	25 Mar 2003 21:01:24 -0000	1.1.2.36
***************
*** 681,685 ****
 compiler_if(struct compiler *c, stmt_ty s)
 {
! 	int end, next, elif = 1;
 
 	assert(s->kind == If_kind);
--- 681,685 ----
 compiler_if(struct compiler *c, stmt_ty s)
 {
! 	int end, next;
 
 	assert(s->kind == If_kind);
***************
*** 687,691 ****
 	if (end < 0)
 		return 0;
! 	while (elif) {
 		next = compiler_new_block(c);
 		if (next < 0)
--- 687,691 ----
 	if (end < 0)
 		return 0;
! 	for (;;) {
 		next = compiler_new_block(c);
 		if (next < 0)
***************
*** 701,713 ****
 			stmt_ty t = asdl_seq_GET(s->v.If.orelse, 0);
 			if (t->kind == If_kind) {
- 				elif = 1;
 				s = t;
 				c->u->u_lineno = t->lineno;
 			}
 		}
 		else
! 			elif = 0;
! 		if (!elif)
! 			VISIT_SEQ(c, stmt, s->v.If.orelse);
 	}
 	compiler_use_block(c, end);
--- 701,714 ----
 			stmt_ty t = asdl_seq_GET(s->v.If.orelse, 0);
 			if (t->kind == If_kind) {
 				s = t;
 				c->u->u_lineno = t->lineno;
 			}
+ 			else {
+ 				VISIT_SEQ(c, stmt, s->v.If.orelse);
+ 				break;
+ 			}
 		}
 		else
! 			break;
 	}
 	compiler_use_block(c, end);

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