utf8.h: Add parens around macro param in expansion
authorKarl Williamson <khw@cpan.org>
Thu, 1 Jun 2017 16:44:08 +0000 (10:44 -0600)
committerJames E Keenan <jkeenan@cpan.org>
Thu, 1 Jun 2017 16:56:23 +0000 (12:56 -0400)
a6951642ede4abe605dcf0e94b74948e0a60a56b added an assertion to find bugs
in calling macros, and so far, instead, it found a bug in a macro.  A
parameter needs to be enclosed in parens in case it is an expression, so
that precedence works.

utf8.h

diff --git a/utf8.h b/utf8.h
index b2e338a..7b2ba14 100644 (file)
--- a/utf8.h
+++ b/utf8.h
@@ -540,9 +540,10 @@ encoded as UTF-8.  C<cp> is a native (ASCII or EBCDIC) code point if less than
                                        & UTF_CONTINUATION_MASK))
 
 /* This works in the face of malformed UTF-8. */
-#define UTF8_IS_NEXT_CHAR_DOWNGRADEABLE(s, e) (UTF8_IS_DOWNGRADEABLE_START(*s) \
-                                               && ( (e) - (s) > 1)             \
-                                               && UTF8_IS_CONTINUATION(*((s)+1)))
+#define UTF8_IS_NEXT_CHAR_DOWNGRADEABLE(s, e)                                 \
+                                       (   UTF8_IS_DOWNGRADEABLE_START(*(s))  \
+                                        && ( (e) - (s) > 1)                   \
+                                        && UTF8_IS_CONTINUATION(*((s)+1)))
 
 /* Number of bytes a code point occupies in UTF-8. */
 #define NATIVE_SKIP(uv) UVCHR_SKIP(uv)