[Python-checkins] python/dist/src/Python ast.c, 2.2, 2.3 compile.c, 2.353, 2.354 symtable.c, 2.13, 2.14

arigo@users.sourceforge.net arigo at users.sourceforge.net
Fri Oct 21 14:57:36 CEST 2005


Update of /cvsroot/python/python/dist/src/Python
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32569/Python

Modified Files:
	ast.c compile.c symtable.c 
Log Message:
ANSI-C-ify the placement of local var declarations.


Index: ast.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/ast.c,v
retrieving revision 2.2
retrieving revision 2.3
diff -u -d -r2.2 -r2.3
--- ast.c	21 Oct 2005 05:15:07 -0000	2.2
+++ ast.c	21 Oct 2005 12:57:31 -0000	2.3
@@ -512,14 +512,14 @@
 seq_for_testlist(struct compiling *c, const node *n)
 {
     /* testlist: test (',' test)* [','] */
+    asdl_seq *seq;
+    expr_ty expression;
+    int i;
     assert(TYPE(n) == testlist
 	   || TYPE(n) == listmaker
 	   || TYPE(n) == testlist_gexp
 	   || TYPE(n) == testlist_safe
 	   );
-    asdl_seq *seq;
-    expr_ty expression;
-    int i;
 
     seq = asdl_seq_new((NCH(n) + 1) / 2);
     if (!seq)
@@ -641,12 +641,13 @@
                                     compiler_complex_args(CHILD(ch, 1))); 
 		}
                 else if (TYPE(CHILD(ch, 0)) == NAME) {
+		    expr_ty name;
 		    if (!strcmp(STR(CHILD(ch, 0)), "None")) {
 			    ast_error(CHILD(ch, 0), "assignment to None");
 			    goto error;
 		    }
-                    expr_ty name = Name(NEW_IDENTIFIER(CHILD(ch, 0)),
-                                        Param, LINENO(ch));
+                    name = Name(NEW_IDENTIFIER(CHILD(ch, 0)),
+                                Param, LINENO(ch));
                     if (!name)
                         goto error;
                     asdl_seq_APPEND(args, name);
@@ -1897,12 +1898,13 @@
 	if (!targets)
 	    return NULL;
 	for (i = 0; i < NCH(n) - 2; i += 2) {
+	    expr_ty e;
 	    node *ch = CHILD(n, i);
 	    if (TYPE(ch) == yield_expr) {
 		ast_error(ch, "assignment to yield expression not possible");
 		goto error;
 	    }
-	    expr_ty e = ast_for_testlist(c, ch, 0);
+	    e = ast_for_testlist(c, ch, 0);
 
 	    /* set context to assign */
 	    if (!e) 

Index: compile.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v
retrieving revision 2.353
retrieving revision 2.354
diff -u -d -r2.353 -r2.354
--- compile.c	20 Oct 2005 19:59:25 -0000	2.353
+++ compile.c	21 Oct 2005 12:57:31 -0000	2.354
@@ -2329,8 +2329,9 @@
 		src = dot + 1;
 		while (dot) {
 			/* NB src is only defined when dot != NULL */
+			PyObject *attr;
 			dot = strchr(src, '.');
-			PyObject *attr = PyString_FromStringAndSize(src, 
+			attr = PyString_FromStringAndSize(src, 
 					    dot ? dot - src : strlen(src));
 			ADDOP_O(c, LOAD_ATTR, attr, names);
 			src = dot + 1;

Index: symtable.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/symtable.c,v
retrieving revision 2.13
retrieving revision 2.14
diff -u -d -r2.13 -r2.14
--- symtable.c	20 Oct 2005 19:59:25 -0000	2.13
+++ symtable.c	21 Oct 2005 12:57:31 -0000	2.14
@@ -444,12 +444,13 @@
 static int
 check_unoptimized(const PySTEntryObject* ste) {
 	char buf[300];
+	const char* trailer;
 
 	if (ste->ste_type == ModuleBlock || !ste->ste_unoptimized
 	    || !(ste->ste_free || ste->ste_child_free))
 		return 1;
 
-	const char* trailer = (ste->ste_child_free ? 
+	trailer = (ste->ste_child_free ? 
 		       "contains a nested function with free variables" :
 			       "is a nested function");
 
@@ -621,8 +622,9 @@
 	/* Recursively call analyze_block() on each child block */
 	for (i = 0; i < PyList_GET_SIZE(ste->ste_children); ++i) {
 		PyObject *c = PyList_GET_ITEM(ste->ste_children, i);
+		PySTEntryObject* entry;
 		assert(c && PySTEntry_Check(c));
-		PySTEntryObject* entry = (PySTEntryObject*)c;
+		entry = (PySTEntryObject*)c;
 		if (!analyze_block(entry, newbound, newfree, newglobal))
 			goto error;
 		if (entry->ste_free || entry->ste_child_free)



More information about the Python-checkins mailing list