# 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',
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