+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>
* acinclude.m4: Include ../libtool.m4.
const char *data;
_IO_size_t to_do;
{
- return (to_do == 0 || new_do_write (fp, data, to_do) == to_do)
- ? 0 : EOF;
+ return (to_do == 0 || new_do_write (fp, data, to_do) == to_do) ? 0 : EOF;
}
static
#ifdef _IO_MTSAFE_IO
_IO_lock_lock (list_all_lock);
#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)
{
- *f = fp->file._chain;
+ *f = (struct _IO_FILE_plus *) fp->file._chain;
break;
}
}
#ifdef _IO_MTSAFE_IO
_IO_lock_lock (list_all_lock);
#endif
- fp->file._chain = _IO_list_all;
+ fp->file._chain = (_IO_FILE *) _IO_list_all;
_IO_list_all = fp;
#ifdef _IO_MTSAFE_IO
_IO_lock_unlock (list_all_lock);
_IO_FILE *f;
int ch;
{
+ /* This is a single-byte stream. */
+ if (f->_mode == 0)
+ _IO_fwide (f, -1);
return _IO_OVERFLOW (f, ch);
}
return EOF;
#endif
+ if (fp->_mode == 0)
+ _IO_fwide (fp, -1);
if (_IO_in_put_mode (fp))
if (_IO_switch_to_get_mode (fp) == EOF)
return EOF;
return EOF;
#endif
+ if (fp->_mode == 0)
+ _IO_fwide (fp, -11);
if (_IO_in_put_mode (fp))
if (_IO_switch_to_get_mode (fp) == EOF)
return EOF;
_IO_flush_all ()
{
int result = 0;
- struct _IO_FILE_plus *fp;
- for (fp = _IO_list_all; fp != NULL; fp = fp->file._chain)
- if (((fp->file._mode < 0 && fp->file._IO_write_ptr > fp->file._IO_write_base)
+ struct _IO_FILE *fp;
+ for (fp = (_IO_FILE *) _IO_list_all; fp; fp = fp->_chain)
+ if (((fp->_mode < 0 && fp->_IO_write_ptr > fp->_IO_write_base)
#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
-
- || (fp->file._vtable_offset == 0
- && fp->file._mode > 0 && (fp->file._wide_data->_IO_write_ptr
- > fp->file._wide_data->_IO_write_base))
+ || (fp->_vtable_offset == 0
+ && fp->_mode > 0 && (fp->_wide_data->_IO_write_ptr
+ > fp->_wide_data->_IO_write_base)))
#endif
- )
- && _IO_OVERFLOW (&fp->file, EOF) == EOF)
+ && _IO_OVERFLOW (fp, EOF) == EOF)
result = EOF;
return result;
}
void
_IO_flush_all_linebuffered ()
{
- struct _IO_FILE_plus *fp;
- for (fp = _IO_list_all; fp != NULL; fp = fp->file._chain)
- if ((fp->file._flags & _IO_NO_WRITES) == 0 && fp->file._flags & _IO_LINE_BUF)
- _IO_OVERFLOW (&fp->file, EOF);
+ struct _IO_FILE *fp;
+ for (fp = (_IO_FILE *) _IO_list_all; fp; fp = fp->_chain)
+ if ((fp->_flags & _IO_NO_WRITES) == 0 && fp->_flags & _IO_LINE_BUF)
+ _IO_OVERFLOW (fp, EOF);
}
static void _IO_unbuffer_write __P ((void));
static void
_IO_unbuffer_write ()
{
- struct _IO_FILE_plus *fp;
- for (fp = _IO_list_all; fp != NULL; fp = fp->file._chain)
- if (! (fp->file._flags & _IO_UNBUFFERED)
- && (! (fp->file._flags & _IO_NO_WRITES)
- || (fp->file._flags & _IO_IS_APPENDING)))
- _IO_SETBUF (&fp->file, NULL, 0);
+ struct _IO_FILE *fp;
+ for (fp = (_IO_FILE *) _IO_list_all; fp; fp = fp->_chain)
+ if (! (fp->_flags & _IO_UNBUFFERED)
+ && (! (fp->_flags & _IO_NO_WRITES)
+ || (fp->_flags & _IO_IS_APPENDING)))
+ _IO_SETBUF (fp, NULL, 0);
}
int
_IO_ITER
_IO_iter_begin()
{
- return _IO_list_all;
+ return (_IO_ITER) _IO_list_all;
}
_IO_ITER
_IO_iter_next(iter)
_IO_ITER iter;
{
- return iter->file._chain;
+ return iter->_chain;
}
_IO_FILE *
_IO_iter_file(iter)
_IO_ITER iter;
{
- return (_IO_FILE *) iter;
+ return iter;
}
void
# include <langinfo.h>
# include <locale/localeinfo.h>
# include <wcsmbs/wcsmbsload.h>
+# include <iconv/gconv_int.h>
#endif
};
+/* 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
the orientation first. */
#undef _IO_fwide
or the orientation already has been determined. */
return fp->_mode;
- _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
- _IO_flockfile (fp);
-
/* Set the orientation appropriately. */
if (mode > 0)
{
cc->__cd_out.__cd.__data[0].__statep = &fp->_wide_data->_IO_state;
/* 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;
+#endif
}
#else
# ifdef _GLIBCPP_USE_WCHAR_T
/* Set the mode now. */
fp->_mode = mode;
- _IO_funlockfile (fp);
- _IO_cleanup_region_end (0);
-
return mode;
}
#endif
};
-struct _IO_FILE_plus;
-
struct _IO_FILE {
int _flags; /* High-order word is _IO_MAGIC; rest is flags. */
#define _IO_file_flags _flags
struct _IO_marker *_markers;
- struct _IO_FILE_plus *_chain;
+ struct _IO_FILE *_chain;
int _fileno;
int _blksize;
typedef struct _IO_FILE _IO_FILE;
#endif
+struct _IO_FILE_plus;
+
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_stderr_;
/* 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 */
# ifdef _IO_USE_OLD_IO_FILE
# define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \
{ _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 }, &_IO_stdfile_##FD##_lock }
+ 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 }
# else
# if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
# define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \
{ _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,\
NULL, WDP, 0 }
# else
# define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \
{ _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 }
# endif
# ifdef _IO_USE_OLD_IO_FILE
# define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \
{ _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
# if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
# define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \
{ _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, \
NULL, WDP, 0 }
# else
# define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \
{ _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 }
# 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 library is free software; you can redistribute it and/or
struct _G_stat64 st;
/* 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)
{
couldbetty = 0;
- size = _IO_BUFSIZ * sizeof (wchar_t);
+ size = _IO_BUFSIZ;
#if 0
/* do not try to optimise fseek() */
fp->_flags |= __SNPT;
{
couldbetty = S_ISCHR (st.st_mode);
#if _IO_HAVE_ST_BLKSIZE
- size = ((st.st_blksize <= 0 ? _IO_BUFSIZ : st.st_blksize)
- * sizeof (wchar_t));
+ size = st.st_blksize <= 0 ? _IO_BUFSIZ : st.st_blksize;
#else
- size = _IO_BUFSIZ * sizeof (wchar_t);
+ size = _IO_BUFSIZ;
#endif
}
- ALLOC_WBUF (p, size, EOF);
+ ALLOC_WBUF (p, size * sizeof (wchar_t), EOF);
_IO_wsetb (fp, p, p + size, 1);
if (couldbetty && isatty (fp->_fileno))
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.
Written by Ulrich Drepper <drepper@cygnus.com>.
Based on the single byte version by Per Bothner <bothner@cygnus.com>.
_IO_size_t to_do;
{
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;
- 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);
+ if (_IO_new_do_write (fp, fp->_IO_write_base,
+ fp->_IO_write_ptr - fp->_IO_write_base) == EOF)
+ return EOF;
}
- /* Now convert from the internal format into the external buffer. */
- 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_write_ptr);
-
- /* Write out what we produced so far. */
- if (_IO_new_do_write (fp, fp->_IO_write_base,
- fp->_IO_write_ptr - fp->_IO_write_base) == EOF)
- /* Something went wrong. */
- return EOF;
-
- count += new_data - data;
- to_do -= new_data - data;
- data = new_data;
-
- /* Next see whether we had problems during the conversion. If yes,
- we cannot go on. */
- if (result != __codecvt_ok)
- break;
+ do
+ {
+ enum __codecvt_result result;
+ const wchar_t *new_data;
+
+ /* Now convert from the internal format into the external buffer. */
+ result = (*cc->__codecvt_do_out) (cc, &fp->_wide_data->_IO_state,
+ data, data + to_do, &new_data,
+ fp->_IO_write_ptr,
+ fp->_IO_buf_end,
+ &fp->_IO_write_ptr);
+
+ /* Write out what we produced so far. */
+ if (_IO_new_do_write (fp, fp->_IO_write_base,
+ fp->_IO_write_ptr - fp->_IO_write_base) == EOF)
+ /* Something went wrong. */
+ return EOF;
+
+ to_do -= new_data - data;
+
+ /* 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,
? fp->_wide_data->_IO_buf_base
: fp->_wide_data->_IO_buf_end);
- return count;
+ return to_do == 0 ? 0 : WEOF;
}
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->_IO_buf_base == NULL)
{
/* Maybe we already have a push back pointer. */
fp->_flags &= ~_IO_IN_BACKUP;
}
_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)
{
/* Maybe we already have a push back pointer. */
_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_buf_base;
fp->_wide_data->_IO_read_end = fp->_wide_data->_IO_buf_base;
_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
{
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;
if (fp->_mode < 0 || (fp->_mode == 0 && _IO_fwide (fp, 1) != 1))
return WEOF;
+ if (fp->_mode == 0)
+ _IO_fwide (fp, 1);
if (_IO_in_put_mode (fp))
if (_IO_switch_to_wget_mode (fp) == EOF)
return WEOF;