Skip to content

Commit b28b686

Browse files
committed
added fix/hack for curses.h fails
1 parent 09bf9b2 commit b28b686

File tree

2 files changed

+10
-32
lines changed

2 files changed

+10
-32
lines changed

Tools/c-analyzer/c_parser/preprocessor/clang.py

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -47,42 +47,10 @@ def preprocess(filename,
4747
return _iter_lines(text, filename, samefiles, cwd)
4848

4949

50-
# Reasons:
51-
# py_curses related have a stack return in unusual order for /include/curses.h
52-
CLANG_IGNORES = (
53-
'/Include/py_curses.h',
54-
'/Modules/_cursesmodule.c',
55-
'/Modules/_curses_panel.c'
56-
)
57-
58-
EXPERIMENTAL_PRINTED = False
59-
60-
CLANG_EXPERIMENTAL = """
61-
62-
WARNING
63-
=======
64-
clang preprocessor is in experimental state.
65-
a) There might be false positives
66-
b) Following files are skipped
67-
{}
68-
69-
""".format('\n'.join([' ' + fn for fn in CLANG_IGNORES]))
70-
71-
7250
EXIT_MARKERS = {'# 2 "<built-in>" 2', '# 3 "<built-in>" 2', '# 4 "<built-in>" 2'}
7351

7452

7553
def _iter_lines(text, reqfile, samefiles, cwd, raw=False):
76-
global EXPERIMENTAL_PRINTED
77-
if not EXPERIMENTAL_PRINTED:
78-
print(CLANG_EXPERIMENTAL, flush=True)
79-
EXPERIMENTAL_PRINTED = True
80-
81-
# NOTE:clang specific
82-
if reqfile.endswith(CLANG_IGNORES):
83-
print(f'\nSkipping: {reqfile}', flush=True)
84-
return
85-
8654
lines = iter(text.splitlines())
8755

8856
# The first line is special.

Tools/c-analyzer/c_parser/preprocessor/gcc.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ def preprocess(filename,
102102

103103

104104
def _iter_lines(text, reqfile, samefiles, cwd, raw=False):
105+
with open('/Users/Edu/Downloads/test.c', 'r') as f:
106+
text = f.read()
105107
lines = iter(text.splitlines())
106108

107109
# The first line is special.
@@ -163,6 +165,14 @@ def _iter_top_include_lines(lines, topfile, cwd,
163165

164166
_lno, included, flags = _parse_marker_line(line)
165167
if included:
168+
# HACK:
169+
# Mixes curses.h and ncurses.h marker lines
170+
# gcc silently passes this, while clang fails
171+
# See: /Include/py_curses.h #if-elif directives
172+
# And compare with preprocessor output
173+
if os.path.basename(included) == 'curses.h':
174+
included = os.path.join(os.path.dirname(included), 'ncurses.h')
175+
166176
lno = _lno
167177
included = _normpath(included, cwd)
168178
# We hit a marker line.

0 commit comments

Comments
 (0)