From: Jim Meyering Date: Thu, 29 Jan 2009 09:44:10 +0000 (+0100) Subject: maint: factor syntax-check rules X-Git-Tag: v7.1~36 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=60ca9e1599ed5c9a1a06130d915438cbb32ab391;p=thirdparty%2Fcoreutils.git maint: factor syntax-check rules * maint.mk (_ignore_case): New macro. (_prohibit_regexp): Use it. Factor many existing syntax-check rules to use $(_prohibit_regexp). --- diff --git a/maint.mk b/maint.mk index 4b449d8eda..38724c24d0 100644 --- a/maint.mk +++ b/maint.mk @@ -62,8 +62,6 @@ release_archive_dir ?= ../release # Doing it here saves us from having to set LC_ALL elsewhere in this file. export LC_ALL = C - - ## --------------- ## ## Sanity checks. ## ## --------------- ## @@ -92,6 +90,10 @@ syntax-check: $(local-check) # exit 1; } || : # FIXME: don't allow `#include .strings\.h' anywhere +# By default, _prohibit_regexp does not ignore case. +export ignore_case = +_ignore_case = $$(test -n "$$ignore_case" && echo -i || :) + # There are many rules below that prohibit constructs in this package. # If the offending construct can be matched with a grep-E-style regexp, # use this macro. The shell variables "re" and "msg" must be defined. @@ -99,7 +101,7 @@ define _prohibit_regexp dummy=; : so we do not need a semicolon before each use \ test "x$$re" != x || { echo '$(ME): re not defined' 1>&2; exit 1; }; \ test "x$$msg" != x || { echo '$(ME): msg not defined' 1>&2; exit 1; };\ - grep -nE "$$re" $$($(VC_LIST_EXCEPT)) && \ + grep $(_ignore_case) -nE "$$re" $$($(VC_LIST_EXCEPT)) && \ { echo '$(ME): '"$$msg" 1>&2; exit 1; } || : endef @@ -175,13 +177,12 @@ sc_error_message_period: exit 1; } || : sc_file_system: - @grep -ni 'file''system' $$($(VC_LIST_EXCEPT)) && \ - { echo '$(ME): found use of "file''system";' \ - 'rewrite to use "file system"' 1>&2; \ - exit 1; } || : + @re=file''system ignore_case=1 \ + msg='found use of "file''system"; spell it "file system"' \ + $(_prohibit_regexp) # Don't use cpp tests of this symbol. All code assumes config.h is included. -sc_no_have_config_h: +sc_prohibit_have_config_h: @grep -n '^# *if.*HAVE''_CONFIG_H' $$($(VC_LIST_EXCEPT)) && \ { echo '$(ME): found use of HAVE''_CONFIG_H; remove' \ 1>&2; exit 1; } || : @@ -278,10 +279,9 @@ sc_prohibit_root_dev_ino_without_use: $(_header_without_use) sc_obsolete_symbols: - @grep -nE '\<(HAVE''_FCNTL_H|O''_NDELAY)\>' \ - $$($(VC_LIST_EXCEPT)) && \ - { echo '$(ME): do not use HAVE''_FCNTL_H or O''_NDELAY' \ - 1>&2; exit 1; } || : + @re='\<(HAVE''_FCNTL_H|O''_NDELAY)\>' \ + msg='do not use HAVE''_FCNTL_H or O'_NDELAY \ + $(_prohibit_regexp) # FIXME: warn about definitions of EXIT_FAILURE, EXIT_SUCCESS, STREQ @@ -320,14 +320,14 @@ sc_require_test_exit_idiom: fi sc_the_the: - @grep -ni '\' $$($(VC_LIST_EXCEPT)) && \ - { echo '$(ME): found use of "the ''the";' 1>&2; \ - exit 1; } || : + @re='\' \ + ignore_case=1 msg='found use of "the ''the";' \ + $(_prohibit_regexp) sc_trailing_blank: - @grep -n '[ ]$$' $$($(VC_LIST_EXCEPT)) && \ - { echo '$(ME): found trailing blank(s)' \ - 1>&2; exit 1; } || : + @re='[ ]$$' \ + ignore_case=1 msg='found trailing blank(s)' \ + $(_prohibit_regexp) # Match lines like the following, but where there is only one space # between the options and the description: @@ -358,8 +358,8 @@ sc_useless_cpp_parens: # Require the latest GPL. sc_GPL_version: - @grep -n 'either ''version [^3]' $$($(VC_LIST_EXCEPT)) && \ - { echo '$(ME): GPL vN, N!=3' 1>&2; exit 1; } || : + @re='either ''version [^3]' msg='GPL vN, N!=3' \ + $(_prohibit_regexp) cvs_keywords = \ Author|Date|Header|Id|Name|Locker|Log|RCSfile|Revision|Source|State