maint.mk: allow fine-grained syntax-check exclusion via Make variables
authorJim Meyering <meyering@redhat.com>
Wed, 16 Mar 2011 11:14:21 +0000 (12:14 +0100)
committerJim Meyering <meyering@redhat.com>
Wed, 16 Mar 2011 11:14:21 +0000 (12:14 +0100)
Before, you would have had to create one .x-sc_ file per rule in order
to exempt offending files.  Now, you may instead use a Make variable --
usually defined in cfg.mk -- whose name identifies the affected rule.
* top/maint.mk (_sc_excl): Define.
(VC_LIST_EXCEPT): Use it to exclude names on a per-rule basis.
(_sc_search_regexp): When not using VC_LIST_EXCEPT, exclude here, too.

ChangeLog
top/maint.mk

index a7c00b4..917e834 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2011-03-16  Jim Meyering  <meyering@redhat.com>
+
+       maint.mk: allow fine-grained syntax-check exclusion via Make variables
+       Before, you would have had to create one .x-sc_ file per rule in order
+       to exempt offending files.  Now, you may instead use a Make variable --
+       usually defined in cfg.mk -- whose name identifies the affected rule.
+       * top/maint.mk (_sc_excl): Define.
+       (VC_LIST_EXCEPT): Use it to exclude names on a per-rule basis.
+       (_sc_search_regexp): When not using VC_LIST_EXCEPT, exclude here, too.
+
 2011-03-13  Bruno Haible  <bruno@clisp.org>
 
        ignore-value tests: Avoid warnings.
index 303e9c1..1df8c7a 100644 (file)
@@ -57,11 +57,13 @@ endif
 # In order to be able to consistently filter "."-relative names,
 # (i.e., with no $(srcdir) prefix), this definition is careful to
 # remove any $(srcdir) prefix, and to restore what it removes.
+_sc_excl = \
+  $(if $(exclude_file_name_regexp--$@),$(exclude_file_name_regexp--$@),^$$)
 VC_LIST_EXCEPT = \
   $(VC_LIST) | sed 's|^$(_dot_escaped_srcdir)/||' \
        | if test -f $(srcdir)/.x-$@; then grep -vEf $(srcdir)/.x-$@; \
          else grep -Ev -e "$${VC_LIST_EXCEPT_DEFAULT-ChangeLog}"; fi \
-       | grep -Ev -e '$(VC_LIST_ALWAYS_EXCLUDE_REGEX)' \
+       | grep -Ev -e '($(VC_LIST_ALWAYS_EXCLUDE_REGEX)|$(_sc_excl))' \
        $(_prepend_srcdir_prefix)
 
 ifeq ($(origin prev_version_file), undefined)
@@ -196,6 +198,16 @@ syntax-check: $(local-check)
 #  halt
 #
 #     Message to display before to halting execution.
+#
+# Finally, you may exempt files based on an ERE matching file names.
+# For example, to exempt from the sc_space_tab check all files with the
+# .diff suffix, set this Make variable:
+#
+# exclude_file_name_regexp--sc_space_tab = \.diff$
+#
+# Note that while this functionality is mostly inherited via VC_LIST_EXCEPT,
+# when filtering by name via in_files, we explicitly filter out matching
+# names here as well.
 
 # By default, _sc_search_regexp does not ignore case.
 export ignore_case =
@@ -233,7 +245,8 @@ define _sc_search_regexp
                                                                        \
    : Filter by file name;                                              \
    if test -n "$$in_files"; then                                       \
-     files=$$(find $(srcdir) | grep -E "$$in_files");                  \
+     files=$$(find $(srcdir) | grep -E "$$in_files"                    \
+              | grep -Ev '$(exclude_file_name_regexp--$@)');           \
    else                                                                        \
      files=$$($(VC_LIST_EXCEPT));                                      \
      if test -n "$$in_vc_files"; then                                  \