Commit 18acf3ba by Benjamin Kosnik Committed by Benjamin Kosnik

fileops.cc: Update to current glibc sources.



2000-07-31  Benjamin Kosnik  <bkoz@cygnus.com>

	* libio/fileops.cc: Update to current glibc sources.
	* libio/genops.c: Same.
	* libio/iofwide.c: Same.
	* libio/libio.h: Same.
	* libio/libioP.h: Same.
	* libio/wfiledoalloc.c: Same.
	* libio/wgenops.c: Same.

From-SVN: r35407
parent da92f7ff
2000-07-31 Benjamin Kosnik <bkoz@cygnus.com>
* libio/fileops.cc: Update to current glibc sources.
* libio/genops.c: Same.
* libio/iofwide.c: Same.
* libio/libio.h: Same.
* libio/libioP.h: Same.
* libio/wfiledoalloc.c: Same.
* libio/wgenops.c: Same.
2000-07-28 Alexandre Oliva <aoliva@redhat.com> 2000-07-28 Alexandre Oliva <aoliva@redhat.com>
* acinclude.m4: Include ../libtool.m4. * acinclude.m4: Include ../libtool.m4.
......
...@@ -380,8 +380,7 @@ _IO_new_do_write (fp, data, to_do) ...@@ -380,8 +380,7 @@ _IO_new_do_write (fp, data, to_do)
const char *data; const char *data;
_IO_size_t to_do; _IO_size_t to_do;
{ {
return (to_do == 0 || new_do_write (fp, data, to_do) == to_do) return (to_do == 0 || new_do_write (fp, data, to_do) == to_do) ? 0 : EOF;
? 0 : EOF;
} }
static static
......
...@@ -45,11 +45,11 @@ _IO_un_link (fp) ...@@ -45,11 +45,11 @@ _IO_un_link (fp)
#ifdef _IO_MTSAFE_IO #ifdef _IO_MTSAFE_IO
_IO_lock_lock (list_all_lock); _IO_lock_lock (list_all_lock);
#endif #endif
for (f = &_IO_list_all; *f != NULL; f = &(*f)->file._chain) for (f = &_IO_list_all; *f; f = (struct _IO_FILE_plus **) &(*f)->file._chain)
{ {
if (*f == fp) if (*f == fp)
{ {
*f = fp->file._chain; *f = (struct _IO_FILE_plus *) fp->file._chain;
break; break;
} }
} }
...@@ -70,7 +70,7 @@ _IO_link_in (fp) ...@@ -70,7 +70,7 @@ _IO_link_in (fp)
#ifdef _IO_MTSAFE_IO #ifdef _IO_MTSAFE_IO
_IO_lock_lock (list_all_lock); _IO_lock_lock (list_all_lock);
#endif #endif
fp->file._chain = _IO_list_all; fp->file._chain = (_IO_FILE *) _IO_list_all;
_IO_list_all = fp; _IO_list_all = fp;
#ifdef _IO_MTSAFE_IO #ifdef _IO_MTSAFE_IO
_IO_lock_unlock (list_all_lock); _IO_lock_unlock (list_all_lock);
...@@ -194,6 +194,9 @@ __overflow (f, ch) ...@@ -194,6 +194,9 @@ __overflow (f, ch)
_IO_FILE *f; _IO_FILE *f;
int ch; int ch;
{ {
/* This is a single-byte stream. */
if (f->_mode == 0)
_IO_fwide (f, -1);
return _IO_OVERFLOW (f, ch); return _IO_OVERFLOW (f, ch);
} }
...@@ -287,6 +290,8 @@ __underflow (fp) ...@@ -287,6 +290,8 @@ __underflow (fp)
return EOF; return EOF;
#endif #endif
if (fp->_mode == 0)
_IO_fwide (fp, -1);
if (_IO_in_put_mode (fp)) if (_IO_in_put_mode (fp))
if (_IO_switch_to_get_mode (fp) == EOF) if (_IO_switch_to_get_mode (fp) == EOF)
return EOF; return EOF;
...@@ -317,6 +322,8 @@ __uflow (fp) ...@@ -317,6 +322,8 @@ __uflow (fp)
return EOF; return EOF;
#endif #endif
if (fp->_mode == 0)
_IO_fwide (fp, -11);
if (_IO_in_put_mode (fp)) if (_IO_in_put_mode (fp))
if (_IO_switch_to_get_mode (fp) == EOF) if (_IO_switch_to_get_mode (fp) == EOF)
return EOF; return EOF;
...@@ -745,17 +752,15 @@ int ...@@ -745,17 +752,15 @@ int
_IO_flush_all () _IO_flush_all ()
{ {
int result = 0; int result = 0;
struct _IO_FILE_plus *fp; struct _IO_FILE *fp;
for (fp = _IO_list_all; fp != NULL; fp = fp->file._chain) for (fp = (_IO_FILE *) _IO_list_all; fp; fp = fp->_chain)
if (((fp->file._mode < 0 && fp->file._IO_write_ptr > fp->file._IO_write_base) if (((fp->_mode < 0 && fp->_IO_write_ptr > fp->_IO_write_base)
#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T #if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
|| (fp->_vtable_offset == 0
|| (fp->file._vtable_offset == 0 && fp->_mode > 0 && (fp->_wide_data->_IO_write_ptr
&& fp->file._mode > 0 && (fp->file._wide_data->_IO_write_ptr > fp->_wide_data->_IO_write_base)))
> fp->file._wide_data->_IO_write_base))
#endif #endif
) && _IO_OVERFLOW (fp, EOF) == EOF)
&& _IO_OVERFLOW (&fp->file, EOF) == EOF)
result = EOF; result = EOF;
return result; return result;
} }
...@@ -763,10 +768,10 @@ _IO_flush_all () ...@@ -763,10 +768,10 @@ _IO_flush_all ()
void void
_IO_flush_all_linebuffered () _IO_flush_all_linebuffered ()
{ {
struct _IO_FILE_plus *fp; struct _IO_FILE *fp;
for (fp = _IO_list_all; fp != NULL; fp = fp->file._chain) for (fp = (_IO_FILE *) _IO_list_all; fp; fp = fp->_chain)
if ((fp->file._flags & _IO_NO_WRITES) == 0 && fp->file._flags & _IO_LINE_BUF) if ((fp->_flags & _IO_NO_WRITES) == 0 && fp->_flags & _IO_LINE_BUF)
_IO_OVERFLOW (&fp->file, EOF); _IO_OVERFLOW (fp, EOF);
} }
static void _IO_unbuffer_write __P ((void)); static void _IO_unbuffer_write __P ((void));
...@@ -774,12 +779,12 @@ static void _IO_unbuffer_write __P ((void)); ...@@ -774,12 +779,12 @@ static void _IO_unbuffer_write __P ((void));
static void static void
_IO_unbuffer_write () _IO_unbuffer_write ()
{ {
struct _IO_FILE_plus *fp; struct _IO_FILE *fp;
for (fp = _IO_list_all; fp != NULL; fp = fp->file._chain) for (fp = (_IO_FILE *) _IO_list_all; fp; fp = fp->_chain)
if (! (fp->file._flags & _IO_UNBUFFERED) if (! (fp->_flags & _IO_UNBUFFERED)
&& (! (fp->file._flags & _IO_NO_WRITES) && (! (fp->_flags & _IO_NO_WRITES)
|| (fp->file._flags & _IO_IS_APPENDING))) || (fp->_flags & _IO_IS_APPENDING)))
_IO_SETBUF (&fp->file, NULL, 0); _IO_SETBUF (fp, NULL, 0);
} }
int int
...@@ -1039,7 +1044,7 @@ _IO_default_imbue (fp, locale) ...@@ -1039,7 +1044,7 @@ _IO_default_imbue (fp, locale)
_IO_ITER _IO_ITER
_IO_iter_begin() _IO_iter_begin()
{ {
return _IO_list_all; return (_IO_ITER) _IO_list_all;
} }
_IO_ITER _IO_ITER
...@@ -1052,14 +1057,14 @@ _IO_ITER ...@@ -1052,14 +1057,14 @@ _IO_ITER
_IO_iter_next(iter) _IO_iter_next(iter)
_IO_ITER iter; _IO_ITER iter;
{ {
return iter->file._chain; return iter->_chain;
} }
_IO_FILE * _IO_FILE *
_IO_iter_file(iter) _IO_iter_file(iter)
_IO_ITER iter; _IO_ITER iter;
{ {
return (_IO_FILE *) iter; return iter;
} }
void void
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
# include <langinfo.h> # include <langinfo.h>
# include <locale/localeinfo.h> # include <locale/localeinfo.h>
# include <wcsmbs/wcsmbsload.h> # include <wcsmbs/wcsmbsload.h>
# include <iconv/gconv_int.h>
#endif #endif
...@@ -76,6 +77,14 @@ struct _IO_codecvt __libio_codecvt = ...@@ -76,6 +77,14 @@ struct _IO_codecvt __libio_codecvt =
}; };
/* static struct __gconv_trans_data libio_translit =*/
#ifdef _LIBC
struct __gconv_trans_data libio_translit =
{
.__trans_fct = __gconv_transliterate
};
#endif
/* Return orientation of stream. If mode is nonzero try to change /* Return orientation of stream. If mode is nonzero try to change
the orientation first. */ the orientation first. */
#undef _IO_fwide #undef _IO_fwide
...@@ -92,9 +101,6 @@ _IO_fwide (fp, mode) ...@@ -92,9 +101,6 @@ _IO_fwide (fp, mode)
or the orientation already has been determined. */ or the orientation already has been determined. */
return fp->_mode; return fp->_mode;
_IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
_IO_flockfile (fp);
/* Set the orientation appropriately. */ /* Set the orientation appropriately. */
if (mode > 0) if (mode > 0)
{ {
...@@ -138,7 +144,11 @@ _IO_fwide (fp, mode) ...@@ -138,7 +144,11 @@ _IO_fwide (fp, mode)
cc->__cd_out.__cd.__data[0].__statep = &fp->_wide_data->_IO_state; cc->__cd_out.__cd.__data[0].__statep = &fp->_wide_data->_IO_state;
/* XXX For now no transliteration. */ /* XXX For now no transliteration. */
#ifdef _LIBC
cc->__cd_out.__cd.__data[0].__trans = &libio_translit;
#else
cc->__cd_out.__cd.__data[0].__trans = NULL; cc->__cd_out.__cd.__data[0].__trans = NULL;
#endif
} }
#else #else
# ifdef _GLIBCPP_USE_WCHAR_T # ifdef _GLIBCPP_USE_WCHAR_T
...@@ -179,9 +189,6 @@ _IO_fwide (fp, mode) ...@@ -179,9 +189,6 @@ _IO_fwide (fp, mode)
/* Set the mode now. */ /* Set the mode now. */
fp->_mode = mode; fp->_mode = mode;
_IO_funlockfile (fp);
_IO_cleanup_region_end (0);
return mode; return mode;
} }
......
...@@ -259,8 +259,6 @@ struct _IO_wide_data ...@@ -259,8 +259,6 @@ struct _IO_wide_data
#endif #endif
}; };
struct _IO_FILE_plus;
struct _IO_FILE { struct _IO_FILE {
int _flags; /* High-order word is _IO_MAGIC; rest is flags. */ int _flags; /* High-order word is _IO_MAGIC; rest is flags. */
#define _IO_file_flags _flags #define _IO_file_flags _flags
...@@ -282,7 +280,7 @@ struct _IO_FILE { ...@@ -282,7 +280,7 @@ struct _IO_FILE {
struct _IO_marker *_markers; struct _IO_marker *_markers;
struct _IO_FILE_plus *_chain; struct _IO_FILE *_chain;
int _fileno; int _fileno;
int _blksize; int _blksize;
...@@ -324,6 +322,8 @@ struct _IO_FILE_complete ...@@ -324,6 +322,8 @@ struct _IO_FILE_complete
typedef struct _IO_FILE _IO_FILE; typedef struct _IO_FILE _IO_FILE;
#endif #endif
struct _IO_FILE_plus;
extern struct _IO_FILE_plus _IO_2_1_stdin_; extern struct _IO_FILE_plus _IO_2_1_stdin_;
extern struct _IO_FILE_plus _IO_2_1_stdout_; extern struct _IO_FILE_plus _IO_2_1_stdout_;
extern struct _IO_FILE_plus _IO_2_1_stderr_; extern struct _IO_FILE_plus _IO_2_1_stderr_;
......
...@@ -323,7 +323,7 @@ struct _IO_cookie_file ...@@ -323,7 +323,7 @@ struct _IO_cookie_file
/* Iterator type for walking global linked list of _IO_FILE objects. */ /* Iterator type for walking global linked list of _IO_FILE objects. */
typedef struct _IO_FILE_plus *_IO_ITER; typedef struct _IO_FILE *_IO_ITER;
/* Generic functions */ /* Generic functions */
...@@ -714,19 +714,19 @@ extern int _IO_vscanf __P ((const char *, _IO_va_list)); ...@@ -714,19 +714,19 @@ extern int _IO_vscanf __P ((const char *, _IO_va_list));
# ifdef _IO_USE_OLD_IO_FILE # ifdef _IO_USE_OLD_IO_FILE
# define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \ # define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \
{ _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \ { _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, CHAIN, FD, \ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (_IO_FILE *) CHAIN, FD, \
0, _IO_pos_BAD, 0, 0, { 0 }, &_IO_stdfile_##FD##_lock } 0, _IO_pos_BAD, 0, 0, { 0 }, &_IO_stdfile_##FD##_lock }
# else # else
# if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T # if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
# define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \ # define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \
{ _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \ { _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, CHAIN, FD, \ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (_IO_FILE *) CHAIN, FD, \
0, _IO_pos_BAD, 0, 0, { 0 }, &_IO_stdfile_##FD##_lock, _IO_pos_BAD,\ 0, _IO_pos_BAD, 0, 0, { 0 }, &_IO_stdfile_##FD##_lock, _IO_pos_BAD,\
NULL, WDP, 0 } NULL, WDP, 0 }
# else # else
# define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \ # define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \
{ _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \ { _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, CHAIN, FD, \ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (_IO_FILE *) CHAIN, FD, \
0, _IO_pos_BAD, 0, 0, { 0 }, &_IO_stdfile_##FD##_lock, _IO_pos_BAD,\ 0, _IO_pos_BAD, 0, 0, { 0 }, &_IO_stdfile_##FD##_lock, _IO_pos_BAD,\
0 } 0 }
# endif # endif
...@@ -735,18 +735,19 @@ extern int _IO_vscanf __P ((const char *, _IO_va_list)); ...@@ -735,18 +735,19 @@ extern int _IO_vscanf __P ((const char *, _IO_va_list));
# ifdef _IO_USE_OLD_IO_FILE # ifdef _IO_USE_OLD_IO_FILE
# define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \ # define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \
{ _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \ { _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, CHAIN, FD, 0, _IO_pos_BAD } 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (_IO_FILE *) CHAIN, FD, \
0, _IO_pos_BAD }
# else # else
# if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T # if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
# define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \ # define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \
{ _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \ { _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, CHAIN, FD, \ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (_IO_FILE *) CHAIN, FD, \
0, _IO_pos_BAD, 0, 0, { 0 }, 0, _IO_pos_BAD, \ 0, _IO_pos_BAD, 0, 0, { 0 }, 0, _IO_pos_BAD, \
NULL, WDP, 0 } NULL, WDP, 0 }
# else # else
# define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \ # define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \
{ _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \ { _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, CHAIN, FD, \ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (_IO_FILE *) CHAIN, FD, \
0, _IO_pos_BAD, 0, 0, { 0 }, 0, _IO_pos_BAD, \ 0, _IO_pos_BAD, 0, 0, { 0 }, 0, _IO_pos_BAD, \
0 } 0 }
# endif # endif
......
/* Copyright (C) 1993, 1997, 1999 Free Software Foundation, Inc. /* Copyright (C) 1993, 1997, 1999, 2000 Free Software Foundation, Inc.
This file is part of the GNU IO Library. This file is part of the GNU IO Library.
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
...@@ -76,12 +76,13 @@ _IO_wfile_doallocate (fp) ...@@ -76,12 +76,13 @@ _IO_wfile_doallocate (fp)
struct _G_stat64 st; struct _G_stat64 st;
/* Allocate room for the external buffer. */ /* Allocate room for the external buffer. */
_IO_file_doallocate (fp); if (fp->_IO_buf_base == NULL)
_IO_file_doallocate (fp);
if (fp->_fileno < 0 || _IO_SYSSTAT (fp, &st) < 0) if (fp->_fileno < 0 || _IO_SYSSTAT (fp, &st) < 0)
{ {
couldbetty = 0; couldbetty = 0;
size = _IO_BUFSIZ * sizeof (wchar_t); size = _IO_BUFSIZ;
#if 0 #if 0
/* do not try to optimise fseek() */ /* do not try to optimise fseek() */
fp->_flags |= __SNPT; fp->_flags |= __SNPT;
...@@ -91,13 +92,12 @@ _IO_wfile_doallocate (fp) ...@@ -91,13 +92,12 @@ _IO_wfile_doallocate (fp)
{ {
couldbetty = S_ISCHR (st.st_mode); couldbetty = S_ISCHR (st.st_mode);
#if _IO_HAVE_ST_BLKSIZE #if _IO_HAVE_ST_BLKSIZE
size = ((st.st_blksize <= 0 ? _IO_BUFSIZ : st.st_blksize) size = st.st_blksize <= 0 ? _IO_BUFSIZ : st.st_blksize;
* sizeof (wchar_t));
#else #else
size = _IO_BUFSIZ * sizeof (wchar_t); size = _IO_BUFSIZ;
#endif #endif
} }
ALLOC_WBUF (p, size, EOF); ALLOC_WBUF (p, size * sizeof (wchar_t), EOF);
_IO_wsetb (fp, p, p + size, 1); _IO_wsetb (fp, p, p + size, 1);
if (couldbetty && isatty (fp->_fileno)) if (couldbetty && isatty (fp->_fileno))
fp->_flags |= _IO_LINE_BUF; fp->_flags |= _IO_LINE_BUF;
......
/* 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. This file is part of the GNU IO Library.
Written by Ulrich Drepper <drepper@cygnus.com>. Written by Ulrich Drepper <drepper@cygnus.com>.
Based on the single byte version by Per Bothner <bothner@cygnus.com>. Based on the single byte version by Per Bothner <bothner@cygnus.com>.
...@@ -77,40 +77,46 @@ _IO_wdo_write (fp, data, to_do) ...@@ -77,40 +77,46 @@ _IO_wdo_write (fp, data, to_do)
_IO_size_t to_do; _IO_size_t to_do;
{ {
struct _IO_codecvt *cc = &fp->_wide_data->_codecvt; struct _IO_codecvt *cc = &fp->_wide_data->_codecvt;
_IO_size_t count = 0;
while (to_do > 0) if (to_do > 0)
{ {
enum __codecvt_result result; if (fp->_IO_write_end == fp->_IO_write_ptr
const wchar_t *new_data; && fp->_IO_write_end != fp->_IO_write_base)
if (fp->_IO_write_end == fp->_IO_write_ptr)
{ {
_IO_new_file_overflow (fp, EOF); if (_IO_new_do_write (fp, fp->_IO_write_base,
assert (fp->_IO_write_end > fp->_IO_write_ptr); fp->_IO_write_ptr - fp->_IO_write_base) == EOF)
return EOF;
} }
/* Now convert from the internal format into the external buffer. */ do
result = (*cc->__codecvt_do_out) (cc, &fp->_wide_data->_IO_state, {
data, data + to_do, &new_data, enum __codecvt_result result;
fp->_IO_write_ptr, const wchar_t *new_data;
fp->_IO_write_end,
&fp->_IO_write_ptr); /* Now convert from the internal format into the external buffer. */
result = (*cc->__codecvt_do_out) (cc, &fp->_wide_data->_IO_state,
/* Write out what we produced so far. */ data, data + to_do, &new_data,
if (_IO_new_do_write (fp, fp->_IO_write_base, fp->_IO_write_ptr,
fp->_IO_write_ptr - fp->_IO_write_base) == EOF) fp->_IO_buf_end,
/* Something went wrong. */ &fp->_IO_write_ptr);
return EOF;
/* Write out what we produced so far. */
count += new_data - data; if (_IO_new_do_write (fp, fp->_IO_write_base,
to_do -= new_data - data; fp->_IO_write_ptr - fp->_IO_write_base) == EOF)
data = new_data; /* Something went wrong. */
return EOF;
/* Next see whether we had problems during the conversion. If yes,
we cannot go on. */ to_do -= new_data - data;
if (result != __codecvt_ok)
break; /* Next see whether we had problems during the conversion. If yes,
we cannot go on. */
if (result != __codecvt_ok
&& (result != __codecvt_partial || new_data - data == 0))
break;
data = new_data;
}
while (to_do > 0);
} }
_IO_wsetg (fp, fp->_wide_data->_IO_buf_base, fp->_wide_data->_IO_buf_base, _IO_wsetg (fp, fp->_wide_data->_IO_buf_base, fp->_wide_data->_IO_buf_base,
...@@ -121,7 +127,7 @@ _IO_wdo_write (fp, data, to_do) ...@@ -121,7 +127,7 @@ _IO_wdo_write (fp, data, to_do)
? fp->_wide_data->_IO_buf_base ? fp->_wide_data->_IO_buf_base
: fp->_wide_data->_IO_buf_end); : fp->_wide_data->_IO_buf_end);
return count; return to_do == 0 ? 0 : WEOF;
} }
...@@ -190,9 +196,6 @@ _IO_wfile_underflow (fp) ...@@ -190,9 +196,6 @@ _IO_wfile_underflow (fp)
fp->_IO_read_base = fp->_IO_read_ptr = fp->_IO_read_end = fp->_IO_read_base = fp->_IO_read_ptr = fp->_IO_read_end =
fp->_IO_buf_base; fp->_IO_buf_base;
fp->_IO_write_base = fp->_IO_write_ptr = fp->_IO_write_end =
fp->_IO_buf_base;
if (fp->_IO_buf_base == NULL) if (fp->_IO_buf_base == NULL)
{ {
/* Maybe we already have a push back pointer. */ /* Maybe we already have a push back pointer. */
...@@ -202,8 +205,14 @@ _IO_wfile_underflow (fp) ...@@ -202,8 +205,14 @@ _IO_wfile_underflow (fp)
fp->_flags &= ~_IO_IN_BACKUP; fp->_flags &= ~_IO_IN_BACKUP;
} }
_IO_doallocbuf (fp); _IO_doallocbuf (fp);
fp->_IO_read_base = fp->_IO_read_ptr = fp->_IO_read_end =
fp->_IO_buf_base;
} }
fp->_IO_write_base = fp->_IO_write_ptr = fp->_IO_write_end =
fp->_IO_buf_base;
if (fp->_wide_data->_IO_buf_base == NULL) if (fp->_wide_data->_IO_buf_base == NULL)
{ {
/* Maybe we already have a push back pointer. */ /* Maybe we already have a push back pointer. */
...@@ -222,11 +231,6 @@ _IO_wfile_underflow (fp) ...@@ -222,11 +231,6 @@ _IO_wfile_underflow (fp)
_IO_switch_to_get_mode (fp); _IO_switch_to_get_mode (fp);
fp->_IO_read_base = fp->_IO_read_ptr = fp->_IO_buf_base;
fp->_IO_read_end = fp->_IO_buf_base;
fp->_IO_write_base = fp->_IO_write_ptr = fp->_IO_write_end
= fp->_IO_buf_base;
fp->_wide_data->_IO_read_base = fp->_wide_data->_IO_read_ptr = fp->_wide_data->_IO_read_base = fp->_wide_data->_IO_read_ptr =
fp->_wide_data->_IO_buf_base; fp->_wide_data->_IO_buf_base;
fp->_wide_data->_IO_read_end = fp->_wide_data->_IO_buf_base; fp->_wide_data->_IO_read_end = fp->_wide_data->_IO_buf_base;
...@@ -306,6 +310,12 @@ _IO_wfile_overflow (f, wch) ...@@ -306,6 +310,12 @@ _IO_wfile_overflow (f, wch)
_IO_wdoallocbuf (f); _IO_wdoallocbuf (f);
_IO_wsetg (f, f->_wide_data->_IO_buf_base, _IO_wsetg (f, f->_wide_data->_IO_buf_base,
f->_wide_data->_IO_buf_base, 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 else
{ {
...@@ -330,13 +340,18 @@ _IO_wfile_overflow (f, wch) ...@@ -330,13 +340,18 @@ _IO_wfile_overflow (f, wch)
f->_wide_data->_IO_read_base = f->_wide_data->_IO_read_ptr = f->_wide_data->_IO_read_base = f->_wide_data->_IO_read_ptr =
f->_wide_data->_IO_read_end; 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; f->_flags |= _IO_CURRENTLY_PUTTING;
if (f->_flags & (_IO_LINE_BUF+_IO_UNBUFFERED)) if (f->_flags & (_IO_LINE_BUF+_IO_UNBUFFERED))
f->_wide_data->_IO_write_end = f->_wide_data->_IO_write_ptr; f->_wide_data->_IO_write_end = f->_wide_data->_IO_write_ptr;
} }
if (wch == WEOF) if (wch == WEOF)
return _IO_do_flush (f); 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 */ /* Buffer is really full */
if (_IO_do_flush (f) == WEOF) if (_IO_do_flush (f) == WEOF)
return WEOF; return WEOF;
......
...@@ -275,6 +275,8 @@ __wunderflow (fp) ...@@ -275,6 +275,8 @@ __wunderflow (fp)
if (fp->_mode < 0 || (fp->_mode == 0 && _IO_fwide (fp, 1) != 1)) if (fp->_mode < 0 || (fp->_mode == 0 && _IO_fwide (fp, 1) != 1))
return WEOF; return WEOF;
if (fp->_mode == 0)
_IO_fwide (fp, 1);
if (_IO_in_put_mode (fp)) if (_IO_in_put_mode (fp))
if (_IO_switch_to_wget_mode (fp) == EOF) if (_IO_switch_to_wget_mode (fp) == EOF)
return WEOF; return WEOF;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment