The next module in the ISO C 99 i18n function series is mbrlen. 2008-12-19 Bruno Haible <br...@clisp.org>
New module 'mbrlen'. * lib/wchar.in.h (mbrlen): New declaration. * lib/mbrlen.c: New file. * m4/mbrlen.m4: New file. * modules/mbrlen: New file. * m4/wchar.m4 (gl_WCHAR_H_DEFAULTS): Initialize GNULIB_MBRLEN and HAVE_MBRLEN. * modules/wchar (Makefile.am): Substitute GNULIB_MBRLEN and HAVE_MBRLEN. * doc/posix-functions/mbrlen.texi: Document the new module. ================================= lib/mbrlen.c ================================= /* Recognize multibyte character. Copyright (C) 1999-2000, 2008 Free Software Foundation, Inc. Written by Bruno Haible <br...@clisp.org>, 2008. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> /* Specification. */ #include <wchar.h> static mbstate_t internal_state; size_t mbrlen (const char *s, size_t n, mbstate_t *ps) { if (ps == NULL) ps = &internal_state; return mbrtowc (NULL, s, n, ps); } ================================= m4/mbrlen.m4 ================================= # mbrlen.m4 serial 1 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, dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_FUNC_MBRLEN], [ AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) AC_REQUIRE([AC_TYPE_MBSTATE_T]) AC_CHECK_FUNCS_ONCE([mbrlen]) if test $ac_cv_func_mbrlen = no; then HAVE_MBRLEN=0 gl_REPLACE_WCHAR_H AC_LIBOBJ([mbrlen]) gl_PREREQ_MBRLEN fi ]) # Prerequisites of lib/mbrlen.c. AC_DEFUN([gl_PREREQ_MBRLEN], [ : ]) ================================ modules/mbrlen ================================ Description: mbrlen() function: recognize multibyte character. Files: lib/mbrlen.c m4/mbrlen.m4 m4/mbstate_t.m4 Depends-on: wchar mbrtowc configure.ac: gl_FUNC_MBRLEN gl_WCHAR_MODULE_INDICATOR([mbrlen]) Makefile.am: Include: <wchar.h> License: LGPL Maintainer: Bruno Haible ================================================================================ --- lib/wchar.in.h.orig 2008-12-19 12:55:37.000000000 +0100 +++ lib/wchar.in.h 2008-12-19 12:45:25.000000000 +0100 @@ -137,6 +137,20 @@ #endif +/* Recognize a multibyte character. */ +#if @GNULIB_MBRLEN@ +# if !...@have_mbrlen@ +extern size_t mbrlen (const char *s, size_t n, mbstate_t *ps); +# endif +#elif defined GNULIB_POSIXCHECK +# undef mbrlen +# define mbrlen(s,n,p) \ + (GL_LINK_WARNING ("mbrlen is unportable - " \ + "use gnulib module mbrlen for portability"), \ + mbrlen (s, n, p)) +#endif + + /* Return the number of screen columns needed for WC. */ #if @GNULIB_WCWIDTH@ # if @REPLACE_WCWIDTH@ --- m4/wchar.m4.orig 2008-12-19 12:55:37.000000000 +0100 +++ m4/wchar.m4 2008-12-19 12:46:16.000000000 +0100 @@ -7,7 +7,7 @@ dnl Written by Eric Blake. -# wchar.m4 serial 9 +# wchar.m4 serial 10 AC_DEFUN([gl_WCHAR_H], [ @@ -65,12 +65,14 @@ GNULIB_WCTOB=0; AC_SUBST([GNULIB_WCTOB]) GNULIB_MBSINIT=0; AC_SUBST([GNULIB_MBSINIT]) GNULIB_MBRTOWC=0; AC_SUBST([GNULIB_MBRTOWC]) + GNULIB_MBRLEN=0; AC_SUBST([GNULIB_MBRLEN]) GNULIB_WCWIDTH=0; AC_SUBST([GNULIB_WCWIDTH]) dnl Assume proper GNU behavior unless another module says otherwise. HAVE_BTOWC=1; AC_SUBST([HAVE_BTOWC]) HAVE_WCTOB=1; AC_SUBST([HAVE_WCTOB]) HAVE_MBSINIT=1; AC_SUBST([HAVE_MBSINIT]) HAVE_MBRTOWC=1; AC_SUBST([HAVE_MBRTOWC]) + HAVE_MBRLEN=1; AC_SUBST([HAVE_MBRLEN]) HAVE_DECL_WCWIDTH=1; AC_SUBST([HAVE_DECL_WCWIDTH]) REPLACE_WCWIDTH=0; AC_SUBST([REPLACE_WCWIDTH]) WCHAR_H=''; AC_SUBST([WCHAR_H]) --- modules/wchar.orig 2008-12-19 12:55:37.000000000 +0100 +++ modules/wchar 2008-12-19 12:43:04.000000000 +0100 @@ -29,12 +29,14 @@ -e 's|@''GNULIB_WCTOB''@|$(GNULIB_WCTOB)|g' \ -e 's|@''GNULIB_MBSINIT''@|$(GNULIB_MBSINIT)|g' \ -e 's|@''GNULIB_MBRTOWC''@|$(GNULIB_MBRTOWC)|g' \ + -e 's|@''GNULIB_MBRLEN''@|$(GNULIB_MBRLEN)|g' \ -e 's|@''GNULIB_WCWIDTH''@|$(GNULIB_WCWIDTH)|g' \ -e 's|@''HAVE_WINT_T''@|$(HAVE_WINT_T)|g' \ -e 's|@''HAVE_BTOWC''@|$(HAVE_BTOWC)|g' \ -e 's|@''HAVE_WCTOB''@|$(HAVE_WCTOB)|g' \ -e 's|@''HAVE_MBSINIT''@|$(HAVE_MBSINIT)|g' \ -e 's|@''HAVE_MBRTOWC''@|$(HAVE_MBRTOWC)|g' \ + -e 's|@''HAVE_MBRLEN''@|$(HAVE_MBRLEN)|g' \ -e 's|@''HAVE_DECL_WCWIDTH''@|$(HAVE_DECL_WCWIDTH)|g' \ -e 's|@''REPLACE_WCWIDTH''@|$(REPLACE_WCWIDTH)|g' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ --- doc/posix-functions/mbrlen.texi.orig 2008-12-19 12:55:37.000000000 +0100 +++ doc/posix-functions/mbrlen.texi 2008-12-19 12:47:31.000000000 +0100 @@ -4,15 +4,15 @@ POSIX specification: @url{http://www.opengroup.org/onlinepubs/9699919799/functions/mbrlen.html} -Gnulib module: --- +Gnulib module: mbrlen Portability problems fixed by Gnulib: @itemize +...@item +This function is missing on some platforms: +HP-UX 11, IRIX 6.5, Solaris 2.6, mingw, Interix 3.5. @end itemize Portability problems not fixed by Gnulib: @itemize -...@item -This function is missing on some platforms: -HP-UX 11, IRIX 6.5, Solaris 2.6, mingw, Interix 3.5. @end itemize