]> sourceware.org Git - glibc.git/commitdiff
Update.
authorUlrich Drepper <drepper@redhat.com>
Wed, 26 Jan 2000 06:55:29 +0000 (06:55 +0000)
committerUlrich Drepper <drepper@redhat.com>
Wed, 26 Jan 2000 06:55:29 +0000 (06:55 +0000)
* libio/fileops.c (_IO_new_file_open): Recognize ,ccs= in mode string
and load appropriate conversions.
* libio/iofwide.c (__libio_codecvt): Renamed from libio_codecvt and
made global.
* libio/libioP.h: Declare __libio_codecvt.
* manual/stdio.texi: Document ,ccs= option for fopen.
* wcsmbs/wcsmbsload.c (__wcsmbs_named_conv): New function.
* wcsmbs/wcsmbsload.h (__wcsmbs_named_conv): Declare.

* libio/iofclose.c: Free conversion data if stream was wide-oriented.

* sysdeps/unix/sysv/linux/i386/Dist: Add sys/io.h.

ChangeLog
libio/fileops.c
libio/iofclose.c
libio/iofwide.c
libio/libioP.h
manual/stdio.texi
sysdeps/unix/sysv/linux/i386/Dist
wcsmbs/wcsmbsload.c
wcsmbs/wcsmbsload.h

index 8b9f092c24ccfcabf9f71297e512d385d88d1f3d..8739cc0cca6db401283ccfb7dd7399e25ba0cd49 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
 2000-01-25  Ulrich Drepper  <drepper@cygnus.com>
 
+       * libio/fileops.c (_IO_new_file_open): Recognize ,ccs= in mode string
+       and load appropriate conversions.
+       * libio/iofwide.c (__libio_codecvt): Renamed from libio_codecvt and
+       made global.
+       * libio/libioP.h: Declare __libio_codecvt.
+       * manual/stdio.texi: Document ,ccs= option for fopen.
+       * wcsmbs/wcsmbsload.c (__wcsmbs_named_conv): New function.
+       * wcsmbs/wcsmbsload.h (__wcsmbs_named_conv): Declare.
+
+       * libio/iofclose.c: Free conversion data if stream was wide-oriented.
+
+       * sysdeps/unix/sysv/linux/i386/Dist: Add sys/io.h.
+
        * sysdeps/unix/sysv/linux/Dist: Remove sys/io.h.
 
        * posix/fnmatch_loop.c: Fix problem with FNM_LEADING_DIR.
index 52039a4a13bbce59d52740722b32a1049981d61f..52880c52a9756c3af9c64091cb5efe5cbd166415 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1995, 1997, 1998, 1999 Free Software Foundation, Inc.
+/* Copyright (C) 1993, 1995, 1997-1999, 2000 Free Software Foundation, Inc.
    This file is part of the GNU IO Library.
    Written by Per Bothner <bothner@cygnus.com>.
 
@@ -37,6 +37,9 @@
 #ifdef __STDC__
 #include <stdlib.h>
 #endif
+#if _LIBC
+# include "../wcsmbs/wcsmbsload.h"
+#endif
 #ifndef errno
 extern int errno;
 #endif
@@ -214,6 +217,11 @@ _IO_new_file_fopen (fp, filename, mode, is32not64)
   int read_write;
   int oprot = 0666;
   int i;
+  _IO_FILE *result;
+#if _LIBC
+  const char *cs;
+#endif
+
   if (_IO_file_is_open (fp))
     return 0;
   switch (*mode)
@@ -257,8 +265,54 @@ _IO_new_file_fopen (fp, filename, mode, is32not64)
       break;
     }
 
-  return _IO_file_open (fp, filename, omode|oflags, oprot, read_write,
-                       is32not64);
+  result = _IO_file_open (fp, filename, omode|oflags, oprot, read_write,
+                         is32not64);
+
+
+#if _LIBC
+  /* Test whether the mode string specifies the conversion.  */
+  cs = strstr (mode, ",ccs=");
+  if (cs != NULL)
+    {
+      /* Yep.  Load the appropriate conversions and set the orientation
+        to wide.  */
+       struct gconv_fcts fcts;
+       struct _IO_codecvt *cc = &fp->_wide_data->_codecvt;
+
+       if (__wcsmbs_named_conv (&fcts, cs + 5) != 0)
+         {
+           /* Something went wrong, we cannot load the conversion modules.
+              This means we cannot proceed since the user explicitly asked
+              for these.  */
+           _IO_new_fclose (result);
+           return NULL;
+         }
+
+       /* The functions are always the same.  */
+       *cc = __libio_codecvt;
+
+       cc->__cd_in.__cd.__nsteps = 1; /* Only one step allowed.  */
+       cc->__cd_in.__cd.__steps = fcts.towc;
+
+       cc->__cd_in.__cd.__data[0].__invocation_counter = 0;
+       cc->__cd_in.__cd.__data[0].__internal_use = 1;
+       cc->__cd_in.__cd.__data[0].__is_last = 1;
+       cc->__cd_in.__cd.__data[0].__statep = &result->_wide_data->_IO_state;
+
+       cc->__cd_out.__cd.__nsteps = 1; /* Only one step allowed.  */
+       cc->__cd_out.__cd.__steps = fcts.tomb;
+
+       cc->__cd_out.__cd.__data[0].__invocation_counter = 0;
+       cc->__cd_out.__cd.__data[0].__internal_use = 1;
+       cc->__cd_out.__cd.__data[0].__is_last = 1;
+       cc->__cd_out.__cd.__data[0].__statep = &result->_wide_data->_IO_state;
+
+       /* Set the mode now.  */
+       result->_mode = 1;
+    }
+#endif /* GNU libc */
+
+  return result;
 }
 
 _IO_FILE *
