[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] maint.mk: allow fine-grained syntax-check exclusion via Make
From: |
Jim Meyering |
Subject: |
Re: [PATCH] maint.mk: allow fine-grained syntax-check exclusion via Make variables |
Date: |
Wed, 16 Mar 2011 12:39:23 +0100 |
Jim Meyering wrote:
> Jim Meyering wrote:
>> Reuben Thomas wrote:
>>> make syntax-check is complaining about space-tabs (sc_space_tab) in a
>>> sort of file where this is perfectly permissable: a .diff file. Why do
>>> I have a diff file in version control? Because I'm patching gnulib.
>>>
>>> Of course, I can add this to VC_LIST_ALWAYS_EXCLUDE_REGEX, but maybe
>>> .diff files should be excluded from this check anyway?
>>
>> They're expected only in .diff files for which
>> the original has context lines that start with a TAB.
>> For that reason (in gnulib, that is only a very small fraction
>> of all files), I think it's slightly better to let those who
>> need it add a line like this to a file named .x-sc_space_tab
>>
>> ^gl/lib/.*\.c\.diff$
>>
>> However, I find that adding a whole new .x-sc_* file
>> just to exempt an exceptional source file from one of the
>> many syntax checks is a disproportionate burden.
>> It has always bothered me to do that.
>>
>> So finally, here's a proposed maint.mk patch to implement a better way,
>> followed by the change induced in coreutils where I remove its 24
>> .x-sc_* files, replacing them with just 30 lines at the end of cfg.mk:
>>
>> Notes on the naming of these new exception-specifying variables:
>> - the resulting variable names are rather long. I erred on the side
>> of being too descriptive. They're going to be used at most once, then
>> probably forgotten forever.
>>
>> - I don't like the fact that they have a common *suffix* rather
>> than a common prefix. That's just what I did in the first cut.
>> They do have a common sc_ suffix, so maybe that's ok,
>> but the long common part, -exclude_file_name_regexp is at the end,
>> and that makes the list in cfg.mk harder to read, so I'm leaning
>> towards reversing, i.e., changing this
>> sc_space_tab-exclude_file_name_regexp = \
>> to this
>> _exclude_file_name_regexp--sc_space_tab = \
>> Note the leading underscore and two hyphens. The former to make
>> it less likely to collied with application names, and the latter
>> to make it clearer where the long common prefix ends and the
>> variable suffix starts.
>>
>> Plus I'll have to split the long line 10 lines down:
>
> I've done the above and have just pushed this change.
> Thanks for inspiring me to do this, Reuben.
...
> Subject: [PATCH] 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.
FYI, here's the corresponding patch to coreutils.
It's not often that we can remove so many files.
This brings the number of VC'd files back below 1000 (now it's 984).
>From 8e4e1d484f88502dbe9336050232a5f90e0b68d4 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Mon, 14 Mar 2011 14:26:38 +0100
Subject: [PATCH] maint: stop using .x-sc_* files to list syntax-check
exemptions
Instead, use the brand new mechanism with which you merely use a
variable (derived from the rule name) defined in cfg.mk to an ERE
matching the exempted file names.
* gnulib: Update to latest, to get maint.mk that implements this.
* Makefile.am (syntax_check_exceptions): Remove variable.
(EXTRA_DIST): Remove use of the variable.
* cfg.mk (sc_x_sc_dist_check): Remove rule, no longer useful.
(exclude_file_name_regexp--sc_space_tab): Define variable.
(exclude_file_name_regexp--sc_bindtextdomain): Likewise.
(exclude_file_name_regexp--sc_unmarked_diagnostics): Likewise.
(exclude_file_name_regexp--sc_error_message_uppercase): Likewise.
(exclude_file_name_regexp--sc_trailing_blank): Likewise.
(exclude_file_name_regexp--sc_system_h_headers): Likewise.
(exclude_file_name_regexp--sc_require_config_h_first): Likewise.
(exclude_file_name_regexp--sc_require_config_h): Likewise.
(exclude_file_name_regexp--sc_po_check): Likewise.
(exclude_file_name_regexp--sc_prohibit_always-defined_macros): Likewise.
(exclude_file_name_regexp--sc_prohibit_empty_lines_at_EOF): Likewise.
(exclude_file_name_regexp--sc_program_name): Likewise.
(exclude_file_name_regexp--sc_file_system): Likewise.
(exclude_file_name_regexp--sc_prohibit_always_true_header_tests):
Likewise.
(exclude_file_name_regexp--sc_prohibit_fail_0): Likewise.
(exclude_file_name_regexp--sc_prohibit_atoi_atof): Likewise.
(exclude_file_name_regexp--sc_prohibit_tab_based_indentation): Likewise.
(exclude_file_name_regexp--sc_prohibit_stat_st_blocks): Likewise.
* configure.ac [whether localtime caches TZ]: Use return 0/1, not
exit (0/1) to avoid triggering a sc_prohibit_magic_number_exit failure.
* .x-sc_GPL_version: Remove file.
* .x-sc_bindtextdomain: Likewise.
* .x-sc_error_message_uppercase: Likewise.
* .x-sc_file_system: Likewise.
* .x-sc_obsolete_symbols: Likewise.
* .x-sc_po_check: Likewise.
* .x-sc_program_name: Likewise.
* .x-sc_prohibit_always-defined_macros: Likewise.
* .x-sc_prohibit_always_true_header_tests: Likewise.
* .x-sc_prohibit_atoi_atof: Likewise.
* .x-sc_prohibit_empty_lines_at_EOF: Likewise.
* .x-sc_prohibit_fail_0: Likewise.
* .x-sc_prohibit_magic_number_exit: Likewise.
* .x-sc_prohibit_stat_st_blocks: Likewise.
* .x-sc_prohibit_strcmp: Likewise.
* .x-sc_prohibit_tab_based_indentation: Likewise.
* .x-sc_require_config_h: Likewise.
* .x-sc_require_config_h_first: Likewise.
* .x-sc_space_tab (config): Likewise.
* .x-sc_sun_os_names: Likewise.
* .x-sc_system_h_headers: Likewise.
* .x-sc_trailing_blank: Likewise.
* .x-sc_unmarked_diagnostics: Likewise.
* .x-sc_useless_cpp_parens: Likewise.
---
.x-sc_GPL_version | 1 -
.x-sc_bindtextdomain | 7 -----
.x-sc_error_message_uppercase | 1 -
.x-sc_file_system | 5 ---
.x-sc_obsolete_symbols | 1 -
.x-sc_po_check | 1 -
.x-sc_program_name | 3 --
.x-sc_prohibit_always-defined_macros | 1 -
.x-sc_prohibit_always_true_header_tests | 2 -
.x-sc_prohibit_atoi_atof | 1 -
.x-sc_prohibit_empty_lines_at_EOF | 1 -
.x-sc_prohibit_fail_0 | 4 ---
.x-sc_prohibit_magic_number_exit | 2 -
.x-sc_prohibit_stat_st_blocks | 4 ---
.x-sc_prohibit_strcmp | 1 -
.x-sc_prohibit_tab_based_indentation | 7 -----
.x-sc_require_config_h | 9 ------
.x-sc_require_config_h_first | 9 ------
.x-sc_space_tab | 12 --------
.x-sc_sun_os_names | 2 -
.x-sc_system_h_headers | 3 --
.x-sc_trailing_blank | 1 -
.x-sc_unmarked_diagnostics | 2 -
.x-sc_useless_cpp_parens | 13 ---------
Makefile.am | 27 ------------------
cfg.mk | 45 ++++++++++++++++++++++---------
configure.ac | 10 +++---
gnulib | 2 +-
28 files changed, 38 insertions(+), 139 deletions(-)
delete mode 100644 .x-sc_GPL_version
delete mode 100644 .x-sc_bindtextdomain
delete mode 100644 .x-sc_error_message_uppercase
delete mode 100644 .x-sc_file_system
delete mode 100644 .x-sc_obsolete_symbols
delete mode 100644 .x-sc_po_check
delete mode 100644 .x-sc_program_name
delete mode 100644 .x-sc_prohibit_always-defined_macros
delete mode 100644 .x-sc_prohibit_always_true_header_tests
delete mode 100644 .x-sc_prohibit_atoi_atof
delete mode 100644 .x-sc_prohibit_empty_lines_at_EOF
delete mode 100644 .x-sc_prohibit_fail_0
delete mode 100644 .x-sc_prohibit_magic_number_exit
delete mode 100644 .x-sc_prohibit_stat_st_blocks
delete mode 100644 .x-sc_prohibit_strcmp
delete mode 100644 .x-sc_prohibit_tab_based_indentation
delete mode 100644 .x-sc_require_config_h
delete mode 100644 .x-sc_require_config_h_first
delete mode 100644 .x-sc_space_tab
delete mode 100644 .x-sc_sun_os_names
delete mode 100644 .x-sc_system_h_headers
delete mode 100644 .x-sc_trailing_blank
delete mode 100644 .x-sc_unmarked_diagnostics
delete mode 100644 .x-sc_useless_cpp_parens
diff --git a/.x-sc_GPL_version b/.x-sc_GPL_version
deleted file mode 100644
index d496afa..0000000
--- a/.x-sc_GPL_version
+++ /dev/null
@@ -1 +0,0 @@
-^build-aux/check\.mk$
diff --git a/.x-sc_bindtextdomain b/.x-sc_bindtextdomain
deleted file mode 100644
index 2a568be..0000000
--- a/.x-sc_bindtextdomain
+++ /dev/null
@@ -1,7 +0,0 @@
-^gl/lib/randint\.c$
-^gl/tests/test-di-set\.c$
-^gl/tests/test-fadvise\.c$
-^gl/tests/test-ino-map\.c$
-^gl/tests/test-mbsalign\.c$
-^gl/tests/test-rand-isaac\.c$
-^lib/euidaccess-stat\.c$
diff --git a/.x-sc_error_message_uppercase b/.x-sc_error_message_uppercase
deleted file mode 100644
index 2452230..0000000
--- a/.x-sc_error_message_uppercase
+++ /dev/null
@@ -1 +0,0 @@
-build-aux/cvsu
diff --git a/.x-sc_file_system b/.x-sc_file_system
deleted file mode 100644
index e997182..0000000
--- a/.x-sc_file_system
+++ /dev/null
@@ -1,5 +0,0 @@
-ChangeLog
-NEWS
-src/df.c
-src/stat.c
-tests/misc/df-P
diff --git a/.x-sc_obsolete_symbols b/.x-sc_obsolete_symbols
deleted file mode 100644
index 56631ab..0000000
--- a/.x-sc_obsolete_symbols
+++ /dev/null
@@ -1 +0,0 @@
-ChangeLog
diff --git a/.x-sc_po_check b/.x-sc_po_check
deleted file mode 100644
index ffa8d97..0000000
--- a/.x-sc_po_check
+++ /dev/null
@@ -1 +0,0 @@
-^gl/
diff --git a/.x-sc_program_name b/.x-sc_program_name
deleted file mode 100644
index 86cc5c1..0000000
--- a/.x-sc_program_name
+++ /dev/null
@@ -1,3 +0,0 @@
-gl/lib/randint.c
-lib/euidaccess-stat.c
-gl/tests/.*\.c
diff --git a/.x-sc_prohibit_always-defined_macros
b/.x-sc_prohibit_always-defined_macros
deleted file mode 100644
index 8c96958..0000000
--- a/.x-sc_prohibit_always-defined_macros
+++ /dev/null
@@ -1 +0,0 @@
-src/seq.c
diff --git a/.x-sc_prohibit_always_true_header_tests
b/.x-sc_prohibit_always_true_header_tests
deleted file mode 100644
index 732d9ec..0000000
--- a/.x-sc_prohibit_always_true_header_tests
+++ /dev/null
@@ -1,2 +0,0 @@
-^m4/stat-prog\.m4$
-ChangeLog
diff --git a/.x-sc_prohibit_atoi_atof b/.x-sc_prohibit_atoi_atof
deleted file mode 100644
index f66450e..0000000
--- a/.x-sc_prohibit_atoi_atof
+++ /dev/null
@@ -1 +0,0 @@
-^lib/euidaccess-stat\.c$
diff --git a/.x-sc_prohibit_empty_lines_at_EOF
b/.x-sc_prohibit_empty_lines_at_EOF
deleted file mode 100644
index 92571d6..0000000
--- a/.x-sc_prohibit_empty_lines_at_EOF
+++ /dev/null
@@ -1 +0,0 @@
-^tests/pr/
diff --git a/.x-sc_prohibit_fail_0 b/.x-sc_prohibit_fail_0
deleted file mode 100644
index 7055351..0000000
--- a/.x-sc_prohibit_fail_0
+++ /dev/null
@@ -1,4 +0,0 @@
-\.mk$
-/Makefile\.am$
-^tests/init\.sh$
-^tests/test-lib\.sh$
diff --git a/.x-sc_prohibit_magic_number_exit b/.x-sc_prohibit_magic_number_exit
deleted file mode 100644
index ffeb5ac..0000000
--- a/.x-sc_prohibit_magic_number_exit
+++ /dev/null
@@ -1,2 +0,0 @@
-configure.ac
-ChangeLog*
diff --git a/.x-sc_prohibit_stat_st_blocks b/.x-sc_prohibit_stat_st_blocks
deleted file mode 100644
index eb590cd..0000000
--- a/.x-sc_prohibit_stat_st_blocks
+++ /dev/null
@@ -1,4 +0,0 @@
-src/system.h
-tests/du/2g
-old/fileutils/ChangeLog-1997
-ChangeLog-2005
diff --git a/.x-sc_prohibit_strcmp b/.x-sc_prohibit_strcmp
deleted file mode 100644
index 56631ab..0000000
--- a/.x-sc_prohibit_strcmp
+++ /dev/null
@@ -1 +0,0 @@
-ChangeLog
diff --git a/.x-sc_prohibit_tab_based_indentation
b/.x-sc_prohibit_tab_based_indentation
deleted file mode 100644
index 388f94a..0000000
--- a/.x-sc_prohibit_tab_based_indentation
+++ /dev/null
@@ -1,7 +0,0 @@
-^GNUMakefile$
-Makefile\.am$
-\.mk$
-^tests/pr/
-ChangeLog.*
-^man/help2man$
-^gl/lib/.*\.c\.diff$
diff --git a/.x-sc_require_config_h b/.x-sc_require_config_h
deleted file mode 100644
index 727bb8e..0000000
--- a/.x-sc_require_config_h
+++ /dev/null
@@ -1,9 +0,0 @@
-^lib/buffer-lcm\.c$
-^src/false\.c$
-^src/lbracket\.c$
-^src/ls-dir\.c$
-^src/ls-ls\.c$
-^src/ls-vdir\.c$
-^src/tac-pipe\.c$
-^src/uname-arch\.c$
-^src/uname-uname\.c$
diff --git a/.x-sc_require_config_h_first b/.x-sc_require_config_h_first
deleted file mode 100644
index 727bb8e..0000000
--- a/.x-sc_require_config_h_first
+++ /dev/null
@@ -1,9 +0,0 @@
-^lib/buffer-lcm\.c$
-^src/false\.c$
-^src/lbracket\.c$
-^src/ls-dir\.c$
-^src/ls-ls\.c$
-^src/ls-vdir\.c$
-^src/tac-pipe\.c$
-^src/uname-arch\.c$
-^src/uname-uname\.c$
diff --git a/.x-sc_space_tab b/.x-sc_space_tab
deleted file mode 100644
index 2ef3428..0000000
--- a/.x-sc_space_tab
+++ /dev/null
@@ -1,12 +0,0 @@
-config(ure|\.(guess|sub))
-tests/pr
-lib/regex.c
-config-log
-tests/misc/nl
-po/de.po
-m4/lib-ld.m4
-m4/lib-prefix.m4
-m4/po.m4
-aclocal.m4
-src/c99-to-c89.diff
-^gl/lib/.*\.c\.diff$
diff --git a/.x-sc_sun_os_names b/.x-sc_sun_os_names
deleted file mode 100644
index 3ffc52c..0000000
--- a/.x-sc_sun_os_names
+++ /dev/null
@@ -1,2 +0,0 @@
-config-log
-build-aux/config.guess
diff --git a/.x-sc_system_h_headers b/.x-sc_system_h_headers
deleted file mode 100644
index 14e020f..0000000
--- a/.x-sc_system_h_headers
+++ /dev/null
@@ -1,3 +0,0 @@
-^src/libstdbuf\.c$
-^src/system\.h$
-^src/copy\.h$
diff --git a/.x-sc_trailing_blank b/.x-sc_trailing_blank
deleted file mode 100644
index 92571d6..0000000
--- a/.x-sc_trailing_blank
+++ /dev/null
@@ -1 +0,0 @@
-^tests/pr/
diff --git a/.x-sc_unmarked_diagnostics b/.x-sc_unmarked_diagnostics
deleted file mode 100644
index aac8984..0000000
--- a/.x-sc_unmarked_diagnostics
+++ /dev/null
@@ -1,2 +0,0 @@
-^lib/xstrtol\.h$
-^build-aux/cvsu$
diff --git a/.x-sc_useless_cpp_parens b/.x-sc_useless_cpp_parens
deleted file mode 100644
index 01eb4b4..0000000
--- a/.x-sc_useless_cpp_parens
+++ /dev/null
@@ -1,13 +0,0 @@
-^build-aux/config.guess
-^configure
-^lib/alloca.c
-^lib/fts.c
-^lib/getdate.c
-^lib/getloadavg.c
-^lib/gettext.h
-^lib/getusershell.c
-^lib/mbswidth.c
-^lib/strtod.c
-^lib/xstrtol.c
-^m4/
-^tests/misc/pwd-unreadable-parent
diff --git a/Makefile.am b/Makefile.am
index 18f09b7..9322658 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -39,35 +39,8 @@ changelog_etc = \
old/textutils/NEWS \
po/ChangeLog-2007
-syntax_check_exceptions = \
- .x-sc_GPL_version \
- .x-sc_bindtextdomain \
- .x-sc_error_message_uppercase \
- .x-sc_file_system \
- .x-sc_obsolete_symbols \
- .x-sc_po_check \
- .x-sc_program_name \
- .x-sc_prohibit_always-defined_macros \
- .x-sc_prohibit_atoi_atof \
- .x-sc_prohibit_empty_lines_at_EOF \
- .x-sc_prohibit_fail_0 \
- .x-sc_prohibit_magic_number_exit \
- .x-sc_prohibit_stat_st_blocks \
- .x-sc_prohibit_strcmp \
- .x-sc_prohibit_tab_based_indentation \
- .x-sc_require_config_h \
- .x-sc_require_config_h_first \
- .x-sc_space_tab \
- .x-sc_sun_os_names \
- .x-sc_system_h_headers \
- .x-sc_trailing_blank \
- .x-sc_prohibit_always_true_header_tests \
- .x-sc_unmarked_diagnostics \
- .x-sc_useless_cpp_parens
-
EXTRA_DIST = \
$(changelog_etc) \
- $(syntax_check_exceptions) \
.mailmap \
.prev-version \
.version \
diff --git a/cfg.mk b/cfg.mk
index c897dc4..fe2dd13 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -93,19 +93,6 @@ sc_root_tests:
exit 1; } || :; \
fi
-# Ensure that the syntax_check_exceptions file list in Makefile.am
-# stays in sync with corresponding files in the repository.
-sce = syntax_check_exceptions
-sc_x_sc_dist_check:
- @test "$$( ($(VC_LIST) | sed -n '/\.x-sc_/p' \
- | sed 's|^$(_dot_escaped_srcdir)/||'; \
- sed -n '/^$(sce) =[ ]*\\$$/,/[^\]$$/p' \
- $(srcdir)/Makefile.am \
- | sed 's/^ *//;/^$(sce) =/d' \
- | tr -s '\012\\' ' ' | fmt -1 \
- ) | sort | uniq -u)" \
- && { echo 'Makefile.am: $(sce) mismatch' >&2; exit 1; } || :;
-
# Create a list of regular expressions matching the names
# of files included from system.h. Exclude a couple.
.re-list:
@@ -337,3 +324,35 @@ include $(srcdir)/dist-check.mk
update-copyright-env = \
UPDATE_COPYRIGHT_USE_INTERVALS=1 \
UPDATE_COPYRIGHT_MAX_LINE_LENGTH=79
+
+# List syntax-check exemptions.
+exclude_file_name_regexp--sc_space_tab = \
+ ^(tests/pr/|tests/misc/nl$$|gl/.*\.diff$$)
+exclude_file_name_regexp--sc_bindtextdomain = ^(gl/.*|lib/euidaccess-stat)\.c$$
+exclude_file_name_regexp--sc_unmarked_diagnostics = ^build-aux/cvsu$$
+exclude_file_name_regexp--sc_error_message_uppercase = ^build-aux/cvsu$$
+exclude_file_name_regexp--sc_trailing_blank = ^tests/pr/
+exclude_file_name_regexp--sc_system_h_headers = \
+ ^src/((system|copy)\.h|libstdbuf\.c)$$
+
+_src = (false|lbracket|ls-(dir|ls|vdir)|tac-pipe|uname-(arch|uname))
+exclude_file_name_regexp--sc_require_config_h_first = \
+ (^lib/buffer-lcm\.c|src/$(_src)\.c)$$
+exclude_file_name_regexp--sc_require_config_h = \
+ $(exclude_file_name_regexp--sc_require_config_h_first)
+
+exclude_file_name_regexp--sc_po_check = ^gl/
+exclude_file_name_regexp--sc_prohibit_always-defined_macros = ^src/seq\.c$$
+exclude_file_name_regexp--sc_prohibit_empty_lines_at_EOF = ^tests/pr/
+exclude_file_name_regexp--sc_program_name = ^(gl/.*|lib/euidaccess-stat)\.c$$
+exclude_file_name_regexp--sc_file_system = NEWS|^(src/df\.c|tests/misc/df-P)$$
+exclude_file_name_regexp--sc_prohibit_always_true_header_tests = \
+ ^m4/stat-prog\.m4$$
+exclude_file_name_regexp--sc_prohibit_fail_0 = \
+ (^tests/init\.sh|Makefile\.am|\.mk)$$
+exclude_file_name_regexp--sc_prohibit_atoi_atof = ^lib/euidaccess-stat\.c$$
+exclude_file_name_regexp--sc_prohibit_tab_based_indentation = \
+ ^tests/pr/|(^gl/lib/reg.*\.c\.diff|Makefile(\.am)?|\.mk|^man/help2man)$$
+
+exclude_file_name_regexp--sc_prohibit_stat_st_blocks = \
+ ^(src/system\.h|tests/du/2g)$$
diff --git a/configure.ac b/configure.ac
index bc9933d..6407bea 100644
--- a/configure.ac
+++ b/configure.ac
@@ -162,18 +162,18 @@ int main()
time_t now = time ((time_t *) 0);
int hour_GMT0, hour_unset;
if (putenv ("TZ=GMT0") != 0)
- exit (1);
+ return 1;
hour_GMT0 = localtime (&now)->tm_hour;
unset_TZ ();
hour_unset = localtime (&now)->tm_hour;
if (putenv ("TZ=PST8") != 0)
- exit (1);
+ return 1;
if (localtime (&now)->tm_hour == hour_GMT0)
- exit (1);
+ return 1;
unset_TZ ();
if (localtime (&now)->tm_hour != hour_unset)
- exit (1);
- exit (0);
+ return 1;
+ return 0;
}]])],
[utils_cv_localtime_cache=no],
[utils_cv_localtime_cache=yes],
diff --git a/gnulib b/gnulib
index 68d757e..0baae9c 160000
--- a/gnulib
+++ b/gnulib
@@ -1 +1 @@
-Subproject commit 68d757e2cb228590d46961cbf3e9ec7d4460e335
+Subproject commit 0baae9cadd08c9704e3c704dd69fb75640293e9d
--
1.7.4.1.408.gb6b16
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [PATCH] maint.mk: allow fine-grained syntax-check exclusion via Make variables,
Jim Meyering <=