New module 'wmemcpy'.
authorBruno Haible <bruno@clisp.org>
Sat, 5 Feb 2011 11:58:40 +0000 (12:58 +0100)
committerBruno Haible <bruno@clisp.org>
Mon, 7 Feb 2011 22:36:02 +0000 (23:36 +0100)
* 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
doc/posix-functions/wmemcpy.texi
lib/wchar.in.h
lib/wmemcpy-impl.h [new file with mode: 0644]
lib/wmemcpy.c [new file with mode: 0644]
m4/wchar_h.m4
m4/wmemcpy.m4 [new file with mode: 0644]
modules/wchar
modules/wmemcpy [new file with mode: 0644]
tests/test-wchar-c++.cc

index abc3c81..6fc0486 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,19 @@
 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'.
        * modules/wmemcmp: New file.
        * lib/wchar.in.h (wmemcmp): New declaration.
index 8e548c1..7066c98 100644 (file)
@@ -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
index ff154ca..3ec14cc 100644 (file)
@@ -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 (file)
index 0000000..6802e76
--- /dev/null
@@ -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;
+}
diff --git a/lib/wmemcpy.c b/lib/wmemcpy.c
new file mode 100644 (file)
index 0000000..0142497
--- /dev/null
@@ -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"
index a94f9c8..f522247 100644 (file)
@@ -50,7 +50,7 @@ AC_DEFUN([gl_WCHAR_H],
 #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 @@ 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 (file)
index 0000000..60af038
--- /dev/null
@@ -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
+])
index 260c210..fbe9e46 100644 (file)
@@ -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 (file)
index 0000000..4e15fa6
--- /dev/null
@@ -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
index cbda43b..d8dc18b 100644 (file)
@@ -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 ()