aboutsummaryrefslogtreecommitdiffstats
path: root/xen/tools/compat-build-header.py
blob: 6fb795eaaa093d944eed13a553ecde2fb6d405ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/python

import re,sys

pats = [
 [ r"__InClUdE__", r"#include" ],
 [ r"\"xen-compat.h\"", r"<public/xen-compat.h>" ],
 [ r"(struct|union|enum)\s+(xen_?)?(\w)", r"\1 compat_\3" ],
 [ r"@KeeP@", r"" ],
 [ r"_t([^\w]|$)", r"_compat_t\1" ],
 [ r"(8|16|32|64)_compat_t([^\w]|$)", r"\1_t\2" ],
 [ r"(^|[^\w])xen_?(\w*)_compat_t([^\w]|$$)", r"\1compat_\2_t\3" ],
 [ r"(^|[^\w])XEN_?", r"\1COMPAT_" ],
 [ r"(^|[^\w])Xen_?", r"\1Compat_" ],
 [ r"(^|[^\w])long([^\w]|$$)", r"\1int\2" ]
];

for line in sys.stdin.readlines():
    for pat in pats:
        line = re.subn(pat[0], pat[1], line)[0]
    print line.rstrip()