From 4d2caff36096b85345a2d734b073d7687a1a72e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Wed, 27 Jan 2016 15:03:52 +0100 Subject: [PATCH] reduce: try to reduce blocks better --- tools/reduce.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/reduce.py b/tools/reduce.py index 4e0b2d059..c099d5a6e 100644 --- a/tools/reduce.py +++ b/tools/reduce.py @@ -178,15 +178,17 @@ def removeblocks(filedata): i2 = i1 indent = 0 - while i2 < len(filedata): + while i2 < len(filedata) and indent>=0: for c in filedata[i2]: if c == '}': indent = indent - 1 - if indent <= 0: - break + if indent == 0: + indent = -100 elif c == '{': indent = indent + 1 i2 = i2 + 1 + if indent == -100: + indent = 0 if i2 == i1 or i2 >= len(filedata): continue if filedata[i2].strip() != '}' and filedata[i2].strip() != '};':