This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
handy.h: Add parens around macro expansion
authorKarl Williamson <khw@cpan.org>
Mon, 24 Apr 2017 19:09:16 +0000 (13:09 -0600)
committerKarl Williamson <khw@cpan.org>
Tue, 24 Oct 2017 16:15:33 +0000 (10:15 -0600)
This guarantees the expected precedence no matter what the context it is
called in.

handy.h

diff --git a/handy.h b/handy.h
index bd1d75a..2999b3c 100644 (file)
--- a/handy.h
+++ b/handy.h
@@ -490,7 +490,7 @@ Returns zero if non-equal, or non-zero if equal.
 /* memEQ and memNE where second comparand is a string constant */
 #define memEQs(s1, l, s2) \
         (((sizeof(s2)-1) == (l)) && memEQ((s1), ("" s2 ""), (sizeof(s2)-1)))
-#define memNEs(s1, l, s2) !memEQs(s1, l, s2)
+#define memNEs(s1, l, s2) (! memEQs(s1, l, s2))
 
 /* memEQ and memNE where second comparand is a string constant
  * and we can assume the length of s1 is at least that of the string */