1#!/usr/bin/env python 2 3import re,sys 4 5pats = [ 6 [ r"__InClUdE__(.*)", r"#include\1\n#pragma pack(4)" ], 7 [ r"__IfDeF__ (XEN_HAVE.*)", r"#ifdef \1" ], 8 [ r"__ElSe__", r"#else" ], 9 [ r"__EnDif__", r"#endif" ], 10 [ r"__DeFiNe__", r"#define" ], 11 [ r"__UnDeF__", r"#undef" ], 12 [ r"\"xen-compat.h\"", r"<public/xen-compat.h>" ], 13 [ r"(struct|union|enum)\s+(xen_?)?(\w)", r"\1 compat_\3" ], 14 [ r"@KeeP@", r"" ], 15 [ r"_t([^\w]|$)", r"_compat_t\1" ], 16 [ r"(8|16|32|64)_compat_t([^\w]|$)", r"\1_t\2" ], 17 [ r"(^|[^\w])xen_?(\w*)_compat_t([^\w]|$$)", r"\1compat_\2_t\3" ], 18 [ r"(^|[^\w])XEN_?", r"\1COMPAT_" ], 19 [ r"(^|[^\w])Xen_?", r"\1Compat_" ], 20 [ r"(^|[^\w])long([^\w]|$$)", r"\1int\2" ] 21]; 22 23for line in sys.stdin.readlines(): 24 for pat in pats: 25 line = re.subn(pat[0], pat[1], line)[0] 26 print line.rstrip() 27