]>
Commit | Line | Data |
---|---|---|
74523b85 MT |
1 | #!/usr/bin/python |
2 | # Copyright (C) 2011 Red Hat, Inc., Michael S. Tsirkin <[email protected]> | |
3 | # | |
4 | # This program is free software; you can redistribute it and/or modify | |
5 | # it under the terms of the GNU General Public License as published by | |
6 | # the Free Software Foundation; either version 2 of the License, or | |
7 | # (at your option) any later version. | |
8 | # | |
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. | |
13 | # | |
14 | # You should have received a copy of the GNU General Public License along | |
15 | # with this program; if not, see <http://www.gnu.org/licenses/>. | |
16 | ||
17 | # Read a preprocessed ASL listing and put each ACPI_EXTRACT | |
18 | # directive in a comment, to make iasl skip it. | |
19 | # We also put each directive on a new line, the machinery | |
20 | # in tools/acpi_extract.py requires this. | |
21 | ||
22 | import re; | |
23 | import sys; | |
24 | import fileinput; | |
25 | ||
26 | def die(diag): | |
27 | sys.stderr.write("Error: %s\n" % (diag)) | |
28 | sys.exit(1) | |
29 | ||
30 | # Note: () around pattern make split return matched string as part of list | |
31 | psplit = re.compile(r''' ( | |
32 | \b # At word boundary | |
33 | ACPI_EXTRACT_\w+ # directive | |
34 | \s+ # some whitespace | |
35 | \w+ # array name | |
36 | )''', re.VERBOSE); | |
37 | ||
38 | lineno = 0 | |
39 | for line in fileinput.input(): | |
40 | # line number and debug string to output in case of errors | |
41 | lineno = lineno + 1 | |
42 | debug = "input line %d: %s" % (lineno, line.rstrip()) | |
43 | ||
44 | s = psplit.split(line); | |
45 | # The way split works, each odd item is the matching ACPI_EXTRACT directive. | |
46 | # Put each in a comment, and on a line by itself. | |
47 | for i in range(len(s)): | |
48 | if (i % 2): | |
49 | sys.stdout.write("\n/* %s */\n" % s[i]) | |
50 | else: | |
51 | sys.stdout.write(s[i]) |