Skip to content

Commit a22136a

Browse files
ar-cetitecdpgeorge
authored andcommitted
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>
1 parent cfd3b70 commit a22136a

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

py/makeqstrdefs.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ def write_out(fname, output):
8686

8787

8888
def process_file(f):
89-
re_line = re.compile(r"#[line]*\s\d+\s\"([^\"]+)\"")
89+
# match gcc-like output (# n "file") and msvc-like output (#line n "file")
90+
re_line = re.compile(r"^#(?:line)?\s+\d+\s\"([^\"]+)\"")
9091
if args.mode == _MODE_QSTR:
9192
re_match = re.compile(r"MP_QSTR_[_a-zA-Z0-9]+")
9293
elif args.mode == _MODE_COMPRESS:
@@ -100,10 +101,8 @@ def process_file(f):
100101
for line in f:
101102
if line.isspace():
102103
continue
103-
# match gcc-like output (# n "file") and msvc-like output (#line n "file")
104-
if line.startswith(("# ", "#line")):
105-
m = re_line.match(line)
106-
assert m is not None
104+
m = re_line.match(line)
105+
if m:
107106
fname = m.group(1)
108107
if not is_c_source(fname) and not is_cxx_source(fname):
109108
continue

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy