Workaround for the "\x{12345678}" plus s/(.)/$1/g plus ord/length
authorJarkko Hietaniemi <jhi@iki.fi>
Wed, 18 Apr 2001 19:06:05 +0000 (19:06 +0000)
committerJarkko Hietaniemi <jhi@iki.fi>
Wed, 18 Apr 2001 19:06:05 +0000 (19:06 +0000)
bug noticed by Robin Houston; basically the code of detecting
value wraparound was acting differently under different compilers
and platforms.  The workaround is to remove the overflow check
for now, a real fix would be to do the overflow (portably) right.

p4raw-id: //depot/perl@9740

t/op/pat.t
utf8.c

index 1d2e632..9130454 100755 (executable)
@@ -5,7 +5,7 @@
 # that does fit that format, add it to op/re_tests, not here.
 
 $| = 1;
-print "1..586\n";
+print "1..587\n";
 
 BEGIN {
     chdir 't' if -d 't';
@@ -1574,3 +1574,12 @@ EOT
        print "ok " . $test++ . "\n";
     }
 }
+
+{
+    # from Robin Houston
+
+    my $x = "\x{12345678}";
+    $x =~ s/(.)/$1/g;
+    print "not " unless ord($x) == 0x12345678 && length($x) == 1;
+    print "ok 587\n";
+}
diff --git a/utf8.c b/utf8.c
index 785047e..1694c0d 100644 (file)
--- a/utf8.c
+++ b/utf8.c
@@ -170,8 +170,13 @@ Perl_is_utf8_char(pTHX_ U8 *s)
        if (!UTF8_IS_CONTINUATION(*s))
            return 0;
        uv = UTF8_ACCUMULATE(uv, *s);
-       if (uv < ouv)
+#if 0
+       /* Depending on the compiler the wrap of the value takig pladve
+        * between 5 and 6 bytes of UTF-8 encoding either works or not.
+        * See similar spot in utf8_to_uvuni(). --jhi */
+       if (uv < ouv) 
            return 0;
+#endif
        ouv = uv;
        s++;
     }
@@ -342,9 +347,14 @@ Perl_utf8n_to_uvuni(pTHX_ U8 *s, STRLEN curlen, STRLEN *retlen, U32 flags)
                }
            }
            else { /* uv < ouv */
+#if 0
+       /* Depending on the compiler the wrap of the value takig pladve
+        * between 5 and 6 bytes of UTF-8 encoding either works or not.
+        * See similar spot in is_utf8_char(). --jhi */
                /* This cannot be allowed. */
                warning = UTF8_WARN_OVERFLOW;
                goto malformed;
+#endif
            }
        }
        s++;