Subversion Repositories Kolibri OS

Rev

Rev 4874 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4874 Rev 4921
Line 73... Line 73...
73
_DEFUN(__sflush_r, (ptr, fp),
73
_DEFUN(__sflush_r, (ptr, fp),
74
       struct _reent *ptr _AND
74
       struct _reent *ptr _AND
75
       register FILE * fp)
75
       register FILE * fp)
76
{
76
{
77
  register unsigned char *p;
77
  register unsigned char *p;
-
 
78
  register _READ_WRITE_BUFSIZE_TYPE n;
-
 
79
  register _READ_WRITE_RETURN_TYPE t;
78
  register int n, t;
80
  short flags;
Line 79... Line 81...
79
 
81
 
80
  t = fp->_flags;
82
  flags = fp->_flags;
81
  if ((t & __SWR) == 0)
83
  if ((flags & __SWR) == 0)
-
 
84
    {
82
    {
85
#ifdef _FSEEK_OPTIMIZATION
83
      /* For a read stream, an fflush causes the next seek to be
86
      /* For a read stream, an fflush causes the next seek to be
84
         unoptimized (i.e. forces a system-level seek).  This conforms
87
         unoptimized (i.e. forces a system-level seek).  This conforms
85
         to the POSIX and SUSv3 standards.  */
88
         to the POSIX and SUSv3 standards.  */
-
 
89
      fp->_flags |= __SNPT;
Line 86... Line 90...
86
      fp->_flags |= __SNPT;
90
#endif
87
 
91
 
88
      /* For a seekable stream with buffered read characters, we will attempt
92
      /* For a seekable stream with buffered read characters, we will attempt
89
         a seek to the current position now.  A subsequent read will then get
93
         a seek to the current position now.  A subsequent read will then get
Line 150... Line 154...
150
	  if (curoff != -1 || ptr->_errno == 0
154
	  if (curoff != -1 || ptr->_errno == 0
151
	      || ptr->_errno == ESPIPE || ptr->_errno == EINVAL)
155
	      || ptr->_errno == ESPIPE || ptr->_errno == EINVAL)
152
	    {
156
	    {
153
	      /* Seek successful or ignorable error condition.
157
	      /* Seek successful or ignorable error condition.
154
		 We can clear read buffer now.  */
158
		 We can clear read buffer now.  */
-
 
159
#ifdef _FSEEK_OPTIMIZATION
155
	      fp->_flags &= ~__SNPT;
160
	      fp->_flags &= ~__SNPT;
-
 
161
#endif
156
	      fp->_r = 0;
162
	      fp->_r = 0;
157
	      fp->_p = fp->_bf._base;
163
	      fp->_p = fp->_bf._base;
158
	      if ((fp->_flags & __SOFF) && (curoff != -1 || ptr->_errno == 0))
164
	      if ((fp->_flags & __SOFF) && (curoff != -1 || ptr->_errno == 0))
159
		fp->_offset = curoff;
165
		fp->_offset = curoff;
160
	      ptr->_errno = tmp_errno;
166
	      ptr->_errno = tmp_errno;
Line 180... Line 186...
180
   * Set these immediately to avoid problems with longjmp
186
   * Set these immediately to avoid problems with longjmp
181
   * and to allow exchange buffering (via setvbuf) in user
187
   * and to allow exchange buffering (via setvbuf) in user
182
   * write function.
188
   * write function.
183
   */
189
   */
184
  fp->_p = p;
190
  fp->_p = p;
185
  fp->_w = t & (__SLBF | __SNBF) ? 0 : fp->_bf._size;
191
  fp->_w = flags & (__SLBF | __SNBF) ? 0 : fp->_bf._size;
Line 186... Line 192...
186
 
192
 
187
  while (n > 0)
193
  while (n > 0)
188
    {
194
    {
189
      t = fp->_write (ptr, fp->_cookie, (char *) p, n);
195
      t = fp->_write (ptr, fp->_cookie, (char *) p, n);
Line 224... Line 230...
224
  CHECK_INIT (ptr, fp);
230
  CHECK_INIT (ptr, fp);
Line 225... Line 231...
225
 
231
 
226
  if (!fp->_flags)
232
  if (!fp->_flags)
Line 227... Line 233...
227
    return 0;
233
    return 0;
228
 
234
 
229
  _flockfile (fp);
235
  _newlib_flockfile_start (fp);
230
  ret = __sflush_r (ptr, fp);
236
  ret = __sflush_r (ptr, fp);
231
  _funlockfile (fp);
237
  _newlib_flockfile_end (fp);
Line 232... Line 238...
232
  return ret;
238
  return ret;