lint/format-strings: Correctly exclude escaped percent symbols
This commit is contained in:
parent
7a30e0f6c5
commit
57281199b8
1 changed files with 2 additions and 3 deletions
|
@ -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":
|
||||||
|
|
Loading…
Reference in a new issue