develooper Front page | perl.perl5.porters | Postings from September 2016

Encode.xs and sv_force_normal

Thread Next
September 29, 2016 19:32
Encode.xs and sv_force_normal
Message ID:

Look at cpan/Encode/Encode.xs for XS functions. Every one has different
check if first argument can be modified or not. Some functions have
SvPOK() check, some SvREADONLY(), SvSMAGICAL(src), SvGMAGICAL() and some

After these check every XS function calling either sv_force_normal() or
sv_mortalcopy() or sv_newmortal()+sv_copypv(). And some none.

In apidoc is documented macro SvTHINKFIRST() which I understand is that
which needs to be called for checking if sv_force_normal() is needed or

I believe that for calling sv_utf8_upgrade() is needed to call
sv_mortalcopy() first (to prevent modification of input scalar).

Can some expert look at that code if this is enough to make sv argument

if (SvTHINKFIRST(sv)) sv_force_normal(sv)

I think because of this problem in Encode (which is in core) there are
bugs like these:

(PS: please CC me as I'm not subscribed to this high volume list)

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