about summary refs log tree commit diff
path: root/libio
diff options
context:
space:
mode:
authorAndreas Schwab <schwab@redhat.com>2009-09-02 11:49:06 +0200
committerAndreas Schwab <schwab@redhat.com>2009-09-02 11:49:06 +0200
commit91740ee0e6897651f4996c52b6056af592f4e977 (patch)
treea517ca4dfac93d24c0c3e1ec897085ca28e4315a /libio
parentb19ed4af95f005441cee8d138951665164bd28a8 (diff)
parentd840539e1271020600edba752e6ee908c00f66eb (diff)
downloadglibc-91740ee0e6897651f4996c52b6056af592f4e977.tar.gz
glibc-91740ee0e6897651f4996c52b6056af592f4e977.tar.xz
glibc-91740ee0e6897651f4996c52b6056af592f4e977.zip
Merge commit 'origin/master' into fedora/master
Diffstat (limited to 'libio')
-rw-r--r--libio/iofflush.c1
-rw-r--r--libio/wfileops.c110
2 files changed, 40 insertions, 71 deletions
diff --git a/libio/iofflush.c b/libio/iofflush.c
index d2d57f57e0..3294276b28 100644
--- a/libio/iofflush.c
+++ b/libio/iofflush.c
@@ -49,6 +49,7 @@ INTDEF(_IO_fflush)
 
 #ifdef weak_alias
 weak_alias (_IO_fflush, fflush)
+libc_hidden_weak (fflush)
 
 #ifndef _IO_MTSAFE_IO
 weak_alias (_IO_fflush, fflush_unlocked)
diff --git a/libio/wfileops.c b/libio/wfileops.c
index 57ed786a8f..be8ae78bfb 100644
--- a/libio/wfileops.c
+++ b/libio/wfileops.c
@@ -678,88 +678,56 @@ _IO_wfile_seekoff (fp, offset, dir, mode)
   if (fp->_offset != _IO_pos_BAD && fp->_IO_read_base != NULL
       && !_IO_in_backup (fp))
     {
-      /* Offset relative to start of main get area. */
-      _IO_off64_t rel_offset = (offset - fp->_offset
-				+ (fp->_IO_read_end - fp->_IO_read_base));
-      if (rel_offset >= 0)
+      _IO_off64_t start_offset = (fp->_offset
+				  - (fp->_IO_read_end - fp->_IO_buf_base));
+      if (offset >= start_offset && offset < fp->_offset)
 	{
-#if 0
-	  if (_IO_in_backup (fp))
-	    _IO_switch_to_main_get_area (fp);
-#endif
-	  if (rel_offset <= fp->_IO_read_end - fp->_IO_read_base)
+	  enum __codecvt_result status;
+	  struct _IO_codecvt *cd = fp->_codecvt;
+	  const char *read_ptr_copy;
+
+	  _IO_setg (fp, fp->_IO_buf_base,
+		    fp->_IO_buf_base + (offset - start_offset),
+		    fp->_IO_read_end);
+	  _IO_setp (fp, fp->_IO_buf_base, fp->_IO_buf_base);
+
+	  /* Now set the pointer for the internal buffer.  This
+	     might be an iterative process.  Though the read
+	     pointer is somewhere in the current external buffer
+	     this does not mean we can convert this whole buffer
+	     at once fitting in the internal buffer.  */
+	  fp->_wide_data->_IO_state = fp->_wide_data->_IO_last_state;
+	  read_ptr_copy = fp->_IO_read_base;
+	  fp->_wide_data->_IO_read_ptr = fp->_wide_data->_IO_read_base;
+	  do
 	    {
-	      enum __codecvt_result status;
-	      struct _IO_codecvt *cd = fp->_codecvt;
-	      const char *read_ptr_copy;
-
-	      fp->_IO_read_ptr = fp->_IO_read_base + rel_offset;
-	      _IO_setp (fp, fp->_IO_buf_base, fp->_IO_buf_base);
-
-	      /* Now set the pointer for the internal buffer.  This
-                 might be an iterative process.  Though the read
-                 pointer is somewhere in the current external buffer
-                 this does not mean we can convert this whole buffer
-                 at once fitting in the internal buffer.  */
-	      fp->_wide_data->_IO_state = fp->_wide_data->_IO_last_state;
-	      read_ptr_copy = fp->_IO_read_base;
-	      fp->_wide_data->_IO_read_ptr = fp->_wide_data->_IO_read_base;
-	      do
+	      wchar_t buffer[1024];
+	      wchar_t *ignore;
+	      status = (*cd->__codecvt_do_in) (cd,
+					       &fp->_wide_data->_IO_state,
+					       read_ptr_copy,
+					       fp->_IO_read_ptr,
+					       &read_ptr_copy,
+					       buffer,
+					       buffer
+					       + (sizeof (buffer)
+						  / sizeof (buffer[0])),
+					       &ignore);
+	      if (status != __codecvt_ok && status != __codecvt_partial)
 		{
-		  wchar_t buffer[1024];
-		  wchar_t *ignore;
-		  status = (*cd->__codecvt_do_in) (cd,
-						   &fp->_wide_data->_IO_state,
-						   read_ptr_copy,
-						   fp->_IO_read_ptr,
-						   &read_ptr_copy,
-						   buffer,
-						   buffer
-						   + (sizeof (buffer)
-						      / sizeof (buffer[0])),
-						   &ignore);
-		  if (status != __codecvt_ok && status != __codecvt_partial)
-		    {
-		      fp->_flags |= _IO_ERR_SEEN;
-		      goto dumb;
-		    }
+		  fp->_flags |= _IO_ERR_SEEN;
+		  goto dumb;
 		}
-	      while (read_ptr_copy != fp->_IO_read_ptr);
+	    }
+	  while (read_ptr_copy != fp->_IO_read_ptr);
 
-	      fp->_wide_data->_IO_read_ptr = fp->_wide_data->_IO_read_base;
+	  fp->_wide_data->_IO_read_ptr = fp->_wide_data->_IO_read_base;
 
-	      _IO_mask_flags (fp, 0, _IO_EOF_SEEN);
-	      goto resync;
-	    }
-#ifdef TODO
-	    /* If we have streammarkers, seek forward by reading ahead. */
-	    if (_IO_have_markers (fp))
-	      {
-		int to_skip = rel_offset
-		  - (fp->_IO_read_ptr - fp->_IO_read_base);
-		if (ignore (to_skip) != to_skip)
-		  goto dumb;
-		_IO_mask_flags (fp, 0, _IO_EOF_SEEN);
-		goto resync;
-	      }
-#endif
-	}
-#ifdef TODO
-      if (rel_offset < 0 && rel_offset >= Bbase () - Bptr ())
-	{
-	  if (!_IO_in_backup (fp))
-	    _IO_switch_to_backup_area (fp);
-	  gbump (fp->_IO_read_end + rel_offset - fp->_IO_read_ptr);
 	  _IO_mask_flags (fp, 0, _IO_EOF_SEEN);
 	  goto resync;
 	}
-#endif
     }
 
-#ifdef TODO
-  INTUSE(_IO_unsave_markers) (fp);
-#endif
-
   if (fp->_flags & _IO_NO_READS)
     goto dumb;