diff options
author | Bernhard Voelker <mail@bernhard-voelker.de> | 2015-02-17 08:46:56 +0100 |
---|---|---|
committer | Bernhard Voelker <mail@bernhard-voelker.de> | 2015-02-17 08:50:34 +0100 |
commit | 9f5dce80702d494535ab332273d20da1f9ca4365 (patch) | |
tree | 6b86c2256ba1d4675513f62bb2454d6eec80c998 /cfg.mk | |
parent | 321bd11352d1f378128d65746852e073f86319d3 (diff) | |
download | coreutils-9f5dce80702d494535ab332273d20da1f9ca4365.tar.gz |
maint: prefer STREQ_LEN and STRPREFIX over strncmp in all cases
* cfg.mk (sc_prohibit_strncmp): Improve the search pattern: use
_sc_search_regexp to find all invocations of strncmp except when
used on a macro definition line; just match the function name with
an opening parenthesis. Before, the expression missed places where
the comparison against 0 was in a subsequent line.
* src/system.h (STRNCMP_LIT): Shorten 'literal' to 'lit' to move
the whole definition of the macro into one line - thus making
sc_prohibit_strncmp pass.
(STRPREFIX): Add space before parenthesis.
* src/du.c (main): Prefer STREQ_LEN over strncmp.
* src/pinky.c (scan_entries): Likewise.
* src/tac.c (tac_seekable): Likewise.
* src/who.c (scan_entries): Likewise.
Diffstat (limited to 'cfg.mk')
-rw-r--r-- | cfg.mk | 8 |
1 files changed, 3 insertions, 5 deletions
@@ -581,11 +581,9 @@ sc_space_before_open_paren: # Similar to the gnulib maint.mk rule for sc_prohibit_strcmp # Use STREQ_LEN or STRPREFIX rather than comparing strncmp == 0, or != 0. sc_prohibit_strncmp: - @grep -nE '! *str''ncmp *\(|\<str''ncmp *\(.+\) *[!=]=' \ - $$($(VC_LIST_EXCEPT)) \ - | grep -vE ':# *define STR(N?EQ_LEN|PREFIX)\(' && \ - { echo '$(ME): use STREQ_LEN or STRPREFIX instead of str''ncmp' \ - 1>&2; exit 1; } || : + @prohibit='^[^#].*str''ncmp *\(' \ + halt='use STREQ_LEN or STRPREFIX instead of str''ncmp' \ + $(_sc_search_regexp) # Enforce recommended preprocessor indentation style. sc_preprocessor_indentation: |