blob: a7f35488603cda4685a0004f323c23fe8e3f744c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
# Trim all trailing whitespace in front of goto labels.
# This is a workaround for a Clang Format limitation where goto labels are
# automatically indented according to nesting.
import re, sys
# 1. Zero or more whitespace characters.
# 2. One or more lowercase ASCII characters.
# 3. Colon character.
p = re.compile('^\s*[a-z_]+:$')
for line in sys.stdin:
m = p.search(line)
if m is not None:
sline = line.lstrip()
# The "default" tag in a switch statement looks identical so we need
# to filter these out here.
if not sline.startswith('default'):
line = sline
sys.stdout.write(line)
|