mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
bracket-spacing-check: Print out more specific error message
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
parent
5e1af759cf
commit
343e53abdc
@ -89,6 +89,7 @@ foreach my $file (@ARGV) {
|
||||
if ($kw =~ /^(if|for|while|switch|return)$/) {
|
||||
$tmpdata =~ s/($kw\s\()/XXX(/;
|
||||
} else {
|
||||
print "Whitespace after non-keyword:\n";
|
||||
print "$file:$.: $line";
|
||||
$ret = 1;
|
||||
last;
|
||||
@ -99,12 +100,14 @@ foreach my $file (@ARGV) {
|
||||
# but none after the opening bracket
|
||||
if ($data =~ /\b(if|for|while|switch|return)\(/ ||
|
||||
$data =~ /\b(if|for|while|switch|return)\s+\(\s/) {
|
||||
print "No whitespace after keyword:\n";
|
||||
print "$file:$.: $line";
|
||||
$ret = 1;
|
||||
}
|
||||
|
||||
# Forbid whitespace between )( of a function typedef
|
||||
if ($data =~ /\(\*\w+\)\s+\(/) {
|
||||
print "Whitespace between ')' and '(':\n";
|
||||
print "$file:$.: $line";
|
||||
$ret = 1;
|
||||
}
|
||||
@ -112,6 +115,7 @@ foreach my $file (@ARGV) {
|
||||
# Forbid whitespace following ( or prior to )
|
||||
if ($data =~ /\S\s+\)/ ||
|
||||
$data =~ /\(\s+\S/) {
|
||||
print "Whitespace after '(' or before ')':\n";
|
||||
print "$file:$.: $line";
|
||||
$ret = 1;
|
||||
}
|
||||
@ -127,6 +131,7 @@ foreach my $file (@ARGV) {
|
||||
# ;
|
||||
#
|
||||
if ($data =~ /[^;\s]\s+[;,]/) {
|
||||
print "Whitespace before (semi)colon:\n";
|
||||
print "$file:$.: $line";
|
||||
$ret = 1;
|
||||
}
|
||||
@ -134,12 +139,14 @@ foreach my $file (@ARGV) {
|
||||
# Require EOL, macro line continuation, or whitespace after ";".
|
||||
# Allow "for (;;)" as an exception.
|
||||
if ($data =~ /;[^ \\\n;)]/) {
|
||||
print "Invalid character after semicolon:\n";
|
||||
print "$file:$.: $line";
|
||||
$ret = 1;
|
||||
}
|
||||
|
||||
# Require EOL, space, or enum/struct end after comma.
|
||||
if ($data =~ /,[^ \\\n)}]/) {
|
||||
print "Invalid character after comma:\n";
|
||||
print "$file:$.: $line";
|
||||
$ret = 1;
|
||||
}
|
||||
@ -150,6 +157,7 @@ foreach my $file (@ARGV) {
|
||||
$tmpdata =~ s/(virAssertCmpInt\(.* ).?=,/$1op,/;
|
||||
if ($tmpdata =~ /[^ ]\b[!<>&|\-+*\/%\^=]?=[^=]/ ||
|
||||
$tmpdata =~ /=[^= \\\n]/) {
|
||||
print "Spacing around '=' or '==':\n";
|
||||
print "$file:$.: $line";
|
||||
$ret = 1;
|
||||
}
|
||||
|
2
cfg.mk
2
cfg.mk
@ -1030,7 +1030,7 @@ endif
|
||||
bracket-spacing-check:
|
||||
$(AM_V_GEN)files=`$(VC_LIST) | grep '\.c$$'`; \
|
||||
$(PERL) $(top_srcdir)/build-aux/bracket-spacing.pl $$files || \
|
||||
{ echo '$(ME): incorrect whitespace, see HACKING for rules' 1>&2; \
|
||||
{ echo '$(ME): incorrect formatting, see HACKING for rules' 1>&2; \
|
||||
exit 1; }
|
||||
|
||||
# sc_po_check can fail if generated files are not built first
|
||||
|
Loading…
Reference in New Issue
Block a user