This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
add note about map in scalar context
[perl5.git] / doio.c
diff --git a/doio.c b/doio.c
index 641046b..695a209 100644 (file)
--- a/doio.c
+++ b/doio.c
@@ -1,6 +1,6 @@
 /*    doio.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.
 #include "perl.h"
 
 #if defined(HAS_MSG) || defined(HAS_SEM) || defined(HAS_SHM)
+#ifndef HAS_SEM
 #include <sys/ipc.h>
+#endif
 #ifdef HAS_MSG
 #include <sys/msg.h>
 #endif
-#ifdef HAS_SEM
-#include <sys/sem.h>
-#endif
 #ifdef HAS_SHM
 #include <sys/shm.h>
 # ifndef HAS_SHMAT_PROTOTYPE
@@ -188,6 +187,13 @@ do_open(GV *gv, register char *name, I32 len, int as_raw, int rawmode, int rawpe
        if (*name == '|') {
            /*SUPPRESS 530*/
            for (name++; isSPACE(*name); name++) ;
+           if (*name == '\0') { /* command is missing 19990114 */
+               dTHR;
+               if (ckWARN(WARN_PIPE))
+                   warner(WARN_PIPE, "Missing command in piped open");
+               errno = EPIPE;
+               goto say_false;
+           }
            if (strNE(name,"-"))
                TAINT_ENV();
            TAINT_PROPER("piped open");
@@ -285,6 +291,13 @@ do_open(GV *gv, register char *name, I32 len, int as_raw, int rawmode, int rawpe
                name[--len] = '\0';
            /*SUPPRESS 530*/
            for (; isSPACE(*name); name++) ;
+           if (*name == '\0') { /* command is missing 19990114 */
+               dTHR;
+               if (ckWARN(WARN_PIPE))
+                   warner(WARN_PIPE, "Missing command in piped open");
+               errno = EPIPE;
+               goto say_false;
+           }
            if (strNE(name,"-"))
                TAINT_ENV();
            TAINT_PROPER("piped open");
@@ -1153,7 +1166,7 @@ apply(I32 type, register SV **mark, register SV **sp)
 
 #define APPLY_TAINT_PROPER() \
     STMT_START {                                                       \
-       if (PL_tainting && PL_tainted) { goto taint_proper_label; }     \
+       if (PL_tainted) { TAINT_PROPER(what); }                         \
     } STMT_END
 
     /* This is a first heuristic; it doesn't catch tainting magic. */
@@ -1311,18 +1324,18 @@ nothing in the core.
            struct utimbuf utbuf;
 #else
            struct {
-               long    actime;
-               long    modtime;
+               Time_t  actime;
+               Time_t  modtime;
            } utbuf;
 #endif
 
            Zero(&utbuf, sizeof utbuf, char);
 #ifdef BIG_TIME
-           utbuf.actime = (Time_t)SvNVx(*++mark);    /* time accessed */
-           utbuf.modtime = (Time_t)SvNVx(*++mark);    /* time modified */
+           utbuf.actime = (Time_t)SvNVx(*++mark);      /* time accessed */
+           utbuf.modtime = (Time_t)SvNVx(*++mark);     /* time modified */
 #else
-           utbuf.actime = SvIVx(*++mark);    /* time accessed */
-           utbuf.modtime = SvIVx(*++mark);    /* time modified */
+           utbuf.actime = (Time_t)SvIVx(*++mark);      /* time accessed */
+           utbuf.modtime = (Time_t)SvIVx(*++mark);     /* time modified */
 #endif
            APPLY_TAINT_PROPER();
            tot = sp - mark;
@@ -1340,10 +1353,6 @@ nothing in the core.
     }
     return tot;
 
-  taint_proper_label:
-    TAINT_PROPER(what);
-    return 0;  /* this should never happen */
-
 #undef APPLY_TAINT_PROPER
 }