diff options
author | Alex Riesen <alexander.riesen@cetitec.com> | 2023-02-21 16:44:08 +0100 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2023-04-11 16:41:10 +1000 |
commit | a22136a7322616e768962804075380103d34a09b (patch) | |
tree | adbe68fe2866928f25608c6fcaa5781c7c72fc69 /py/makeqstrdefs.py | |
parent | cfd3b70934791abc07f9476a956781de92ddf715 (diff) | |
download | micropython-a22136a7322616e768962804075380103d34a09b.tar.gz micropython-a22136a7322616e768962804075380103d34a09b.zip |
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>
Diffstat (limited to 'py/makeqstrdefs.py')
-rw-r--r-- | py/makeqstrdefs.py | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/py/makeqstrdefs.py b/py/makeqstrdefs.py index c445d6d1fe..13a8b54d67 100644 --- a/py/makeqstrdefs.py +++ b/py/makeqstrdefs.py @@ -86,7 +86,8 @@ def write_out(fname, output): 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: re_match = re.compile(r"MP_QSTR_[_a-zA-Z0-9]+") elif args.mode == _MODE_COMPRESS: @@ -100,10 +101,8 @@ def process_file(f): for line in f: if line.isspace(): continue - # match gcc-like output (# n "file") and msvc-like output (#line n "file") - if line.startswith(("# ", "#line")): - m = re_line.match(line) - assert m is not None + m = re_line.match(line) + if m: fname = m.group(1) if not is_c_source(fname) and not is_cxx_source(fname): continue |