aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAriadne Conill <ariadne@dereferenced.org>2021-12-14 14:09:15 -0600
committerAriadne Conill <ariadne@dereferenced.org>2021-12-14 14:09:15 -0600
commitaff17d7e25c06521e2f9d85c3d8fdfc85eae498c (patch)
tree2ed63cff051cbdfdca73516576633addcf2f0a57
parent0a5db96c5c40409f1b627e34f83efe88d2e6feaa (diff)
downloadapk-tools-feature/macos.tar.gz
apk-tools-feature/macos.tar.bz2
apk-tools-feature/macos.tar.xz
portability: take over strlcpyfeature/macos
-rw-r--r--portability/meson.build1
-rw-r--r--portability/strlcpy.c13
-rw-r--r--src/blob.c13
3 files changed, 14 insertions, 13 deletions
diff --git a/portability/meson.build b/portability/meson.build
index 851dfca..90d6cd7 100644
--- a/portability/meson.build
+++ b/portability/meson.build
@@ -11,6 +11,7 @@ libportability_src = []
check_functions = [
['memrchr', 'memrchr.c', 'NEED_MEMRCHR', 'string.h'],
+ ['strlcpy', 'strlcpy.c', 'NEED_STRLCPY', 'string.h'],
]
diff --git a/portability/strlcpy.c b/portability/strlcpy.c
new file mode 100644
index 0000000..6ce46e3
--- /dev/null
+++ b/portability/strlcpy.c
@@ -0,0 +1,13 @@
+#include <stddef.h>
+#include <string.h>
+
+size_t strlcpy(char *dst, const char *src, size_t size)
+{
+ size_t ret = strlen(src), len;
+ if (!size) return ret;
+ len = ret;
+ if (len >= size) len = size - 1;
+ memcpy(dst, src, len);
+ dst[len] = 0;
+ return ret;
+}
diff --git a/src/blob.c b/src/blob.c
index 6af22d1..0d7274e 100644
--- a/src/blob.c
+++ b/src/blob.c
@@ -677,16 +677,3 @@ void apk_blob_pull_base64(apk_blob_t *b, apk_blob_t to)
err:
*b = APK_BLOB_NULL;
}
-
-#if defined(__GLIBC__) && !defined(__UCLIBC__)
-size_t strlcpy(char *dst, const char *src, size_t size)
-{
- size_t ret = strlen(src), len;
- if (!size) return ret;
- len = ret;
- if (len >= size) len = size - 1;
- memcpy(dst, src, len);
- dst[len] = 0;
- return ret;
-}
-#endif