aboutsummaryrefslogtreecommitdiffstats
path: root/libabort_saprintf.c
diff options
context:
space:
mode:
authorMattias Andrée <m@maandree.se>2026-02-28 19:17:45 +0100
committerMattias Andrée <m@maandree.se>2026-02-28 19:17:45 +0100
commit7c545b4b9c31dbfb2e8430aded030654a92e967a (patch)
treecd79fb055bfcca79dee8b1b35c0ed59ea3a0c85a /libabort_saprintf.c
downloadlibabort-1.0.tar.gz
libabort-1.0.tar.bz2
libabort-1.0.tar.xz
First commitHEAD1.0master
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to 'libabort_saprintf.c')
-rw-r--r--libabort_saprintf.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/libabort_saprintf.c b/libabort_saprintf.c
new file mode 100644
index 0000000..4468b91
--- /dev/null
+++ b/libabort_saprintf.c
@@ -0,0 +1,28 @@
+/* See LICENSE file for copyright and license details. */
+#include "common.h"
+#ifndef TEST
+
+extern inline int libabort_saprintf(char *str, size_t size, const char *fmt, ...);
+
+#else
+
+int
+main(void)
+{
+ char buf[6];
+ int r;
+
+ INIT_TEST_ABORT();
+
+ EXPECT_NO_ABORT(r = libabort_saprintf(buf, sizeof(buf), "%s", "hello"));
+ EXPECT(r == 5);
+ EXPECT(!buf[r]);
+ EXPECT(!strcmp(buf, "hello"));
+
+ EXPECT_ABORT(libabort_saprintf(buf, sizeof(buf), "%s", "hello!"));
+ EXPECT_ABORT(libabort_saprintf(buf, 0, "%s", ""));
+
+ return 0;
+}
+
+#endif