diff options
author | MarcoFalke <falke.marco@gmail.com> | 2018-12-22 17:13:27 +0100 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2018-12-22 17:13:34 +0100 |
commit | 18857b4c4034af54e7ad3cbd78ff6f87f4f22567 (patch) | |
tree | c7c7ca4c2a4cd7ef34865deb718f6f74ab934973 | |
parent | 1ac7d599f9223afa677f4c034e773713cc7be9be (diff) | |
parent | 57281199b857afad232d52423e35c9d501e44b5f (diff) |
Merge #14960: lint/format-strings: Correctly exclude escaped percent symbols
57281199b8 lint/format-strings: Correctly exclude escaped percent symbols (Luke Dashjr)
Pull request description:
The current code fails to exclude correctly for patterns like `"%%%X"`
Tree-SHA512: cac6f6fb3f06a9190310cd9764ec31cd7d636f9c831057622f418ae5fd2e1d80927a88f585d18f57b279ac21e81518f714dc1a25155377b9297741a73600461e
-rwxr-xr-x | test/lint/lint-format-strings.py | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/test/lint/lint-format-strings.py b/test/lint/lint-format-strings.py index 5caebf3739..f5d4780b6d 100755 --- a/test/lint/lint-format-strings.py +++ b/test/lint/lint-format-strings.py @@ -241,12 +241,11 @@ def count_format_specifiers(format_string): 4 """ assert(type(format_string) is str) + format_string = format_string.replace('%%', 'X') n = 0 in_specifier = False for i, char in enumerate(format_string): - if format_string[i - 1:i + 1] == "%%" or format_string[i:i + 2] == "%%": - pass - elif char == "%": + if char == "%": in_specifier = True n += 1 elif char in "aAcdeEfFgGinopsuxX": |