(data)
| 46 | |
| 47 | # check data |
| 48 | def stringConcatInArrayInit(data): |
| 49 | # Get all string macros |
| 50 | stringMacros = [] |
| 51 | for cfg in data.iterconfigurations(): |
| 52 | for directive in cfg.directives: |
| 53 | res = re.match(r'#define[ ]+([A-Za-z0-9_]+)[ ]+".*', directive.str) |
| 54 | if res: |
| 55 | macroName = res.group(1) |
| 56 | if macroName not in stringMacros: |
| 57 | stringMacros.append(macroName) |
| 58 | |
| 59 | # Check code |
| 60 | arrayInit = False |
| 61 | for i in range(len(data.rawTokens)): |
| 62 | if i < 2: |
| 63 | continue |
| 64 | tok1 = data.rawTokens[i-2].str |
| 65 | tok2 = data.rawTokens[i-1].str |
| 66 | tok3 = data.rawTokens[i-0].str |
| 67 | if tok3 == '}': |
| 68 | arrayInit = False |
| 69 | elif tok1 == ']' and tok2 == '=' and tok3 == '{': |
| 70 | arrayInit = True |
| 71 | elif arrayInit and (tok1 in [',', '{']): |
| 72 | isString2 = (isStringLiteral(tok2) or (tok2 in stringMacros)) |
| 73 | isString3 = (isStringLiteral(tok3) or (tok3 in stringMacros)) |
| 74 | if isString2 and isString3: |
| 75 | reportError(data.rawTokens[i], 'style', 'String concatenation in array initialization, missing comma?', 'stringConcatInArrayInit') |
| 76 | |
| 77 | |
| 78 | def implicitlyVirtual(data): |
no test coverage detected