summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabian Groffen <grobian@gentoo.org>2016-07-11 11:02:25 +0200
committerFabian Groffen <grobian@gentoo.org>2016-07-11 11:02:39 +0200
commit75def684be04605c57136532039683b5dacc5fa4 (patch)
tree5ba29a53320107a1a040adb9399a29b2524c5a65
parentmedia-video/smplayer: Bump to version 16.7.0 (bug #588574). (diff)
downloadgentoo-75def684be04605c57136532039683b5dacc5fa4.tar.gz
gentoo-75def684be04605c57136532039683b5dacc5fa4.tar.bz2
gentoo-75def684be04605c57136532039683b5dacc5fa4.zip
net-analyzer/openbsd-netcat: better fix for Darwin
Package-Manager: portage-2.2.28
-rw-r--r--net-analyzer/openbsd-netcat/files/openbsd-netcat-1.105-darwin.patch86
-rw-r--r--net-analyzer/openbsd-netcat/openbsd-netcat-1.105-r1.ebuild8
2 files changed, 89 insertions, 5 deletions
diff --git a/net-analyzer/openbsd-netcat/files/openbsd-netcat-1.105-darwin.patch b/net-analyzer/openbsd-netcat/files/openbsd-netcat-1.105-darwin.patch
new file mode 100644
index 000000000000..8c68a66ad548
--- /dev/null
+++ b/net-analyzer/openbsd-netcat/files/openbsd-netcat-1.105-darwin.patch
@@ -0,0 +1,86 @@
+Allow compilation on Darwin
+
+--- netcat.c
++++ netcat.c
+@@ -43,11 +43,13 @@
+ #include <arpa/telnet.h>
+ #include <arpa/inet.h>
+
++#ifndef IPTOS_LOWCOST
++# define IPTOS_LOWCOST 0x02
++#endif
+ #ifndef IPTOS_LOWDELAY
+ # define IPTOS_LOWDELAY 0x10
+ # define IPTOS_THROUGHPUT 0x08
+ # define IPTOS_RELIABILITY 0x04
+-# define IPTOS_LOWCOST 0x02
+ # define IPTOS_MINCOST IPTOS_LOWCOST
+ #endif /* IPTOS_LOWDELAY */
+
+@@ -96,8 +98,9 @@
+ #include <unistd.h>
+ #include <fcntl.h>
+ #include <limits.h>
+-#include <bsd/stdlib.h>
+-#include <bsd/string.h>
++#include <stdlib.h>
++#include <string.h>
++#include <ctype.h>
+ #include "atomicio.h"
+
+ #ifndef SUN_LEN
+@@ -169,6 +172,43 @@
+ socklen_t salen, int ctimeout);
+ static void quit();
+
++static char* strtonumerrs[] = {
++ "too large",
++ "too small",
++ "invalid"
++};
++
++static long long
++strtonum(
++ const char *nptr,
++ long long minval,
++ long long maxval,
++ const char **errstr)
++{
++ long long val;
++
++ while (*nptr != '\0' && isspace(*nptr))
++ nptr++;
++ if (*nptr == '\0') {
++ if (errstr != NULL)
++ *errstr = strtonumerrs[2];
++ return 0;
++ }
++ val = atoll(nptr);
++ if (val < minval) {
++ if (errstr != NULL)
++ *errstr = strtonumerrs[1];
++ return 0;
++ }
++ if (val > maxval) {
++ if (errstr != NULL)
++ *errstr = strtonumerrs[0];
++ return 0;
++ }
++ *errstr = NULL;
++ return val;
++}
++
+ int
+ main(int argc, char *argv[])
+ {
+--- socks.c
++++ socks.c
+@@ -38,7 +38,7 @@
+ #include <string.h>
+ #include <unistd.h>
+ #include <resolv.h>
+-#include <bsd/readpassphrase.h>
++#include <readpassphrase.h>
+ #include "atomicio.h"
+
+ #define SOCKS_PORT "1080"
diff --git a/net-analyzer/openbsd-netcat/openbsd-netcat-1.105-r1.ebuild b/net-analyzer/openbsd-netcat/openbsd-netcat-1.105-r1.ebuild
index f20c5c3d5566..e80ac3a3a399 100644
--- a/net-analyzer/openbsd-netcat/openbsd-netcat-1.105-r1.ebuild
+++ b/net-analyzer/openbsd-netcat/openbsd-netcat-1.105-r1.ebuild
@@ -4,7 +4,7 @@
EAPI=6
-inherit toolchain-funcs flag-o-matic
+inherit toolchain-funcs eutils
DESCRIPTION="The OpenBSD network swiss army knife"
HOMEPAGE="http://www.openbsd.org/cgi-bin/cvsweb/src/usr.bin/nc/"
@@ -29,10 +29,8 @@ PATCHES=( "${WORKDIR}/debian/patches" )
src_prepare() {
default
if [[ ${CHOST} == *-darwin* ]] ; then
- # Darwin = BSD, so remove libbsd dependency
- sed -i -e '/#include/s|bsd/||' -e 's/strtonum/strtoimax/' *.[ch] || die
- # Clang defaults to C99, but strtoimax isn't in C99
- append-flags -DIPTOS_LOWCOST=0x02 -std=c89
+ # this undoes some of the Debian/Linux changes
+ epatch "${FILESDIR}"/${P}-darwin.patch
fi
}