commit add3e4aaeb65f8d563ff8066d57ce458b554fcee
parent 8726efe4673acb05acbf3bb8cac871f32bca7397
Author: hhvn <dev@hhvn.uk>
Date: Sun, 16 Jan 2022 20:04:41 +0000
configure zygo.h strlcat.c: strlcat
Diffstat:
2 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/configure b/configure
@@ -55,3 +55,19 @@ ${CC} -ltinfow -o test test.c >/dev/null 2>/dev/null && {
EOF
} || printf '%s\n' "no"
}
+
+printf '%s' "checking for strlcat... "
+cat > test.c <<- EOF
+ #include <string.h>
+ int main(void) { char a[3] = {'a', 0, 0}; strlcat(a, "hello", sizeof(a)); return 0; }
+EOF
+${CC} -o test test.c >/dev/null 2>/dev/null && ./test >/dev/null 2>/dev/null && {
+ printf '%s\n' "yes"
+} || {
+ printf '%s\n' "no"
+ cat >> config.mk <<- EOF
+ # linking an included version of strlcat, as your system doesn't have it
+ CFLAGS += -DZYGO_STRLCAT
+ SRC += src/strlcpy.c
+ EOF
+}
diff --git a/zygo.h b/zygo.h
@@ -113,3 +113,7 @@ void run(void);
int readline(char *buf, size_t count);
int go(Elem *e, int mhist);
void sighandler(int signal);
+#ifdef ZYGO_STRLCAT
+#undef strlcat
+size_t strlcat(char *dst, const char *src, size_t dstsize);
+#endif