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 <[email protected]>
> ---
>  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

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to