From c42926bf1eeb4ff3b1e604c7efa66da64221b9cb Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sun, 13 Jul 2003 09:03:13 +0000 Subject: [PATCH] (syntax-check): Move each individual check into its own target. (syntax-check-rules): This is the list of syntax-check targets. (sc_unmarked_diagnostics, sc_cast_of_argument_to_free): (sc_cast_of_x_alloc_return_value, sc_space_tab): (sc_error_exit_success, sc_xalloc_h_in_src): New targets. --- Makefile.maint | 74 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 54 insertions(+), 20 deletions(-) diff --git a/Makefile.maint b/Makefile.maint index 4ab4621145..0f24288fa5 100644 --- a/Makefile.maint +++ b/Makefile.maint @@ -19,6 +19,8 @@ ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA ## 02111-1307, USA. +ME := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) + # Do not save the original name or timestamp in the .tar.gz file. GZIP_ENV = '--no-name --best' @@ -57,39 +59,71 @@ local-check = \ # Make sure C source files in src/ don't include xalloc.h directly, # since they all already include it via sys2.h. # It's not a big deal -- just aesthetics. -syntax-check: - if test -f $(srcdir)/src/sys2.h; then \ - if grep 'xalloc\.h' $(srcdir)/src/*.c; then \ - exit 1; \ - fi; \ - fi - @grep -E '[ ] ' --exclude=$(srcdir)/lib/regex.c \ - $(srcdir)/{lib,src}/*.[chly] \ - $(find -name Makefile.am) && \ - { echo '$(ME): found SPACE-TAB sequence; remove the SPACE' \ - 1>&2; \ +.PHONY: $(syntax-check-rules) +syntax-check-rules = \ + sc_unmarked_diagnostics \ + sc_cast_of_argument_to_free \ + sc_cast_of_x_alloc_return_value \ + sc_space_tab \ + sc_error_exit_success \ + sc_xalloc_h_in_src + +syntax-check: $(syntax-check-rules) +# @grep -E '# *include <(limits|std(def|arg|bool))\.h>' \ +# $$(find -type f -name '*.[chly]') && \ +# { echo '$(ME): found conditional include' 1>&2; \ +# exit 1; } || : + +# grep -E '^# *include <(string|stdlib)\.h>' \ +# $(srcdir)/{lib,src}/*.[chy] && \ +# { echo '$(ME): FIXME' 1>&2; \ +# exit 1; } || : +# FIXME: don't allow `#include .strings\.h' anywhere + +# Look for diagnostics that aren't marked for translation. +# This won't find any for which error's format string is on a separate line. +sc_unmarked_diagnostics: + @grep --exclude=$(srcdir)/src/shred.c -E \ + '\&2; \ exit 1; } || : + +sc_cast_of_argument_to_free: @grep -E '\&2; \ exit 1; } || : + +sc_cast_of_x_alloc_return_value: @grep -E --exclude=$(srcdir)/lib/regex.c \ '\*\) *x(m|c|re)alloc\>' $(srcdir)/{lib,src}/*.[chy] && \ { echo '$(ME): don'\''t cast x*alloc return value' 1>&2; \ exit 1; } || : + +sc_space_tab: + @grep -E '[ ] ' --exclude=$(srcdir)/lib/regex.c \ + $(srcdir)/{lib,src}/*.[chly] \ + $(find -name Makefile.am) && \ + { echo '$(ME): found SPACE-TAB sequence; remove the SPACE' \ + 1>&2; \ + exit 1; } || : + +# Using EXIT_SUCCESS as the first argument to error is misleading, +# since when that parameter is 0, error does not exit. Use `0' instead. +sc_error_exit_success: @grep -F 'error (EXIT_SUCCESS,' \ $$(find -type f -name '*.[chly]') && \ { echo '$(ME): found error (EXIT_SUCCESS' 1>&2; \ exit 1; } || : -# @grep -E '# *include <(limits|std(def|arg|bool))\.h>' \ -# $$(find -type f -name '*.[chly]') && \ -# { echo '$(ME): found conditional include' 1>&2; \ -# exit 1; } || : -# grep -E '^# *include <(string|stdlib)\.h>' \ -# $(srcdir)/{lib,src}/*.[chy] && \ -# { echo '$(ME): FIXME' 1>&2; \ -# exit 1; } || : -# FIXME: don't allow `#include .strings\.h' anywhere +# xalloc.h is included via system.h, so should not be included +# directly by any file in src/. +sc_xalloc_h_in_src: + @if test -f $(srcdir)/src/sys2.h; then \ + if grep 'xalloc\.h' $(srcdir)/src/*.c; then \ + exit 1; \ + fi; \ + fi # Ensure that date's --help output stays in sync with the info # documentation for GNU strftime. The only exception is %N, -- 2.47.2