On Mon, Jan 26, 2004 at 04:28:23PM -0800 unkno me wrote:

> Hi,
> Does anyone how to set/unset warnings and strict from
> XS? I want to enable or disable warnings and strict
> depends on flag passed to my XS function.

For disabling strictures I would try mimicking what strict.pm does:

    SV *mask = sv_get("^H", FALSE);
    SvIVX(mask) &= ~ 0x00000602;

I don't know whether this works. Also remember that strict 'subs' and
'vars' only have a compile-time effect.

As for warnings, I had this problem recently. I have defined two macros:

    #define WARN_OFF \
        SV *oldwarn = PL_curcop->cop_warnings; \
        PL_curcop->cop_warnings = pWARN_NONE;

    #define WARN_RESTORE \
        PL_curcop->cop_warnings = oldwarn;

WARN_RESTORE has to be called in the same scope of WARN_OFF, or you make
'oldwarn' a global variable.

Nick Ing-Simmons mentioned that one could use save_item() to save the
old value of PL_curcop->cop_warnings scope-wise. That however didn't
work for me and resulted in segfaults.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval

Reply via email to