File tree Expand file tree Collapse file tree 4 files changed +26
-0
lines changed
Expand file tree Collapse file tree 4 files changed +26
-0
lines changed Original file line number Diff line number Diff line change 33import re , sys
44
55PAT_TAB = re .compile ("#?\t *[^\t ]*$" )
6+ PAT_BAD_COMMENT = re .compile (r"\s*//" )
67
78def checkascii (l ):
89 return any ((ord (c ) < 32 or ord (c ) > 127 ) and c != '\t ' for c in l )
@@ -45,6 +46,9 @@ def checkascii(l):
4546 if is_source and l .startswith (" " ):
4647 sys .stderr .write ("*** {}:{}: Use tabs for indentation: '{}'\n " .format (filename , line , l ))
4748 status = 1
49+ if is_source and PAT_BAD_COMMENT .match (l ):
50+ sys .stderr .write ("*** {}:{}: Use /* */ for free standing comments: '{}'\n " .format (filename , line , l ))
51+ status = 1
4852 line += 1
4953 elif l .startswith (" " ):
5054 line += 1
Original file line number Diff line number Diff line change 1+ // Foo
2+ // bar
3+
4+ int foo ()
5+ {
6+ return bar;
7+ }
Original file line number Diff line number Diff line change 1+ // Foo
2+ // bar
3+
4+ int foo ()
5+ {
6+ return bar;
7+ }
Original file line number Diff line number Diff line change @@ -163,6 +163,14 @@ git_good add case7.cpp
163163test_commit_bad " Add: Preprocessor hash indented"
164164git_good reset case7.cpp
165165
166+ git_good add case8.cpp
167+ test_commit_bad " Add: Wrong comment style"
168+ git_good reset case8.cpp
169+
170+ git_good add case9.cpp
171+ test_commit_bad " Add: Wrong comment style"
172+ git_good reset case9.cpp
173+
166174git_good push
167175
168176# setup badguy
You can’t perform that action at this time.
0 commit comments