On 03/21/2014 07:11 AM, Ján Tomko wrote:
Indent labels by one space.
Add the rule to HACKING and enforce it by syntax-check.
---
Adding a space helps git's function context detection, but the fallout
patch is over 800K.
My reasoning for also indenting labels in nested code is that
vim's cinoptions don't have a separate option for these labels
(or I haven't searched hard enough?).
Alas, I don't know enough on vim to help there.
Inspired by this thread:
https://www.redhat.com/archives/libvir-list/2014-March/msg01310.html
cfg.mk | 7 +++++++
docs/hacking.html.in | 18 +++++++++++++++++-
2 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/cfg.mk b/cfg.mk
index 559f719..1512fb2 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -898,6 +898,13 @@ sc_prohibit_virConnectOpen_in_virsh:
halt='Use vshConnect() in virsh instead of virConnectOpen*' \
$(_sc_search_regexp)
+sc_require_space_before_label:
+ @prohibit='^(( {2})*|( {3})*)([_a-zA-Z0-9]+):$$' \
This doesn't do what you want; it sounds like you want to require all
labels to have (4n+1) spaces, so you want 4n+{0,2,3} to be forbidden.
Something like:
@prohibit='^( {4})*(| | )([_a-zA-Z0-9]+):$$'
+ exclude='( {4})*default:$$'
\
+ in_vc_files='\.[ch]$$' \
+ halt="Labels should be indented by 4*n + 1 spaces" \
+ $(_sc_search_regexp)
The rest of this makes sense, if I can figure out why my emacs settings
aren't doing this already, and if we update .dir-locals.el in the same
patch.
+<pre>
+int foo()
+{
+ if (wizz) {
+ retry:
+ goto retry;
+ }
+ cleanup:
+}
Wouldn't actually compile (a label needs to be attached to a statement,
and our warnings coupled with -Werror would call out the fact that
cleanup: is unused), but gets the point across.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library
http://libvirt.org