This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Parenthesize macro arguments to ninstr()
authorKarl Williamson <khw@cpan.org>
Fri, 15 Sep 2017 03:58:14 +0000 (21:58 -0600)
committerKarl Williamson <khw@cpan.org>
Fri, 15 Sep 2017 04:19:53 +0000 (22:19 -0600)
This did not work properly if called if expressions for arguments.

Could someone write a porting test to look for non-parenthesized macro
arguments involved in expressions

util.h

diff --git a/util.h b/util.h
index 6b63d90..0b6b59a 100644 (file)
--- a/util.h
+++ b/util.h
@@ -243,7 +243,8 @@ means arg not present, 1 is empty string/null byte */
 
 #ifdef HAS_MEMMEM
 #   define ninstr(big, bigend, little, lend)                                \
-            ((char *) memmem(big, bigend - big, little, lend - little))
+            ((char *) memmem((big), (bigend) - (big),                       \
+                             (little), (lend) - (little)))
 #endif
 
 #if defined(HAS_MKSTEMP) && defined(PERL_CORE)