diff options
author | Jim Meyering <meyering@redhat.com> | 2012-01-09 22:56:54 +0100 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2012-01-11 09:27:50 +0100 |
commit | d3227eeb90c8308abd1e6bf08ee253b7a4e78d1d (patch) | |
tree | 3ccee2bcd24ae57b9c9b539cd964b103a5271f4a /cfg.mk | |
parent | bfe711db1c07e73a5806647a637f609eb8c1773d (diff) | |
download | coreutils-d3227eeb90c8308abd1e6bf08ee253b7a4e78d1d.tar.xz |
maint: adjust formatting of certain continued strings
Add a rule to ding any source file that has a continued string
with a word in the first column of the following line.
Those tend to trigger malfunction in tools that try to map an
arbitrary line number to an enclosing function name. Of course,
very many strings do precisely this, *when they are part of the
usage function*. So we exempt the body of each usage function.
* src/dircolors.c (main): Separate a long, continued string
into two separately-quoted parts.
* src/od.c (decode_one_format): Likewise.
(decode_one_format, main): Move a space from end of
preceding line to the beginning of the continued line.
* src/tr.c (unquote, string2_extend, validate): Likewise.
* src/seq.c (main): Split in two and use string concatenation.
* src/stat.c (default_format): Use a mix of techniques.
* cfg.mk (sc_prohibit_continued_string_alpha_in_column_1): New rule.
Exempt three files in src: system.h, od.c, printf.c.
Diffstat (limited to 'cfg.mk')
-rw-r--r-- | cfg.mk | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -289,6 +289,26 @@ sc_prohibit_framework_failure: halt='use framework_failure_ instead' \ $(_sc_search_regexp) +# Exempt the contents of any usage function from the following. +_continued_string_col_1 = \ +s/^usage .*?\n}//ms;/\\\n\w/ and print ("$$ARGV\n"),$$e=1;END{$$e||=0;exit $$e} +# Ding any source file that has a continued string with an alphabetic in the +# first column of the following line. We prohibit them because they usually +# trigger false positives in tools that try to map an arbitrary line number +# to the enclosing function name. Of course, very many strings do precisely +# this, *when they are part of the usage function*. That is why we exempt +# the contents of any function named "usage". +sc_prohibit_continued_string_alpha_in_column_1: + @perl -0777 -ne '$(_continued_string_col_1)' \ + $$($(VC_LIST_EXCEPT) | grep '\.[ch]$$') \ + || { echo '$(ME): continued string with word in first column' \ + 1>&2; exit 1; } || : +# Use this to list offending lines: +# git ls-files |grep '\.[ch]$' | xargs \ +# perl -n -0777 -e 's/^usage.*?\n}//ms;/\\\n\w/ and print "$ARGV\n"' \ +# | xargs grep -A1 '\\$'|grep '\.[ch][:-][_a-zA-Z]' + + ########################################################### _p0 = \([^"'/]\|"\([^\"]\|[\].\)*"\|'\([^\']\|[\].\)*' _pre = $(_p0)\|[/][^"'/*]\|[/]"\([^\"]\|[\].\)*"\|[/]'\([^\']\|[\].\)*'\)* @@ -409,3 +429,6 @@ exclude_file_name_regexp--sc_preprocessor_indentation = \ ^(gl/lib/rand-isaac\.[ch]|gl/tests/test-rand-isaac\.c)$$ exclude_file_name_regexp--sc_prohibit_stat_st_blocks = \ ^(src/system\.h|tests/du/2g)$$ + +exclude_file_name_regexp--sc_prohibit_continued_string_alpha_in_column_1 = \ + ^src/(system\.h|od\.c|printf\.c)$$ |