# HG changeset patch # User Bruno Haible # Date 1548373360 -3600 # Node ID 11b97647fb110aca409b7d421931783296a680f9 # Parent 6bcaf5dcb02b5aed3e929cb4add5cfff9e641227 mbtowc: Fix compilation error on Android 4.3. * lib/stdlib.in.h (mbtowc): Test also HAVE_MBTOWC. * m4/mbtowc.m4 (gl_FUNC_MBTOWC): Test whether mbtowc exists. Set HAVE_MBTOWC. * m4/stdlib_h.m4 (gl_STDLIB_H): Test whether mbtowc is declared. (gl_STDLIB_H_DEFAULTS): Initialize HAVE_MBTOWC. * modules/stdlib (Makefile.am): Substitute HAVE_MBTOWC. * modules/mbtowc (Depends-on, configure.ac): Test also HAVE_MBTOWC. * doc/posix-functions/mbtowc.texi: Mention the change. diff -r 6bcaf5dcb02b -r 11b97647fb11 ChangeLog --- a/ChangeLog Fri Jan 25 00:15:50 2019 +0100 +++ b/ChangeLog Fri Jan 25 00:42:40 2019 +0100 @@ -1,3 +1,15 @@ +2019-01-24 Bruno Haible + + mbtowc: Fix compilation error on Android 4.3. + * lib/stdlib.in.h (mbtowc): Test also HAVE_MBTOWC. + * m4/mbtowc.m4 (gl_FUNC_MBTOWC): Test whether mbtowc exists. Set + HAVE_MBTOWC. + * m4/stdlib_h.m4 (gl_STDLIB_H): Test whether mbtowc is declared. + (gl_STDLIB_H_DEFAULTS): Initialize HAVE_MBTOWC. + * modules/stdlib (Makefile.am): Substitute HAVE_MBTOWC. + * modules/mbtowc (Depends-on, configure.ac): Test also HAVE_MBTOWC. + * doc/posix-functions/mbtowc.texi: Mention the change. + 2019-01-24 Bruno Haible fdatasync: Fix compilation error on Android 4.3. diff -r 6bcaf5dcb02b -r 11b97647fb11 doc/posix-functions/mbtowc.texi --- a/doc/posix-functions/mbtowc.texi Fri Jan 25 00:15:50 2019 +0100 +++ b/doc/posix-functions/mbtowc.texi Fri Jan 25 00:42:40 2019 +0100 @@ -8,14 +8,14 @@ Portability problems fixed by Gnulib: @itemize +@item +This function is missing on some platforms: +Android 4.4. @end itemize Portability problems not fixed by Gnulib: @itemize @item -This function is missing on some platforms: -Android 4.4. -@item This function accumulates hidden state on some platforms: glibc 2.8 (see @url{https://sourceware.org/bugzilla/show_bug.cgi?id=9674}). @item diff -r 6bcaf5dcb02b -r 11b97647fb11 lib/stdlib.in.h --- a/lib/stdlib.in.h Fri Jan 25 00:15:50 2019 +0100 +++ b/lib/stdlib.in.h Fri Jan 25 00:42:40 2019 +0100 @@ -306,9 +306,18 @@ _GL_FUNCDECL_RPL (mbtowc, int, (wchar_t *pwc, const char *s, size_t n)); _GL_CXXALIAS_RPL (mbtowc, int, (wchar_t *pwc, const char *s, size_t n)); # else +# if !@HAVE_MBTOWC@ +_GL_FUNCDECL_SYS (mbtowc, int, (wchar_t *pwc, const char *s, size_t n)); +# endif _GL_CXXALIAS_SYS (mbtowc, int, (wchar_t *pwc, const char *s, size_t n)); # endif _GL_CXXALIASWARN (mbtowc); +#elif defined GNULIB_POSIXCHECK +# undef mbtowc +# if HAVE_RAW_DECL_MBTOWC +_GL_WARN_ON_USE (mbtowc, "mbtowc is not portable - " + "use gnulib module mbtowc for portability"); +# endif #endif #if @GNULIB_MKDTEMP@ diff -r 6bcaf5dcb02b -r 11b97647fb11 m4/mbtowc.m4 --- a/m4/mbtowc.m4 Fri Jan 25 00:15:50 2019 +0100 +++ b/m4/mbtowc.m4 Fri Jan 25 00:42:40 2019 +0100 @@ -1,4 +1,4 @@ -# mbtowc.m4 serial 2 +# mbtowc.m4 serial 3 dnl Copyright (C) 2011-2019 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -8,8 +8,13 @@ [ AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) - if false; then - REPLACE_MBTOWC=1 + AC_CHECK_FUNCS([mbtowc]) + if test $ac_cv_func_mbtowc = no; then + HAVE_MBTOWC=0 + else + if false; then + REPLACE_MBTOWC=1 + fi fi ]) diff -r 6bcaf5dcb02b -r 11b97647fb11 m4/stdlib_h.m4 --- a/m4/stdlib_h.m4 Fri Jan 25 00:15:50 2019 +0100 +++ b/m4/stdlib_h.m4 Fri Jan 25 00:42:40 2019 +0100 @@ -1,4 +1,4 @@ -# stdlib_h.m4 serial 45 +# stdlib_h.m4 serial 46 dnl Copyright (C) 2007-2019 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -23,7 +23,7 @@ # include #endif ]], [_Exit atoll canonicalize_file_name getloadavg getsubopt grantpt - initstate initstate_r mkdtemp mkostemp mkostemps mkstemp mkstemps + initstate initstate_r mbtowc mkdtemp mkostemp mkostemps mkstemp mkstemps posix_openpt ptsname ptsname_r qsort_r random random_r reallocarray realpath rpmatch secure_getenv setenv setstate setstate_r srandom srandom_r strtod strtoll strtoull unlockpt unsetenv]) @@ -82,6 +82,7 @@ HAVE_GETSUBOPT=1; AC_SUBST([HAVE_GETSUBOPT]) HAVE_GRANTPT=1; AC_SUBST([HAVE_GRANTPT]) HAVE_DECL_INITSTATE=1; AC_SUBST([HAVE_DECL_INITSTATE]) + HAVE_MBTOWC=1; AC_SUBST([HAVE_MBTOWC]) HAVE_MKDTEMP=1; AC_SUBST([HAVE_MKDTEMP]) HAVE_MKOSTEMP=1; AC_SUBST([HAVE_MKOSTEMP]) HAVE_MKOSTEMPS=1; AC_SUBST([HAVE_MKOSTEMPS]) diff -r 6bcaf5dcb02b -r 11b97647fb11 modules/mbtowc --- a/modules/mbtowc Fri Jan 25 00:15:50 2019 +0100 +++ b/modules/mbtowc Fri Jan 25 00:42:40 2019 +0100 @@ -8,12 +8,12 @@ Depends-on: stdlib -mbrtowc [test $REPLACE_MBTOWC = 1] -wchar [test $REPLACE_MBTOWC = 1] +mbrtowc [test $HAVE_MBTOWC = 0 || test $REPLACE_MBTOWC = 1] +wchar [test $HAVE_MBTOWC = 0 || test $REPLACE_MBTOWC = 1] configure.ac: gl_FUNC_MBTOWC -if test $REPLACE_MBTOWC = 1; then +if test $HAVE_MBTOWC = 0 || test $REPLACE_MBTOWC = 1; then AC_LIBOBJ([mbtowc]) gl_PREREQ_MBTOWC fi diff -r 6bcaf5dcb02b -r 11b97647fb11 modules/stdlib --- a/modules/stdlib Fri Jan 25 00:15:50 2019 +0100 +++ b/modules/stdlib Fri Jan 25 00:42:40 2019 +0100 @@ -73,6 +73,7 @@ -e 's|@''HAVE_GETSUBOPT''@|$(HAVE_GETSUBOPT)|g' \ -e 's|@''HAVE_GRANTPT''@|$(HAVE_GRANTPT)|g' \ -e 's|@''HAVE_DECL_INITSTATE''@|$(HAVE_DECL_INITSTATE)|g' \ + -e 's|@''HAVE_MBTOWC''@|$(HAVE_MBTOWC)|g' \ -e 's|@''HAVE_MKDTEMP''@|$(HAVE_MKDTEMP)|g' \ -e 's|@''HAVE_MKOSTEMP''@|$(HAVE_MKOSTEMP)|g' \ -e 's|@''HAVE_MKOSTEMPS''@|$(HAVE_MKOSTEMPS)|g' \