diff options
author | Jim Meyering <meyering@redhat.com> | 2012-04-30 10:37:14 +0200 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2012-05-02 10:31:53 +0200 |
commit | e744f4b7b7de9b76fdd314aa406e9fb150b9168d (patch) | |
tree | 8656dd87e6c7ce4d1fd496ad70094a07f7346acc | |
parent | 57e0a882ef70712f79e7255aa5c1f8ba27b4c33e (diff) | |
download | coreutils-e744f4b7b7de9b76fdd314aa406e9fb150b9168d.tar.xz |
maint: prohibit an operator at end of line
Many coding standards, including GNU's, advocate that when
splitting a line near a binary operator, one should put the
operator at the beginning of the continued line, rather than
at the end of the preceding one. This is for readability:
such operators are relatively important to readability, and
they are more apparent at the beginning of a line than
at the varying-column end of line,
* cfg.mk (sc_prohibit_operator_at_end_of_line): New rule.
Exempt test.c and head.c.
-rw-r--r-- | cfg.mk | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -200,6 +200,18 @@ sc_no_exec_perl_coreutils: exit 1; } || :; \ fi +# With split lines, don't leave an operator at end of line. +# Instead, put it on the following line, where it is more apparent. +# Don't bother checking for "*" at end of line, since it provokes +# far too many false positives, matching constructs like "TYPE *". +# Similarly, omit "=" (initializers). +binop_re_ ?= [-/+^!<>]|[-/+*^!<>=]=|&&?|\|\|?|<<=?|>>=? +sc_prohibit_operator_at_end_of_line: + @prohibit='. ($(binop_re_))$$' \ + in_vc_files='\.[chly]$$' \ + halt='found operator at end of line' \ + $(_sc_search_regexp) + # Don't use "readlink" or "readlinkat" directly sc_prohibit_readlink: @prohibit='\<readlink(at)? \(' \ @@ -456,3 +468,7 @@ exclude_file_name_regexp--sc_prohibit_continued_string_alpha_in_column_1 = \ exclude_file_name_regexp--sc_prohibit_test_backticks = \ ^tests/(init\.sh|check\.mk|misc/stdbuf)$$ + +# Exempt test.c, since it's nominally shared, and relatively static. +exclude_file_name_regexp--sc_prohibit_operator_at_end_of_line = \ + ^src/(ptx|test|head)\.c$$ |