develooper Front page | perl.perl5.porters | Postings from July 2011

Re: GSOC Status Report, Week 5

Thread Previous
Father Chrysostomos
July 3, 2011 18:36
Re: GSOC Status Report, Week 5
Message ID:

On Jul 3, 2011, at 4:06 PM, Brian Fraser wrote:

> On Sun, Jul 3, 2011 at 5:40 PM, Father Chrysostomos <> wrote:
> Concerning the SvUTF8 flag on GVs (that’s what you mean, isn’t it), I just had a look in gv.h, and I don’t see any UTF8 flag that goes in GvFLAGS. (Based on what you said earlier, I had assumed there was, without even looking.) Am I missing something?
> If I’m correct, then you can use SvUTF8(gv) itself to store the UTF8 flag and your problem is solved. Any time a GV is copied, however, you need to make sure that flag is copied too, just as for strings.
> It is; Sorry for the fuzzyness in that mail, I should've had a coffee before writing it.
> You could set the UTF8 flag on a GV, but that's problematic by itself. You end up with a proxy flag that can mean several different things, and may not even be correct; If either the stash or the gv changes, you have to change the flags on the GV, but what if you only have the stash at hand?

Yes, of course. What was I thinking? You could follow the backreferences, but that is started to get too complicated.

> It's certainly doable though. Just requires a bit more work, and I assume more discipline from extension writers - i.e."if you mess with a GV, don't forget to update the flags."
> The alternative would be to do something like this in sv.h:
> #define SvUTF8(sv)   (isGV(sv) ? ((GvNAMEUTF8(sv) || (GvSTASH(sv) && HvNAMEUTF8(GvSTASH(sv)))) ? SVf_UTF8 : 0) : (SvFLAGS(sv) & SVf_UTF8))
> ...But that's going to slow things down.

Only for GVs, which are not the common case, so it shouldn’t matter. But I think you need GvENAME and GvESTASH.

> Oh, since we are at it, question. I have a HEK. Doing this fails when it has UTF-8 data:
> hv_common(isa, NULL, HEK_KEY(canon_name), HEK_LEN(canon_name), HEK_FLAGS(canon_name), HV_FETCH_ISEXISTS, NULL, HEK_HASH(canon_name));
> But this succeeds:
> hv_common(isa, NULL, HEK_KEY(canon_name), HEK_LEN(canon_name), HEK_FLAGS(canon_name), HV_FETCH_ISEXISTS, NULL, 0);
> Does that mean that I'm storing the wrong hash somewhere?

I think so.

Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About