Commit 5434ba169bddb985ca7d0b8f1635b105b0038643

Guillem Jover 2023-04-23T02:05:04

build: Conditionalize wcslcpy() and wcslcat() functions on macOS These functions are provided by the system libc.

diff --git a/configure.ac b/configure.ac
index 9b2c277..aabe28e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -324,6 +324,7 @@ need_progname=yes
 need_md5=yes
 need_nlist=yes
 need_strl=yes
+need_wcsl=yes
 need_strmode=yes
 need_id_from_name=yes
 need_fpurge=yes
@@ -354,6 +355,7 @@ AS_CASE([$host_os],
     need_md5=no
     need_nlist=no
     need_strl=no
+    need_wcsl=no
     need_strmode=no
     need_id_from_name=no
     need_fpurge=no
@@ -371,6 +373,7 @@ AM_CONDITIONAL([NEED_TRANSPARENT_LIBMD], [test "x$need_transparent_libmd" = "xye
 AM_CONDITIONAL([NEED_MD5], [test "x$need_md5" = "xyes"])
 AM_CONDITIONAL([NEED_NLIST], [test "x$need_nlist" = "xyes"])
 AM_CONDITIONAL([NEED_STRL], [test "x$need_strl" = "xyes"])
+AM_CONDITIONAL([NEED_WCSL], [test "x$need_wcsl" = "xyes"])
 AM_CONDITIONAL([NEED_STRMODE], [test "x$need_strmode" = "xyes"])
 AM_CONDITIONAL([NEED_ID_FROM_NAME], [test "x$need_id_from_name" = "xyes"])
 AM_CONDITIONAL([NEED_FPURGE], [test "x$need_fpurge" = "xyes"])
diff --git a/include/bsd/wchar.h b/include/bsd/wchar.h
index 7216503..8edef23 100644
--- a/include/bsd/wchar.h
+++ b/include/bsd/wchar.h
@@ -50,8 +50,10 @@
 __BEGIN_DECLS
 wchar_t *fgetwln(FILE *stream, size_t *len);
 
+#if !defined(__APPLE__)
 size_t wcslcat(wchar_t *dst, const wchar_t *src, size_t size);
 size_t wcslcpy(wchar_t *dst, const wchar_t *src, size_t size);
+#endif
 __END_DECLS
 
 #endif
diff --git a/man/Makefile.am b/man/Makefile.am
index 118ab2d..b89c3dd 100644
--- a/man/Makefile.am
+++ b/man/Makefile.am
@@ -238,8 +238,6 @@ dist_man_MANS = \
 	unvis.3bsd \
 	user_from_uid.3bsd \
 	vis.3bsd \
-	wcslcat.3bsd \
-	wcslcpy.3bsd \
 	# EOL
 
 if NEED_PROGNAME
@@ -268,6 +266,13 @@ dist_man_MANS += \
 	# EOL
 endif
 
+if NEED_WCSL
+dist_man_MANS += \
+	wcslcat.3bsd \
+	wcslcpy.3bsd \
+	# EOL
+endif
+
 if NEED_STRMODE
 dist_man_MANS += \
 	strmode.3bsd \
diff --git a/src/Makefile.am b/src/Makefile.am
index 0648b03..fd4bee9 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -112,8 +112,6 @@ libbsd_la_SOURCES = \
 	timeconv.c \
 	unvis.c \
 	vis.c \
-	wcslcat.c \
-	wcslcpy.c \
 	# EOL
 
 if NEED_BSD_GETOPT
@@ -158,6 +156,13 @@ libbsd_la_SOURCES += \
 	# EOL
 endif
 
+if NEED_WCSL
+libbsd_la_SOURCES += \
+	wcslcat.c \
+	wcslcpy.c \
+	# EOL
+endif
+
 if NEED_STRMODE
 libbsd_la_SOURCES += \
 	strmode.c \