Subversion Repositories Kolibri OS

Rev

Rev 4874 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4874 Rev 4921
Line 103... Line 103...
103
       struct _reent *ptr _AND
103
       struct _reent *ptr _AND
104
       register FILE * fp)
104
       register FILE * fp)
105
{
105
{
106
  _fpos_t pos;
106
  _fpos_t pos;
Line 107... Line -...
107
 
-
 
108
  /* Ensure stdio is set up.  */
-
 
109
 
-
 
110
  CHECK_INIT (ptr, fp);
-
 
111
 
-
 
112
  _flockfile (fp);
-
 
113
 
-
 
114
  if (fp->_seek == NULL)
-
 
115
    {
-
 
116
      ptr->_errno = ESPIPE;
-
 
117
      _funlockfile (fp);
-
 
118
      return -1L;
-
 
119
    }
-
 
120
 
-
 
121
  /* Find offset of underlying I/O object, then adjust for buffered
-
 
122
     bytes.  Flush a write stream, since the offset may be altered if
-
 
123
     the stream is appending.  Do not flush a read stream, since we
-
 
124
     must not lose the ungetc buffer.  */
-
 
125
  if (fp->_flags & __SWR)
107
 
126
    _fflush_r (ptr, fp);
-
 
127
  if (fp->_flags & __SOFF)
-
 
128
    pos = fp->_offset;
-
 
129
  else
-
 
130
    {
-
 
131
      pos = fp->_seek (ptr, fp->_cookie, (_fpos_t) 0, SEEK_CUR);
-
 
132
      if (pos == -1L)
-
 
133
        {
-
 
134
          _funlockfile (fp);
-
 
135
          return pos;
-
 
136
        }
-
 
137
    }
-
 
138
  if (fp->_flags & __SRD)
-
 
139
    {
-
 
140
      /*
-
 
141
       * Reading.  Any unread characters (including
-
 
142
       * those from ungetc) cause the position to be
-
 
143
       * smaller than that in the underlying object.
-
 
144
       */
-
 
145
      pos -= fp->_r;
-
 
146
      if (HASUB (fp))
-
 
147
	pos -= fp->_ur;
-
 
148
    }
-
 
149
  else if ((fp->_flags & __SWR) && fp->_p != NULL)
-
 
150
    {
-
 
151
      /*
-
 
152
       * Writing.  Any buffered characters cause the
-
 
153
       * position to be greater than that in the
-
 
154
       * underlying object.
-
 
155
       */
-
 
156
      pos += fp->_p - fp->_bf._base;
-
 
157
    }
-
 
158
 
-
 
159
  _funlockfile (fp);
108
  pos = _ftello_r (ptr, fp);
160
  if ((long)pos != pos)
109
  if ((long)pos != pos)
161
    {
110
    {
162
      pos = -1;
111
      pos = -1;
163
      ptr->_errno = EOVERFLOW;
112
      ptr->_errno = EOVERFLOW;
164
    }
113
    }
165
  return pos;
114
  return (long)pos;
Line 166... Line 115...
166
}
115
}
Line 167... Line 116...
167
 
116