Down with C++ reserved names
[p5sagit/p5-mst-13.2.git] / perlio.c
index e03ed45..04677b8 100644 (file)
--- a/perlio.c
+++ b/perlio.c
@@ -1,5 +1,5 @@
 /*
- * perlio.c Copyright (c) 1996-2004, Nick Ing-Simmons You may distribute
+ * perlio.c Copyright (c) 1996-2005, Nick Ing-Simmons You may distribute
  * under the terms of either the GNU General Public License or the
  * Artistic License, as specified in the README file.
  */
@@ -454,7 +454,7 @@ PerlIO_debug(const char *fmt, ...)
     va_list ap;
     dSYS;
     va_start(ap, fmt);
-    if (!dbg) {
+    if (!dbg && !PL_tainting && PL_uid == PL_euid && PL_gid == PL_egid) {
        char *s = PerlEnv_getenv("PERLIO_DEBUG");
        if (s && *s)
            dbg = PerlLIO_open3(s, O_WRONLY | O_CREAT | O_APPEND, 0666);
@@ -463,21 +463,20 @@ PerlIO_debug(const char *fmt, ...)
     }
     if (dbg > 0) {
        dTHX;
+       const char *s;
 #ifdef USE_ITHREADS
        /* Use fixed buffer as sv_catpvf etc. needs SVs */
        char buffer[1024];
-       char *s;
        STRLEN len;
        s = CopFILE(PL_curcop);
        if (!s)
            s = "(none)";
-       sprintf(buffer, "%s:%" IVdf " ", s, (IV) CopLINE(PL_curcop));
+       sprintf(buffer, "%.40s:%" IVdf " ", s, (IV) CopLINE(PL_curcop));
        len = strlen(buffer);
        vsprintf(buffer+len, fmt, ap);
        PerlLIO_write(dbg, buffer, strlen(buffer));
 #else
        SV *sv = newSVpvn("", 0);
-       char *s;
        STRLEN len;
        s = CopFILE(PL_curcop);
        if (!s)
@@ -610,7 +609,7 @@ PerlIO_list_push(pTHX_ PerlIO_list_t *list, PerlIO_funcs *funcs, SV *arg)
     p = &(list->array[list->cur++]);
     p->funcs = funcs;
     if ((p->arg = arg)) {
-       SvREFCNT_inc(arg);
+       (void)SvREFCNT_inc(arg);
     }
 }
 
@@ -2390,7 +2389,7 @@ IV
 PerlIOUnix_seek(pTHX_ PerlIO *f, Off_t offset, int whence)
 {
     int fd = PerlIOSelf(f, PerlIOUnix)->fd;
-    Off_t new;
+    Off_t new_loc;
     if (PerlIOBase(f)->flags & PERLIO_F_NOTREG) {
 #ifdef  ESPIPE
        SETERRNO(ESPIPE, LIB_INVARG);
@@ -2399,8 +2398,8 @@ PerlIOUnix_seek(pTHX_ PerlIO *f, Off_t offset, int whence)
 #endif
        return -1;
     }
-    new  = PerlLIO_lseek(fd, offset, whence);
-    if (new == (Off_t) - 1)
+    new_loc = PerlLIO_lseek(fd, offset, whence);
+    if (new_loc == (Off_t) - 1)
      {
       return -1;
      }
@@ -2885,6 +2884,13 @@ PerlIOStdio_invalidate_fileno(pTHX_ FILE *f)
      */
     f->_file = -1;
     return 1;
+#  elif defined(__OpenBSD__)
+    /* There may be a better way on OpenBSD:
+        - we could insert a dummy func in the _close function entry
+       f->_close = (int (*)(void *)) dummy_close;
+     */
+    f->_file = -1;
+    return 1;
 #  elif defined(__EMX__)
     /* f->_flags &= ~_IOOPEN; */       /* Will leak stream->_buffer */
     f->_handle = -1;
@@ -4721,8 +4727,8 @@ char *
 PerlIO_getname(PerlIO *f, char *buf)
 {
     dTHX;
-    char *name = NULL;
 #ifdef VMS
+    char *name = NULL;
     bool exported = FALSE;
     FILE *stdio = PerlIOSelf(f, PerlIOStdio)->stdio;
     if (!stdio) {
@@ -4733,10 +4739,13 @@ PerlIO_getname(PerlIO *f, char *buf)
        name = fgetname(stdio, buf);
        if (exported) PerlIO_releaseFILE(f,stdio);
     }
+    return name;
 #else
+    (void)f;
+    (void)buf;
     Perl_croak(aTHX_ "Don't know how to get file name");
+    return Nullch;
 #endif
-    return name;
 }