Reorganize process_export() to eliminate duplicated code, don't look for exports in states where we don't expect them, and don't bother with normal state-machine processing if an export declaration has been found.
Unified · Split
| @@ -1211,16 +1211,17 @@ class KernelDoc: · 1210 unmodified lines | ||
| 1211 | 1211 | |
| 1212 | 1212 | if export_symbol.search(line): |
| 1213 | 1213 | symbol = export_symbol.group(2) |
| 1214 | − for suffix in suffixes: | |
| 1215 | − symbol = symbol.removesuffix(suffix) | |
| 1216 | − function_set.add(symbol) | |
| 1217 | − return | |
| 1218 | − | |
| 1219 | − if export_symbol_ns.search(line): | |
| 1214 | + elif export_symbol_ns.search(line): | |
| 1220 | 1215 | symbol = export_symbol_ns.group(2) |
| 1221 | − for suffix in suffixes: | |
| 1222 | − symbol = symbol.removesuffix(suffix) | |
| 1223 | − function_set.add(symbol) | |
| 1216 | + else: | |
| 1217 | + return False | |
| 1218 | + # | |
| 1219 | + # Found an export, trim out any special suffixes | |
| 1220 | + # | |
| 1221 | + for suffix in suffixes: | |
| 1222 | + symbol = symbol.removesuffix(suffix) | |
| 1223 | + function_set.add(symbol) | |
| 1224 | + return True | |
| 1224 | 1225 | |
| 1225 | 1226 | def process_normal(self, ln, line): |
| 1226 | 1227 | """ |
| @@ -1767,13 +1768,10 @@ class KernelDoc: · 540 unmodified lines | ||
| 1767 | 1768 | # it was read twice. Here, we use the already-existing |
| 1768 | 1769 | # loop to parse exported symbols as well. |
| 1769 | 1770 | # |
| 1770 | − # TODO: It should be noticed that not all states are | |
| 1771 | − # needed here. On a future cleanup, process export only | |
| 1772 | − # at the states that aren't handling comment markups. | |
| 1773 | − self.process_export(export_table, line) | |
| 1774 | − | |
| 1775 | − # Hand this line to the appropriate state handler | |
| 1776 | − self.state_actions[self.state](self, ln, line) | |
| 1771 | + if (self.state != state.NORMAL) or \ | |
| 1772 | + not self.process_export(export_table, line): | |
| 1773 | + # Hand this line to the appropriate state handler | |
| 1774 | + self.state_actions[self.state](self, ln, line) | |
| 1777 | 1775 | |
| 1778 | 1776 | except OSError: |
| 1779 | 1777 | self.config.log.error(f"Error: Cannot open file {self.fname}") |