2 # Copyright (C) 2011 Red Hat, Inc., Michael S. Tsirkin <mst@redhat.com>
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.
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.
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/>.
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.
27 sys
.stderr
.write("Error: %s\n" % (diag
))
30 # Note: () around pattern make split return matched string as part of list
31 psplit
= re
.compile(r
''' (
33 ACPI_EXTRACT_\w+ # directive
39 for line
in fileinput
.input():
40 # line number and debug string to output in case of errors
42 debug
= "input line %d: %s" % (lineno
, line
.rstrip())
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
)):
49 sys
.stdout
.write("\n/* %s */\n" % s
[i
])
51 sys
.stdout
.write(s
[i
])