From: Jim Meyering Date: Sun, 10 Apr 2011 08:26:46 +0000 (+0200) Subject: maint.mk: prohibit doubled words X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a81348d2e136b0f2de110b49a5d0dfa5d7d76f71;p=pspp maint.mk: prohibit doubled words Detect them also when they're separated by a newline. There are 3 ways to customize it: - disable the test on a per file basis, as usual with rules using $(VC_LIST_EXCEPT) - replace the default doubled-word-selecting regexp (affects all files) - ignore a particular file-vs-doubled-word match I nearly used that last one to ignore the "is is" match in coreutils' NEWS file, since the text was "ls -is is ..." To do that, I would have added this line to cfg.mk: ignore_doubled_word_match_RE_ = ^NEWS:[0-9]+:is[ ]is$ but it would have ignored any "is is" match in NEWS. Low probability, but still... Instead, I changed the text, slightly: - ls -is is now consistent with ls -lis in ignoring values returned + "ls -is" is now consistent with ls -lis in ignoring values returned * top/maint.mk (prohibit_double_word_RE_): Provide default. (prohibit_doubled_word_): Define. (sc_prohibit_doubled_word): New rule. (sc_prohibit_the_the): Remove. Subsumed by the above. --- diff --git a/ChangeLog b/ChangeLog index 110cee574d..365dd2f658 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,26 @@ +2011-04-10 Jim Meyering + + maint.mk: prohibit doubled words + Detect them also when they're separated by a newline. + There are 3 ways to customize it: + - disable the test on a per file basis, as usual with rules using + $(VC_LIST_EXCEPT) + - replace the default doubled-word-selecting regexp (affects all files) + - ignore a particular file-vs-doubled-word match + I nearly used that last one to ignore the "is is" match in + coreutils' NEWS file, since the text was "ls -is is ..." + To do that, I would have added this line to cfg.mk: + ignore_doubled_word_match_RE_ = ^NEWS:[0-9]+:is[ ]is$ + but it would have ignored any "is is" match in NEWS. + Low probability, but still... + Instead, I changed the text, slightly: + - ls -is is now consistent with ls -lis in ignoring values returned + + "ls -is" is now consistent with ls -lis in ignoring values returned + * top/maint.mk (prohibit_double_word_RE_): Provide default. + (prohibit_doubled_word_): Define. + (sc_prohibit_doubled_word): New rule. + (sc_prohibit_the_the): Remove. Subsumed by the above. + 2011-04-10 Jim Meyering maint: fix doubled-word typo in comment diff --git a/top/maint.mk b/top/maint.mk index ada00be4dc..07a7773b9f 100644 --- a/top/maint.mk +++ b/top/maint.mk @@ -841,10 +841,25 @@ sc_prohibit_S_IS_definition: halt='do not define S_IS* macros; include ' \ $(_sc_search_regexp) -sc_prohibit_the_the: - @prohibit='\' \ - halt='avoid double "the"' \ - $(_sc_search_regexp) +prohibit_doubled_word_RE_ ?= \ + /\b(then?|[iao]n|i[fst]|but|f?or|at|and|[dt]o)\s+\1\b/gims +prohibit_doubled_word_ = \ + -e 'while ($(prohibit_doubled_word_RE_))' \ + -e ' {' \ + -e ' $$n = ($$` =~ tr/\n/\n/ + 1);' \ + -e ' ($$v = $$&) =~ s/\n/\\n/g;' \ + -e ' print "$$ARGV:$$n:$$v\n";' \ + -e ' }' + +# 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_doubled_word_match_RE_ ?= ^$$ + +sc_prohibit_doubled_word: + @perl -n -0777 $(prohibit_doubled_word_) $$($(VC_LIST_EXCEPT)) \ + | grep -vE '$(ignore_doubled_word_match_RE_)' \ + | grep . && { echo '$(ME): doubled words' 1>&2; exit 1; } || : sc_prohibit_can_not: @prohibit='\' \