mirror of
https://github.com/micropython/micropython.git
synced 2025-08-26 04:20:37 +02:00
py/makeqstrdefs.py: Fix handling GreenHills C/C++ preprocessor output.
The GreenHills preprocessor produces #line directives without a file name, which the regular expression used to distiguish between "# <number> file..." (GCC and similar) and "#line <number> file..." (Microsoft C and similar) does not match, aborting processing. Besides, the regular expression was unnecessarily wide, matching lines containing a "#", followed by any number of 'l','i','n', and 'e' characters. Signed-off-by: Alex Riesen <alexander.riesen@cetitec.com>
This commit is contained in:
committed by
Damien George
parent
cfd3b70934
commit
a22136a732
@@ -86,7 +86,8 @@ def write_out(fname, output):
|
|||||||
|
|
||||||
|
|
||||||
def process_file(f):
|
def process_file(f):
|
||||||
re_line = re.compile(r"#[line]*\s\d+\s\"([^\"]+)\"")
|
# match gcc-like output (# n "file") and msvc-like output (#line n "file")
|
||||||
|
re_line = re.compile(r"^#(?:line)?\s+\d+\s\"([^\"]+)\"")
|
||||||
if args.mode == _MODE_QSTR:
|
if args.mode == _MODE_QSTR:
|
||||||
re_match = re.compile(r"MP_QSTR_[_a-zA-Z0-9]+")
|
re_match = re.compile(r"MP_QSTR_[_a-zA-Z0-9]+")
|
||||||
elif args.mode == _MODE_COMPRESS:
|
elif args.mode == _MODE_COMPRESS:
|
||||||
@@ -100,10 +101,8 @@ def process_file(f):
|
|||||||
for line in f:
|
for line in f:
|
||||||
if line.isspace():
|
if line.isspace():
|
||||||
continue
|
continue
|
||||||
# match gcc-like output (# n "file") and msvc-like output (#line n "file")
|
m = re_line.match(line)
|
||||||
if line.startswith(("# ", "#line")):
|
if m:
|
||||||
m = re_line.match(line)
|
|
||||||
assert m is not None
|
|
||||||
fname = m.group(1)
|
fname = m.group(1)
|
||||||
if not is_c_source(fname) and not is_cxx_source(fname):
|
if not is_c_source(fname) and not is_cxx_source(fname):
|
||||||
continue
|
continue
|
||||||
|
Reference in New Issue
Block a user