maint.mk: improve sc_prohibit_strcmp regex
authorEric Blake <eblake@redhat.com>
Thu, 6 Jan 2011 21:24:57 +0000 (14:24 -0700)
committerEric Blake <eblake@redhat.com>
Fri, 7 Jan 2011 00:08:15 +0000 (17:08 -0700)
* top/maint.mk (sc_prohibit_strcmp): Detect strcmp()!=0, as
documented.  Also, detect strcmp((expr),expr) == 0.  Exempt the
definition of STRNEQ.

Signed-off-by: Eric Blake <eblake@redhat.com>
ChangeLog
top/maint.mk

index 2816f95..d233fb7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2011-01-06  Eric Blake  <eblake@redhat.com>
 
+       maint.mk: improve sc_prohibit_strcmp regex
+       * top/maint.mk (sc_prohibit_strcmp): Detect strcmp()!=0, as
+       documented.  Also, detect strcmp((expr),expr) == 0.  Exempt the
+       definition of STRNEQ.
+
        signal: work around Haiku issue with SIGBUS
        * lib/siglist.h: Add comment.
        * lib/sig2str.c (numname_table): Swap SIGBUS order, to match
index f892304..ae280f6 100644 (file)
@@ -292,10 +292,10 @@ sc_prohibit_atoi_atof:
 
 # Use STREQ rather than comparing strcmp == 0, or != 0.
 sc_prohibit_strcmp:
-       @grep -nE '! *str''cmp *\(|\<str''cmp *\([^)]+\) *=='           \
+       @grep -nE '! *str''cmp *\(|\<str''cmp *\(.+\) *[!=]='   \
            $$($(VC_LIST_EXCEPT))                                       \
-         | grep -vE ':# *define STREQ\(' &&                            \
-         { echo '$(ME): use STREQ in place of the above uses of str''cmp' \
+         | grep -vE ':# *define STRN?EQ\(' &&                          \
+         { echo '$(ME): replace str''cmp calls above with STREQ/STRNEQ' \
                1>&2; exit 1; } || :
 
 # Pass EXIT_*, not number, to usage, exit, and error (when exiting)