This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
regcomp.c: Fix wrong type for format
[perl5.git] / mg.c
diff --git a/mg.c b/mg.c
index 71f650c..cd1f57d 100644 (file)
--- a/mg.c
+++ b/mg.c
@@ -41,6 +41,7 @@ tie.
 #include "EXTERN.h"
 #define PERL_IN_MG_C
 #include "perl.h"
+#include "feature.h"
 
 #if defined(HAS_GETGROUPS) || defined(HAS_SETGROUPS)
 #  ifdef I_GRP
@@ -62,13 +63,6 @@ tie.
 #  include <sys/prctl.h>
 #endif
 
-
-#ifdef PERL_USE_3ARG_SIGHANDLER
-Signal_t Perl_csighandler(int sig, Siginfo_t *, void *);
-#else
-Signal_t Perl_csighandler(int sig);
-#endif
-
 #ifdef __Lynx__
 /* Missing protos on LynxOS */
 void setruid(uid_t id);
@@ -1036,9 +1030,6 @@ Perl_magic_get(pTHX_ SV *sv, MAGIC *mg)
         if (nextchar == '\0') {
             sv_setiv(sv, (IV)PL_maxsysfd);
         }
-        else if (strEQ(remaining, "EATURE_BITS")) {
-            sv_setuv(sv, PL_compiling.cop_features);
-        }
        break;
     case '\007':               /* ^GLOBAL_PHASE */
        if (strEQ(remaining, "LOBAL_PHASE")) {
@@ -1762,7 +1753,8 @@ Perl_magic_setsig(pTHX_ SV *sv, MAGIC *mg)
               Ideally we'd find some way of making SVs at (C) compile time, or
               at least, doing most of the work.  */
            if (!PL_psig_name[i]) {
-               PL_psig_name[i] = newSVpvn(s, len);
+               const char* name = PL_sig_name[i];
+               PL_psig_name[i] = newSVpvn(name, strlen(name));
                SvREADONLY_on(PL_psig_name[i]);
            }
        } else {
@@ -2893,9 +2885,6 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg)
         if (mg->mg_ptr[1] == '\0') {
             PL_maxsysfd = SvIV(sv);
         }
-        else if (strEQ(mg->mg_ptr + 1, "EATURE_BITS")) {
-            PL_compiling.cop_features = SvUV(sv);
-        }
        break;
     case '\010':       /* ^H */
         {
@@ -3490,46 +3479,48 @@ Perl_perly_sighandler(int sig, Siginfo_t *sip PERL_UNUSED_DECL,
     PUSHSTACKi(PERLSI_SIGNAL);
     PUSHMARK(SP);
     PUSHs(sv);
+
 #if defined(HAS_SIGACTION) && defined(SA_SIGINFO)
     {
         struct sigaction oact;
 
         if (sip && sigaction(sig, 0, &oact) == 0 && oact.sa_flags & SA_SIGINFO) {
-                  HV *sih = newHV();
-                  SV *rv  = newRV_noinc(MUTABLE_SV(sih));
-                  /* The siginfo fields signo, code, errno, pid, uid,
-                   * addr, status, and band are defined by POSIX/SUSv3. */
-                  (void)hv_stores(sih, "signo", newSViv(sip->si_signo));
-                  (void)hv_stores(sih, "code", newSViv(sip->si_code));
-#ifdef HAS_SIGINFO_SI_ERRNO
-                  (void)hv_stores(sih, "errno",      newSViv(sip->si_errno));
-#endif
-#ifdef HAS_SIGINFO_SI_STATUS
-                  (void)hv_stores(sih, "status",     newSViv(sip->si_status));
-#endif
-#ifdef HAS_SIGINFO_SI_UID
-                  {
-                       SV *uid = newSV(0);
-                       sv_setuid(uid, sip->si_uid);
-                       (void)hv_stores(sih, "uid", uid);
-                  }
-#endif
-#ifdef HAS_SIGINFO_SI_PID
-                  (void)hv_stores(sih, "pid",        newSViv(sip->si_pid));
-#endif
-#ifdef HAS_SIGINFO_SI_ADDR
-                  (void)hv_stores(sih, "addr",       newSVuv(PTR2UV(sip->si_addr)));
-#endif
-#ifdef HAS_SIGINFO_SI_BAND
-                  (void)hv_stores(sih, "band",       newSViv(sip->si_band));
-#endif
-                  EXTEND(SP, 2);
-                  PUSHs(rv);
-                  mPUSHp((char *)sip, sizeof(*sip));
+               HV *sih = newHV();
+               SV *rv  = newRV_noinc(MUTABLE_SV(sih));
+               /* The siginfo fields signo, code, errno, pid, uid,
+                * addr, status, and band are defined by POSIX/SUSv3. */
+               (void)hv_stores(sih, "signo", newSViv(sip->si_signo));
+               (void)hv_stores(sih, "code", newSViv(sip->si_code));
+#  ifdef HAS_SIGINFO_SI_ERRNO
+               (void)hv_stores(sih, "errno",      newSViv(sip->si_errno));
+#  endif
+#  ifdef HAS_SIGINFO_SI_STATUS
+               (void)hv_stores(sih, "status",     newSViv(sip->si_status));
+#  endif
+#  ifdef HAS_SIGINFO_SI_UID
+               {
+                    SV *uid = newSV(0);
+                    sv_setuid(uid, sip->si_uid);
+                    (void)hv_stores(sih, "uid", uid);
+               }
+#  endif
+#  ifdef HAS_SIGINFO_SI_PID
+               (void)hv_stores(sih, "pid",        newSViv(sip->si_pid));
+#  endif
+#  ifdef HAS_SIGINFO_SI_ADDR
+               (void)hv_stores(sih, "addr",       newSVuv(PTR2UV(sip->si_addr)));
+#  endif
+#  ifdef HAS_SIGINFO_SI_BAND
+               (void)hv_stores(sih, "band",       newSViv(sip->si_band));
+#  endif
+               EXTEND(SP, 2);
+               PUSHs(rv);
+               mPUSHp((char *)sip, sizeof(*sip));
 
         }
     }
 #endif
+
     PUTBACK;
 
     errsv_save = newSVsv(ERRSV);
@@ -3541,12 +3532,13 @@ Perl_perly_sighandler(int sig, Siginfo_t *sip PERL_UNUSED_DECL,
        SV * const errsv = ERRSV;
        if (SvTRUE_NN(errsv)) {
            SvREFCNT_dec(errsv_save);
+
 #ifndef PERL_MICRO
-       /* Handler "died", for example to get out of a restart-able read().
-        * Before we re-do that on its behalf re-enable the signal which was
-        * blocked by the system when we entered.
-        */
-#ifdef HAS_SIGPROCMASK
+            /* Handler "died", for example to get out of a restart-able read().
+             * Before we re-do that on its behalf re-enable the signal which was
+             * blocked by the system when we entered.
+             */
+#  ifdef HAS_SIGPROCMASK
            if (!safe) {
                 /* safe signals called via dispatch_signals() set up a
                  * savestack destructor, unblock_sigmask(), to
@@ -3559,15 +3551,16 @@ Perl_perly_sighandler(int sig, Siginfo_t *sip PERL_UNUSED_DECL,
                sigaddset(&set,sig);
                sigprocmask(SIG_UNBLOCK, &set, NULL);
            }
-#else
+#  else
            /* Not clear if this will work */
             /* XXX not clear if this should be protected by 'if (safe)'
              * too */
 
            (void)rsignal(sig, SIG_IGN);
            (void)rsignal(sig, PL_csighandlerp);
-#endif
+#  endif
 #endif /* !PERL_MICRO */
+
            die_sv(errsv);
        }
        else {
@@ -3683,6 +3676,7 @@ Perl_magic_sethint(pTHX_ SV *sv, MAGIC *mg)
     PL_hints |= HINT_LOCALIZE_HH;
     CopHINTHASH_set(&PL_compiling,
        cophh_store_sv(CopHINTHASH_get(&PL_compiling), key, 0, sv, 0));
+    magic_sethint_feature(key, NULL, 0, sv, 0);
     return 0;
 }
 
@@ -3707,6 +3701,10 @@ Perl_magic_clearhint(pTHX_ SV *sv, MAGIC *mg)
                                 MUTABLE_SV(mg->mg_ptr), 0, 0)
         : cophh_delete_pvn(CopHINTHASH_get(&PL_compiling),
                                 mg->mg_ptr, mg->mg_len, 0, 0));
+    if (mg->mg_len == HEf_SVKEY)
+        magic_sethint_feature(MUTABLE_SV(mg->mg_ptr), NULL, 0, NULL, FALSE);
+    else
+        magic_sethint_feature(NULL, mg->mg_ptr, mg->mg_len, NULL, FALSE);
     return 0;
 }
 
@@ -3725,6 +3723,7 @@ Perl_magic_clearhints(pTHX_ SV *sv, MAGIC *mg)
     PERL_UNUSED_ARG(mg);
     cophh_free(CopHINTHASH_get(&PL_compiling));
     CopHINTHASH_set(&PL_compiling, cophh_new_empty());
+    CLEARFEATUREBITS();
     return 0;
 }