INSTALL patches
[p5sagit/p5-mst-13.2.git] / pp_sys.c
index a35a206..45eee0b 100644 (file)
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -1,6 +1,6 @@
 /*    pp_sys.c
  *
- *    Copyright (c) 1991-1997, Larry Wall
+ *    Copyright (c) 1991-1999, Larry Wall
  *
  *    You may distribute under the terms of either the GNU General Public
  *    License or the Artistic License, as specified in the README file.
@@ -370,7 +370,7 @@ PP(pp_glob)
     PL_last_in_gv = (GV*)*PL_stack_sp--;
 
     SAVESPTR(PL_rs);           /* This is not permanent, either. */
-    PL_rs = sv_2mortal(newSVpv("", 1));
+    PL_rs = sv_2mortal(newSVpvn("\000", 1));
 #ifndef DOSISH
 #ifndef CSH
     *SvPVX(PL_rs) = '\n';
@@ -400,27 +400,31 @@ PP(pp_rcatline)
 PP(pp_warn)
 {
     djSP; dMARK;
+    SV *tmpsv;
     char *tmps;
-    STRLEN n_a;
+    STRLEN len;
     if (SP - MARK != 1) {
        dTARGET;
        do_join(TARG, &PL_sv_no, MARK, SP);
-       tmps = SvPV(TARG, n_a);
+       tmpsv = TARG;
        SP = MARK + 1;
     }
     else {
-       tmps = SvPV(TOPs, n_a);
+       tmpsv = TOPs;
     }
-    if (!tmps || !*tmps) {
+    tmps = SvPV(tmpsv, len);
+    if (!tmps || !len) {
        SV *error = ERRSV;
        (void)SvUPGRADE(error, SVt_PV);
        if (SvPOK(error) && SvCUR(error))
            sv_catpv(error, "\t...caught");
-       tmps = SvPV(error, n_a);
+       tmpsv = error;
+       tmps = SvPV(tmpsv, len);
     }
-    if (!tmps || !*tmps)
-       tmps = "Warning: something's wrong";
-    warn("%s", tmps);
+    if (!tmps || !len)
+       tmpsv = sv_2mortal(newSVpvn("Warning: something's wrong", 26));
+
+    warn("%_", tmpsv);
     RETSETYES;
 }
 
@@ -428,26 +432,28 @@ PP(pp_die)
 {
     djSP; dMARK;
     char *tmps;
-    SV *tmpsv = Nullsv;
-    char *pat = "%s";
-    STRLEN n_a;
+    SV *tmpsv;
+    STRLEN len;
+    bool multiarg = 0;
     if (SP - MARK != 1) {
        dTARGET;
        do_join(TARG, &PL_sv_no, MARK, SP);
-       tmps = SvPV(TARG, n_a);
+       tmpsv = TARG;
+       tmps = SvPV(tmpsv, len);
+       multiarg = 1;
        SP = MARK + 1;
     }
     else {
        tmpsv = TOPs;
-       tmps = SvROK(tmpsv) ? Nullch : SvPV(tmpsv, n_a);
+       tmps = SvROK(tmpsv) ? Nullch : SvPV(tmpsv, len);
     }
-    if (!tmps || !*tmps) {
+    if (!tmps || !len) {
        SV *error = ERRSV;
        (void)SvUPGRADE(error, SVt_PV);
-       if(tmpsv ? SvROK(tmpsv) : SvROK(error)) {
-           if(tmpsv)
+       if (multiarg ? SvROK(error) : SvROK(tmpsv)) {
+           if (!multiarg)
                SvSetSV(error,tmpsv);
-           else if(sv_isobject(error)) {
+           else if (sv_isobject(error)) {
                HV *stash = SvSTASH(SvRV(error));
                GV *gv = gv_fetchmethod(stash, "PROPAGATE");
                if (gv) {
@@ -464,17 +470,19 @@ PP(pp_die)
                    sv_setsv(error,*PL_stack_sp--);
                }
            }
-           pat = Nullch;
+           DIE(Nullch);
        }
        else {
            if (SvPOK(error) && SvCUR(error))
                sv_catpv(error, "\t...propagated");
-           tmps = SvPV(error, n_a);
+           tmpsv = error;
+           tmps = SvPV(tmpsv, len);
        }
     }
-    if (!tmps || !*tmps)
-       tmps = "Died";
-    DIE(pat, tmps);
+    if (!tmps || !len)
+       tmpsv = sv_2mortal(newSVpvn("Died", 4));
+
+    DIE("%_", tmpsv);
 }
 
 /* I/O. */
@@ -607,7 +615,7 @@ PP(pp_fileno)
 PP(pp_umask)
 {
     djSP; dTARGET;
-    int anum;
+    Mode_t anum;
 
 #ifdef HAS_UMASK
     if (MAXARG < 1) {
@@ -869,8 +877,8 @@ PP(pp_sselect)
     /* If SELECT_MIN_BITS is greater than one we most probably will want
      * to align the sizes with SELECT_MIN_BITS/8 because for example
      * in many little-endian (Intel, Alpha) systems (Linux, OS/2, Digital
-     * UNIX, Solaris, NeXT) the smallest quantum select() operates on
-     * (sets bit) is 32 bits.  */
+     * UNIX, Solaris, NeXT, Rhapsody) the smallest quantum select() operates
+     * on (sets/tests/clears bits) is 32 bits.  */
     growsize = maxlen + (SELECT_MIN_BITS/8 - (maxlen % (SELECT_MIN_BITS/8)));
 #  else
     growsize = sizeof(fd_set);
@@ -1639,7 +1647,7 @@ PP(pp_sysseek)
        Off_t n = do_sysseek(gv, offset, whence);
        PUSHs((n < 0) ? &PL_sv_undef
              : sv_2mortal(n ? newSViv((IV)n)
-                          : newSVpv(zero_but_true, ZBTLEN)));
+                          : newSVpvn(zero_but_true, ZBTLEN)));
     }
     RETURN;
 }
@@ -2332,7 +2340,7 @@ PP(pp_stat)
 #ifdef USE_STAT_RDEV
        PUSHs(sv_2mortal(newSViv((I32)PL_statcache.st_rdev)));
 #else
-       PUSHs(sv_2mortal(newSVpv("", 0)));
+       PUSHs(sv_2mortal(newSVpvn("", 0)));
 #endif
        PUSHs(sv_2mortal(newSViv((I32)PL_statcache.st_size)));
 #ifdef BIG_TIME
@@ -2348,8 +2356,8 @@ PP(pp_stat)
        PUSHs(sv_2mortal(newSViv((I32)PL_statcache.st_blksize)));
        PUSHs(sv_2mortal(newSViv((I32)PL_statcache.st_blocks)));
 #else
-       PUSHs(sv_2mortal(newSVpv("", 0)));
-       PUSHs(sv_2mortal(newSVpv("", 0)));
+       PUSHs(sv_2mortal(newSVpvn("", 0)));
+       PUSHs(sv_2mortal(newSVpvn("", 0)));
 #endif
     }
     RETURN;
