]> Savannah Git Hosting - gnulib.git/commitdiff
memccpy tests: Verify N3322 functionality.
authorBruno Haible <bruno@clisp.org>
Tue, 5 Nov 2024 20:10:08 +0000 (21:10 +0100)
committerBruno Haible <bruno@clisp.org>
Tue, 5 Nov 2024 21:19:16 +0000 (22:19 +0100)
* modules/memccpy: New file.
* doc/posix-functions/memccpy.texi: Mention the new module.
* tests/test-memccpy.c: New file.
* modules/memccpy-tests: New file.

ChangeLog
doc/posix-functions/memccpy.texi
modules/memccpy [new file with mode: 0644]
modules/memccpy-tests [new file with mode: 0644]
tests/test-memccpy.c [new file with mode: 0644]

index 362894241570ea9ab7b95f8e0cfe6347d3290d5f..4e9afd809896802d008f076336974cef318ccd3c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2024-11-05  Bruno Haible  <bruno@clisp.org>
+
+       memccpy tests: Verify N3322 functionality.
+       * modules/memccpy: New file.
+       * doc/posix-functions/memccpy.texi: Mention the new module.
+       * tests/test-memccpy.c: New file.
+       * modules/memccpy-tests: New file.
+
 2024-11-05  Bruno Haible  <bruno@clisp.org>
 
        memcpy tests: Verify N3322 functionality.
index 7761aca6a8633d30166617aa92d9ad4f9aef54bc..becefb1a0335f1fd673cd8090a037037b4dc346f 100644 (file)
@@ -4,7 +4,8 @@
 
 POSIX specification:@* @url{https://pubs.opengroup.org/onlinepubs/9799919799/functions/memccpy.html}
 
-Gnulib module: ---
+Gnulib module: memccpy
+@mindex memccpy
 
 Portability problems fixed by Gnulib:
 @itemize
diff --git a/modules/memccpy b/modules/memccpy
new file mode 100644 (file)
index 0000000..4c3a773
--- /dev/null
@@ -0,0 +1,25 @@
+Description:
+Copy delimited memory area.
+
+Status:
+obsolete
+
+Notice:
+This module is obsolete.
+
+Files:
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+
+Include:
+<string.h>
+
+License:
+LGPLv2+
+
+Maintainer:
+all
diff --git a/modules/memccpy-tests b/modules/memccpy-tests
new file mode 100644 (file)
index 0000000..0a09402
--- /dev/null
@@ -0,0 +1,11 @@
+Files:
+tests/test-memccpy.c
+tests/macros.h
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-memccpy
+check_PROGRAMS += test-memccpy
diff --git a/tests/test-memccpy.c b/tests/test-memccpy.c
new file mode 100644 (file)
index 0000000..576748d
--- /dev/null
@@ -0,0 +1,44 @@
+/* Test of memccpy() function.
+   Copyright (C) 2024 Free Software Foundation, Inc.
+
+   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 <https://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+/* Specification.  */
+#include <string.h>
+
+#include <stddef.h>
+
+#include "macros.h"
+
+int
+main (void)
+{
+  int volatile value;
+
+  /* Test zero-length operations on NULL pointers, allowed by
+     <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3322.pdf>.  */
+
+  value = (memccpy (NULL, "x", '?', 0) == NULL);
+  ASSERT (value);
+
+  {
+    char y[1];
+    value = (memccpy (y, NULL, '?', 0) == NULL);
+    ASSERT (value);
+  }
+
+  return test_exit_status;
+}