This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
utf8.c: Silence compiler warning
authorKarl Williamson <khw@cpan.org>
Fri, 25 Nov 2016 15:35:30 +0000 (08:35 -0700)
committerKarl Williamson <khw@cpan.org>
Sun, 11 Dec 2016 21:33:47 +0000 (14:33 -0700)
This was generating a "comparison between signed and unsigned integer
expression" warning

utf8.c

diff --git a/utf8.c b/utf8.c
index 8ab38ea..f748c20 100644 (file)
--- a/utf8.c
+++ b/utf8.c
@@ -430,6 +430,12 @@ S_does_utf8_overflow(const U8 * const s, const U8 * e)
     const U8 *x;
     const U8 * y = (const U8 *) HIGHEST_REPRESENTABLE_UTF8;
 
+#if ! defined(UV_IS_QUAD) && ! defined(EBCDIC)
+
+    const STRLEN len = e - s;
+
+#endif
+
     /* Returns a boolean as to if this UTF-8 string would overflow a UV on this
      * platform, that is if it represents a code point larger than the highest
      * representable code point.  (For ASCII platforms, we could use memcmp()
@@ -449,10 +455,10 @@ S_does_utf8_overflow(const U8 * const s, const U8 * e)
     /* On 32 bit ASCII machines, many overlongs that start with FF don't
      * overflow */
 
-    if (isFF_OVERLONG(s, e - s)) {
+    if (isFF_OVERLONG(s, len)) {
         const U8 max_32_bit_overlong[] = "\xFF\x80\x80\x80\x80\x80\x80\x84";
         return memGE(s, max_32_bit_overlong,
-                                MIN(e - s, sizeof(max_32_bit_overlong) - 1));
+                                MIN(len, sizeof(max_32_bit_overlong) - 1));
     }
 
 #endif