Re: Named-capture regex syntax
[p5sagit/p5-mst-13.2.git] / mg.c
diff --git a/mg.c b/mg.c
index 611bb4e..d658bbc 100644 (file)
--- a/mg.c
+++ b/mg.c
@@ -1290,6 +1290,10 @@ Perl_magic_clearsig(pTHX_ SV *sv, MAGIC *mg)
     return 0;
 }
 
+#ifndef SIG_PENDING_DIE_COUNT
+#  define SIG_PENDING_DIE_COUNT 120
+#endif
+
 static void
 S_raise_signal(pTHX_ int sig)
 {
@@ -1297,7 +1301,9 @@ S_raise_signal(pTHX_ int sig)
     /* Set a flag to say this signal is pending */
     PL_psig_pend[sig]++;
     /* And one to say _a_ signal is pending */
-    PL_sig_pending = 1;
+    if (++PL_sig_pending >= SIG_PENDING_DIE_COUNT)
+       Perl_croak(aTHX_ "Maximal count of pending signals (%lu) exceeded",
+               (unsigned long)SIG_PENDING_DIE_COUNT);
 }
 
 Signal_t
@@ -1897,8 +1903,7 @@ Perl_magic_setglob(pTHX_ SV *sv, MAGIC *mg)
 
     if (!SvOK(sv))
        return 0;
-    if (SvFLAGS(sv) & SVp_SCREAM
-       && (SvTYPE(sv) == SVt_PVGV || SvTYPE(sv) == SVt_PVGV)) {
+    if (isGV_with_GP(sv)) {
        /* We're actually already a typeglob, so don't need the stuff below.
         */
        return 0;
@@ -2117,6 +2122,7 @@ Perl_magic_setbm(pTHX_ SV *sv, MAGIC *mg)
 {
     PERL_UNUSED_ARG(mg);
     sv_unmagic(sv, PERL_MAGIC_bm);
+    SvTAIL_off(sv);
     SvVALID_off(sv);
     return 0;
 }
@@ -2629,20 +2635,20 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg)
            }
            else {
                /* Shorter than original, will be padded. */
-               Copy(s, PL_origargv[0], len, char);
-               PL_origargv[0][len] = 0;
 #ifdef PERL_DARWIN
-               /* Special case for darwin: see [perl #38868] */
-               memset(PL_origargv[0] + len + 1,
-                      (int)'\0', PL_origalen - len - 1);
+               /* Special case for Mac OS X: see [perl #38868] */
+               const int pad = 0;
 #else
                /* Is the space counterintuitive?  Yes.
                 * (You were expecting \0?)
                 * Does it work?  Seems to.  (In Linux 2.4.20 at least.)
                 * --jhi */
-               memset(PL_origargv[0] + len + 1,
-                      (int)' ',  PL_origalen - len - 1);
+               const int pad = ' ';
 #endif
+               Copy(s, PL_origargv[0], len, char);
+               PL_origargv[0][len] = 0;
+               memset(PL_origargv[0] + len + 1,
+                      pad,  PL_origalen - len - 1);
            }
            PL_origargv[0][PL_origalen-1] = 0;
            for (i = 1; i < PL_origargc; i++)