Using compiled regular expressions for DACA2 functions (#1209)

​The method “match” was used as a module-level function in ​for loops
of implementations for DACA2 functions so far.
Use ​compiled regular expression objects instead.

Delete a duplicate element from an alternation.

Link: https://trac.cppcheck.net/ticket/8553
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
This commit is contained in:
Markus Elfring 2018-05-07 22:18:05 +02:00 committed by Daniel Marjamäki
parent 78e1474f55
commit bd6173be6e
2 changed files with 4 additions and 3 deletions

View File

@ -94,6 +94,7 @@ for severity in ['error', 'warning', 'style', 'portability', 'performance']:
categories[severity] = []
daca2 = daca2folder
pattern = re.compile(r'.*: (error|warning|style|performance|portability):.* \[([a-zA-Z0-9_\\-]+)\]')
for lib in (False, True):
for a in "0123456789abcdefghijklmnopqrstuvwxyz":
if lib:
@ -120,7 +121,7 @@ for lib in (False, True):
datestr = ''
for line in data.split('\n'):
res = re.match(r'.*: (error|warning|style|performance|style|portability):.* \[([a-zA-Z0-9_\\-]+)\]', line)
res = pattern.match(line)
if res is None:
continue
severity = res.group(1)

View File

@ -53,10 +53,10 @@ def doSearch(path,arguments):
def summary(path, arguments):
count = {}
pattern = re.compile(r'.*: (error|warning|style|performance|portability):.*\[([a-zA-Z0-9]+)\]$')
for g in getfiles(path, arguments):
for line in readlines(g):
line = trimline(line)
res = re.match(r'.*: (error|warning|style|performance|portability):.*\[([a-zA-Z0-9]+)\]$', line)
res = pattern.match(trimline(line))
if res is None:
continue
id = res.group(2)