0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-02 09:46:52 -05:00

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
This commit is contained in:
MarcoFalke 2018-12-22 17:13:27 +01:00
commit 18857b4c40
No known key found for this signature in database
GPG key ID: D2EA4850E7528B25

View file

@ -241,12 +241,11 @@ def count_format_specifiers(format_string):
4 4
""" """
assert(type(format_string) is str) assert(type(format_string) is str)
format_string = format_string.replace('%%', 'X')
n = 0 n = 0
in_specifier = False in_specifier = False
for i, char in enumerate(format_string): for i, char in enumerate(format_string):
if format_string[i - 1:i + 1] == "%%" or format_string[i:i + 2] == "%%": if char == "%":
pass
elif char == "%":
in_specifier = True in_specifier = True
n += 1 n += 1
elif char in "aAcdeEfFgGinopsuxX": elif char in "aAcdeEfFgGinopsuxX":