misc.py: Fixed FP for string concatenation
This commit is contained in:
parent
a8cd2ac0ea
commit
19591298f1
|
@ -42,6 +42,12 @@ def check(data):
|
|||
elif tok1 == ']' and tok2 == '=' and tok3 == '{':
|
||||
arrayInit = True
|
||||
elif arrayInit and (tok1 in [',', '{']) and tok2.startswith('"') and tok3.startswith('"'):
|
||||
if tok1 == '{':
|
||||
i2 = i + 1
|
||||
while i2 < len(data.rawTokens) and data.rawTokens[i2].str not in [',', '}']:
|
||||
i2 = i2 + 1
|
||||
if i2 >= len(data.rawTokens) or data.rawTokens[i2].str != ',':
|
||||
continue
|
||||
reportError(data.rawTokens[i], 'style', 'string concatenation', 'stringConcatInArrayInit')
|
||||
|
||||
for arg in sys.argv[1:]:
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// To test:
|
||||
// ~/cppcheck/cppcheck --dump cert-test.c && python ../cert.py -verify cert-test.c.dump
|
||||
// ~/cppcheck/cppcheck --dump misc-test.c && python ../misc.py -verify misc-test.c.dump
|
||||
|
||||
const char *a[] = {"a" "b"}; // stringConcatInArrayInit
|
||||
const char *a[] = {"a" "b"};
|
||||
const char *b[] = {"a","b" "c"}; // stringConcatInArrayInit
|
||||
|
|
Loading…
Reference in New Issue