From dd69251f09566ef67e349cc217744efee5ebf526 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 10 Sep 2003 19:40:02 +0000 Subject: [PATCH] We reduce shell scripts effectively. --- filterator | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/filterator b/filterator index 994520d..d7dff5b 100755 --- a/filterator +++ b/filterator @@ -31,19 +31,21 @@ junk = { r'\s*#include.*',r'#\s*line.*', # Common error macros. r'\bEFAULT\b', r'\bEINVAL\b', r'\bENOSYS\b', - # Punctuation + # Punctuation and whitespace r'\{', r'\}', r'\(', r'\)', r'\<', r'\>', r'\[', r'\]', r'\^', '&', r'\|', r'\*', r'\?', r'\.', r'\+', '\\\n', ';', ':', '%', ',', '-', '/', '=', '!', '\n','\t', '\v' )), "shell": map(re.compile, ( # Idioms that don't convey any meaning in isolation - r"exit *\([01]\);", + r"exit *[01];?", # Bare shell keywords - "\bcase\b", "\bdone\b", "\bdo\b", "\belse\b", "\besac\b", - "\bfi\b", "\bif\b", "\bwhile\b", + r"\bcase\b", r"\bdone\b", r"\bdo\b", r"\belse\b", r"\besac\b", + r"\bfi\b", r"\bif\b", r"\bwhile\b", # Blank comment "^#\n", + # Ounctuation and whitespace + ':', '\n','\t', '\v' )), } @@ -65,7 +67,6 @@ def nontrivial(text, filetype): if savecopy == text: break else: - text = text.strip() if debug: print "Reduced:", `text` continue -- 2.43.0