]> thyrsus.com Git - mad.git/commitdiff
Better indent generation.
authorEric S. Raymond <esr@thyrsus,com>
Sat, 14 Feb 2004 00:00:23 +0000 (00:00 +0000)
committerEric S. Raymond <esr@thyrsus,com>
Sat, 14 Feb 2004 00:00:23 +0000 (00:00 +0000)
mad

diff --git a/mad b/mad
index 977f8bf0759fbf24a28b997090fefeb121434d97..a7bfd72cbf925f04deec225f598bb97bc02a16b0 100755 (executable)
--- a/mad
+++ b/mad
@@ -1005,12 +1005,11 @@ def generate_C_code(out):
             (exc_type, exc_value, exc_traceback) = sys.exc_info()
             raise exc_type, exc_value, exc_traceback
         if rep:
-            indentchange = rep.count('{') - rep.count('}')
-            if indentchange < 0:
-                indent += indentchange
+            if rep[0] == '}':
+                indent -= 1
             out.write('    '*indent + rep + '\n')
-            if indentchange > 0:
-                indent += indentchange
+            if rep[-1] == '{':
+                indent += 1
         while scopes and label == scopes[-1]:
             indent -= 1
             out.write(('    '*indent) + '}')