Update.
authorUlrich Drepper <drepper@redhat.com>
Tue, 21 Apr 1998 19:09:49 +0000 (19:09 +0000)
committerUlrich Drepper <drepper@redhat.com>
Tue, 21 Apr 1998 19:09:49 +0000 (19:09 +0000)
1998-04-21 19:05  Ulrich Drepper  <drepper@cygnus.com>

* iconv/gconv.h (struct gconv_step): Add element stateful.
* iconv/gconv_builtin.c (__gconv_builtin_trans): Initialize stateful
to zero for all internal conversions.
* iconv/skeleton.c: Initialize stateful depending on whether or not
RESET_STATE is defined to one or zero respectively.
* stdlib/mblen.c: Use stateful element of currently selected
converter for result if S is NULL.
* stdlib/mbtowc.c: Likewise.
* stdlib/wctomb.c: Likewise.

ChangeLog
iconv/gconv.h
iconv/gconv_builtin.c
iconv/skeleton.c
stdlib/mblen.c
stdlib/mbtowc.c
stdlib/wctomb.c

index 8672e03..5a5a9dc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+1998-04-21 19:05  Ulrich Drepper  <drepper@cygnus.com>
+
+       * iconv/gconv.h (struct gconv_step): Add element stateful.
+       * iconv/gconv_builtin.c (__gconv_builtin_trans): Initialize stateful
+       to zero for all internal conversions.
+       * iconv/skeleton.c: Initialize stateful depending on whether or not
+       RESET_STATE is defined to one or zero respectively.
+       * stdlib/mblen.c: Use stateful element of currently selected
+       converter for result if S is NULL.
+       * stdlib/mbtowc.c: Likewise.
+       * stdlib/wctomb.c: Likewise.
+
 1998-04-21 18:00  Ulrich Drepper  <drepper@cygnus.com>
 
        * iconv/gconv.c (__gconv): Remove bogus input buffer size computation.
index cd0e3de..b359c92 100644 (file)
@@ -87,6 +87,9 @@ struct gconv_step
   int min_needed_to;
   int max_needed_to;
 
+  /* Flag whether this is a stateful encoding or not.  */
+  int stateful;
+
   void *data;          /* Pointer to step-local data.  */
 };
 
index a970fcc..4f3ca56 100644 (file)
@@ -81,4 +81,7 @@ __gconv_get_builtin_trans (const char *name, struct gconv_step *step)
   step->max_needed_from = map[cnt].max_needed_from;
   step->min_needed_to = map[cnt].min_needed_to;
   step->max_needed_to = map[cnt].max_needed_to;
+
+  /* None of the builtin converters handles stateful encoding.  */
+  step->stateful = 0;
 }
index f905bcd..36cc33c 100644 (file)
@@ -143,6 +143,12 @@ gconv_init (struct gconv_step *step)
   step->min_needed_to = MIN_NEEDED_TO;
   step->max_needed_to = MAX_NEEDED_TO;
 
+#ifdef RESET_STATE
+  step->stateful = 1;
+#else
+  step->stateful = 0;
+#endif
+
   return GCONV_OK;
 }
 #endif
index d60a1fb..9d8d0cc 100644 (file)
@@ -18,6 +18,8 @@
 
 #include <stdlib.h>
 #include <wchar.h>
+#include <gconv.h>
+#include <wcsmbs/wcsmbsload.h>
 
 
 /* Return the length of the multibyte character (if there is one)
@@ -32,12 +34,14 @@ mblen (const char *s, size_t n)
 
   /* If S is NULL the function has to return null or not null
      depending on the encoding having a state depending encoding or
-     not.  This is nonsense because any multibyte encoding has a
-     state.  The ISO C amendment 1 corrects this while introducing the
-     restartable functions.  We simply say here all encodings have a
-     state.  */
+     not.  */
   if (s == NULL)
-    result = 1;
+    {
+      /* Make sure we use the correct value.  */
+      update_conversion_ptrs ();
+
+      result = __wcsmbs_gconv_fcts.towc->stateful;
+    }
   else if (*s == '\0')
     /* According to the ISO C 89 standard this is the expected behaviour.
        Idiotic, but true.  */
index 50e7c09..938d547 100644 (file)
@@ -18,6 +18,8 @@
 
 #include <stdlib.h>
 #include <wchar.h>
+#include <gconv.h>
+#include <wcsmbs/wcsmbsload.h>
 
 
 /* Common state for all non-restartable conversion functions.  */
@@ -38,12 +40,14 @@ mbtowc (wchar_t *pwc, const char *s, size_t n)
 
   /* If S is NULL the function has to return null or not null
      depending on the encoding having a state depending encoding or
-     not.  This is nonsense because any multibyte encoding has a
-     state.  The ISO C amendment 1 corrects this while introducing the
-     restartable functions.  We simply say here all encodings have a
-     state.  */
+     not.  */
   if (s == NULL)
-    result = 1;
+    {
+      /* Make sure we use the correct value.  */
+      update_conversion_ptrs ();
+
+      result = __wcsmbs_gconv_fcts.towc->stateful;
+    }
   else if (*s == '\0')
     {
       if (pwc != NULL)
index acf1393..b7132e0 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1992, 1995, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 92, 95, 96, 97, 98 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -18,6 +18,8 @@
 
 #include <stdlib.h>
 #include <wchar.h>
+#include <gconv.h>
+#include <wcsmbs/wcsmbsload.h>
 
 
 extern mbstate_t __no_r_state; /* Defined in mbtowc.c.  */
@@ -34,12 +36,14 @@ wctomb (char *s, wchar_t wchar)
 {
   /* If S is NULL the function has to return null or not null
      depending on the encoding having a state depending encoding or
-     not.  This is nonsense because any multibyte encoding has a
-     state.  The ISO C amendment 1 corrects this while introducing the
-     restartable functions.  We simply say here all encodings have a
-     state.  */
+     not.  */
   if (s == NULL)
-    return 1;
+    {
+      /* Make sure we use the correct value.  */
+      update_conversion_ptrs ();
+
+      return __wcsmbs_gconv_fcts.tomb->stateful;
+    }
 
   return __wcrtomb (s, wchar, &__no_r_state);
 }