summaryrefslogtreecommitdiff
path: root/op.c
diff options
context:
space:
mode:
authorBrian Fraser <fraserbn@gmail.com>2011-07-11 18:50:10 +0100
committerFather Chrysostomos <sprout@cpan.org>2011-10-06 13:01:19 -0700
commite0260a5b7a4c9245402af2910213dd35717e5bd2 (patch)
tree4a8e6fe940f71045523d4f2dd71cbe94c0aa1bb9 /op.c
parenta180b31a163df6f094784ad4abcff6b8d80304d2 (diff)
downloadperl-e0260a5b7a4c9245402af2910213dd35717e5bd2.tar.gz
gv.c, op.c, pp.c: Stash-injected prototypes and prototype() are UTF-8 clean.
This makes perl -E '$::{example} = "\x{30cb}"; say prototype example;' store and fetch the correctly flagged prototype. With this, all TODO tests in gv.t pass; The next commit will deal with making the parsing of prototypes nul-clean.
Diffstat (limited to 'op.c')
-rw-r--r--op.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/op.c b/op.c
index 7335747855..64cbcb79b2 100644
--- a/op.c
+++ b/op.c
@@ -6421,6 +6421,7 @@ Perl_newATTRSUB(pTHX_ I32 floor, OP *o, OP *proto, OP *attrs, OP *block)
GV *gv;
const char *ps;
STRLEN ps_len = 0; /* init it to avoid false uninit warning from icc */
+ U32 ps_utf8 = 0;
register CV *cv = NULL;
SV *const_sv;
/* If the subroutine has no body, no attributes, and no builtin attributes
@@ -6439,6 +6440,7 @@ Perl_newATTRSUB(pTHX_ I32 floor, OP *o, OP *proto, OP *attrs, OP *block)
if (proto) {
assert(proto->op_type == OP_CONST);
ps = SvPV_const(((SVOP*)proto)->op_sv, ps_len);
+ ps_utf8 = SvUTF8(((SVOP*)proto)->op_sv);
}
else
ps = NULL;
@@ -6480,8 +6482,10 @@ Perl_newATTRSUB(pTHX_ I32 floor, OP *o, OP *proto, OP *attrs, OP *block)
}
cv_ckproto_len((const CV *)gv, NULL, ps, ps_len);
}
- if (ps)
+ if (ps) {
sv_setpvn(MUTABLE_SV(gv), ps, ps_len);
+ if ( ps_utf8 ) SvUTF8_on(MUTABLE_SV(gv));
+ }
else
sv_setiv(MUTABLE_SV(gv), -1);
@@ -6659,8 +6663,10 @@ Perl_newATTRSUB(pTHX_ I32 floor, OP *o, OP *proto, OP *attrs, OP *block)
apply_attrs(stash, MUTABLE_SV(cv), attrs, FALSE);
}
- if (ps)
+ if (ps) {
sv_setpvn(MUTABLE_SV(cv), ps, ps_len);
+ if ( ps_utf8 ) SvUTF8_on(MUTABLE_SV(cv));
+ }
if (PL_parser && PL_parser->error_count) {
op_free(block);