changeset 72b399971cbc in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=72b399971cbc
description:
style: Add a control character checker
Add a style checker that verifies that source code doesn't contain
non-printable (control) characters. The only allowed control
characters are:
* 0x0a / \n: New line
* 0x09 / \t: Tab (the whitespace checker enforces no-tabs for C/C++
files)
Signed-off-by: Andreas Sandberg <[email protected]>
Reviewed-by: Brandon Potter <[email protected]>
diffstat:
util/style/verifiers.py | 14 ++++++++++++++
1 files changed, 14 insertions(+), 0 deletions(-)
diffs (24 lines):
diff -r e8949ea6961f -r 72b399971cbc util/style/verifiers.py
--- a/util/style/verifiers.py Wed Mar 30 15:30:32 2016 +0100
+++ b/util/style/verifiers.py Wed Mar 30 15:31:23 2016 +0100
@@ -348,6 +348,20 @@
def fix_line(self, line):
pass
+class ControlCharacters(LineVerifier):
+ languages = set(('C', 'C++', 'swig', 'python', 'asm', 'isa', 'scons'))
+ test_name = 'control character'
+ opt_name = 'ascii'
+
+ valid = ('\n', '\t')
+ invalid = "".join([chr(i) for i in range(0, 0x20) if chr(i) not in valid])
+
+ def check_line(self, line):
+ return self.fix_line(line) == line
+
+ def fix_line(self, line):
+ return line.translate(None, ControlCharacters.invalid)
+
class BoolCompare(LineVerifier):
languages = set(('C', 'C++', 'python'))
test_name = 'boolean comparison'
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev