This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Re: [perl #38868] Changing $0 on darwin leads to excessive padding in 'ps'
[perl5.git] / mg.c
diff --git a/mg.c b/mg.c
index 494e9fd..56e8065 100644 (file)
--- a/mg.c
+++ b/mg.c
@@ -871,7 +871,7 @@ Perl_magic_get(pTHX_ SV *sv, MAGIC *mg)
                    TAINT_NOT;
                    sv_setpvn(sv, s, i);
                    PL_tainted = oldtainted;
-                   if ( (rx->reganch & ROPT_CANY_SEEN)
+                   if ( (rx->extflags & RXf_CANY_SEEN)
                        ? (RX_MATCH_UTF8(rx)
                                    && (!i || is_utf8_string((U8*)s, i)))
                        : (RX_MATCH_UTF8(rx)) )
@@ -1459,7 +1459,7 @@ Perl_magic_setsig(pTHX_ SV *sv, MAGIC *mg)
            SvREFCNT_dec(to_dec);
        return 0;
     }
-    s = SvOK(sv) ? SvPV_force(sv,len) : "IGNORE";
+    s = SvOK(sv) ? SvPV_force(sv,len) : "DEFAULT";
     if (strEQ(s,"IGNORE")) {
        if (i) {
 #ifdef FAKE_PERSISTENT_SIGNAL_HANDLERS
@@ -2611,15 +2611,14 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg)
            setproctitle("%s", s);
 #   endif
        }
-#endif
-#if defined(__hpux) && defined(PSTAT_SETCMD)
+#elif defined(__hpux) && defined(PSTAT_SETCMD)
        if (PL_origalen != 1) {
             union pstun un;
             s = SvPV_const(sv, len);
             un.pst_command = (char *)s;
             pstat(PSTAT_SETCMD, un, len, 0, 0);
        }
-#endif
+#else
        if (PL_origalen > 1) {
            /* PL_origalen is set in perl_parse(). */
            s = SvPV_force(sv,len);
@@ -2633,17 +2632,23 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg)
                Copy(s, PL_origargv[0], len, char);
                PL_origargv[0][len] = 0;
                memset(PL_origargv[0] + len + 1,
+#ifdef PERL_DARWIN
+                      /* Special case for darwin: see [perl #38868] */
+                      (int)'\0',
+#else
                       /* Is the space counterintuitive?  Yes.
-                       * (You were expecting \0?)  
+                       * (You were expecting \0?)
                        * Does it work?  Seems to.  (In Linux 2.4.20 at least.)
                        * --jhi */
                       (int)' ',
+#endif
                       PL_origalen - len - 1);
            }
            PL_origargv[0][PL_origalen-1] = 0;
            for (i = 1; i < PL_origargc; i++)
                PL_origargv[i] = 0;
        }
+#endif
        UNLOCK_DOLLARZERO_MUTEX;
        break;
 #endif