From 7c545b4b9c31dbfb2e8430aded030654a92e967a Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sat, 28 Feb 2026 19:17:45 +0100 Subject: First commit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- libabort_stpacat.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 libabort_stpacat.c (limited to 'libabort_stpacat.c') diff --git a/libabort_stpacat.c b/libabort_stpacat.c new file mode 100644 index 0000000..35d8dd8 --- /dev/null +++ b/libabort_stpacat.c @@ -0,0 +1,30 @@ +/* See LICENSE file for copyright and license details. */ +#include "common.h" +#ifndef TEST + +extern inline char *libabort_stpacat(char *dst, const char *src, size_t size); + +#else + +int +main(void) +{ + char buf[32]; + char *p; + + INIT_TEST_ABORT(); + + stracpy(buf, "hello", sizeof(buf)); + EXPECT_NO_ABORT(p = stpacat(buf, " world", sizeof(buf))); + EXPECT(!strcmp(buf, "hello world")); + EXPECT(p == &buf[11]); + EXPECT(*p == '\0'); + + stracpy(buf, "hello", sizeof(buf)); + EXPECT_ABORT(stpacat(buf, " world", 11)); + EXPECT_ABORT(stpacat(buf, "", 0)); + + return 0; +} + +#endif -- cgit v1.2.3-70-g09d2