diff options
Diffstat (limited to 'stdlib')
-rw-r--r-- | stdlib/mblen.c | 14 | ||||
-rw-r--r-- | stdlib/mbtowc.c | 14 | ||||
-rw-r--r-- | stdlib/wctomb.c | 16 |
3 files changed, 28 insertions, 16 deletions
diff --git a/stdlib/mblen.c b/stdlib/mblen.c index d60a1fb160..9d8d0ccc5a 100644 --- a/stdlib/mblen.c +++ b/stdlib/mblen.c @@ -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. */ diff --git a/stdlib/mbtowc.c b/stdlib/mbtowc.c index 50e7c09834..938d54750c 100644 --- a/stdlib/mbtowc.c +++ b/stdlib/mbtowc.c @@ -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) diff --git a/stdlib/wctomb.c b/stdlib/wctomb.c index acf139380f..b7132e02c4 100644 --- a/stdlib/wctomb.c +++ b/stdlib/wctomb.c @@ -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); } |