perl5.004 on AIX: Patches
[p5sagit/p5-mst-13.2.git] / doio.c
diff --git a/doio.c b/doio.c
index b8c5a06..0d57425 100644 (file)
--- a/doio.c
+++ b/doio.c
@@ -660,22 +660,15 @@ do_tell(gv)
 GV *gv;
 {
     register IO *io;
+    register PerlIO *fp;
 
-    if (!gv)
-       goto phooey;
-
-    io = GvIO(gv);
-    if (!io || !IoIFP(io))
-       goto phooey;
-
+    if (gv && (io = GvIO(gv)) && (fp = IoIFP(io))) {
 #ifdef ULTRIX_STDIO_BOTCH
-    if (PerlIO_eof(IoIFP(io)))
-       (void)PerlIO_seek (IoIFP(io), 0L, 2);           /* ultrix 1.2 workaround */
+       if (PerlIO_eof(fp))
+           (void)PerlIO_seek(fp, 0L, 2);       /* ultrix 1.2 workaround */
 #endif
-
-    return PerlIO_tell(IoIFP(io));
-
-phooey:
+       return PerlIO_tell(fp);
+    }
     if (dowarn)
        warn("tell() on unopened file");
     SETERRNO(EBADF,RMS$_IFI);
@@ -696,10 +689,7 @@ int whence;
        if (PerlIO_eof(fp))
            (void)PerlIO_seek(fp, 0L, 2);       /* ultrix 1.2 workaround */
 #endif
-       if (op->op_type == OP_SYSSEEK)
-           return lseek(PerlIO_fileno(fp), pos, whence) >= 0;
-       else
-           return PerlIO_seek(fp, pos, whence) >= 0;
+       return PerlIO_seek(fp, pos, whence) >= 0;
     }
     if (dowarn)
        warn("seek() on unopened file");
@@ -707,6 +697,23 @@ int whence;
     return FALSE;
 }
 
+long
+do_sysseek(gv, pos, whence)
+GV *gv;
+long pos;
+int whence;
+{
+    register IO *io;
+    register PerlIO *fp;
+
+    if (gv && (io = GvIO(gv)) && (fp = IoIFP(io)))
+       return lseek(PerlIO_fileno(fp), pos, whence);
+    if (dowarn)
+       warn("sysseek() on unopened file");
+    SETERRNO(EBADF,RMS$_IFI);
+    return -1L;
+}
+
 #if !defined(HAS_TRUNCATE) && !defined(HAS_CHSIZE) && defined(F_FREESP)
        /* code courtesy of William Kucharski */
 #define HAS_CHSIZE