I am wondering if anybody can give me some feedback on the following C/CS code.
Basically I need to be able to compile a regex INTO a specific empty
SV but the api does not support passing in the SV the regexp will be
compiled into.
So I came up with the following code which swaps the bodies of the SV
that CALLREGCOMP returns with the body of the SV (which will be
SVt_NULL) which I want the regexp to be compiled into.
Can anyone see anything wrong with this? So far the C/XS hackers I've
asked do not see a problem with it.
{
/* compile the regex */
SV *referent= (SV*)CALLREGCOMP(sv_pat, flags);
SV tmp;
/* make sure the SV came from us (it should) and
* is bodyless */
assert(svtype(into)==SVt_NULL);
/* Swap the contents of the two heads. */
Copy(into, &tmp, 1, SV);
Copy((SV*)referent, into, 1, SV);
Copy(&tmp, (SV*)referent, 1, SV);
}
Thanks a lot,
Yves
--
perl -Mre=debug -e "/just|another|perl|hacker/"
Thread Next