summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2001-04-18 19:06:05 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2001-04-18 19:06:05 +0000
commit209a9bc1bcfe078e350f0f6efa8375fce6dcbb44 (patch)
treec2a0f03103452f6a54bc214dfe6dc6062a6cec59
parenta0405c928fce3c813775d09acdf2325ec8e1b2ed (diff)
downloadperl-209a9bc1bcfe078e350f0f6efa8375fce6dcbb44.tar.gz
Workaround for the "\x{12345678}" plus s/(.)/$1/g plus ord/length
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
-rwxr-xr-xt/op/pat.t11
-rw-r--r--utf8.c12
2 files changed, 21 insertions, 2 deletions
diff --git a/t/op/pat.t b/t/op/pat.t
index 1d2e632e6a..9130454dcb 100755
--- a/t/op/pat.t
+++ b/t/op/pat.t
@@ -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 785047e673..1694c0d5aa 100644
--- 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++;