hirc

IRC client
Log | Files | Refs

commit 09e473886e7a5026a45b90c51da6ed06c0859f47
parent 6b6e8e550b0aa6a9607e0bbfca38d719791c9e67
Author: hhvn <dev@hhvn.uk>
Date:   Sun, 12 Dec 2021 12:38:53 +0000

Makefile configure s/hirc.h: only link our strlcpy if needed

Diffstat:
MMakefile | 2+-
Mconfigure | 15+++++++++++++++
Msrc/hirc.h | 4++--
3 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile @@ -6,7 +6,7 @@ MANDIR = $(PREFIX)/share/man BIN = hirc SRC = src/main.c src/handle.c src/hist.c src/nick.c \ src/chan.c src/serv.c src/ui.c src/commands.c \ - src/config.c src/strlcpy.c + src/config.c OBJ = $(SRC:.c=.o) MAN = hirc.1 COMMIT = $(shell git log HEAD...HEAD~1 --pretty=format:%h) diff --git a/configure b/configure @@ -46,3 +46,18 @@ ${CC} -ltinfow -o test test.c >/dev/null 2>/dev/null && { printf '%s\n' "no" fi } + +printf '%s' "checking for strlcpy... " +cat > test.c <<- EOF + #include <string.h> + int main(void) { char a[2]; strlcpy(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 + CFLAGS += -DHIRC_STRLCPY + SRC += src/strlcpy.c + EOF +} diff --git a/src/hirc.h b/src/hirc.h @@ -12,10 +12,10 @@ #define strcmp_n(s1, s2) (s1 == s2 ? 0 : (s1 ? s2 ? strcmp(s1, s2) : -1 : -1)) /* strlcpy.c */ -#ifndef __OpenBSD__ +#ifdef HIRC_STRLCPY #undef strlcpy size_t strlcpy(char *dst, const char *src, size_t dsize); -#endif /* __OpenBSD__ */ +#endif /* HIST_STRLCPY */ /* main.c */ void * emalloc(size_t size);