$Socket::VERSION++; # You always miss one.
[p5sagit/p5-mst-13.2.git] / mg.c
diff --git a/mg.c b/mg.c
index 3e3ebfd..fb47f1f 100644 (file)
--- a/mg.c
+++ b/mg.c
@@ -647,6 +647,7 @@ Perl_magic_len(pTHX_ SV *sv, MAGIC *mg)
     while (len > 0 && isSPACE(p[len-1])) \
        --len; \
     SvCUR_set(sv, len); \
+    p[len] = '\0'; \
 } STMT_END
 
 int
@@ -817,7 +818,7 @@ Perl_magic_get(pTHX_ SV *sv, MAGIC *mg)
                 * it could have been extended by warnings::register */
                SV **bits_all;
                HV * const bits=get_hv("warnings::Bits", FALSE);
-               if (bits && (bits_all=hv_fetch(bits, "all", 3, FALSE))) {
+               if (bits && (bits_all=hv_fetchs(bits, "all", FALSE))) {
                    sv_setsv(sv, *bits_all);
                }
                else {
@@ -1003,29 +1004,22 @@ Perl_magic_get(pTHX_ SV *sv, MAGIC *mg)
        break;
     case '(':
        sv_setiv(sv, (IV)PL_gid);
-#ifdef HAS_GETGROUPS
-       Perl_sv_setpvf(aTHX_ sv, "%"Gid_t_f, PL_gid);
-#endif
        goto add_groups;
     case ')':
        sv_setiv(sv, (IV)PL_egid);
-#ifdef HAS_GETGROUPS
-       Perl_sv_setpvf(aTHX_ sv, "%"Gid_t_f, PL_egid);
-#endif
       add_groups:
 #ifdef HAS_GETGROUPS
        {
            Groups_t *gary = NULL;
-           I32 num_groups = getgroups(0, gary);
+           I32 i, num_groups = getgroups(0, gary);
             Newx(gary, num_groups, Groups_t);
             num_groups = getgroups(num_groups, gary);
-           while (--num_groups >= 0)
-               Perl_sv_catpvf(aTHX_ sv, " %"Gid_t_f,
-                              gary[num_groups]);
+           for (i = 0; i < num_groups; i++)
+               Perl_sv_catpvf(aTHX_ sv, " %"IVdf, (IV)gary[i]);
             Safefree(gary);
        }
-#endif
        (void)SvIOK_on(sv);     /* what a wonderful hack! */
+#endif
        break;
 #ifndef MACOS_TRADITIONAL
     case '0':
@@ -2540,7 +2534,7 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg)
        /* The BSDs don't show the argv[] in ps(1) output, they
         * show a string from the process struct and provide
         * the setproctitle() routine to manipulate that. */
-       {
+       if (PL_origalen != 1) {
            s = SvPV_const(sv, len);
 #   if __FreeBSD_version > 410001
            /* The leading "-" removes the "perl: " prefix,
@@ -2561,7 +2555,7 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg)
        }
 #endif
 #if defined(__hpux) && defined(PSTAT_SETCMD)
-       {
+       if (PL_origalen != 1) {
             union pstun un;
             s = SvPV_const(sv, len);
             un.pst_command = (char *)s;