提交 cab2b44d 编写于 作者: J Ján Tomko

check-spacing: use non-capturing groups

上级 633daa4c
...@@ -43,7 +43,7 @@ foreach my $file (@ARGV) { ...@@ -43,7 +43,7 @@ foreach my $file (@ARGV) {
$data =~ s/'[";,=]'/'X'/g; $data =~ s/'[";,=]'/'X'/g;
# Kill any quoted strings # Kill any quoted strings
$data =~ s,"([^\\\"]|\\.)*","XXX",g; $data =~ s,"(?:[^\\\"]|\\.)*","XXX",g;
# Kill any C++ style comments # Kill any C++ style comments
$data =~ s,//.*$,//,; $data =~ s,//.*$,//,;
...@@ -91,8 +91,8 @@ foreach my $file (@ARGV) { ...@@ -91,8 +91,8 @@ foreach my $file (@ARGV) {
my $kw = $1; my $kw = $1;
# Allow space after keywords only # Allow space after keywords only
if ($kw =~ /^(if|for|while|switch|return)$/) { if ($kw =~ /^(?:if|for|while|switch|return)$/) {
$tmpdata =~ s/($kw\s\()/XXX(/; $tmpdata =~ s/(?:$kw\s\()/XXX(/;
} else { } else {
print "Whitespace after non-keyword:\n"; print "Whitespace after non-keyword:\n";
print "$file:$.: $line"; print "$file:$.: $line";
...@@ -102,7 +102,7 @@ foreach my $file (@ARGV) { ...@@ -102,7 +102,7 @@ foreach my $file (@ARGV) {
} }
# Require whitespace immediately after keywords # Require whitespace immediately after keywords
if ($data =~ /\b(if|for|while|switch|return)\(/) { if ($data =~ /\b(?:if|for|while|switch|return)\(/) {
print "No whitespace after keyword:\n"; print "No whitespace after keyword:\n";
print "$file:$.: $line"; print "$file:$.: $line";
$ret = 1; $ret = 1;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册