POSIX: add isatty to @EXPORT_OK, reformat.
[p5sagit/p5-mst-13.2.git] / pp_sys.c
index b1ce18a..099eab9 100644 (file)
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -1134,7 +1134,7 @@ PP(pp_getc)
 {
     dSP; dTARGET;
     GV *gv;
-    IO *io;
+    IO *io = NULL;
     MAGIC *mg;
 
     if (MAXARG == 0)
@@ -1157,8 +1157,11 @@ PP(pp_getc)
            SvSetMagicSV_nosteal(TARG, TOPs);
        RETURN;
     }
-    if (!gv || do_eof(gv)) /* make sure we have fp with something */
+    if (!gv || do_eof(gv)) { /* make sure we have fp with something */
+       if (ckWARN2(WARN_UNOPENED,WARN_CLOSED) && IoTYPE(io) != IoTYPE_WRONLY)
+           report_evil_fh(gv, io, PL_op->op_type);
        RETPUSHUNDEF;
+    }
     TAINT;
     sv_setpv(TARG, " ");
     *SvPVX(TARG) = PerlIO_getc(IoIFP(GvIOp(gv))); /* should never be EOF */
@@ -1894,7 +1897,7 @@ PP(pp_eof)
     if (MAXARG == 0) {
        if (PL_op->op_flags & OPf_SPECIAL) {    /* eof() */
            IO *io;
-           gv = PL_last_in_gv = PL_argvgv;
+           gv = PL_last_in_gv = GvEGV(PL_argvgv);
            io = GvIO(gv);
            if (io && !IoIFP(io)) {
                if ((IoFLAGS(io) & IOf_START) && av_len(GvAVn(gv)) < 0) {
@@ -2726,9 +2729,11 @@ PP(pp_stat)
     if (PL_op->op_flags & OPf_REF) {
        gv = cGVOP_gv;
        if (PL_op->op_type == OP_LSTAT) {
-           if (gv != PL_defgv)
-               Perl_croak(aTHX_ "You can't use lstat() on a filehandle");
-           if (PL_laststype != OP_LSTAT)
+           if (gv != PL_defgv) {
+               if (ckWARN(WARN_IO))
+                   Perl_warner(aTHX_ WARN_IO,
+                       "lstat() on filehandle %s", GvENAME(gv));
+           } else if (PL_laststype != OP_LSTAT)
                Perl_croak(aTHX_ "The stat preceding lstat() wasn't an lstat");
        }
 
@@ -2754,6 +2759,9 @@ PP(pp_stat)
        }
        else if (SvROK(sv) && SvTYPE(SvRV(sv)) == SVt_PVGV) {
            gv = (GV*)SvRV(sv);
+           if (PL_op->op_type == OP_LSTAT && ckWARN(WARN_IO))
+               Perl_warner(aTHX_ WARN_IO,
+                       "lstat() on filehandle %s", GvENAME(gv));
            goto do_fstat;
        }
        sv_setpv(PL_statname, SvPV(sv,n_a));
@@ -4023,12 +4031,22 @@ PP(pp_system)
     int pp[2];
     I32 did_pipes = 0;
 
-    if (SP - MARK == 1) {
-       if (PL_tainting) {
-           (void)SvPV_nolen(TOPs);      /* stringify for taint check */
-           TAINT_ENV();
+    if (PL_tainting) {
+       TAINT_ENV();
+       while (++MARK <= SP) {
+           (void)SvPV_nolen(*MARK);      /* stringify for taint check */
+           if (PL_tainted) 
+               break;
+       }
+       MARK = ORIGMARK;
+       /* XXX Remove warning at end of deprecation cycle --RD 2002-02  */
+       if (SP - MARK == 1) {
            TAINT_PROPER("system");
        }
+       else if (ckWARN(WARN_TAINT)) {
+           Perl_warner(aTHX_ WARN_TAINT, 
+               "Use of tainted arguments in %s is deprecated", "system");
+       }
     }
     PERL_FLUSHALL_FOR_CHILD;
 #if (defined(HAS_FORK) || defined(AMIGAOS)) && !defined(VMS) && !defined(OS2) || defined(PERL_MICRO)
@@ -4036,16 +4054,6 @@ PP(pp_system)
         Pid_t childpid;
         int status;
         Sigsave_t ihand,qhand;     /* place to save signals during system() */
-       
-        if (PL_tainting) {
-            SV *cmd = NULL;
-            if (PL_op->op_flags & OPf_STACKED)
-               cmd = *(MARK + 1);
-            else if (SP - MARK != 1)
-               cmd = *SP;
-            if (cmd && *(SvPV_nolen(cmd)) != '/')
-               TAINT_ENV();
-        }
 
         if (PerlProc_pipe(pp) >= 0)
              did_pipes = 1;
@@ -4147,6 +4155,23 @@ PP(pp_exec)
     I32 value;
     STRLEN n_a;
 
+    if (PL_tainting) {
+       TAINT_ENV();
+       while (++MARK <= SP) {
+           (void)SvPV_nolen(*MARK);      /* stringify for taint check */
+           if (PL_tainted) 
+               break;
+       }
+       MARK = ORIGMARK;
+       /* XXX Remove warning at end of deprecation cycle --RD 2002-02  */
+       if (SP - MARK == 1) {
+           TAINT_PROPER("exec");
+       }
+       else if (ckWARN(WARN_TAINT)) {
+           Perl_warner(aTHX_ WARN_TAINT, 
+               "Use of tainted arguments in %s is deprecated", "exec");
+       }
+    }
     PERL_FLUSHALL_FOR_CHILD;
     if (PL_op->op_flags & OPf_STACKED) {
        SV *really = *++MARK;
@@ -4166,11 +4191,6 @@ PP(pp_exec)
 #  endif
 #endif
     else {
-       if (PL_tainting) {
-           (void)SvPV_nolen(*SP);      /* stringify for taint check */
-           TAINT_ENV();
-           TAINT_PROPER("exec");
-       }
 #ifdef VMS
        value = (I32)vms_do_exec(SvPVx(sv_mortalcopy(*SP), n_a));
 #else