| 100 | |
| 101 | |
| 102 | def get_header_c(fp): |
| 103 | with open(fp, "r") as f: |
| 104 | lines = iter(l for l in f.readlines()) |
| 105 | |
| 106 | header = [] |
| 107 | rest = [] |
| 108 | in_multiline = False |
| 109 | |
| 110 | while (l := next(lines, None)) is not None: |
| 111 | l = l.strip() |
| 112 | if l.startswith(C_ML_OPEN): |
| 113 | # Detected multiline comment |
| 114 | if not l.endswith(C_ML_CLOSE): |
| 115 | # multiline comment not closed on same line |
| 116 | in_multiline = True |
| 117 | elif l.endswith(C_ML_CLOSE): |
| 118 | # Ended a multiline comment |
| 119 | in_multiline = False |
| 120 | elif not in_multiline or l.startswith(C_SL_COMMENT) or l.isspace(): |
| 121 | # Not in a comment |
| 122 | rest += [l + "\n"] |
| 123 | break |
| 124 | header.append(l) |
| 125 | |
| 126 | rest += list(lines) |
| 127 | |
| 128 | return header, rest |
| 129 | |
| 130 | |
| 131 | def get_header_bash(fp): |