fix code writer indentation correct for '} else {'
authorStefan Behnel <scoder@users.berlios.de>
Fri, 11 Jul 2008 12:32:07 +0000 (14:32 +0200)
committerStefan Behnel <scoder@users.berlios.de>
Fri, 11 Jul 2008 12:32:07 +0000 (14:32 +0200)
Cython/Compiler/Code.py

index afba02f8c3ba767d5501c7d4b216fa3d519ce254..ce615cf1b1a583f338e11d62d9b31d7ff79fae45 100644 (file)
@@ -64,13 +64,17 @@ class CCodeWriter:
         dl = code.count("{") - code.count("}")
         if dl < 0:
             self.level += dl
+        elif dl == 0 and code.startswith('}'):
+            self.level -= 1
         if self.bol:
             self.indent()
         self._write(code)
         self.bol = 0
         if dl > 0:
             self.level += dl
-    
+        elif dl == 0 and code.startswith('}'):
+            self.level += 1
+
     def increase_indent(self):
         self.level = self.level + 1