]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
syntax-check: Add prohibit_space_in_label rule
authorAndrea Bolognani <abologna@redhat.com>
Mon, 2 Nov 2015 11:12:22 +0000 (12:12 +0100)
committerAndrea Bolognani <abologna@redhat.com>
Mon, 16 Nov 2015 16:49:36 +0000 (17:49 +0100)
This guards against code such as

 cleanup :

which is happily accepted by the compiler but does not conform
to our style guidelines.

cfg.mk

diff --git a/cfg.mk b/cfg.mk
index db513be7301219d305129d34928218266c79152a..fd9fd75ae5ace3b3751f142f42f58024e036db16 100644 (file)
--- a/cfg.mk
+++ b/cfg.mk
@@ -919,6 +919,15 @@ sc_require_space_before_label:
        halt="Top-level labels should be indented by one space"        \
          $(_sc_search_regexp)
 
+# Allow for up to three spaces before the label: this is to avoid running
+# into situations where neither this rule nor require_space_before_label
+# would apply, eg. a line matching ^[a-zA-Z0-9]+ :$
+sc_prohibit_space_in_label:
+       @prohibit='^ {0,3}[_a-zA-Z0-9]+ +:$$'                          \
+       in_vc_files='\.[ch]$$'                                         \
+       halt="There should be no space between label name and colon"   \
+         $(_sc_search_regexp)
+
 # Doesn't catch all cases of mismatched braces across if-else, but it helps
 sc_require_if_else_matching_braces:
        @prohibit='(  else( if .*\))? {|} else( if .*\))?$$)'           \