diff options
author | gfx <gfuji@cpan.org> | 2010-04-25 22:02:09 +0200 |
---|---|---|
committer | Rafael Garcia-Suarez <rgs@consttype.org> | 2010-04-25 22:02:09 +0200 |
commit | 76f730215a330c9eedad075cf13e470e97f62846 (patch) | |
tree | c803d1e6682bedca0691094abce5a70093de46db | |
parent | 39cf747a86645fde6898cd6d09d351d50755c2fa (diff) | |
download | perl-76f730215a330c9eedad075cf13e470e97f62846.tar.gz |
Fix utf8::is_utf8 to respect GMAGIC (e.g. $1)
-rw-r--r-- | MANIFEST | 1 | ||||
-rw-r--r-- | t/op/utf8magic.t | 19 | ||||
-rw-r--r-- | universal.c | 3 |
3 files changed, 22 insertions, 1 deletions
@@ -4501,6 +4501,7 @@ t/op/unshift.t See if unshift works t/op/upgrade.t See if upgrading and assigning scalars works t/op/utf8cache.t Tests malfunctions of utf8 cache t/op/utf8decode.t See if UTF-8 decoding works +t/op/utf8magic.t See if utf8:: functions handle magic variables t/op/utfhash.t See if utf8 keys in hashes behave t/op/utftaint.t See if utf8 and taint work together t/op/vec.t See if vectors work diff --git a/t/op/utf8magic.t b/t/op/utf8magic.t new file mode 100644 index 0000000000..2c915b716e --- /dev/null +++ b/t/op/utf8magic.t @@ -0,0 +1,19 @@ +#!perl -w +use strict; +use Test::More; + +my $str = "\x{99f1}\x{99dd}"; # "camel" in Japanese kanji +$str =~ /(.)/; + +ok utf8::is_utf8($1), "is_utf8(unistr)"; +scalar "$1"; # invoke SvGETMAGIC +ok utf8::is_utf8($1), "is_utf8(unistr)"; + +utf8::encode($str); # off the utf8 flag +$str =~ /(.)/; + +ok !utf8::is_utf8($1), "is_utf8(bytes)"; +scalar "$1"; # invoke SvGETMAGIC +ok !utf8::is_utf8($1), "is_utf8(bytes)"; + +done_testing; diff --git a/universal.c b/universal.c index ce56d0becd..006baa2fed 100644 --- a/universal.c +++ b/universal.c @@ -794,7 +794,8 @@ XS(XS_utf8_is_utf8) if (items != 1) croak_xs_usage(cv, "sv"); else { - const SV * const sv = ST(0); + SV * const sv = ST(0); + SvGETMAGIC(sv); if (SvUTF8(sv)) XSRETURN_YES; else |