MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / parse_config_h

Function parse_config_h

tools/python-3.11.9-amd64/Lib/sysconfig.py:553–584  ·  view source on GitHub ↗

Parse a config.h-style file. A dictionary containing name/value pairs is returned. If an optional dictionary is passed in as the second argument, it is used instead of a new dictionary.

(fp, vars=None)

Source from the content-addressed store, hash-verified

551
552
553def parse_config_h(fp, vars=None):
554 """Parse a config.h-style file.
555
556 A dictionary containing name/value pairs is returned. If an
557 optional dictionary is passed in as the second argument, it is
558 used instead of a new dictionary.
559 """
560 if vars is None:
561 vars = {}
562 import re
563 define_rx = re.compile("#define ([A-Z][A-Za-z0-9_]+) (.*)\n")
564 undef_rx = re.compile("/[*] #undef ([A-Z][A-Za-z0-9_]+) [*]/\n")
565
566 while True:
567 line = fp.readline()
568 if not line:
569 break
570 m = define_rx.match(line)
571 if m:
572 n, v = m.group(1, 2)
573 try:
574 if n in _ALWAYS_STR:
575 raise ValueError
576 v = int(v)
577 except ValueError:
578 pass
579 vars[n] = v
580 else:
581 m = undef_rx.match(line)
582 if m:
583 vars[m.group(1)] = 0
584 return vars
585
586
587def get_config_h_filename():

Callers 1

_generate_posix_varsFunction · 0.70

Calls 4

compileMethod · 0.45
readlineMethod · 0.45
matchMethod · 0.45
groupMethod · 0.45

Tested by

no test coverage detected