Mercurial > hg > octave-nkf > gnulib-hg
changeset 14278:fe5382375992
New module 'wmemcpy'.
* modules/wmemcpy: New file.
* lib/wchar.in.h (wmemcpy): New declaration.
* lib/wmemcpy.c: New file.
* lib/wmemcpy-impl.h: New file, from libutf8 with modifications.
* m4/wmemcpy.m4: New file.
* m4/wchar_h.m4 (gl_WCHAR_H): Test whether wmemcpy is declared.
(gl_WCHAR_H_DEFAULTS): Initialize GNULIB_WMEMCPY, HAVE_WMEMCPY.
* modules/wchar (Makefile.am): Substitute GNULIB_WMEMCPY, HAVE_WMEMCPY.
* tests/test-wchar-c++.cc: Test the declaration of wmemcpy.
* doc/posix-functions/wmemcpy.texi: Mention the new module.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sat, 05 Feb 2011 12:58:40 +0100 |
parents | 91a2110f419b |
children | 2a7d15223d39 |
files | ChangeLog doc/posix-functions/wmemcpy.texi lib/wchar.in.h lib/wmemcpy-impl.h lib/wmemcpy.c m4/wchar_h.m4 m4/wmemcpy.m4 modules/wchar modules/wmemcpy tests/test-wchar-c++.cc |
diffstat | 10 files changed, 135 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2011-02-05 Bruno Haible <bruno@clisp.org> + + New module 'wmemcpy'. + * modules/wmemcpy: New file. + * lib/wchar.in.h (wmemcpy): New declaration. + * lib/wmemcpy.c: New file. + * lib/wmemcpy-impl.h: New file, from libutf8 with modifications. + * m4/wmemcpy.m4: New file. + * m4/wchar_h.m4 (gl_WCHAR_H): Test whether wmemcpy is declared. + (gl_WCHAR_H_DEFAULTS): Initialize GNULIB_WMEMCPY, HAVE_WMEMCPY. + * modules/wchar (Makefile.am): Substitute GNULIB_WMEMCPY, HAVE_WMEMCPY. + * tests/test-wchar-c++.cc: Test the declaration of wmemcpy. + * doc/posix-functions/wmemcpy.texi: Mention the new module. + 2011-02-05 Bruno Haible <bruno@clisp.org> New module 'wmemcmp'.
--- a/doc/posix-functions/wmemcpy.texi +++ b/doc/posix-functions/wmemcpy.texi @@ -4,18 +4,18 @@ POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/wmemcpy.html} -Gnulib module: --- +Gnulib module: wmemcpy Portability problems fixed by Gnulib: @itemize +@item +This function is missing on some platforms: +HP-UX 11.00, IRIX 6.5, Solaris 2.6, Interix 3.5. @end itemize Portability problems not fixed by Gnulib: @itemize @item -This function is missing on some platforms: -HP-UX 11.00, IRIX 6.5, Solaris 2.6, Interix 3.5. -@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 @@ -464,6 +464,24 @@ #endif +/* Copy N wide characters of SRC to DEST. */ +#if @GNULIB_WMEMCPY@ +# if !@HAVE_WMEMCPY@ +_GL_FUNCDECL_SYS (wmemcpy, wchar_t *, + (wchar_t *dest, const wchar_t *src, size_t n)); +# endif +_GL_CXXALIAS_SYS (wmemcpy, wchar_t *, + (wchar_t *dest, const wchar_t *src, size_t n)); +_GL_CXXALIASWARN (wmemcpy); +#elif defined GNULIB_POSIXCHECK +# undef wmemcpy +# if HAVE_RAW_DECL_WMEMCPY +_GL_WARN_ON_USE (wmemcpy, "wmemcpy is unportable - " + "use gnulib module wmemcpy for portability"); +# endif +#endif + + #endif /* _GL_WCHAR_H */ #endif /* _GL_WCHAR_H */ #endif
new file mode 100644 --- /dev/null +++ b/lib/wmemcpy-impl.h @@ -0,0 +1,26 @@ +/* Copy wide character array. + 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 * +wmemcpy (wchar_t *dest, const wchar_t *src, size_t n) +{ + wchar_t *destptr = dest; + + for (; n > 0; n--) + *destptr++ = *src++; + return dest; +}
new file mode 100644 --- /dev/null +++ b/lib/wmemcpy.c @@ -0,0 +1,23 @@ +/* Copy wide character array. + 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 "wmemcpy-impl.h"
--- a/m4/wchar_h.m4 +++ b/m4/wchar_h.m4 @@ -50,7 +50,7 @@ #include <wchar.h> ]], [btowc wctob mbsinit mbrtowc mbrlen mbsrtowcs mbsnrtowcs wcrtomb - wcsrtombs wcsnrtombs wcwidth wmemchr wmemcmp + wcsrtombs wcsnrtombs wcwidth wmemchr wmemcmp wmemcpy ]) ]) @@ -147,6 +147,7 @@ GNULIB_WCWIDTH=0; AC_SUBST([GNULIB_WCWIDTH]) GNULIB_WMEMCHR=0; AC_SUBST([GNULIB_WMEMCHR]) GNULIB_WMEMCMP=0; AC_SUBST([GNULIB_WMEMCMP]) + GNULIB_WMEMCPY=0; AC_SUBST([GNULIB_WMEMCPY]) dnl Assume proper GNU behavior unless another module says otherwise. HAVE_BTOWC=1; AC_SUBST([HAVE_BTOWC]) HAVE_MBSINIT=1; AC_SUBST([HAVE_MBSINIT]) @@ -159,6 +160,7 @@ HAVE_WCSNRTOMBS=1; AC_SUBST([HAVE_WCSNRTOMBS]) HAVE_WMEMCHR=1; AC_SUBST([HAVE_WMEMCHR]) HAVE_WMEMCMP=1; AC_SUBST([HAVE_WMEMCMP]) + HAVE_WMEMCPY=1; AC_SUBST([HAVE_WMEMCPY]) 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/wmemcpy.m4 @@ -0,0 +1,15 @@ +# wmemcpy.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_WMEMCPY], +[ + AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) + AC_CHECK_FUNCS_ONCE([wmemcpy]) + if test $ac_cv_func_wmemcpy = no; then + HAVE_WMEMCPY=0 + AC_LIBOBJ([wmemcpy]) + fi +])
--- a/modules/wchar +++ b/modules/wchar @@ -43,6 +43,7 @@ -e 's|@''GNULIB_WCWIDTH''@|$(GNULIB_WCWIDTH)|g' \ -e 's|@''GNULIB_WMEMCHR''@|$(GNULIB_WMEMCHR)|g' \ -e 's|@''GNULIB_WMEMCMP''@|$(GNULIB_WMEMCMP)|g' \ + -e 's|@''GNULIB_WMEMCPY''@|$(GNULIB_WMEMCPY)|g' \ -e 's|@''HAVE_WINT_T''@|$(HAVE_WINT_T)|g' \ -e 's|@''HAVE_BTOWC''@|$(HAVE_BTOWC)|g' \ -e 's|@''HAVE_MBSINIT''@|$(HAVE_MBSINIT)|g' \ @@ -55,6 +56,7 @@ -e 's|@''HAVE_WCSNRTOMBS''@|$(HAVE_WCSNRTOMBS)|g' \ -e 's|@''HAVE_WMEMCHR''@|$(HAVE_WMEMCHR)|g' \ -e 's|@''HAVE_WMEMCMP''@|$(HAVE_WMEMCMP)|g' \ + -e 's|@''HAVE_WMEMCPY''@|$(HAVE_WMEMCPY)|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/wmemcpy @@ -0,0 +1,25 @@ +Description: +wmemcpy() function: copy wide character array. + +Files: +lib/wmemcpy.c +lib/wmemcpy-impl.h +m4/wmemcpy.m4 + +Depends-on: +wchar + +configure.ac: +gl_FUNC_WMEMCPY +gl_WCHAR_MODULE_INDICATOR([wmemcpy]) + +Makefile.am: + +Include: +<wchar.h> + +License: +LGPL + +Maintainer: +Bruno Haible