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 2816f95196d517dfc887f85178ce9c25131b0590..d233fb72bf6c3f32b8e30b7245ba3e81917e2ceb 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 f8923048d0aa46ec8f774631cee66ab4483b3500..ae280f648581df4232ac7467828386c5eb1bd5c2 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)