Mercurial > hg > octave-nkf > gnulib-hg
changeset 14296:932d02b6b200
New module 'wcschr'.
* modules/wcschr: New file.
* lib/wchar.in.h (wcschr): New declaration.
* lib/wcschr.c: New file.
* lib/wcschr-impl.h: New file, from libutf8 with modifications.
* m4/wcschr.m4: New file.
* m4/wchar_h.m4 (gl_WCHAR_H): Test whether wcschr is declared.
(gl_WCHAR_H_DEFAULTS): Initialize GNULIB_WCSCHR, HAVE_WCSCHR.
* modules/wchar (Makefile.am): Substitute GNULIB_WCSCHR, HAVE_WCSCHR.
* tests/test-wchar-c++.cc: Test the declaration of wcschr.
* doc/posix-functions/wcschr.texi: Mention the new module.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sun, 06 Feb 2011 13:52:11 +0100 |
parents | 34809a158a33 |
children | 029111e5ac51 |
files | ChangeLog doc/posix-functions/wcschr.texi lib/wchar.in.h lib/wcschr-impl.h lib/wcschr.c m4/wchar_h.m4 m4/wcschr.m4 modules/wchar modules/wcschr tests/test-wchar-c++.cc |
diffstat | 10 files changed, 145 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2011-02-06 Bruno Haible <bruno@clisp.org> + + New module 'wcschr'. + * modules/wcschr: New file. + * lib/wchar.in.h (wcschr): New declaration. + * lib/wcschr.c: New file. + * lib/wcschr-impl.h: New file, from libutf8 with modifications. + * m4/wcschr.m4: New file. + * m4/wchar_h.m4 (gl_WCHAR_H): Test whether wcschr is declared. + (gl_WCHAR_H_DEFAULTS): Initialize GNULIB_WCSCHR, HAVE_WCSCHR. + * modules/wchar (Makefile.am): Substitute GNULIB_WCSCHR, HAVE_WCSCHR. + * tests/test-wchar-c++.cc: Test the declaration of wcschr. + * doc/posix-functions/wcschr.texi: Mention the new module. + 2011-02-06 Bruno Haible <bruno@clisp.org> New module 'wcsdup'.
--- a/doc/posix-functions/wcschr.texi +++ b/doc/posix-functions/wcschr.texi @@ -4,18 +4,18 @@ POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/wcschr.html} -Gnulib module: --- +Gnulib module: wcschr Portability problems fixed by Gnulib: @itemize +@item +This function is missing on some platforms: +IRIX 5.3, Solaris 2.5.1. @end itemize Portability problems not fixed by Gnulib: @itemize @item -This function is missing on some platforms: -IRIX 5.3, Solaris 2.5.1. -@item On AIX and Windows platforms, @code{wchar_t} is a 16-bit type and therefore cannot accommodate all Unicode characters. @end itemize
--- a/lib/wchar.in.h +++ b/lib/wchar.in.h @@ -771,6 +771,22 @@ #endif +/* Find the first occurrence of WC in WCS. */ +#if @GNULIB_WCSCHR@ +# if !@HAVE_WCSCHR@ +_GL_FUNCDECL_SYS (wcschr, wchar_t *, (const wchar_t *wcs, wchar_t wc)); +# endif +_GL_CXXALIAS_SYS (wcschr, wchar_t *, (const wchar_t *wcs, wchar_t wc)); +_GL_CXXALIASWARN (wcschr); +#elif defined GNULIB_POSIXCHECK +# undef wcschr +# if HAVE_RAW_DECL_WCSCHR +_GL_WARN_ON_USE (wcschr, "wcschr is unportable - " + "use gnulib module wcschr for portability"); +# endif +#endif + + #endif /* _GL_WCHAR_H */ #endif /* _GL_WCHAR_H */ #endif
new file mode 100644 --- /dev/null +++ b/lib/wcschr-impl.h @@ -0,0 +1,32 @@ +/* Search wide string for a wide character. + Copyright (C) 1999, 2011 Free Software Foundation, Inc. + Written by Bruno Haible <bruno@clisp.org>, 1999. + + 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/>. */ + +wchar_t * +wcschr (const wchar_t *wcs, wchar_t wc) +{ + for (;; wcs++) + { + if (*wcs == wc) + break; + if (*wcs == (wchar_t)'\0') + goto notfound; + } + return (wchar_t *) wcs; + + notfound: + return NULL; +}
new file mode 100644 --- /dev/null +++ b/lib/wcschr.c @@ -0,0 +1,23 @@ +/* Search wide string for a wide character. + Copyright (C) 2011 Free Software Foundation, Inc. + Written by Bruno Haible <bruno@clisp.org>, 2011. + + 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> + +#include "wcschr-impl.h"
--- a/m4/wchar_h.m4 +++ b/m4/wchar_h.m4 @@ -52,7 +52,7 @@ [btowc wctob mbsinit mbrtowc mbrlen mbsrtowcs mbsnrtowcs wcrtomb wcsrtombs wcsnrtombs wcwidth wmemchr wmemcmp wmemcpy wmemmove wmemset wcslen wcsnlen wcscpy wcpcpy wcsncpy wcpncpy wcscat wcsncat wcscmp - wcsncmp wcscasecmp wcsncasecmp wcscoll wcsxfrm wcsdup + wcsncmp wcscasecmp wcsncasecmp wcscoll wcsxfrm wcsdup wcschr ]) ]) @@ -167,6 +167,7 @@ GNULIB_WCSCOLL=0; AC_SUBST([GNULIB_WCSCOLL]) GNULIB_WCSXFRM=0; AC_SUBST([GNULIB_WCSXFRM]) GNULIB_WCSDUP=0; AC_SUBST([GNULIB_WCSDUP]) + GNULIB_WCSCHR=0; AC_SUBST([GNULIB_WCSCHR]) dnl Assume proper GNU behavior unless another module says otherwise. HAVE_BTOWC=1; AC_SUBST([HAVE_BTOWC]) HAVE_MBSINIT=1; AC_SUBST([HAVE_MBSINIT]) @@ -197,6 +198,7 @@ HAVE_WCSCOLL=1; AC_SUBST([HAVE_WCSCOLL]) HAVE_WCSXFRM=1; AC_SUBST([HAVE_WCSXFRM]) HAVE_WCSDUP=1; AC_SUBST([HAVE_WCSDUP]) + HAVE_WCSCHR=1; AC_SUBST([HAVE_WCSCHR]) HAVE_DECL_WCTOB=1; AC_SUBST([HAVE_DECL_WCTOB]) HAVE_DECL_WCWIDTH=1; AC_SUBST([HAVE_DECL_WCWIDTH]) REPLACE_MBSTATE_T=0; AC_SUBST([REPLACE_MBSTATE_T])
new file mode 100644 --- /dev/null +++ b/m4/wcschr.m4 @@ -0,0 +1,15 @@ +# wcschr.m4 serial 1 +dnl Copyright (C) 2011 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_WCSCHR], +[ + AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) + AC_CHECK_FUNCS_ONCE([wcschr]) + if test $ac_cv_func_wcschr = no; then + HAVE_WCSCHR=0 + AC_LIBOBJ([wcschr]) + fi +])
--- a/modules/wchar +++ b/modules/wchar @@ -61,6 +61,7 @@ -e 's|@''GNULIB_WCSCOLL''@|$(GNULIB_WCSCOLL)|g' \ -e 's|@''GNULIB_WCSXFRM''@|$(GNULIB_WCSXFRM)|g' \ -e 's|@''GNULIB_WCSDUP''@|$(GNULIB_WCSDUP)|g' \ + -e 's|@''GNULIB_WCSCHR''@|$(GNULIB_WCSCHR)|g' \ -e 's|@''HAVE_WINT_T''@|$(HAVE_WINT_T)|g' \ -e 's|@''HAVE_BTOWC''@|$(HAVE_BTOWC)|g' \ -e 's|@''HAVE_MBSINIT''@|$(HAVE_MBSINIT)|g' \ @@ -91,6 +92,7 @@ -e 's|@''HAVE_WCSCOLL''@|$(HAVE_WCSCOLL)|g' \ -e 's|@''HAVE_WCSXFRM''@|$(HAVE_WCSXFRM)|g' \ -e 's|@''HAVE_WCSDUP''@|$(HAVE_WCSDUP)|g' \ + -e 's|@''HAVE_WCSCHR''@|$(HAVE_WCSCHR)|g' \ -e 's|@''HAVE_DECL_WCTOB''@|$(HAVE_DECL_WCTOB)|g' \ -e 's|@''HAVE_DECL_WCWIDTH''@|$(HAVE_DECL_WCWIDTH)|g' \ -e 's|@''REPLACE_MBSTATE_T''@|$(REPLACE_MBSTATE_T)|g' \
new file mode 100644 --- /dev/null +++ b/modules/wcschr @@ -0,0 +1,31 @@ +Description: +wcschr() function: search wide string for a wide character. + +Status: +obsolete + +Notice: +This module is obsolete. + +Files: +lib/wcschr.c +lib/wcschr-impl.h +m4/wcschr.m4 + +Depends-on: +wchar + +configure.ac: +gl_FUNC_WCSCHR +gl_WCHAR_MODULE_INDICATOR([wcschr]) + +Makefile.am: + +Include: +<wchar.h> + +License: +LGPL + +Maintainer: +Bruno Haible