From c20b0560d1c6f31c35e502a58a283f07e1a72869 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sat, 5 Feb 2011 12:58:40 +0100 Subject: [PATCH] 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. --- ChangeLog | 14 ++++++++++++++ doc/posix-functions/wmemcpy.texi | 8 ++++---- lib/wchar.in.h | 18 ++++++++++++++++++ lib/wmemcpy-impl.h | 26 ++++++++++++++++++++++++++ lib/wmemcpy.c | 23 +++++++++++++++++++++++ m4/wchar_h.m4 | 4 +++- m4/wmemcpy.m4 | 15 +++++++++++++++ modules/wchar | 2 ++ modules/wmemcpy | 25 +++++++++++++++++++++++++ tests/test-wchar-c++.cc | 5 +++++ 10 files changed, 135 insertions(+), 5 deletions(-) create mode 100644 lib/wmemcpy-impl.h create mode 100644 lib/wmemcpy.c create mode 100644 m4/wmemcpy.m4 create mode 100644 modules/wmemcpy diff --git a/ChangeLog b/ChangeLog index abc3c81a4..6fc04860c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,19 @@ 2011-02-05 Bruno Haible + 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 + New module 'wmemcmp'. * modules/wmemcmp: New file. * lib/wchar.in.h (wmemcmp): New declaration. diff --git a/doc/posix-functions/wmemcpy.texi b/doc/posix-functions/wmemcpy.texi index 8e548c17f..7066c9810 100644 --- 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 diff --git a/lib/wchar.in.h b/lib/wchar.in.h index ff154cae8..3ec14cc6c 100644 --- a/lib/wchar.in.h +++ b/lib/wchar.in.h @@ -464,6 +464,24 @@ _GL_WARN_ON_USE (wmemcmp, "wmemcmp is unportable - " #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 diff --git a/lib/wmemcpy-impl.h b/lib/wmemcpy-impl.h new file mode 100644 index 000000000..6802e7673 --- /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 , 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 . */ + +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; +} diff --git a/lib/wmemcpy.c b/lib/wmemcpy.c new file mode 100644 index 000000000..01424973e --- /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 , 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 . */ + +#include + +/* Specification. */ +#include + +#include "wmemcpy-impl.h" diff --git a/m4/wchar_h.m4 b/m4/wchar_h.m4 index a94f9c838..f5222475e 100644 --- a/m4/wchar_h.m4 +++ b/m4/wchar_h.m4 @@ -50,7 +50,7 @@ AC_DEFUN([gl_WCHAR_H], #include ]], [btowc wctob mbsinit mbrtowc mbrlen mbsrtowcs mbsnrtowcs wcrtomb - wcsrtombs wcsnrtombs wcwidth wmemchr wmemcmp + wcsrtombs wcsnrtombs wcwidth wmemchr wmemcmp wmemcpy ]) ]) @@ -147,6 +147,7 @@ AC_DEFUN([gl_WCHAR_H_DEFAULTS], 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 @@ AC_DEFUN([gl_WCHAR_H_DEFAULTS], 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]) diff --git a/m4/wmemcpy.m4 b/m4/wmemcpy.m4 new file mode 100644 index 000000000..60af038ef --- /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 +]) diff --git a/modules/wchar b/modules/wchar index 260c210a1..fbe9e469d 100644 --- a/modules/wchar +++ b/modules/wchar @@ -43,6 +43,7 @@ wchar.h: wchar.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) -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 @@ wchar.h: wchar.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) -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' \ diff --git a/modules/wmemcpy b/modules/wmemcpy new file mode 100644 index 000000000..4e15fa6b0 --- /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: + + +License: +LGPL + +Maintainer: +Bruno Haible diff --git a/tests/test-wchar-c++.cc b/tests/test-wchar-c++.cc index cbda43b05..d8dc18b79 100644 --- a/tests/test-wchar-c++.cc +++ b/tests/test-wchar-c++.cc @@ -85,6 +85,11 @@ SIGNATURE_CHECK (GNULIB_NAMESPACE::wmemcmp, int, (const wchar_t *, const wchar_t *, size_t)); #endif +#if GNULIB_TEST_WMEMCPY +SIGNATURE_CHECK (GNULIB_NAMESPACE::wmemcpy, wchar_t *, + (wchar_t *, const wchar_t *, size_t)); +#endif + int main () -- 2.11.0