[libvirt] [PATCH 2/2] maint: tighten curly brace syntax checking
Peter Krempa
pkrempa at redhat.com
Thu Sep 4 09:39:42 UTC 2014
On 09/04/14 01:17, Eric Blake wrote:
> Now that hanging brace offenders have been fixed, we can automate
> the check, and document our style. Done as a separate commit from
> code changes, to make it easier to just backport code changes, if
> that is ever needed.
>
> * cfg.mk (sc_curly_braces_style): Catch hanging braces.
> * docs/hacking.html.in: Document it.
> * HACKING: Regenerate.
>
> Signed-off-by: Eric Blake <eblake at redhat.com>
> ---
> HACKING | 27 +++++++++++++++++++++++++++
> cfg.mk | 18 ++++++++++++------
> docs/hacking.html.in | 31 +++++++++++++++++++++++++++++++
> 3 files changed, 70 insertions(+), 6 deletions(-)
>
> diff --git a/HACKING b/HACKING
> index 88a4286..add0841 100644
> --- a/HACKING
> +++ b/HACKING
>
> sc_curly_braces_style:
> - @files=$$($(VC_LIST_EXCEPT) | grep '\.[ch]$$'); \
> - $(GREP) -nHP \
> -'^\s*(?!([a-zA-Z_]*for_?each[a-zA-Z_]*) ?\()([_a-zA-Z0-9]+( [_a-zA-Z0-9]+)* ?\()?(\*?[_a-zA-Z0-9]+(,? \*?[_a-zA-Z0-9\[\]]+)+|void)\) ?\{' \
> - $$files && { echo '$(ME): Non-K&R style used for curly' \
> - 'braces around function body, see' \
> - 'HACKING' 1>&2; exit 1; } || :
> + @files=$$($(VC_LIST_EXCEPT) | grep '\.[ch]$$'); \
> + if $(GREP) -nHP \
> +'^\s*(?!([a-zA-Z_]*for_?each[a-zA-Z_]*) ?\()([_a-zA-Z0-9]+( [_a-zA-Z0-9]+)* ?\()?(\*?[_a-zA-Z0-9]+(,? \*?[_a-zA-Z0-9\[\]]+)+|void)\) ?\{' \
> + $$files; then \
> + echo '$(ME): Non-K&R style used for curly braces around' \
> + 'function body, see HACKING' 1>&2; exit 1; \
> + fi; \
> + if $(GREP) -A1 -En ' ((if|for|while|switch) \(|(else|do)\b)[^{]*$$'\
> + $$files | grep '^[^ ]*- *{'; then \
> + echo '$(ME): Use hanging braces for compound statements,' \
> + 'see HACKING' 1>&2; exit 1; \
> + fi
>
> sc_prohibit_windows_special_chars_in_filename:
> @files=$$($(VC_LIST_EXCEPT) | grep '[:*?"<>|]'); \
My brain isn't that good in parsing regexes, but they look good to me
and the test passed.
ACK.
Peter
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140904/92c13ec2/attachment-0001.sig>
More information about the libvir-list
mailing list