MCPcopy Index your code
hub / github.com/python/cpython / _strip_directives

Function _strip_directives

Tools/c-analyzer/c_parser/preprocessor/gcc.py:247–269  ·  view source on GitHub ↗
(line, partial=0)

Source from the content-addressed store, hash-verified

245
246
247def _strip_directives(line, partial=0):
248 # We assume there are no string literals with parens in directive bodies.
249 while partial > 0:
250 if not (m := re.match(r'[^{}]*([()])', line)):
251 return None, partial
252 delim, = m.groups()
253 partial += 1 if delim == '(' else -1 # opened/closed
254 line = line[m.end():]
255
256 line = re.sub(r'__extension__', '', line)
257 line = re.sub(r'__thread\b', '_Thread_local', line)
258
259 while (m := COMPILER_DIRECTIVE_RE.match(line)):
260 before, _, _, closed = m.groups()
261 if closed:
262 line = f'{before} {line[m.end():]}'
263 else:
264 after, partial = _strip_directives(line[m.end():], 2)
265 line = f'{before} {after or ""}'
266 if partial:
267 break
268
269 return line, partial
270
271
272def _filter_reqfile(current, reqfile, samefiles):

Callers 1

_iter_top_include_linesFunction · 0.85

Calls 4

matchMethod · 0.45
groupsMethod · 0.45
endMethod · 0.45
subMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…