From 78f5fbf491b6f12a67a633f919ec24f97570a733 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 21 Dec 2008 04:53:17 +0100 Subject: [PATCH] Override mbsrtowcs when redefining mbstate_t. --- ChangeLog | 6 ++++++ lib/wchar.in.h | 6 +++++- m4/mbsrtowcs.m4 | 8 +++++++- m4/wchar.m4 | 3 ++- modules/wchar | 1 + 5 files changed, 21 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 972a94071f..5670e7647d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2008-12-20 Bruno Haible + * lib/wchar.in.h (mbsrtowcs): Redefine if REPLACE_MBSRTOWCS is set. + * m4/mbsrtowcs.m4 (gl_FUNC_MBSRTOWCS): Invoke gl_MBSTATE_T_BROKEN. Set + REPLACE_MBSRTOWCS if mbsrtowcs needs to be overridden. + * m4/wchar.m4 (gl_WCHAR_H_DEFAULTS): Initialize REPLACE_MBSRTOWCS. + * modules/wchar (Makefile.am): Substitute REPLACE_MBSRTOWCS. + Work around mbrtowc bugs on AIX, HP-UX, OSF/1, Solaris. * lib/wchar.in.h (mbstate_t): Redefine also if REPLACE_MBSTATE_T is set. diff --git a/lib/wchar.in.h b/lib/wchar.in.h index 62844af72b..c4269664cd 100644 --- a/lib/wchar.in.h +++ b/lib/wchar.in.h @@ -167,7 +167,11 @@ extern size_t mbrlen (const char *s, size_t n, mbstate_t *ps); /* Convert a string to a wide string. */ #if @GNULIB_MBSRTOWCS@ -# if !@HAVE_MBSRTOWCS@ +# if @REPLACE_MBSRTOWCS@ +# undef mbsrtowcs +# define mbsrtowcs rpl_mbsrtowcs +# endif +# if !@HAVE_MBSRTOWCS@ || @REPLACE_MBSRTOWCS@ extern size_t mbsrtowcs (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps); # endif #elif defined GNULIB_POSIXCHECK diff --git a/m4/mbsrtowcs.m4 b/m4/mbsrtowcs.m4 index 004e500b30..58ae2c683c 100644 --- a/m4/mbsrtowcs.m4 +++ b/m4/mbsrtowcs.m4 @@ -1,4 +1,4 @@ -# mbsrtowcs.m4 serial 1 +# mbsrtowcs.m4 serial 2 dnl Copyright (C) 2008 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -9,9 +9,15 @@ AC_DEFUN([gl_FUNC_MBSRTOWCS], AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) AC_REQUIRE([AC_TYPE_MBSTATE_T]) + gl_MBSTATE_T_BROKEN + if test $REPLACE_MBSTATE_T = 1; then + REPLACE_MBSRTOWCS=1 + fi AC_CHECK_FUNCS_ONCE([mbsrtowcs]) if test $ac_cv_func_mbsrtowcs = no; then HAVE_MBSRTOWCS=0 + fi + if test $HAVE_MBSRTOWCS = 0 || test $REPLACE_MBSRTOWCS = 1; then gl_REPLACE_WCHAR_H AC_LIBOBJ([mbsrtowcs]) gl_PREREQ_MBSRTOWCS diff --git a/m4/wchar.m4 b/m4/wchar.m4 index 0809b3c790..6e0fe01886 100644 --- a/m4/wchar.m4 +++ b/m4/wchar.m4 @@ -7,7 +7,7 @@ dnl with or without modifications, as long as this notice is preserved. dnl Written by Eric Blake. -# wchar.m4 serial 14 +# wchar.m4 serial 15 AC_DEFUN([gl_WCHAR_H], [ @@ -80,6 +80,7 @@ AC_DEFUN([gl_WCHAR_H_DEFAULTS], REPLACE_WCTOB=0; AC_SUBST([REPLACE_WCTOB]) REPLACE_MBSINIT=0; AC_SUBST([REPLACE_MBSINIT]) REPLACE_MBRTOWC=0; AC_SUBST([REPLACE_MBRTOWC]) + REPLACE_MBSRTOWCS=0; AC_SUBST([REPLACE_MBSRTOWCS]) REPLACE_WCWIDTH=0; AC_SUBST([REPLACE_WCWIDTH]) WCHAR_H=''; AC_SUBST([WCHAR_H]) ]) diff --git a/modules/wchar b/modules/wchar index 716e7f2802..fcef30e69a 100644 --- a/modules/wchar +++ b/modules/wchar @@ -44,6 +44,7 @@ wchar.h: wchar.in.h -e 's|@''REPLACE_WCTOB''@|$(REPLACE_WCTOB)|g' \ -e 's|@''REPLACE_MBSINIT''@|$(REPLACE_MBSINIT)|g' \ -e 's|@''REPLACE_MBRTOWC''@|$(REPLACE_MBRTOWC)|g' \ + -e 's|@''REPLACE_MBSRTOWCS''@|$(REPLACE_MBSRTOWCS)|g' \ -e 's|@''REPLACE_WCWIDTH''@|$(REPLACE_WCWIDTH)|g' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ < $(srcdir)/wchar.in.h; \ -- 2.30.2