Change 13316 by jhi@alpha on 2001/11/27 14:26:25
Fix for
Subject: [ID 20011127.151] regex result vars no longer marked as utf8
From: Marc Lehmann <[EMAIL PROTECTED]>
Date: Tue, 27 Nov 2001 14:27:14 +0100
Message-Id: <[EMAIL PROTECTED]>
Affected files ...
.... //depot/perl/ext/Encode.t#3 edit
.... //depot/perl/ext/Encode/Encode.xs#37 edit
Differences ...
==== //depot/perl/ext/Encode.t#3 (text) ====
Index: perl/ext/Encode.t
--- perl/ext/Encode.t.~1~ Tue Nov 27 07:30:05 2001
+++ perl/ext/Encode.t Tue Nov 27 07:30:05 2001
@@ -8,7 +8,9 @@
}
}
use Test;
-use Encode qw(from_to encode decode encode_utf8 decode_utf8 find_encoding);
+use Encode qw(from_to encode decode
+ encode_utf8 decode_utf8
+ find_encoding is_utf8);
use charnames qw(greek);
my @encodings = grep(/iso-?8859/,Encode::encodings());
my $n = 2;
@@ -16,7 +18,7 @@
my @source = qw(ascii iso8859-1 cp1250);
my @destiny = qw(cp1047 cp37 posix-bc);
my @ebcdic_sets = qw(cp1047 cp37 posix-bc);
-plan test => 38+$n*@encodings + 2*@source*@destiny*@character_set +
2*@ebcdic_sets*256;
+plan test => 38+$n*@encodings + 2*@source*@destiny*@character_set +
+2*@ebcdic_sets*256 + 6;
my $str = join('',map(chr($_),0x20..0x7E));
my $cpy = $str;
ok(length($str),from_to($cpy,'iso8859-1','Unicode'),"Length Wrong");
@@ -120,3 +122,19 @@
}
+# is_utf8
+
+ok( is_utf8("\x{100}"));
+ok(! is_utf8("a"));
+ok(! is_utf8(""));
+"\x{100}" =~ /(.)/;
+ok( is_utf8($1)); # ID 20011127.151
+$a = $1;
+ok( is_utf8($a));
+$a = "\x{100}";
+chop $a;
+ok( is_utf8($a)); # weird but true: an empty UTF-8 string
+
+
+
+
==== //depot/perl/ext/Encode/Encode.xs#37 (text) ====
Index: perl/ext/Encode/Encode.xs
--- perl/ext/Encode/Encode.xs.~1~ Tue Nov 27 07:30:05 2001
+++ perl/ext/Encode/Encode.xs Tue Nov 27 07:30:05 2001
@@ -613,6 +613,8 @@
bool check
CODE:
{
+ if (SvGMAGICAL(sv)) /* it could be $1, for example */
+ sv = newSVsv(sv); /* GMAGIG will be done */
if (SvPOK(sv)) {
RETVAL = SvUTF8(sv) ? TRUE : FALSE;
if (RETVAL &&
@@ -622,6 +624,8 @@
} else {
RETVAL = FALSE;
}
+ if (sv != ST(0))
+ SvREFCNT_dec(sv); /* it was a temp copy */
}
OUTPUT:
RETVAL
End of Patch.