aboutsummaryrefslogtreecommitdiff
path: root/lib/compat.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/compat.c')
-rw-r--r--lib/compat.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/compat.c b/lib/compat.c
new file mode 100644
index 0000000..5fd2cc4
--- /dev/null
+++ b/lib/compat.c
@@ -0,0 +1,23 @@
+#include "config.h"
+
+#ifndef HAVE_STRSEP
+#include <string.h>
+// credit: Dan Cross via https://unixpapa.com/incnote/string.html
+char *strsep(char **sp, char *sep)
+{
+ char *p, *s;
+ if (sp == NULL || *sp == NULL || **sp == '\0') return(NULL);
+ s = *sp;
+ p = s + strcspn(s, sep);
+ if (*p != '\0') *p++ = '\0';
+ *sp = p;
+ return(s);
+}
+#endif
+
+#ifndef HAVE_REALLOCARRAY
+#include <stdlib.h>
+void *reallocarray (void *__ptr, size_t __nmemb, size_t __size) {
+ return realloc(__ptr, __nmemb * __size);
+}
+#endif