diff options
author | Bruno Haible <bruno@clisp.org> | 2010-12-27 14:28:11 +0100 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2010-12-27 14:29:25 +0100 |
commit | 777cb5e9cb12fd56d998f2eaa9348dd4e0078cac (patch) | |
tree | 860a9b97679852b6ffd2d6ad06d41d76a79bb0ed /lib/mbrtowc.c | |
parent | 94879b67cd7832e8a60df732a23fb764f2a15075 (diff) | |
download | gnulib-777cb5e9cb12fd56d998f2eaa9348dd4e0078cac.tar.gz |
mbrtowc: Work around a Solaris 7 bug.
* m4/mbrtowc.m4 (gl_MBRTOWC_NULL_ARG1): New macro.
(gl_MBRTOWC_NULL_ARG2): Renamed from gl_MBRTOWC_NULL_ARG.
(gl_FUNC_MBRTOWC): Update. Define MBRTOWC_NULL_ARG2_BUG instead of
MBRTOWC_NULL_ARG_BUG. Invoke gl_MBRTOWC_NULL_ARG1 and define
MBRTOWC_NULL_ARG1_BUG.
* lib/mbrtowc.c (rpl_mbrtowc): Use MBRTOWC_NULL_ARG2_BUG instead of
MBRTOWC_NULL_ARG_BUG. Handle MBRTOWC_NULL_ARG1_BUG.
* tests/test-mbrtowc.c (main): Test support of a NULL first argument.
* doc/posix-functions/mbrtowc.texi: Mention the Solaris 7 bug.
Diffstat (limited to 'lib/mbrtowc.c')
-rw-r--r-- | lib/mbrtowc.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/mbrtowc.c b/lib/mbrtowc.c index 25dac59e7f..06349a3d55 100644 --- a/lib/mbrtowc.c +++ b/lib/mbrtowc.c @@ -321,7 +321,7 @@ mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps) size_t rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps) { -# if MBRTOWC_NULL_ARG_BUG || MBRTOWC_RETVAL_BUG +# if MBRTOWC_NULL_ARG2_BUG || MBRTOWC_RETVAL_BUG if (s == NULL) { pwc = NULL; @@ -379,7 +379,16 @@ rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps) return ret; } # else - return mbrtowc (pwc, s, n, ps); + { +# if MBRTOWC_NULL_ARG1_BUG + wchar_t dummy; + + if (pwc == NULL) + pwc = &dummy; +# endif + + return mbrtowc (pwc, s, n, ps); + } # endif } |