summary refs log tree commit diff
path: root/libio/wfileops.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2000-07-20 08:56:12 +0000
committerUlrich Drepper <drepper@redhat.com>2000-07-20 08:56:12 +0000
commit9c38a6899957746cbf2c0c04d110626a9271d51a (patch)
tree7baeb90b3aff1cf0acf63fed32577f3a9ad17764 /libio/wfileops.c
parent4e8286acfa4224ac9ccfb07e90b8fd70fab1467e (diff)
downloadglibc-9c38a6899957746cbf2c0c04d110626a9271d51a.tar.gz
glibc-9c38a6899957746cbf2c0c04d110626a9271d51a.tar.xz
glibc-9c38a6899957746cbf2c0c04d110626a9271d51a.zip
Update.
2000-07-20  Ulrich Drepper  <drepper@redhat.com>

	* libio/Makefile (tests): Add tst_wprintf2.
	(tst_wprintf2-ARGS): Define.
	* libio/tst_wprintf2.c: New file.
	Based on a test case by Yoshito Kawada <KAWADA@jp.ibm.com>.

	* libio/wfiledoalloc.c: Only allocate external buffer if this
	hasn't happened yet.

	* libio/wfileops.c (_IO_wdo_write): Overflow only if there is really
	something in the buffer.  gconv call can write up to end of the
	buffer, not only _IO_write_end.
	(_IO_wfile_overflow): Allocate also external buffer.

	* stdio-common/vfprintf.c (process_string_arg): Handle multibyte
	strings with precision in vfwprintf correctly.
	* stdio-common/vfprintf.c: Fix completely broken handling of
	unbuffered wide character streams.
	Reported by Yoshito Kawada <KAWADA@jp.ibm.com>.
Diffstat (limited to 'libio/wfileops.c')
-rw-r--r--libio/wfileops.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/libio/wfileops.c b/libio/wfileops.c
index 3489b36fb1..94c14c9151 100644
--- a/libio/wfileops.c
+++ b/libio/wfileops.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1995, 1997, 1998, 1999 Free Software Foundation, Inc.
+/* Copyright (C) 1993, 95, 97, 98, 99, 2000 Free Software Foundation, Inc.
    This file is part of the GNU IO Library.
    Written by Ulrich Drepper <drepper@cygnus.com>.
    Based on the single byte version by Per Bothner <bothner@cygnus.com>.
@@ -67,7 +67,8 @@ _IO_wdo_write (fp, data, to_do)
       enum __codecvt_result result;
       const wchar_t *new_data;
 
-      if (fp->_IO_write_end == fp->_IO_write_ptr)
+      if (fp->_IO_write_end == fp->_IO_write_ptr
+	  && fp->_IO_write_end != fp->_IO_write_base)
 	{
 	  _IO_new_file_overflow (fp, EOF);
 	  assert (fp->_IO_write_end > fp->_IO_write_ptr);
@@ -77,7 +78,7 @@ _IO_wdo_write (fp, data, to_do)
       result = (*cc->__codecvt_do_out) (cc, &fp->_wide_data->_IO_state,
 					data, data + to_do, &new_data,
 					fp->_IO_write_ptr,
-					fp->_IO_write_end,
+					fp->_IO_buf_end,
 					&fp->_IO_write_ptr);
 
       /* Write out what we produced so far.  */
@@ -289,6 +290,12 @@ _IO_wfile_overflow (f, wch)
 	  _IO_wdoallocbuf (f);
 	  _IO_wsetg (f, f->_wide_data->_IO_buf_base,
 		     f->_wide_data->_IO_buf_base, f->_wide_data->_IO_buf_base);
+
+	  if (f->_IO_write_base == NULL)
+	    {
+	      _IO_doallocbuf (f);
+	      _IO_setg (f, f->_IO_buf_base, f->_IO_buf_base, f->_IO_buf_base);
+	    }
 	}
       else
 	{
@@ -313,13 +320,18 @@ _IO_wfile_overflow (f, wch)
       f->_wide_data->_IO_read_base = f->_wide_data->_IO_read_ptr =
 	f->_wide_data->_IO_read_end;
 
+      f->_IO_write_ptr = f->_IO_read_ptr;
+      f->_IO_write_base = f->_IO_write_ptr;
+      f->_IO_write_end = f->_IO_buf_end;
+      f->_IO_read_base = f->_IO_read_ptr = f->_IO_read_end;
+
       f->_flags |= _IO_CURRENTLY_PUTTING;
       if (f->_flags & (_IO_LINE_BUF+_IO_UNBUFFERED))
 	f->_wide_data->_IO_write_end = f->_wide_data->_IO_write_ptr;
     }
   if (wch == WEOF)
     return _IO_do_flush (f);
-  if (f->_wide_data->_IO_write_ptr == f->_wide_data->_IO_buf_end )
+  if (f->_wide_data->_IO_write_ptr == f->_wide_data->_IO_buf_end)
     /* Buffer is really full */
     if (_IO_do_flush (f) == WEOF)
       return WEOF;