diff options
author | Nicholas Clark <nick@ccl4.org> | 2009-10-13 11:30:14 +0100 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2009-10-13 11:30:14 +0100 |
commit | ad287e37d27b33d67ab22c0c8a7294f1eb467342 (patch) | |
tree | 908ba734d7f993bba674dcb398adc9920149d844 /util.c | |
parent | 2acdbac104deb9113282247f3dbee83c4705a525 (diff) | |
download | perl-ad287e37d27b33d67ab22c0c8a7294f1eb467342.tar.gz |
In Perl_ckwarn() and Perl_ckwarn_d() disentangle the complex conditionals.
It's much easier to see what is going on, if we use multiple return statements.
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 66 |
1 files changed, 36 insertions, 30 deletions
@@ -1598,20 +1598,25 @@ bool Perl_ckwarn(pTHX_ U32 w) { dVAR; - return isLEXWARN_on - ? (PL_curcop->cop_warnings != pWARN_NONE - && ( - PL_curcop->cop_warnings == pWARN_ALL - || isWARN_on(PL_curcop->cop_warnings, unpackWARN1(w)) - || (unpackWARN2(w) && - isWARN_on(PL_curcop->cop_warnings, unpackWARN2(w))) - || (unpackWARN3(w) && - isWARN_on(PL_curcop->cop_warnings, unpackWARN3(w))) - || (unpackWARN4(w) && - isWARN_on(PL_curcop->cop_warnings, unpackWARN4(w))) - ) - ) - : (PL_dowarn & G_WARN_ON); + /* If lexical warnings have not been set, use $^W. */ + if (isLEXWARN_off) + return PL_dowarn & G_WARN_ON; + + if (PL_curcop->cop_warnings == pWARN_ALL) + return TRUE; + + if (PL_curcop->cop_warnings == pWARN_NONE) + return FALSE; + + /* Right, dealt with all the special cases, which are implemented as non- + pointers, so there is a pointer to a real warnings mask. */ + return isWARN_on(PL_curcop->cop_warnings, unpackWARN1(w)) + || (unpackWARN2(w) && + isWARN_on(PL_curcop->cop_warnings, unpackWARN2(w))) + || (unpackWARN3(w) && + isWARN_on(PL_curcop->cop_warnings, unpackWARN3(w))) + || (unpackWARN4(w) && + isWARN_on(PL_curcop->cop_warnings, unpackWARN4(w))); } /* implements the ckWARN?_d macro */ @@ -1620,22 +1625,23 @@ bool Perl_ckwarn_d(pTHX_ U32 w) { dVAR; - return - isLEXWARN_off - || PL_curcop->cop_warnings == pWARN_ALL - || ( - PL_curcop->cop_warnings != pWARN_NONE - && ( - isWARN_on(PL_curcop->cop_warnings, unpackWARN1(w)) - || (unpackWARN2(w) && - isWARN_on(PL_curcop->cop_warnings, unpackWARN2(w))) - || (unpackWARN3(w) && - isWARN_on(PL_curcop->cop_warnings, unpackWARN3(w))) - || (unpackWARN4(w) && - isWARN_on(PL_curcop->cop_warnings, unpackWARN4(w))) - ) - ) - ; + /* If lexical warnings have not been set then default classes warn. */ + if (isLEXWARN_off) + return TRUE; + + if (PL_curcop->cop_warnings == pWARN_ALL) + return TRUE; + + if (PL_curcop->cop_warnings == pWARN_NONE) + return FALSE; + + return isWARN_on(PL_curcop->cop_warnings, unpackWARN1(w)) + || (unpackWARN2(w) && + isWARN_on(PL_curcop->cop_warnings, unpackWARN2(w))) + || (unpackWARN3(w) && + isWARN_on(PL_curcop->cop_warnings, unpackWARN3(w))) + || (unpackWARN4(w) && + isWARN_on(PL_curcop->cop_warnings, unpackWARN4(w))); } /* Set buffer=NULL to get a new one. */ |