OSDN Git Service

2000-07-31 Benjamin Kosnik <bkoz@cygnus.com>
authorbkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 1 Aug 2000 07:44:11 +0000 (07:44 +0000)
committerbkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 1 Aug 2000 07:44:11 +0000 (07:44 +0000)
* 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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@35407 138bc75d-0d04-0410-961f-82ee72b054a4

libstdc++-v3/ChangeLog
libstdc++-v3/libio/fileops.c
libstdc++-v3/libio/genops.c
libstdc++-v3/libio/iofwide.c
libstdc++-v3/libio/libio.h
libstdc++-v3/libio/libioP.h
libstdc++-v3/libio/wfiledoalloc.c
libstdc++-v3/libio/wfileops.c
libstdc++-v3/libio/wgenops.c

index 825ef61..75d91b4 100644 (file)
@@ -1,3 +1,13 @@
+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.
index 122203e..f3baa04 100644 (file)
@@ -380,8 +380,7 @@ _IO_new_do_write (fp, data, to_do)
      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
index c27f314..281bab0 100644 (file)
@@ -45,11 +45,11 @@ _IO_un_link (fp)
 #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;
            }
        }
@@ -70,7 +70,7 @@ _IO_link_in (fp)
 #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);
@@ -194,6 +194,9 @@ __overflow (f, ch)
      _IO_FILE *f;
      int ch;
 {
+  /* This is a single-byte stream.  */
+  if (f->_mode == 0)
+    _IO_fwide (f, -1);
   return _IO_OVERFLOW (f, ch);
 }
 
@@ -287,6 +290,8 @@ __underflow (fp)
     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;
@@ -317,6 +322,8 @@ __uflow (fp)
     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;
@@ -745,17 +752,15 @@ int
 _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;
 }
@@ -763,10 +768,10 @@ _IO_flush_all ()
 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));
@@ -774,12 +779,12 @@ 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
@@ -1039,7 +1044,7 @@ _IO_default_imbue (fp, locale)
 _IO_ITER
 _IO_iter_begin()
 {
-  return _IO_list_all;
+  return (_IO_ITER) _IO_list_all;
 }
 
 _IO_ITER
@@ -1052,14 +1057,14 @@ _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
index 39c7b02..5032ce5 100644 (file)
@@ -35,6 +35,7 @@
 # include <langinfo.h>
 # include <locale/localeinfo.h>
 # include <wcsmbs/wcsmbsload.h>
+# include <iconv/gconv_int.h>
 #endif
 
 
@@ -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
    the orientation first.  */
 #undef _IO_fwide
@@ -92,9 +101,6 @@ _IO_fwide (fp, mode)
        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)
     {
@@ -138,7 +144,11 @@ _IO_fwide (fp, mode)
        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
@@ -179,9 +189,6 @@ _IO_fwide (fp, mode)
   /* Set the mode now.  */
   fp->_mode = mode;
 
-  _IO_funlockfile (fp);
-  _IO_cleanup_region_end (0);
-
   return mode;
 }
 
index e9fb03e..7b3b2e1 100644 (file)
@@ -259,8 +259,6 @@ struct _IO_wide_data
 #endif
 };
 
-struct _IO_FILE_plus;
-
 struct _IO_FILE {
   int _flags;          /* High-order word is _IO_MAGIC; rest is flags. */
 #define _IO_file_flags _flags
@@ -282,7 +280,7 @@ struct _IO_FILE {
 
   struct _IO_marker *_markers;
 
-  struct _IO_FILE_plus *_chain;
+  struct _IO_FILE *_chain;
 
   int _fileno;
   int _blksize;
@@ -324,6 +322,8 @@ struct _IO_FILE_complete
 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_;
index a9681a3..b2a4ecf 100644 (file)
@@ -323,7 +323,7 @@ struct _IO_cookie_file
 
 /* 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 */
 
@@ -714,19 +714,19 @@ extern int _IO_vscanf __P ((const char *, _IO_va_list));
 # 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
@@ -735,18 +735,19 @@ extern int _IO_vscanf __P ((const char *, _IO_va_list));
 # 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
index 7f5cb7f..4e4ca67 100644 (file)
@@ -1,4 +1,4 @@
-/* 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
@@ -76,12 +76,13 @@ _IO_wfile_doallocate (fp)
   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;
@@ -91,13 +92,12 @@ _IO_wfile_doallocate (fp)
     {
       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;
index ad46c7c..e30bbe1 100644 (file)
@@ -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>.
@@ -77,40 +77,46 @@ _IO_wdo_write (fp, data, to_do)
      _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,
@@ -121,7 +127,7 @@ _IO_wdo_write (fp, data, to_do)
                                   ? fp->_wide_data->_IO_buf_base
                                   : fp->_wide_data->_IO_buf_end);
 
-  return count;
+  return to_do == 0 ? 0 : WEOF;
 }
 
 
@@ -190,9 +196,6 @@ _IO_wfile_underflow (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->_IO_buf_base == NULL)
     {
       /* Maybe we already have a push back pointer.  */
@@ -202,8 +205,14 @@ _IO_wfile_underflow (fp)
          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.  */
@@ -222,11 +231,6 @@ _IO_wfile_underflow (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_buf_base;
   fp->_wide_data->_IO_read_end = fp->_wide_data->_IO_buf_base;
@@ -306,6 +310,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
        {
@@ -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_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;
index 22a38f0..7440e69 100644 (file)
@@ -275,6 +275,8 @@ __wunderflow (fp)
   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;