diff options
author | Nicolas R <atoomic@cpan.org> | 2020-03-10 11:14:04 -0600 |
---|---|---|
committer | Tony Cook <tony@develop-help.com> | 2020-03-16 10:37:17 +1100 |
commit | 94c8b9c1f0f31f0e85c11a61ad166ea156ae2b3a (patch) | |
tree | fb8784fec659db0d521401acd43a18580870cffb /mg.c | |
parent | 7c1815b7942f8c7e3651d98060ca7a0760e6483c (diff) | |
download | perl-94c8b9c1f0f31f0e85c11a61ad166ea156ae2b3a.tar.gz |
Add macro to free and set cop_warnings
This is avoiding the boilerplate to free
the cop_warning string when setting it.
Diffstat (limited to 'mg.c')
-rw-r--r-- | mg.c | 32 |
1 files changed, 13 insertions, 19 deletions
@@ -2966,9 +2966,7 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg) else if (strEQ(mg->mg_ptr+1, "ARNING_BITS")) { if ( ! (PL_dowarn & G_WARN_ALL_MASK)) { if (!SvPOK(sv)) { - if (!specialWARN(PL_compiling.cop_warnings)) - PerlMemShared_free(PL_compiling.cop_warnings); - PL_compiling.cop_warnings = pWARN_STD; + free_and_set_cop_warnings(PL_compiling, pWARN_STD); break; } { @@ -2980,26 +2978,22 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg) not_all |= ptr[i] ^ 0x55; } if (!not_none) { - if (!specialWARN(PL_compiling.cop_warnings)) - PerlMemShared_free(PL_compiling.cop_warnings); - PL_compiling.cop_warnings = pWARN_NONE; + free_and_set_cop_warnings(PL_compiling, pWARN_NONE); } else if (len >= WARNsize && !not_all) { - if (!specialWARN(PL_compiling.cop_warnings)) - PerlMemShared_free(PL_compiling.cop_warnings); - PL_compiling.cop_warnings = pWARN_ALL; - PL_dowarn |= G_WARN_ONCE ; - } - else { - STRLEN len; - const char *const p = SvPV_const(sv, len); - - PL_compiling.cop_warnings - = Perl_new_warnings_bitfield(aTHX_ PL_compiling.cop_warnings, + free_and_set_cop_warnings(PL_compiling, pWARN_ALL); + PL_dowarn |= G_WARN_ONCE ; + } + else { + STRLEN len; + const char *const p = SvPV_const(sv, len); + + PL_compiling.cop_warnings + = Perl_new_warnings_bitfield(aTHX_ PL_compiling.cop_warnings, p, len); - if (isWARN_on(PL_compiling.cop_warnings, WARN_ONCE)) + if (isWARN_on(PL_compiling.cop_warnings, WARN_ONCE)) PL_dowarn |= G_WARN_ONCE ; - } + } } } |