Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

docs: kdoc: Simplify the dump_function() prototype regexes

The regexes for the parsing of function prototypes were more complicated
than they needed to be and difficult to understand -- at least, I spent a
fair amount of time bashing my head against them. Simplify them, and add
some documentation comments as well.

Signed-off-by: Jonathan Corbet <corbet@lwn.net>

+10 -10
+10 -10
scripts/lib/kdoc/kdoc_parser.py
··· 959 959 # - pci_match_device, __copy_to_user (long return type) 960 960 961 961 name = r'\w+' 962 - prototype_end1 = r'[^\(]*' 963 - prototype_end2 = r'[^\{]*' 964 - prototype_end = fr'\(({prototype_end1}|{prototype_end2})\)' 965 - 966 - # Besides compiling, Perl qr{[\w\s]+} works as a non-capturing group. 967 - # So, this needs to be mapped in Python with (?:...)? or (?:...)+ 968 - 969 962 type1 = r'(?:[\w\s]+)?' 970 963 type2 = r'(?:[\w\s]+\*+)+' 964 + # 965 + # Attempt to match first on (args) with no internal parentheses; this 966 + # lets us easily filter out __acquires() and other post-args stuff. If 967 + # that fails, just grab the rest of the line to the last closing 968 + # parenthesis. 969 + # 970 + proto_args = r'\(([^\(]*|.*)\)' 971 971 972 972 found = False 973 973 ··· 983 983 984 984 if not found: 985 985 patterns = [ 986 - rf'^()({name})\s*{prototype_end}', 987 - rf'^({type1})\s+({name})\s*{prototype_end}', 988 - rf'^({type2})\s*({name})\s*{prototype_end}', 986 + rf'^()({name})\s*{proto_args}', 987 + rf'^({type1})\s+({name})\s*{proto_args}', 988 + rf'^({type2})\s*({name})\s*{proto_args}', 989 989 ] 990 990 991 991 for p in patterns: