>From bda6e6a07764e0ece7e9f7869d40ae4daed10e28 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Tue, 5 Nov 2024 21:10:08 +0100 Subject: [PATCH 04/23] 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. --- ChangeLog | 8 ++++++ doc/posix-functions/memccpy.texi | 3 ++- modules/memccpy | 25 ++++++++++++++++++ modules/memccpy-tests | 11 ++++++++ tests/test-memccpy.c | 44 ++++++++++++++++++++++++++++++++ 5 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 modules/memccpy create mode 100644 modules/memccpy-tests create mode 100644 tests/test-memccpy.c diff --git a/ChangeLog b/ChangeLog index 3628942415..4e9afd8098 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2024-11-05 Bruno Haible + + 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 memcpy tests: Verify N3322 functionality. diff --git a/doc/posix-functions/memccpy.texi b/doc/posix-functions/memccpy.texi index 7761aca6a8..becefb1a03 100644 --- a/doc/posix-functions/memccpy.texi +++ b/doc/posix-functions/memccpy.texi @@ -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 index 0000000000..4c3a773c97 --- /dev/null +++ b/modules/memccpy @@ -0,0 +1,25 @@ +Description: +Copy delimited memory area. + +Status: +obsolete + +Notice: +This module is obsolete. + +Files: + +Depends-on: + +configure.ac: + +Makefile.am: + +Include: + + +License: +LGPLv2+ + +Maintainer: +all diff --git a/modules/memccpy-tests b/modules/memccpy-tests new file mode 100644 index 0000000000..0a09402ba7 --- /dev/null +++ b/modules/memccpy-tests @@ -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 index 0000000000..576748dad8 --- /dev/null +++ b/tests/test-memccpy.c @@ -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 . */ + +#include + +/* Specification. */ +#include + +#include + +#include "macros.h" + +int +main (void) +{ + int volatile value; + + /* Test zero-length operations on NULL pointers, allowed by + . */ + + value = (memccpy (NULL, "x", '?', 0) == NULL); + ASSERT (value); + + { + char y[1]; + value = (memccpy (y, NULL, '?', 0) == NULL); + ASSERT (value); + } + + return test_exit_status; +} -- 2.34.1