Parse the contents of a config.c file. The file defines external symbols for module init functions and the mapping of module name to module initializer function.
(s: str)
| 711 | |
| 712 | |
| 713 | def parse_config_c(s: str): |
| 714 | """Parse the contents of a config.c file. |
| 715 | |
| 716 | The file defines external symbols for module init functions and the |
| 717 | mapping of module name to module initializer function. |
| 718 | """ |
| 719 | |
| 720 | # Some config.c files have #ifdef. We don't care about those because |
| 721 | # in all cases the condition is true. |
| 722 | |
| 723 | extensions = {} |
| 724 | |
| 725 | seen_inittab = False |
| 726 | |
| 727 | for line in s.splitlines(): |
| 728 | if line.startswith("struct _inittab"): |
| 729 | seen_inittab = True |
| 730 | |
| 731 | if not seen_inittab: |
| 732 | continue |
| 733 | |
| 734 | if "/* Sentinel */" in line: |
| 735 | break |
| 736 | |
| 737 | m = RE_INITTAB_ENTRY.search(line) |
| 738 | |
| 739 | if m: |
| 740 | extensions[m.group(1)] = m.group(2) |
| 741 | |
| 742 | return extensions |
| 743 | |
| 744 | |
| 745 | def extension_modules_config(yaml_path: pathlib.Path): |
no outgoing calls
no test coverage detected