diff --git a/contrib/check-code.py b/contrib/check-code.py --- a/contrib/check-code.py +++ b/contrib/check-code.py @@ -317,6 +317,22 @@ checks = [ ('txt', r'.*\.txt$', txtfilters, txtpats), ] +def _preparepats(): + for c in checks: + failandwarn = c[-1] + for pats in failandwarn: + for i, pseq in enumerate(pats): + # fix-up regexes for multi-line searches + po = p = pseq[0] + # \s doesn't match \n + p = re.sub(r'(?', p + pats[i] = (p,) + pseq[1:] +_preparepats() + class norepeatlogger(object): def __init__(self): self._lastseen = None @@ -403,15 +419,6 @@ def checkfile(f, logfunc=_defaultlogger. p, msg = pat ignore = None - # fix-up regexes for multi-line searches - po = p - # \s doesn't match \n - p = re.sub(r'(?', p - pos = 0 n = 0 for m in re.finditer(p, post, re.MULTILINE):