@@ -3235,7 +3243,7 @@ PP(pp_readdir)
        /*SUPPRESS 560*/
        while (dp = (Direntry_t *)PerlDir_read(IoDIRP(io))) {
 #ifdef DIRNAMLEN
-           sv = newSVpv(dp->d_name, dp->d_namlen);
+           sv = newSVpvn(dp->d_name, dp->d_namlen);
 #else
            sv = newSVpv(dp->d_name, 0);
 #endif
@@ -3249,7 +3257,7 @@ PP(pp_readdir)
        if (!(dp = (Direntry_t *)PerlDir_read(IoDIRP(io))))
            goto nope;
 #ifdef DIRNAMLEN
-       sv = newSVpv(dp->d_name, dp->d_namlen);
+       sv = newSVpvn(dp->d_name, dp->d_namlen);
 #else
        sv = newSVpv(dp->d_name, 0);
 #endif
@@ -3380,7 +3388,7 @@ PP(pp_fork)
 {
 #ifdef HAS_FORK
     djSP; dTARGET;
-    int childpid;
+    Pid_t childpid;
     GV *tmpgv;
 
     EXTEND(SP, 1);
@@ -3404,7 +3412,7 @@ PP(pp_wait)
 {
 #if !defined(DOSISH) || defined(OS2) || defined(WIN32)
     djSP; dTARGET;
-    int childpid;
+    Pid_t childpid;
     int argflags;
 
     childpid = wait4pid(-1, &argflags, 0);
@@ -3420,7 +3428,7 @@ PP(pp_waitpid)
 {
 #if !defined(DOSISH) || defined(OS2) || defined(WIN32)
     djSP; dTARGET;
-    int childpid;
+    Pid_t childpid;
     int optype;
     int argflags;
 
@@ -3439,7 +3447,7 @@ PP(pp_system)
 {
     djSP; dMARK; dORIGMARK; dTARGET;
     I32 value;
-    int childpid;
+    Pid_t childpid;
     int result;
     int status;
     Sigsave_t ihand,qhand;     /* place to save signals during system() */