>From 02611ab0826cb35f4c5c6c2a2198ada0d6f20296 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Fri, 25 Jan 2019 00:42:40 +0100 Subject: [PATCH 6/7] 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. --- ChangeLog | 12 ++++++++++++ doc/posix-functions/mbtowc.texi | 6 +++--- lib/stdlib.in.h | 9 +++++++++ m4/mbtowc.m4 | 11 ++++++++--- m4/stdlib_h.m4 | 5 +++-- modules/mbtowc | 6 +++--- modules/stdlib | 1 + 7 files changed, 39 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4955af1..24d5755 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,17 @@ 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. * m4/fdatasync.m4 (gl_FUNC_FDATASYNC): On platforms other than Solaris, test whether fdatasync() exists. diff --git a/doc/posix-functions/mbtowc.texi b/doc/posix-functions/mbtowc.texi index 022e1a2..5188a7f 100644 --- a/doc/posix-functions/mbtowc.texi +++ b/doc/posix-functions/mbtowc.texi @@ -8,14 +8,14 @@ Gnulib module: mbtowc Portability problems fixed by Gnulib: @itemize address@hidden +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. address@hidden This function accumulates hidden state on some platforms: glibc 2.8 (see @url{https://sourceware.org/bugzilla/show_bug.cgi?id=9674}). @item diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h index d80d7ec..0f581d9 100644 --- a/lib/stdlib.in.h +++ b/lib/stdlib.in.h @@ -306,9 +306,18 @@ _GL_WARN_ON_USE (malloc, "malloc is not POSIX compliant everywhere - " _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 address@hidden@ +_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 --git a/m4/mbtowc.m4 b/m4/mbtowc.m4 index 202c3fb..5a4b92e 100644 --- a/m4/mbtowc.m4 +++ b/m4/mbtowc.m4 @@ -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_DEFUN([gl_FUNC_MBTOWC], [ 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 --git a/m4/stdlib_h.m4 b/m4/stdlib_h.m4 index cf06428..c449a54 100644 --- a/m4/stdlib_h.m4 +++ b/m4/stdlib_h.m4 @@ -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 @@ AC_DEFUN([gl_STDLIB_H], # 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 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS], 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 --git a/modules/mbtowc b/modules/mbtowc index a665e22..2db32de 100644 --- a/modules/mbtowc +++ b/modules/mbtowc @@ -8,12 +8,12 @@ m4/mbtowc.m4 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 --git a/modules/stdlib b/modules/stdlib index 62224e8..dd1556e 100644 --- a/modules/stdlib +++ b/modules/stdlib @@ -73,6 +73,7 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \ -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' \ -- 2.7.4