do subname() is deprecated, so update this hunk of test dating from perl 1.
[p5sagit/p5-mst-13.2.git] / util.c
diff --git a/util.c b/util.c
index 13b56a0..b72f263 100644 (file)
--- a/util.c
+++ b/util.c
@@ -1627,15 +1627,26 @@ S_ckwarn_common(pTHX_ U32 w)
     if (PL_curcop->cop_warnings == pWARN_NONE)
        return FALSE;
 
+    /* Check the assumption that at least the first slot is non-zero.  */
+    assert(unpackWARN1(w));
+
+    /* Check the assumption that it is valid to stop as soon as a zero slot is
+       seen.  */
+    if (!unpackWARN2(w)) {
+       assert(!unpackWARN3(w));
+       assert(!unpackWARN4(w));
+    } else if (!unpackWARN3(w)) {
+       assert(!unpackWARN4(w));
+    }
+       
     /* 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)));
+    do {
+       if (isWARN_on(PL_curcop->cop_warnings, unpackWARN1(w)))
+           return TRUE;
+    } while (w >>= WARNshift);
+
+    return FALSE;
 }
 
 /* Set buffer=NULL to get a new one.  */