ss_dup wrapper const casting analagous to change 34626.
[p5sagit/p5-mst-13.2.git] / doio.c
diff --git a/doio.c b/doio.c
index 16d8d01..39cda9a 100644 (file)
--- a/doio.c
+++ b/doio.c
@@ -1,7 +1,7 @@
 /*    doio.c
  *
- *    Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
- *    2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, by Larry Wall and others
+ *    Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
+ *    2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 by Larry Wall and others
  *
  *    You may distribute under the terms of either the GNU General Public
  *    License or the Artistic License, as specified in the README file.
@@ -926,7 +926,7 @@ Perl_do_close(pTHX_ GV *gv, bool not_implicit)
 
     if (!gv)
        gv = PL_argvgv;
-    if (!gv || SvTYPE(gv) != SVt_PVGV) {
+    if (!gv || !isGV_with_GP(gv)) {
        if (not_implicit)
            SETERRNO(EBADF,SS_IVCHAN);
        return FALSE;
@@ -1096,12 +1096,10 @@ Perl_do_sysseek(pTHX_ GV *gv, Off_t pos, int whence)
 }
 
 int
-Perl_mode_from_discipline(pTHX_ SV *discp)
+Perl_mode_from_discipline(pTHX_ const char *s, STRLEN len)
 {
     int mode = O_BINARY;
-    if (discp) {
-       STRLEN len;
-       const char *s = SvPV_const(discp,len);
+    if (s) {
        while (*s) {
            if (*s == ':') {
                switch (s[1]) {
@@ -1309,11 +1307,11 @@ Perl_my_stat(pTHX)
        const char *s;
        STRLEN len;
        PUTBACK;
-       if (SvTYPE(sv) == SVt_PVGV) {
+       if (isGV_with_GP(sv)) {
            gv = (GV*)sv;
            goto do_fstat;
        }
-       else if (SvROK(sv) && SvTYPE(SvRV(sv)) == SVt_PVGV) {
+       else if (SvROK(sv) && isGV_with_GP(SvRV(sv))) {
            gv = (GV*)SvRV(sv);
            goto do_fstat;
        }
@@ -1343,6 +1341,7 @@ Perl_my_lstat(pTHX)
     static const char no_prev_lstat[] = "The stat preceding -l _ wasn't an lstat";
     dSP;
     SV *sv;
+    const char *file;
     if (PL_op->op_flags & OPf_REF) {
        EXTEND(SP,1);
        if (cGVOP_gv == PL_defgv) {
@@ -1364,15 +1363,15 @@ Perl_my_lstat(pTHX)
     PL_statgv = NULL;
     sv = POPs;
     PUTBACK;
-    if (SvROK(sv) && SvTYPE(SvRV(sv)) == SVt_PVGV && ckWARN(WARN_IO)) {
+    if (SvROK(sv) && isGV_with_GP(SvRV(sv)) && ckWARN(WARN_IO)) {
        Perl_warner(aTHX_ packWARN(WARN_IO), "Use of -l on filehandle %s",
                GvENAME((GV*) SvRV(sv)));
        return (PL_laststatval = -1);
     }
-    /* XXX Do really need to be calling SvPV() all these times? */
-    sv_setpv(PL_statname,SvPV_nolen_const(sv));
-    PL_laststatval = PerlLIO_lstat(SvPV_nolen_const(sv),&PL_statcache);
-    if (PL_laststatval < 0 && ckWARN(WARN_NEWLINE) && strchr(SvPV_nolen_const(sv), '\n'))
+    file = SvPV_nolen_const(sv);
+    sv_setpv(PL_statname,file);
+    PL_laststatval = PerlLIO_lstat(file,&PL_statcache);
+    if (PL_laststatval < 0 && ckWARN(WARN_NEWLINE) && strchr(file, '\n'))
        Perl_warner(aTHX_ packWARN(WARN_NEWLINE), PL_warn_nl, "lstat");
     return PL_laststatval;
 }
@@ -1625,7 +1624,7 @@ Perl_apply(pTHX_ I32 type, register SV **mark, register SV **sp)
            tot = sp - mark;
            while (++mark <= sp) {
                 GV* gv;
-                if (SvTYPE(*mark) == SVt_PVGV) {
+                if (isGV_with_GP(*mark)) {
                     gv = (GV*)*mark;
                do_fchmod:
                    if (GvIO(gv) && IoIFP(GvIOp(gv))) {
@@ -1641,7 +1640,7 @@ Perl_apply(pTHX_ I32 type, register SV **mark, register SV **sp)
                        tot--;
                    }
                }
-               else if (SvROK(*mark) && SvTYPE(SvRV(*mark)) == SVt_PVGV) {
+               else if (SvROK(*mark) && isGV_with_GP(SvRV(*mark))) {
                    gv = (GV*)SvRV(*mark);
                    goto do_fchmod;
                }
@@ -1665,7 +1664,7 @@ Perl_apply(pTHX_ I32 type, register SV **mark, register SV **sp)
            tot = sp - mark;
            while (++mark <= sp) {
                 GV* gv;
-                if (SvTYPE(*mark) == SVt_PVGV) {
+                if (isGV_with_GP(*mark)) {
                     gv = (GV*)*mark;
                do_fchown:
                    if (GvIO(gv) && IoIFP(GvIOp(gv))) {
@@ -1681,7 +1680,7 @@ Perl_apply(pTHX_ I32 type, register SV **mark, register SV **sp)
                        tot--;
                    }
                }
-               else if (SvROK(*mark) && SvTYPE(SvRV(*mark)) == SVt_PVGV) {
+               else if (SvROK(*mark) && isGV_with_GP(SvRV(*mark))) {
                    gv = (GV*)SvRV(*mark);
                    goto do_fchown;
                }
@@ -1837,7 +1836,7 @@ nothing in the core.
            tot = sp - mark;
            while (++mark <= sp) {
                 GV* gv;
-                if (SvTYPE(*mark) == SVt_PVGV) {
+                if (isGV_with_GP(*mark)) {
                     gv = (GV*)*mark;
                do_futimes:
                    if (GvIO(gv) && IoIFP(GvIOp(gv))) {
@@ -1854,7 +1853,7 @@ nothing in the core.
                        tot--;
                    }
                }
-               else if (SvROK(*mark) && SvTYPE(SvRV(*mark)) == SVt_PVGV) {
+               else if (SvROK(*mark) && isGV_with_GP(SvRV(*mark))) {
                    gv = (GV*)SvRV(*mark);
                    goto do_futimes;
                }