]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/cortex-strings/scripts/fixup.py
msdosfs: Fix a leak of dirent padding bytes
[FreeBSD/FreeBSD.git] / contrib / cortex-strings / scripts / fixup.py
1 """Simple script that enables target specific blocks based on the first argument.
2
3 Matches comment blocks like this:
4
5 /* For Foo: abc
6 def
7 */
8
9 and de-comments them giving:
10 abc
11 def
12 """
13 import re
14 import sys
15
16 def main():
17     key = sys.argv[1]
18     expr = re.compile(r'/\* For %s:\s([^*]+)\*/' % key, re.M)
19
20     for arg in sys.argv[2:]:
21         with open(arg) as f:
22             body = f.read()
23         with open(arg, 'w') as f:
24             f.write(expr.sub(r'\1', body))
25
26 if __name__ == '__main__':
27     main()