[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] maint.mk: prohibit use of "can not"
From: |
Jim Meyering |
Subject: |
Re: [PATCH] maint.mk: prohibit use of "can not" |
Date: |
Wed, 11 May 2011 10:58:23 +0200 |
Jim Meyering wrote:
> Eric Blake wrote:
>
>> On 04/09/2011 03:02 PM, Jim Meyering wrote:
>>> There was a new use of "can not" in coreutils despite
>>> my having performed this transformation before.
>>> Autoconf is the same: one current/new violation,
>>> in spite of applying the fix before.
>>> I noticed that James Youngman recently fixed one in findutils
>>> and there are several here in gnulib.
>>>
>>> With this, new offenses will be less likely.
>>>
>>>>From 2ba828d7b521d831648a4d0926d7885705cf1d59 Mon Sep 17 00:00:00 2001
>>> From: Jim Meyering <address@hidden>
>>> Date: Sat, 9 Apr 2011 22:58:06 +0200
>>> Subject: [PATCH] maint.mk: prohibit use of "can not"
>>>
>>> * top/maint.mk (sc_prohibit_can_not): New rule.
>>> Writing "can not" (rather than "cannot") is too common. Prohibit it.
>>
>> A recent libvirt patch demonstrated that this rule currently misses
>> "can\n not"; should sc_prohibit_can_not be rewritten in the same style
>> as sc_prohibit_doubled_word to also catch violations that are currently
>> hidden by line-wrapping?
>
> Yes, I'd planned to do that.
> With the patch below, I've generalized the rule and variable names,
> so that if we identify other undesirable sequences of words, this is
> where we can add them.
>
> Here's what I've just pushed:
...
> Subject: [PATCH] maint.mk: improve "can not" detection and generalize rule
> name
>
> * top/maint.mk (sc_prohibit_misc): Renamed from sc_prohibit_can_not,
> since we'll probably add a few more word pairs here.
> Use the same technique as in sc_prohibit_doubled_word, so that
> we recognize "can not" also when the words are separated by a newline.
> Suggested by Eric Blake.
> (perl_filename_lineno_text_): Define. Factored out of...
> (prohibit_doubled_word_): ...here. Use the new definition.
> (prohibit_misc_): New var. Use it here, too.
> (prohibit_misc_RE_): New overridable variable.
The name "misc" grated.
Plus, I'd omitted the corresponding ignore_ variable.
Now, with better names and that fix:
>From d48feb15b4580be907f374c5994c570176669a9e Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Wed, 11 May 2011 10:41:23 +0200
Subject: [PATCH] maint.mk: adjust previous commit
Change "misc" in names to "undesirable_word_seq".
"misc" is rarely desirable, in a name ;-)
Define and use ignore_undesirable_word_sequence_RE_ properly.
---
ChangeLog | 9 +++++----
top/maint.mk | 19 ++++++++++++-------
2 files changed, 17 insertions(+), 11 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 00e42d5..cbe24ca 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,15 +1,16 @@
2011-05-11 Jim Meyering <address@hidden>
maint.mk: improve "can not" detection and generalize rule name
- * top/maint.mk (sc_prohibit_misc): Renamed from sc_prohibit_can_not,
- since we'll probably add a few more word pairs here.
+ * top/maint.mk (sc_prohibit_undesirable_word_seq): Renamed from
+ sc_prohibit_can_not, since we'll probably add a few more word pairs
here.
Use the same technique as in sc_prohibit_doubled_word, so that
we recognize "can not" also when the words are separated by a newline.
Suggested by Eric Blake.
(perl_filename_lineno_text_): Define. Factored out of...
(prohibit_doubled_word_): ...here. Use the new definition.
- (prohibit_misc_): New var. Use it here, too.
- (prohibit_misc_RE_): New overridable variable.
+ (prohibit_undesirable_word_seq_): New var. Use it here, too.
+ (prohibit_undesirable_word_seq_RE_): New overridable variable.
+ (ignore_undesirable_word_sequence_RE_): New overridable variable.
2011-05-10 Eric Blake <address@hidden>
diff --git a/top/maint.mk b/top/maint.mk
index bb4354f..4088a79 100644
--- a/top/maint.mk
+++ b/top/maint.mk
@@ -868,16 +868,21 @@ sc_prohibit_doubled_word:
# A regular expression matching undesirable combinations of words like
# "can not"; this matches them even when the two words appear on different
# lines, but not when there is an intervening delimiter like "#" or "*".
-prohibit_misc_RE_ ?= \
+prohibit_undesirable_word_seq_RE_ ?= \
/\bcan\s+not\b/gims
-prohibit_misc_ = \
- -e 'while ($(prohibit_misc_RE_))' \
+prohibit_undesirable_word_seq_ = \
+ -e 'while ($(prohibit_undesirable_word_seq_RE_))' \
$(perl_filename_lineno_text_)
+# Define this to a regular expression that matches
+# any filename:dd:match lines you want to ignore.
+# The default is to ignore no matches.
+ignore_undesirable_word_sequence_RE_ ?= ^$$
-sc_prohibit_misc:
- @perl -n -0777 $(prohibit_misc_) $$($(VC_LIST_EXCEPT)) \
- | grep -vE '$(prohibit_misc_RE_)' \
- | grep . && { echo '$(ME): undesirable words' 1>&2; exit 1; } || :
+sc_prohibit_undesirable_word_seq:
+ @perl -n -0777 $(prohibit_undesirable_word_seq_) \
+ $$($(VC_LIST_EXCEPT)) \
+ | grep -vE '$(ignore_undesirable_word_sequence_RE_)' | grep . \
+ && { echo '$(ME): undesirable word sequence' >&2; exit 1; } || :
_ptm1 = use "test C1 && test C2", not "test C1 -''a C2"
_ptm2 = use "test C1 || test C2", not "test C1 -''o C2"
--
1.7.5.1.354.g761178