This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
utf8.h: Make sure char* is cast to U8* for unsigned comparison
authorKarl Williamson <public@khwilliamson.com>
Mon, 24 Dec 2012 02:04:30 +0000 (19:04 -0700)
committerKarl Williamson <public@khwilliamson.com>
Mon, 24 Dec 2012 02:39:05 +0000 (19:39 -0700)
If a char* is passed prior to this commit, an above-ASCII char could
have been considered negative instead of positive, and thus screwed up
these tests

utf8.h

diff --git a/utf8.h b/utf8.h
index 5aac904..5be352e 100644 (file)
--- a/utf8.h
+++ b/utf8.h
@@ -375,11 +375,12 @@ Perl's extended UTF-8 means we can have start bytes up to FF.
  * U+110001: \xF4\x90\x80\x81  \xF9\xA2\xA0\xA0\xA1
  */
 #ifdef EBCDIC /* Both versions assume well-formed UTF8 */
  * U+110001: \xF4\x90\x80\x81  \xF9\xA2\xA0\xA0\xA1
  */
 #ifdef EBCDIC /* Both versions assume well-formed UTF8 */
-#   define UTF8_IS_SUPER(s)  (NATIVE_TO_I8(*(s)) >= 0xF9                       \
-      && (NATIVE_TO_I8(*(s)) > 0xF9) || (NATIVE_TO_I8(*((s)) + 1 >= 0xA2)))
+#   define UTF8_IS_SUPER(s)  (NATIVE_TO_I8(* (U8*) (s)) >= 0xF9                 \
+                              && (NATIVE_TO_I8(* (U8*) (s)) > 0xF9              \
+                                  || (NATIVE_TO_I8(* (U8*) ((s)) + 1 >= 0xA2))))
 #else
 #else
-#   define UTF8_IS_SUPER(s)  (*(s) >= 0xF4                                      \
-                                       && (*(s) > 0xF4 || (*((s) + 1) >= 0x90)))
+#   define UTF8_IS_SUPER(s) (*(U8*) (s) >= 0xF4                                 \
+                            && (*(U8*) (s) > 0xF4 || (*((U8*) (s) + 1) >= 0x90)))
 #endif
 
 /* These are now machine generated, and the 'given' clause is no longer
 #endif
 
 /* These are now machine generated, and the 'given' clause is no longer