Adjust strlcpy() and strlcat() per glibc adoption These functions were added in glibc 2.38, in anticipation of POSIX adopting them too. Closes: #26
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
diff --git a/configure.ac b/configure.ac
index 8ff2bef..aea61ab 100644
--- a/configure.ac
+++ b/configure.ac
@@ -267,6 +267,11 @@ need_id_from_name=yes
need_fpurge=yes
need_funopen=yes
AS_CASE([$host_os],
+ [*-gnu*], [
+ # On glibc >= 2.38, strlcpy() and strlcat() got added,
+ # so these could then be dropped on the next SOVERSION bump.
+ #need_strl=no
+ ],
[*-musl*], [
# On musl >= 0.5.0, strlcpy() and strlcat() were already implemented,
# so these can then be dropped on the next SOVERSION bump.
diff --git a/include/bsd/string.h b/include/bsd/string.h
index 1996697..64b4e13 100644
--- a/include/bsd/string.h
+++ b/include/bsd/string.h
@@ -41,7 +41,8 @@
#include <sys/types.h>
__BEGIN_DECLS
-#ifndef __APPLE__
+#if !defined(__APPLE__) && \
+ (!defined(__GLIBC__) || !__GLIBC_PREREQ(2, 38) || !defined(_DEFAULT_SOURCE))
size_t strlcpy(char *dst, const char *src, size_t siz);
size_t strlcat(char *dst, const char *src, size_t siz);
#endif
diff --git a/man/strlcpy.3bsd b/man/strlcpy.3bsd
index ebc9758..c3eee4f 100644
--- a/man/strlcpy.3bsd
+++ b/man/strlcpy.3bsd
@@ -14,7 +14,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: May 31 2007 $
+.Dd $Mdocdate: January 7 2024 $
.Dt strlcpy 3bsd
.Os
.Sh NAME
@@ -192,6 +192,7 @@ and
functions first appeared in
.Ox 2.4 ,
and made their appearance in
-.Nx 1.4.3
+.Nx 1.4.3 ,
+.Fx 3.3
and
-.Fx 3.3 .
+glibc 2.38.