History

docs: kdoc_parser: fix variable regexes to work with size_t

The regular expressions meant to pick variable types are too naive: they forgot that the type word may contain underlines. It also means that we need to change the regex which detects var attributes to handle "const".

Mauro Carvalho Chehab committed 8 months ago

Commit 4fd349f1 parent cca1bbd1 file · +4 −3Browse files

Unified · Split

tools/lib/python/kdoc/kdoc_parser.py+4−3
@@ -981,8 +981,9 @@ class KernelDoc: · 980 unmodified lines
981981 """
982982 VAR_ATTRIBS = [
983983 "extern",
984+ "const",
984985 ]
985− OPTIONAL_VAR_ATTR = "^(?:" + "|".join(VAR_ATTRIBS) + ")?"
986+ OPTIONAL_VAR_ATTR = r"^(?:\b(?:" +"|".join(VAR_ATTRIBS) +r")\b\s*)*"
986987
987988 #
988989 # Store the full prototype before modifying it
@@ -1018,14 +1019,14 @@ class KernelDoc: · 29 unmodified lines
10181019
10191020 default_val = None
10201021
1021− r= KernRe(OPTIONAL_VAR_ATTR + r"\w.*\s+(?:\*+)?([\w_]+)\s*[\d\]\[]*\s*(=.*)?")
1022+ r= KernRe(OPTIONAL_VAR_ATTR + r"[\w_]*\s+(?:\*+)?([\w_]+)\s*[\d\]\[]*\s*(=.*)?")
10221023 if r.match(proto):
10231024 if not declaration_name:
10241025 declaration_name = r.group(1)
10251026
10261027 default_val = r.group(2)
10271028 else:
1028− r= KernRe(OPTIONAL_VAR_ATTR + r"(?:\w.*)?\s+(?:\*+)?(?:[\w_]+)\s*[\d\]\[]*\s*(=.*)?")
1029+ r= KernRe(OPTIONAL_VAR_ATTR + r"(?:[\w_]*)?\s+(?:\*+)?(?:[\w_]+)\s*[\d\]\[]*\s*(=.*)?")
10291030 if r.match(proto):
10301031 default_val = r.group(1)
10311032