[PATCH] perlcommunity.pod: add information about OSDC.fr
[p5sagit/p5-mst-13.2.git] / util.c
diff --git a/util.c b/util.c
index dc1a26f..f60f3d0 100644 (file)
--- a/util.c
+++ b/util.c
@@ -1361,7 +1361,6 @@ S_vdie(pTHX_ const char* pat, va_list *args)
 {
     dVAR;
     const char *message;
-    const int was_in_eval = PL_in_eval;
     STRLEN msglen;
     I32 utf8 = 0;
 
@@ -1369,9 +1368,9 @@ S_vdie(pTHX_ const char* pat, va_list *args)
 
     PL_restartop = die_where(message, msglen);
     SvFLAGS(ERRSV) |= utf8;
-    if ((!PL_restartop && was_in_eval) || PL_top_env->je_prev)
-       JMPENV_JUMP(3);
-    return PL_restartop;
+    JMPENV_JUMP(3);
+    /* NOTREACHED */
+    return NULL;
 }
 
 #if defined(PERL_IMPLICIT_CONTEXT)
@@ -1602,21 +1601,7 @@ Perl_ckwarn(pTHX_ U32 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)));
+    return ckwarn_common(w);
 }
 
 /* implements the ckWARN?_d macro */
@@ -1629,19 +1614,38 @@ Perl_ckwarn_d(pTHX_ U32 w)
     if (isLEXWARN_off)
        return TRUE;
 
+    return ckwarn_common(w);
+}
+
+static bool
+S_ckwarn_common(pTHX_ U32 w)
+{
     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)));
+    /* 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.  */
+    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.  */
@@ -6049,17 +6053,14 @@ Perl_my_dirfd(pTHX_ DIR * dir) {
 
 REGEXP *
 Perl_get_re_arg(pTHX_ SV *sv) {
-    SV    *tmpsv;
 
     if (sv) {
         if (SvMAGICAL(sv))
             mg_get(sv);
-        if (SvROK(sv) &&
-            (tmpsv = MUTABLE_SV(SvRV(sv))) &&            /* assign deliberate */
-            SvTYPE(tmpsv) == SVt_REGEXP)
-        {
-            return (REGEXP*) tmpsv;
-        }
+        if (SvROK(sv))
+           sv = MUTABLE_SV(SvRV(sv));
+        if (SvTYPE(sv) == SVt_REGEXP)
+            return (REGEXP*) sv;
     }
  
     return NULL;