From d079d16fdcab9fd626ee40658b9ba28bb9801c38 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 25 Aug 2003 18:24:24 +0000 Subject: [PATCH] Better significance filtering. --- filterator | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/filterator b/filterator index 5284efd..81c4f6b 100755 --- a/filterator +++ b/filterator @@ -9,11 +9,21 @@ shredline = re.compile("-> ([^:]*):([0-9]+)-([0-9]+)") # Tokens to be removed when checking whether a shred is significant C_junk = [r'\bbreak\b', r'\bcontinue\b', r'\bdefault\b', - r'\belse\b', r'\breturn\b', + r'\belse\b', r'\bif\b', r'\bgoto\b', r'\breturn\b', r'\bint\b', r'\blong\b', r'\bshort\b', r'\bstatic\b', r'\bvoid\b', - '#endif', '#else', r'#if\b', r'\bNULL\b', + r'#define',r'#endif',r'#else',r'#if\b',r'#ifdef\b',r'#ifndef\b', r'/\*+', r'\*+/', r'\*+', - r'\b0\b', r'\b1\b',] + r'\b0\b', r'\b1\b', + # Common preprocessor macros, not significant by themselves. + r'\bASSERT\b', r'\bFALSE\b', r'\bNULL\b', r'\bSTATIC\b', r'\bTRUE\b', + # Common error macros. + r'\bEINVAL\b', r'\bENOSYS\b', + # Conventional variables frequently found in kernel code. + # But if they're surrounded by nothing but C syntax and no + # 'real' identifiers, we're looking at boilerplate + # function-return code. + r'\berr\b', r'\berror\b', r'\brc\b', r'\bretcode\b', r'\bretval\b', + ] # C junk to be removed from matches; inclues all single-lowercase-letter vars. junk = re.compile("|".join(C_junk + map(lambda x: r'\b' + chr(x) + r'\b', @@ -69,7 +79,7 @@ if __name__ == '__main__': rfp.close() if nofilter or nontrivial(text): count += 1 - print "%s:%s-%s:" % (file, start, end) - #sys.stdout.write(text) - print `nontrivial(text)` + print "%%%%#%%%% %s:%s-%s:" % (file, start, end) + sys.stdout.write(text) + #print `nontrivial(text)` print "%d overlaps." % count -- 2.43.0