File Coverage

hax/cop_warnings.c.inc
Criterion Covered Total %
statement 8 8 100.0
branch 3 6 50.0
condition n/a
subroutine n/a
pod n/a
total 11 14 78.5


line stmt bran cond sub pod time code
1             /* vi: set ft=c : */
2              
3             /* TODO: This only adds cop_disable_warning. Still need to add
4             * cop_has_warning
5             * cop_enable_warning
6             */
7              
8             #ifndef Perl_Warn_Off_
9             # define Perl_Warn_Off_(x) ((x) / 8)
10             # define Perl_Warn_Bit_(x) (1 << ((x) % 8))
11             #endif
12              
13             #ifndef cop_disable_warning
14             # define cop_disable_warning(cop, warn_bit) S_cop_disable_warning(aTHX_ cop, warn_bit)
15 2           void S_cop_disable_warning(pTHX_ COP *cop, int warn_bit)
16             {
17             #if HAVE_PERL_VERSION(5,37,6)
18             /* cop_warnings no longer has the weird STRLEN prefix on it
19             * https://github.com/Perl/perl5/pull/20469
20             */
21 2           char *warnings = cop->cop_warnings;
22             # define WARNING_BITS warnings
23             #else
24             STRLEN *warnings = cop->cop_warnings;
25             # define WARNING_BITS (char *)(warnings + 1)
26             #endif
27             char *warning_bits;
28              
29 2 50         if(warnings == pWARN_NONE)
30             return;
31              
32 2 50         if(warnings == pWARN_STD)
33             /* TODO: understand what STD vs ALL means */
34             warning_bits = WARN_ALLstring;
35 2 50         else if(warnings == pWARN_ALL)
36             warning_bits = WARN_ALLstring;
37             else
38             warning_bits = WARNING_BITS;
39              
40 2           warnings = Perl_new_warnings_bitfield(aTHX_ warnings, warning_bits, WARNsize);
41 2           cop->cop_warnings = warnings;
42              
43             warning_bits = WARNING_BITS;
44 2           warning_bits[Perl_Warn_Off_(2*warn_bit)] &= ~Perl_Warn_Bit_(2*warn_bit);
45              
46             #undef WARNING_BITS
47             }
48             #endif