aboutsummaryrefslogtreecommitdiff
path: root/archivers/unmakeself
diff options
context:
space:
mode:
authorJean-Yves Lefort <jylefort@FreeBSD.org>2006-11-07 16:07:35 +0000
committerJean-Yves Lefort <jylefort@FreeBSD.org>2006-11-07 16:07:35 +0000
commit601267275690ea39761d853e68c7c58d6d2cf335 (patch)
tree95eb0d8f4ca69ea978abdfc86de012b5b4febaaa /archivers/unmakeself
parent64809ed7bfcec67f04bc5b04dba7265b8b9f3d0a (diff)
downloadports-601267275690ea39761d853e68c7c58d6d2cf335.tar.gz
ports-601267275690ea39761d853e68c7c58d6d2cf335.zip
Notes
Diffstat (limited to 'archivers/unmakeself')
-rw-r--r--archivers/unmakeself/Makefile10
-rw-r--r--archivers/unmakeself/files/unmakeself.c35
2 files changed, 44 insertions, 1 deletions
diff --git a/archivers/unmakeself/Makefile b/archivers/unmakeself/Makefile
index 704799081d5e..e7d6b837c2e8 100644
--- a/archivers/unmakeself/Makefile
+++ b/archivers/unmakeself/Makefile
@@ -27,8 +27,16 @@ CPPFLAGS+= -I${LOCALBASE}/include
LDFLAGS+= -L${LOCALBASE}/lib
.endif
+do-configure:
+ @${RM} -f ${WRKSRC}/config.h
+ @if ${GREP} -q memmem /usr/include/string.h; then \
+ ${ECHO_CMD} "#define HAS_MEMMEM" > ${WRKSRC}/config.h; \
+ else \
+ ${ECHO_CMD} "#undef HAS_MEMMEM" > ${WRKSRC}/config.h; \
+ fi
+
do-build:
- ${CC} ${CFLAGS} ${CPPFLAGS} -o ${WRKSRC}/unmakeself \
+ ${CC} ${CFLAGS} ${CPPFLAGS} -I${WRKSRC} -o ${WRKSRC}/unmakeself \
${FILESDIR}/unmakeself.c ${LDFLAGS}
do-install:
diff --git a/archivers/unmakeself/files/unmakeself.c b/archivers/unmakeself/files/unmakeself.c
index d4b9542e110a..bc275d19b6e2 100644
--- a/archivers/unmakeself/files/unmakeself.c
+++ b/archivers/unmakeself/files/unmakeself.c
@@ -42,6 +42,7 @@
#include <unistd.h>
#include <getopt.h>
#include <archive.h>
+#include "config.h"
#define N_ELEMENTS(arr) (sizeof(arr) / sizeof((arr)[0]))
@@ -50,6 +51,40 @@ static char *filename;
static struct archive *archive;
static int extract_flags = ARCHIVE_EXTRACT_TIME; /* bsdtar default */
+#ifndef HAS_MEMMEM
+/* taken from lib/libc/string/memmem.c */
+static void *
+memmem(l, l_len, s, s_len)
+ const void *l; size_t l_len;
+ const void *s; size_t s_len;
+{
+ register char *cur, *last;
+ const char *cl = (const char *)l;
+ const char *cs = (const char *)s;
+
+ /* we need something to compare */
+ if (l_len == 0 || s_len == 0)
+ return NULL;
+
+ /* "s" must be smaller or equal to "l" */
+ if (l_len < s_len)
+ return NULL;
+
+ /* special case where s_len == 1 */
+ if (s_len == 1)
+ return memchr(l, (int)*cs, l_len);
+
+ /* the last position where its possible to find "s" in "l" */
+ last = (char *)cl + l_len - s_len;
+
+ for (cur = (char *)cl; cur <= last; cur++)
+ if (cur[0] == cs[0] && memcmp(cur, cs, s_len) == 0)
+ return cur;
+
+ return NULL;
+}
+#endif /* HAS_MEMMEM */
+
static void
unmakeself_print_help (void)
{