diff options
Diffstat (limited to 'src/etc/tidy.py')
| -rw-r--r-- | src/etc/tidy.py | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/etc/tidy.py b/src/etc/tidy.py index b342b9602ae..9bab9a3d998 100644 --- a/src/etc/tidy.py +++ b/src/etc/tidy.py @@ -14,6 +14,9 @@ import snapshot err=0 cols=100 +cr_flag="xfail-tidy-cr" +tab_flag="xfail-tidy-tab" +linelength_flag="xfail-tidy-linelength" # Be careful to support Python 2.4, 2.6, and 3.x here! config_proc=subprocess.Popen([ "git", "config", "core.autocrlf" ], @@ -46,12 +49,22 @@ file_names = [s for s in sys.argv[1:] if (not s.endswith("_gen.rs")) current_name = "" current_contents = "" +check_tab = True +check_cr = True +check_linelength = True + try: for line in fileinput.input(file_names, openhook=fileinput.hook_encoded("utf-8")): if fileinput.filename().find("tidy.py") == -1: + if line.find(cr_flag) != -1: + check_cr = False + if line.find(tab_flag) != -1: + check_tab = False + if line.find(linelength_flag) != -1: + check_linelength = False if line.find("// XXX") != -1: report_err("XXX is no longer necessary, use FIXME") if line.find("TODO") != -1: @@ -72,16 +85,16 @@ try: if "SNAP" in line: report_warn("unmatched SNAP line: " + line) - if (line.find('\t') != -1 and + if check_tab and (line.find('\t') != -1 and fileinput.filename().find("Makefile") == -1): report_err("tab character") - if not autocrlf and line.find('\r') != -1: + if check_cr and not autocrlf and line.find('\r') != -1: report_err("CR character") if line.endswith(" \n") or line.endswith("\t\n"): report_err("trailing whitespace") line_len = len(line)-2 if autocrlf else len(line)-1 - if line_len > cols: + if check_linelength and line_len > cols: report_err("line longer than %d chars" % cols) if fileinput.isfirstline() and current_name != "": @@ -90,6 +103,9 @@ try: if fileinput.isfirstline(): current_name = fileinput.filename() current_contents = "" + check_cr = True + check_tab = True + check_linelength = True current_contents += line |
