BSD 4_1_snap release
[unix-history] / usr / src / libc / stdio / ftell.c
index b33252b..e2226c8 100644 (file)
@@ -1,3 +1,4 @@
+/* @(#)ftell.c 4.2 (Berkeley) 3/9/81 */
 /*
  * Return file offset.
  * Coordinates with buffering.
 /*
  * Return file offset.
  * Coordinates with buffering.
@@ -17,9 +18,9 @@ FILE *iop;
                iop->_cnt = 0;
        if (iop->_flag&_IOREAD)
                adjust = - iop->_cnt;
                iop->_cnt = 0;
        if (iop->_flag&_IOREAD)
                adjust = - iop->_cnt;
-       else if (iop->_flag&_IOWRT) {
+       else if (iop->_flag&(_IOWRT|_IORW)) {
                adjust = 0;
                adjust = 0;
-               if (iop->_base && (iop->_flag&_IONBF)==0)
+               if (iop->_flag&_IOWRT && iop->_base && (iop->_flag&_IONBF)==0)
                        adjust = iop->_ptr - iop->_base;
        } else
                return(-1);
                        adjust = iop->_ptr - iop->_base;
        } else
                return(-1);