bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: prohibit_strcmp


From: Jim Meyering
Subject: Re: prohibit_strcmp
Date: Fri, 24 Feb 2012 10:32:12 +0100

Akim Demaille wrote:
> Le 24 févr. 2012 à 10:08, Jim Meyering a écrit :
>
>> Here's a complete patch, with the additional tweak of replacing
>> the other occurrence of str''cmp with $(s_).
>
> Actually I don't think you need it.  Ironically,
> you need it only when not factoring it, and this
> gives a furious desire to factor it :)
>
> I thought this was done to avoid being matched by
> itself, but actually the pattern features \(, not
> (, so maybe it's something else?  To avoid false
> matches with plain git grep strcmp within gnulib
> itself?

Well caught!  Thank you.

It was necessary back when we hard-coded the space between "strcmp" and "(".
Once that we inserted the "*" to make that space optional, the
obfuscation became unnecessary.

Here's the delta and then the complete version:

diff --git a/top/maint.mk b/top/maint.mk
index 50d8f9e..ee721de 100644
--- a/top/maint.mk
+++ b/top/maint.mk
@@ -303,13 +303,12 @@ sc_prohibit_atoi_atof:
          $(_sc_search_regexp)

 # Use STREQ rather than comparing strcmp == 0, or != 0.
-s_ = str''cmp
-sp_ = $(s_) *\(.+\)
+sp_ = strcmp *\(.+\)
 sc_prohibit_strcmp:
-       @grep -nE '! *$(s_) *\(|\<$(sp_) *[!=]=|[!=]= *$(sp_)'          \
+       @grep -nE '! *strcmp *\(|\<$(sp_) *[!=]=|[!=]= *$(sp_)'         \
            $$($(VC_LIST_EXCEPT))                                       \
          | grep -vE ':# *define STRN?EQ\(' &&                          \
-         { echo '$(ME): replace $(s_) calls above with STREQ/STRNEQ'   \
+         { echo '$(ME): replace strcmp calls above with STREQ/STRNEQ'  \
                1>&2; exit 1; } || :

 # Pass EXIT_*, not number, to usage, exit, and error (when exiting)


>From ee9ca22d1200ba7766c934e1eb2de23baeb75b2b Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Fri, 24 Feb 2012 09:45:54 +0100
Subject: [PATCH] maint.mk: tell sc_prohibit_strcmp to ding "0 == strcmp
 (...)", too

* top/maint.mk (sc_prohibit_strcmp): Also prohibit uses of strcmp
uses with "==" *before* the call, e.g., 0 == strcmp (...)
Remove now-unnecessary str''cmp obfuscation.
Suggested by Akim Demaille.
---
 ChangeLog    |    8 ++++++++
 top/maint.mk |    5 +++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 444422e..8c7bf1e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2012-02-24  Jim Meyering  <address@hidden>
+
+       maint.mk: tell sc_prohibit_strcmp to ding "0 == strcmp (...)", too
+       * top/maint.mk (sc_prohibit_strcmp): Also prohibit uses of strcmp
+       uses with "==" *before* the call, e.g., 0 == strcmp (...)
+       Remove now-unnecessary str''cmp obfuscation.
+       Suggested by Akim Demaille.
+
 2012-02-20  Paul Eggert  <address@hidden>

        regex: fix typo in definition of MIN
diff --git a/top/maint.mk b/top/maint.mk
index 1dd6493..ee721de 100644
--- a/top/maint.mk
+++ b/top/maint.mk
@@ -303,11 +303,12 @@ sc_prohibit_atoi_atof:
          $(_sc_search_regexp)

 # Use STREQ rather than comparing strcmp == 0, or != 0.
+sp_ = strcmp *\(.+\)
 sc_prohibit_strcmp:
-       @grep -nE '! *str''cmp *\(|\<str''cmp *\(.+\) *[!=]='   \
+       @grep -nE '! *strcmp *\(|\<$(sp_) *[!=]=|[!=]= *$(sp_)'         \
            $$($(VC_LIST_EXCEPT))                                       \
          | grep -vE ':# *define STRN?EQ\(' &&                          \
-         { echo '$(ME): replace str''cmp calls above with STREQ/STRNEQ' \
+         { echo '$(ME): replace strcmp calls above with STREQ/STRNEQ'  \
                1>&2; exit 1; } || :

 # Pass EXIT_*, not number, to usage, exit, and error (when exiting)
--
1.7.9.2.235.g1d0cd



reply via email to

[Prev in Thread] Current Thread [Next in Thread]