From fef5a69b0903704f5c20dcb8acbfc9f310060c8a Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Mon, 1 Aug 2011 16:17:59 +0200 Subject: [PATCH 1/2] Mac OS X fixes: include string.h, add strndup(), disable xmllint for the docs --- i3bar/doc/Makefile | 2 +- i3bar/src/ipc.c | 1 + i3bar/src/xcb.c | 24 ++++++++++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/i3bar/doc/Makefile b/i3bar/doc/Makefile index a8144cd8..69566750 100644 --- a/i3bar/doc/Makefile +++ b/i3bar/doc/Makefile @@ -2,7 +2,7 @@ all: i3bar.1 i3bar.1: i3bar.man echo "A2X i3bar" - a2x -f manpage i3bar.man + a2x --no-xmllint -f manpage i3bar.man clean: rm -f i3bar.xml i3bar.1 i3bar.html diff --git a/i3bar/src/ipc.c b/i3bar/src/ipc.c index 85cd234f..7769fdb1 100644 --- a/i3bar/src/ipc.c +++ b/i3bar/src/ipc.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include diff --git a/i3bar/src/xcb.c b/i3bar/src/xcb.c index 62160f40..b8ab5ed2 100644 --- a/i3bar/src/xcb.c +++ b/i3bar/src/xcb.c @@ -27,6 +27,30 @@ #include "common.h" +#if defined(__APPLE__) + +/* + * Taken from FreeBSD + * Returns a pointer to a new string which is a duplicate of the + * string, but only copies at most n characters. + * + */ +char *strndup(const char *str, size_t n) { + size_t len; + char *copy; + + for (len = 0; len < n && str[len]; len++) + continue; + + if ((copy = malloc(len + 1)) == NULL) + return (NULL); + memcpy(copy, str, len); + copy[len] = '\0'; + return (copy); +} + +#endif + /* We save the Atoms in an easy to access array, indexed by an enum */ enum { #define ATOM_DO(name) name, From 32ce533d54f3474f11d871fa754d621e0e820dd2 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Mon, 1 Aug 2011 18:09:27 +0200 Subject: [PATCH 2/2] =?UTF-8?q?enable=20-Wl,--as-needed=20only=20on=20Linu?= =?UTF-8?q?x=20(doesn=E2=80=99t=20work=20on=20Mac=20OS=20X)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common.mk | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/common.mk b/common.mk index 05b10611..ce41f287 100644 --- a/common.mk +++ b/common.mk @@ -71,7 +71,11 @@ LIBS += $(call ldflags_for_lib, x11, X11) LIBS += $(call ldflags_for_lib, yajl, yajl) LIBS += $(call ldflags_for_lib, libev, ev) +# Please test if -Wl,--as-needed works on your platform and send me a patch. +# it is known not to work on Darwin (Mac OS X) +ifneq (,$(filter Linux GNU GNU/%, $(UNAME))) LDFLAGS += -Wl,--as-needed +endif ifeq ($(UNAME),NetBSD) # We need -idirafter instead of -I to prefer the system’s iconv over GNU libiconv