index 04503e78174b51790158d167f70c6cf52fd002b0..a10ed9266fb88bbc05c112bd89f56154755559be 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1995, 1997, 1998, 1999 Free Software Foundation, Inc.
+/* Copyright (C) 1993, 1995, 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
@@ -27,6 +27,9 @@
 #ifdef __STDC__
 #include <stdlib.h>
 #endif
+#if _LIBC
+# include "../iconv/gconv_int.h"
+#endif
 
 int
 _IO_new_fclose (fp)
@@ -52,6 +55,25 @@ _IO_new_fclose (fp)
     status = fp->_flags & _IO_ERR_SEEN ? -1 : 0;
   _IO_FINISH (fp);
   _IO_funlockfile (fp);
+  if (fp->_mode > 0)
+    {
+#if _LIBC
+      /* This stream has a wide orientation.  This means we have to free
+        the conversion functions.  */
+      struct _IO_codecvt *cc = &fp->_wide_data->_codecvt;
+
+      if (cc->__cd_in.__cd.__steps->__shlib_handle != NULL)
+       {
+         --cc->__cd_in.__cd.__steps->__counter;
+         __gconv_close_transform (cc->__cd_in.__cd.__steps, 1);
+       }
+      if (cc->__cd_out.__cd.__steps->__shlib_handle != NULL)
+       {
+         --cc->__cd_out.__cd.__steps->__counter;
+         __gconv_close_transform (cc->__cd_out.__cd.__steps, 1);
+       }
+#endif
+    }
   _IO_cleanup_region_end (0);
   if (_IO_have_backup (fp))
     _IO_free_backup_area (fp);
index 853920a001576603c1a79dd50070c13899a4006d..04c8bba6385f55202648dc6bb0bf5ef4bc39b6cf 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999 Free Software Foundation, Inc.
+/* Copyright (C) 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
@@ -62,7 +62,7 @@ static int do_always_noconv (struct _IO_codecvt *codecvt);
 
 
 /* The functions used in `codecvt' for libio are always the same.  */
