Change 24733 allows several pointers to be NULL. Therefore this
[p5sagit/p5-mst-13.2.git] / pp_sys.c
index 98b99e4..bce7ffe 100644 (file)
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -322,7 +322,7 @@ PP(pp_backtick)
     dSP; dTARGET;
     PerlIO *fp;
     STRLEN n_a;
-    char *tmps = POPpx;
+    const char *tmps = POPpconstx;
     const I32 gimme = GIMME_V;
     const char *mode = "r";
 
@@ -331,7 +331,7 @@ PP(pp_backtick)
        mode = "rb";
     else if (PL_op->op_private & OPpOPEN_IN_CRLF)
        mode = "rt";
-    fp = PerlProc_popen(tmps, (char *)mode);
+    fp = PerlProc_popen((char*)tmps, (char *)mode);
     if (fp) {
         const char *type = NULL;
        if (PL_curcop->cop_io) {
@@ -449,7 +449,7 @@ PP(pp_warn)
     tmps = SvPV(tmpsv, len);
     if ((!tmps || !len) && PL_errgv) {
        SV *error = ERRSV;
-       (void)SvUPGRADE(error, SVt_PV);
+       SvUPGRADE(error, SVt_PV);
        if (SvPOK(error) && SvCUR(error))
            sv_catpv(error, "\t...caught");
        tmpsv = error;
@@ -476,17 +476,17 @@ PP(pp_die)
        dTARGET;
        do_join(TARG, &PL_sv_no, MARK, SP);
        tmpsv = TARG;
-       tmps = SvPV(tmpsv, len);
+       tmps = SvPV_const(tmpsv, len);
        multiarg = 1;
        SP = MARK + 1;
     }
     else {
        tmpsv = TOPs;
-        tmps = SvROK(tmpsv) ? Nullch : SvPV(tmpsv, len);
+        tmps = SvROK(tmpsv) ? Nullch : SvPV_const(tmpsv, len);
     }
     if (!tmps || !len) {
        SV *error = ERRSV;
-       (void)SvUPGRADE(error, SVt_PV);
+       SvUPGRADE(error, SVt_PV);
        if (multiarg ? SvROK(error) : SvROK(tmpsv)) {
            if (!multiarg)
                SvSetSV(error,tmpsv);
@@ -532,7 +532,7 @@ PP(pp_open)
     GV *gv;
     SV *sv;
     IO *io;
-    char *tmps;
+    const char *tmps;
     STRLEN len;
     MAGIC *mg;
     bool  ok;
@@ -563,8 +563,8 @@ PP(pp_open)
        sv = GvSV(gv);
     }
 
-    tmps = SvPV(sv, len);
-    ok = do_openn(gv, tmps, len, FALSE, O_RDONLY, 0, Nullfp, MARK+1, (SP-MARK));
+    tmps = SvPV_const(sv, len);
+    ok = do_openn(gv, (char *)tmps, len, FALSE, O_RDONLY, 0, Nullfp, MARK+1, (SP-MARK));
     SP = ORIGMARK;
     if (ok)
        PUSHi( (I32)PL_forkprocess );
@@ -1390,7 +1390,7 @@ PP(pp_leavewrite)
        cv = GvFORM(fgv);
        if (!cv) {
            SV * const sv = sv_newmortal();
-           char *name;
+           const char *name;
            gv_efullname4(sv, fgv, Nullch, FALSE);
            name = SvPV_nolen(sv);
            if (name && *name)
@@ -1698,7 +1698,7 @@ PP(pp_sysread)
        SvCUR_set(bufsv, offset);
 
        read_target = sv_newmortal();
-       (void)SvUPGRADE(read_target, SVt_PV);
+       SvUPGRADE(read_target, SVt_PV);
        buffer = SvGROW(read_target, (STRLEN)(length + 1));
     }
 
@@ -2840,7 +2840,7 @@ PP(pp_stat)
                        "lstat() on filehandle %s", GvENAME(gv));
            goto do_fstat;
        }
-       sv_setpv(PL_statname, SvPV(sv,n_a));
+       sv_setpv(PL_statname, SvPV_const(sv,n_a));
        PL_statgv = Nullgv;
        PL_laststype = PL_op->op_type;
        if (PL_op->op_type == OP_LSTAT)
@@ -3546,12 +3546,12 @@ PP(pp_ftbinary)
 PP(pp_chdir)
 {
     dSP; dTARGET;
-    char *tmps;
+    const char *tmps;
     SV **svp;
     STRLEN n_a;
 
     if( MAXARG == 1 )
-        tmps = POPpx;
+        tmps = POPpconstx;
     else
         tmps = 0;
 
@@ -3565,7 +3565,7 @@ PP(pp_chdir)
         {
             if( MAXARG == 1 )
                 deprecate("chdir('') or chdir(undef) as chdir()");
-            tmps = SvPV(*svp, n_a);
+            tmps = SvPV_const(*svp, n_a);
         }
         else {
             PUSHi(0);
@@ -3727,9 +3727,9 @@ PP(pp_readlink)
 
 #if !defined(HAS_MKDIR) || !defined(HAS_RMDIR)
 STATIC int
-S_dooneliner(pTHX_ char *cmd, char *filename)
+S_dooneliner(pTHX_ const char *cmd, const char *filename)
 {
-    char *save_filename = filename;
+    char * const save_filename = filename;
     char *cmdline;
     char *s;
     PerlIO *myfp;
@@ -3823,7 +3823,7 @@ S_dooneliner(pTHX_ char *cmd, char *filename)
  * -d, chdir(), chmod(), chown(), chroot(), fcntl()?,
  * (mkdir()), opendir(), rename(), rmdir(), stat(). --jhi */
 
-#define TRIMSLASHES(tmps,len,copy) (tmps) = SvPV(TOPs, (len)); \
+#define TRIMSLASHES(tmps,len,copy) (tmps) = SvPV_const(TOPs, (len)); \
     if ((len) > 1 && (tmps)[(len)-1] == '/') { \
        do { \
            (len)--; \
@@ -3840,7 +3840,7 @@ PP(pp_mkdir)
     int oldumask;
 #endif
     STRLEN len;
-    char *tmps;
+    const char *tmps;
     bool copy = FALSE;
 
     if (MAXARG > 1)
@@ -3868,7 +3868,7 @@ PP(pp_rmdir)
 {
     dSP; dTARGET;
     STRLEN len;
-    char *tmps;
+    const char *tmps;
     bool copy = FALSE;
 
     TRIMSLASHES(tmps,len,copy);
@@ -4372,12 +4372,9 @@ PP(pp_getppid)
 #ifdef HAS_GETPPID
     dSP; dTARGET;
 #   ifdef THREADS_HAVE_PIDS
-    {
-       IV cur_ppid = getppid();
-       if (cur_ppid == 1)
-           /* maybe the parent process has died. Refresh ppid cache */
-           PL_ppid = cur_ppid;
-    }
+    if (PL_ppid != 1 && getppid() == 1)
+       /* maybe the parent process has died. Refresh ppid cache */
+       PL_ppid = 1;
     XPUSHi( PL_ppid );
 #   else
     XPUSHi( getppid() );