Refactor Perl_magic_setsig() to remove duplication in the function exit logic.
Nicholas Clark [Wed, 20 May 2009 20:53:31 +0000 (22:53 +0200)]
(With a lot of re-indenting, which vanishes with a whitespace ignoring diff)

mg.c

diff --git a/mg.c b/mg.c
index 55d46d2..819e105 100644 (file)
--- a/mg.c
+++ b/mg.c
@@ -1454,55 +1454,51 @@ Perl_magic_setsig(pTHX_ SV *sv, MAGIC *mg)
     if (sv && (isGV_with_GP(sv) || SvROK(sv))) {
        if (i) {
            (void)rsignal(i, PL_csighandlerp);
-#ifdef HAS_SIGPROCMASK
-           LEAVE;
-#endif
        }
        else
            *svp = SvREFCNT_inc_simple_NN(sv);
-       if(to_dec)
-           SvREFCNT_dec(to_dec);
-       return 0;
-    }
-    if (sv && SvOK(sv)) {
-       s = SvPV_force(sv, len);
     } else {
-       sv = NULL;
-    }
-    if (sv && strEQ(s,"IGNORE")) {
-       if (i) {
+       if (sv && SvOK(sv)) {
+           s = SvPV_force(sv, len);
+       } else {
+           sv = NULL;
+       }
+       if (sv && strEQ(s,"IGNORE")) {
+           if (i) {
 #ifdef FAKE_PERSISTENT_SIGNAL_HANDLERS
-           PL_sig_ignoring[i] = 1;
-           (void)rsignal(i, PL_csighandlerp);
+               PL_sig_ignoring[i] = 1;
+               (void)rsignal(i, PL_csighandlerp);
 #else
-           (void)rsignal(i, (Sighandler_t) SIG_IGN);
+               (void)rsignal(i, (Sighandler_t) SIG_IGN);
 #endif
+           }
        }
-    }
-    else if (!sv || strEQ(s,"DEFAULT") || !len) {
-       if (i) {
+       else if (!sv || strEQ(s,"DEFAULT") || !len) {
+           if (i) {
 #ifdef FAKE_DEFAULT_SIGNAL_HANDLERS
-           PL_sig_defaulting[i] = 1;
-           (void)rsignal(i, PL_csighandlerp);
+               PL_sig_defaulting[i] = 1;
+               (void)rsignal(i, PL_csighandlerp);
 #else
-           (void)rsignal(i, (Sighandler_t) SIG_DFL);
+               (void)rsignal(i, (Sighandler_t) SIG_DFL);
 #endif
+           }
+       }
+       else {
+           /*
+            * We should warn if HINT_STRICT_REFS, but without
+            * access to a known hint bit in a known OP, we can't
+            * tell whether HINT_STRICT_REFS is in force or not.
+            */
+           if (!strchr(s,':') && !strchr(s,'\''))
+               Perl_sv_insert_flags(aTHX_ sv, 0, 0, STR_WITH_LEN("main::"),
+                                    SV_GMAGIC);
+           if (i)
+               (void)rsignal(i, PL_csighandlerp);
+           else
+               *svp = SvREFCNT_inc_simple_NN(sv);
        }
     }
-    else {
-       /*
-        * We should warn if HINT_STRICT_REFS, but without
-        * access to a known hint bit in a known OP, we can't
-        * tell whether HINT_STRICT_REFS is in force or not.
-        */
-       if (!strchr(s,':') && !strchr(s,'\''))
-           Perl_sv_insert_flags(aTHX_ sv, 0, 0, STR_WITH_LEN("main::"),
-                                SV_GMAGIC);
-       if (i)
-           (void)rsignal(i, PL_csighandlerp);
-       else
-           *svp = SvREFCNT_inc_simple_NN(sv);
-    }
+
 #ifdef HAS_SIGPROCMASK
     if(i)
        LEAVE;