-static struct _IO_codecvt libio_codecvt =
+struct _IO_codecvt __libio_codecvt =
 {
   .__codecvt_destr = NULL,             /* Destructor, never used.  */
   .__codecvt_do_out = do_out,
@@ -114,7 +114,7 @@ _IO_fwide (fp, mode)
        __wcsmbs_clone_conv (&fcts);
 
        /* The functions are always the same.  */
-       *cc = libio_codecvt;
+       *cc = __libio_codecvt;
 
        cc->__cd_in.__cd.__nsteps = 1; /* Only one step allowed.  */
        cc->__cd_in.__cd.__steps = fcts.towc;
index f31a26b0d7dc42b21f0a45918add342e6171751a..e3356f4a7ed5e83ea284e42ffd9569e2e43a9f28 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1997, 1998, 1999 Free Software Foundation, Inc.
+/* Copyright (C) 1993, 1997, 1998, 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
@@ -390,6 +390,7 @@ extern struct _IO_jump_t _IO_proc_jumps;
 extern struct _IO_jump_t _IO_old_proc_jumps;
 extern struct _IO_jump_t _IO_str_jumps;
 extern struct _IO_jump_t _IO_wstr_jumps;
+extern struct _IO_codecvt __libio_codecvt;
 extern int _IO_do_write __P ((_IO_FILE *, const char *, _IO_size_t));
 extern int _IO_new_do_write __P ((_IO_FILE *, const char *, _IO_size_t));
 extern int _IO_old_do_write __P ((_IO_FILE *, const char *, _IO_size_t));
index 882494cb7b59b812be7d13104ce4696dc4e8e55a..98c4de7e131e24b310cf716c70189a370c9e050d 100644 (file)
@@ -206,6 +206,21 @@ difference in POSIX systems (including the GNU system).  If both
 @samp{+} and @samp{b} are specified, they can appear in either order.
 @xref{Binary Streams}.
 
+@cindex stream orientation
+@cindex orientation, stream
+If the @var{opentype} string contains the sequence
+@code{,ccs=@var{STRING}} then @var{STRING} is taken as the name of a
+coded character set and @code{fopen} will mark the stream as
+wide-oriented which appropriate conversion functions in place to convert
+from and to the character set @var{STRING} is place.  Any other stream
+is opened initially unoriented and the orientation is decided with the
+first file operation.  If the first operation is a wide character
+operation, the stream is not only marked as wide-oriented, also the
+conversion functions to convert to the coded character set used for the
+current locale are loaded.  This will not change anymore from this point
+on even if the locale selected for the @code{LC_CTYPE} category is
+changed.
+
 Any other characters in @var{opentype} are simply ignored.  They may be
 meaningful in other systems.
 
index babeff87c601eb5c413b4ff78a2f1ecf14af5b1a..087ad88b4e2356b15c7215ce1316d5b003a3ff29 100644 (file)
@@ -6,6 +6,7 @@ setfsuid.c
 setfsgid.c
 sys/debugreg.h
 sys/elf.h
+sys/io.h
 sys/perm.h
 sys/procfs.h
 sys/reg.h
index 26633e0de23037cfd52f1ccac5c7daf241532705..719bd1b5cf5c11060d6440cecf4f44c6337c6141 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+/* Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
 
@@ -250,3 +250,29 @@ __wcsmbs_clone_conv (struct gconv_fcts *copy)
 
   __libc_lock_unlock (lock);
 }
+
+
+/* Clone the current conversion function set.  */
+int
+internal_function
+__wcsmbs_named_conv (struct gconv_fcts *copy, const char *name)
+{
+  copy->towc = getfct ("INTERNAL", name);
+  if (copy->towc != NULL)
+    {
+      copy->tomb = getfct (name, "INTERNAL");
+      if (copy->tomb == NULL)
+       __gconv_close_transform (copy->towc, 1);
+    }
+
+  if (copy->towc == NULL || copy->tomb == NULL)
+    return 1;
+
+  /* Now increment the usage counters.  */
+  if (copy->towc->__shlib_handle != NULL)
+    ++copy->towc->__counter;
+  if (copy->tomb->__shlib_handle != NULL)
+    ++copy->tomb->__counter;
+
+  return 0;
+}
index a3652d22ac355da7366a0775b411fa7a5f62cb80..a4d35053d23621cbfe3cd95deed5e83a05008725 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+/* Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
 
@@ -45,6 +45,10 @@ extern void __wcsmbs_load_conv (const struct locale_data *new_category)
 extern void __wcsmbs_clone_conv (struct gconv_fcts *copy)
      internal_function;
 
+/* Find the conversion functions for converting to and from NAME.  */
+extern int __wcsmbs_named_conv (struct gconv_fcts *copy, const char *name)
+     internal_function;
+
 
 /* Check whether the LC_CTYPE locale changed since the last call.
    Update the pointers appropriately.  */
This page took 0.059128 seconds and 5 git commands to generate.