From e3b22389a852e9afe16ebc15ce0f95c21ff3f041 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Tue, 18 Mar 2008 21:32:03 +0100 Subject: Factor out duplication in sc_prohibit_*_without_use rules. * Makefile.maint (_header_without_use): New "command", factored out of four sc_prohibit_HEADER_without_use rules. (sc_prohibit_assert_without_use): Rewrite using $(_header_without_use). (sc_prohibit_getopt_without_use): Likewise. (sc_prohibit_quotearg_without_use): Likewise. (sc_prohibit_quote_without_use): Likewise. --- Makefile.maint | 55 +++++++++++++++++++------------------------------------ 1 file changed, 19 insertions(+), 36 deletions(-) diff --git a/Makefile.maint b/Makefile.maint index 23a64ee37..a79b2787f 100644 --- a/Makefile.maint +++ b/Makefile.maint @@ -166,53 +166,36 @@ sc_require_config_h: else :; \ fi +# To use this "command" macro, you must first define two shell variables: +# h: the header, enclosed in <> or "" +# re: a regular expression that matches IFF something provided by $h is used. +define _header_without_use + h_esc=`echo "$$h"|sed 's/\./\\./'`; \ + if $(CVS_LIST_EXCEPT) | grep '\.c$$' > /dev/null; then \ + files=$$(grep -l '^# *include '"$$h_esc" \ + $$($(CVS_LIST_EXCEPT) | grep '\.c$$')) && \ + grep -LE "$$re" $$files | grep . && \ + { echo "$(ME): the above files include $$h but don't use it" \ + 1>&2; exit 1; } || :; \ + else :; \ + fi +endef + # Prohibit the inclusion of assert.h without an actual use of assert. sc_prohibit_assert_without_use: - @if $(CVS_LIST_EXCEPT) | grep '\.c$$' > /dev/null; then \ - files=$$(grep -l '# *include ' \ - $$($(CVS_LIST_EXCEPT) | grep '\.c$$')) && \ - grep -L '\ but don't use it" \ - 1>&2; exit 1; } || :; \ - else :; \ - fi + @h='' re='\ /dev/null; then \ - files=$$(grep -l '# *include ' \ - $$($(CVS_LIST_EXCEPT) | grep '\.c$$')) && \ - grep -E -L '\ but don't use it" \ - 1>&2; exit 1; } || :; \ - else :; \ - fi + @h='' re='\ /dev/null; then \ - files=$$(grep -l '# *include "quotearg\.h"' \ - $$($(CVS_LIST_EXCEPT) | grep '\.c$$')) && \ - grep -LE '\&2; exit 1; } || :; \ - else :; \ - fi + @h='"quotearg.h"' re='\ /dev/null; then \ - files=$$(grep -l '# *include "quote\.h"' \ - $$($(CVS_LIST_EXCEPT) | grep '\.c$$')) && \ - grep -LE '\&2; exit 1; } || :; \ - else :; \ - fi + @h='"quote.h"' re='\' \ -- cgit v1.2.3-54-g00ecf