Re: Exception to space-tab rule

2011-03-14 Thread Jim Meyering
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:

diff --git a/top/maint.mk b/top/maint.mk
index 303e9c1..0720dc7 100644
--- a/top/maint.mk
+++ b/top/maint.mk
@@ -57,11 +57,12 @@ 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 +197,12 @@ 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 from the set this Make variable:
+#
+# sc_space_tab-exclude_file_name_regexp = \.diff$

 # By default, _sc_search_regexp does not ignore case.
 export ignore_case =
@@ -233,7 +240,10 @@ define _sc_search_regexp
\
: Filter by file name;  \
if test -n $$in_files; then   \
- files=$$(find $(srcdir) | grep -E $$in_files);  \
+ _gl_exclude_re='$($@-exclude_file_name_regexp)';  \
+ test -z $$_gl_exclude_re  _gl_exclude_re='^$$';   \
+ files=$$(find $(srcdir) | grep -E $$in_files\
+  | grep -Ev $$_gl_exclude_re);  \
else
\
  files=$$($(VC_LIST_EXCEPT));  \
  if test -n $$in_vc_files; then  \


From 04cf87961db3aedf5966f3547ec19d532b131877 Mon Sep 17 00:00:00 2001
From: Jim Meyering meyer...@redhat.com
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.
* 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.
(sc_space_tab-exclude_file_name_regexp): Define variable.
(sc_bindtextdomain-exclude_file_name_regexp): Likewise.
(sc_unmarked_diagnostics-exclude_file_name_regexp): Likewise.
(sc_error_message_uppercase-exclude_file_name_regexp): 

Re: Exception to space-tab rule

2011-03-14 Thread Reuben Thomas
On 14 March 2011 14:23, Jim Meyering j...@meyering.net wrote:
 -    exit (1);
 -  exit (0);
 +    return 1;
 +  return 1;

Was that intentional? i.e. should second return be return 0?

-- 
http://rrt.sc3d.org



Re: Exception to space-tab rule

2011-03-14 Thread Jim Meyering
Reuben Thomas wrote:
 On 14 March 2011 14:23, Jim Meyering j...@meyering.net wrote:
 -    exit (1);
 -  exit (0);
 +    return 1;
 +  return 1;

 Was that intentional? i.e. should second return be return 0?

Not at all.  Thank you!
I've fixed it locally.



Re: Exception to space-tab rule

2011-03-14 Thread Eric Blake
On 03/14/2011 08:23 AM, Jim Meyering wrote:
 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:

I _love_ it!  Let's get those naming issues resolved, since using cfg.mk
for this instead of lots of new little files is very nice.

-- 
Eric Blake   ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature


Exception to space-tab rule

2011-03-13 Thread Reuben Thomas
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?

-- 
http://rrt.sc3d.org