Config_66-01
[p5sagit/p5-mst-13.2.git] / doio.c
diff --git a/doio.c b/doio.c
index bbf3837..9d841a1 100644 (file)
--- a/doio.c
+++ b/doio.c
@@ -506,7 +506,7 @@ nextargv(register GV *gv)
                    (void)fchown(lastfd,fileuid,filegid);
 #else
 #ifdef HAS_CHOWN
-                   (void)chown(oldname,fileuid,filegid);
+                   (void)PerlLIO_chown(oldname,fileuid,filegid);
 #endif
 #endif
                }
@@ -579,14 +579,17 @@ do_close(GV *gv, bool not_implicit)
     if (!gv)
        gv = argvgv;
     if (!gv || SvTYPE(gv) != SVt_PVGV) {
-       SETERRNO(EBADF,SS$_IVCHAN);
+       if (not_implicit)
+           SETERRNO(EBADF,SS$_IVCHAN);
        return FALSE;
     }
     io = GvIO(gv);
     if (!io) {         /* never opened */
-       if (dowarn && not_implicit)
-           warn("Close on unopened file <%s>",GvENAME(gv));
-       SETERRNO(EBADF,SS$_IVCHAN);
+       if (not_implicit) {
+           if (dowarn)
+               warn("Close on unopened file <%s>",GvENAME(gv));
+           SETERRNO(EBADF,SS$_IVCHAN);
+       }
        return FALSE;
     }
     retval = io_close(io);
@@ -741,7 +744,7 @@ do_binmode(PerlIO *fp, int iotype, int flag)
         * document this anywhere). GSAR 97-5-24
         */
        PerlIO_seek(fp,0L,0);
-       fp->flags |= _F_BIN;
+       ((FILE*)fp)->flags |= _F_BIN;
 #endif
        return 1;
     }
@@ -1085,7 +1088,9 @@ apply(I32 type, register SV **mark, register SV **sp)
     SV **oldmark = mark;
 
 #define APPLY_TAINT_PROPER() \
-    if (!(tainting && tainted)) {} else { goto taint_proper; }
+    STMT_START {                                               \
+       if (tainting && tainted) { goto taint_proper_label; }   \
+    } STMT_END
 
     /* This is a first heuristic; it doesn't catch tainting magic. */
     if (tainting) {
@@ -1125,7 +1130,7 @@ apply(I32 type, register SV **mark, register SV **sp)
            while (++mark <= sp) {
                char *name = SvPVx(*mark, na);
                APPLY_TAINT_PROPER();
-               if (chown(name, val, val2))
+               if (PerlLIO_chown(name, val, val2))
                    tot--;
            }
        }
@@ -1271,7 +1276,7 @@ nothing in the core.
     }
     return tot;
 
-  taint_proper:
+  taint_proper_label:
     TAINT_PROPER(what);
     return 0;  /* this should never happen */
 
@@ -1389,21 +1394,6 @@ do_ipcget(I32 optype, SV **mark, SV **sp)
     return -1;                 /* should never happen */
 }
 
-#if defined(__sun) && defined(__svr4__) /* XXX Need metaconfig test */
-/* Solaris manpage says that it uses (like linux)
-   int semctl (int semid, int semnum, int cmd, union semun arg)
-   but the system include files do not define union semun !!!!
-   Note: Linux/glibc *does* declare union semun in <sys/sem_buf.h>
-   but, unlike the older Linux libc and Solaris, it has an extra
-   struct seminfo * on the end.
-*/
-union semun {
-     int val;
-     struct semid_ds *buf;
-     ushort *array;
-};
-#endif
-
 I32
 do_ipcctl(I32 optype, SV **mark, SV **sp)
 {
@@ -1412,26 +1402,6 @@ do_ipcctl(I32 optype, SV **mark, SV **sp)
     char *a;
     I32 id, n, cmd, infosize, getinfo;
     I32 ret = -1;
-/* XXX REALLY need metaconfig test */
-/* linux and Solaris2 use:
-   int semctl (int semid, int semnum, int cmd, union semun arg)
-   instead of:
-   int semctl (int semid, int semnum, int cmd, struct semid_ds *arg);
-   Solaris and Linux (pre-glibc) use
-       union semun {
-            int val;
-            struct semid_ds *buf;
-            ushort *array;
-       };
-   but Solaris doesn't declare it in a header file (we declared it
-   explicitly earlier). Linux/glibc declares a *different* union semun
-   so we just refer to "union semun" here.
-    
-*/
-#if defined(__linux__) || (defined(__sun__) && defined(__svr4__))
-#   define SEMCTL_SEMUN
-    union semun unsemds, semun;
-#endif
 
     id = SvIVx(*++mark);
     n = (optype == OP_SEMCTL) ? SvIVx(*++mark) : 0;
@@ -1461,14 +1431,12 @@ do_ipcctl(I32 optype, SV **mark, SV **sp)
        else if (cmd == GETALL || cmd == SETALL)
        {
            struct semid_ds semds;
-#ifdef SEMCTL_SEMUN
+           union semun semun;
+
             semun.buf = &semds;
-           if (semctl(id, 0, IPC_STAT, semun) == -1)
-#else
-           if (semctl(id, 0, IPC_STAT, &semds) == -1)
-#endif
-               return -1;
            getinfo = (cmd == GETALL);
+           if (Semctl(id, 0, IPC_STAT, semun) == -1)
+               return -1;
            infosize = semds.sem_nsems * sizeof(short);
                /* "short" is technically wrong but much more portable
                   than guessing about u_?short(_t)? */
@@ -1511,14 +1479,12 @@ do_ipcctl(I32 optype, SV **mark, SV **sp)
        break;
 #endif
 #ifdef HAS_SEM
-    case OP_SEMCTL:
-#ifdef SEMCTL_SEMUN
-       /* XXX Need metaconfig test */
-        unsemds.buf = (struct semid_ds *)a;
-       ret = semctl(id, n, cmd, unsemds);
-#else
-       ret = semctl(id, n, cmd, (struct semid_ds *)a);
-#endif
+    case OP_SEMCTL: {
+            union semun unsemds;
+
+            unsemds.buf = (struct semid_ds *)a;
+           ret = Semctl(id, n, cmd, unsemds);
+        }
        break;
 #endif
 #ifdef HAS_SHM