Tools: include STRNLEN macros in code_clean utility
This commit is contained in:
@@ -1154,6 +1154,29 @@ class edit_generators:
|
||||
content_fail='__ALWAYS_FAIL__',
|
||||
))
|
||||
|
||||
# `BLI_strnlen(a, sizeof(a))` -> `STRNLEN(a)`
|
||||
# `BLI_strnlen(a, SOME_ID)` -> `STRNLEN(a)`
|
||||
for src, dst in (
|
||||
("BLI_strnlen", "STRNLEN"),
|
||||
("BLI_strnlen_utf8", "STRNLEN_UTF8"),
|
||||
):
|
||||
for match in re.finditer(
|
||||
(r"\b" + src + (
|
||||
r"\(([^,]+),\s+" r"("
|
||||
r"sizeof\([^\(\)]+\)" # Trailing `sizeof(..)`.
|
||||
r"|"
|
||||
r"[a-zA-Z0-9_]+" # Trailing identifier (typically a define).
|
||||
r")" r"\)"
|
||||
)),
|
||||
data,
|
||||
flags=re.MULTILINE,
|
||||
):
|
||||
edits.append(Edit(
|
||||
span=match.span(),
|
||||
content='{:s}({:s})'.format(dst, match.group(1)),
|
||||
content_fail='__ALWAYS_FAIL__',
|
||||
))
|
||||
|
||||
# `BLI_snprintf(a, SOME_SIZE, ...` -> `SNPRINTF(a, ...`
|
||||
for src, dst in (
|
||||
("BLI_snprintf", "SNPRINTF"),
|
||||
|
||||
Reference in New Issue
Block a user