Hi all,

The diff below updates x11/i3 to the lastest version, 4.0.2.

i3-wsbar is gone and i3bar has been integrated to replace i3-wsbar.

So, when I'll commit this diff, x11/i3bar and x11/p5-AnyEvent-I3 can
go to the Attic. I've already added the proper @conflict marker for
i3bar.

Waiting for OKs...

cheers!
David

Index: Makefile
===================================================================
RCS file: /cvs/ports/x11/i3/Makefile,v
retrieving revision 1.18
diff -u -p -r1.18 Makefile
--- Makefile    9 May 2011 11:33:35 -0000       1.18
+++ Makefile    14 Sep 2011 13:20:51 -0000
@@ -2,9 +2,7 @@
 
 COMMENT =      improved dynamic tiling window manager
 
-DISTNAME =     i3-3.e-bf3
-PKGNAME =      i3-3.5.3
-REVISION =     0
+DISTNAME =     i3-4.0.2
 
 CATEGORIES =   x11
 
@@ -19,19 +17,16 @@ PERMIT_PACKAGE_FTP =     Yes
 PERMIT_DISTFILES_CDROM = Yes
 PERMIT_DISTFILES_FTP =   Yes
 
-WANTLIB +=     X11 c ev m xcb xcb-atom xcb-aux xcb-event
-WANTLIB +=     xcb-icccm xcb-keysyms xcb-randr xcb-xinerama
-WANTLIB +=     yajl
+WANTLIB +=     X11 Xcursor c ev m xcb xcb-atom xcb-aux
+WANTLIB +=     xcb-event xcb-icccm xcb-keysyms
+WANTLIB +=     xcb-property xcb-randr xcb-xinerama yajl
 
 MODULES =      converters/libiconv
 LIB_DEPENDS =  devel/libev \
                devel/libyajl>=2.0.0
-BUILD_DEPENDS =        devel/bison
-RUN_DEPENDS =  x11/dmenu \
-               devel/p5-IPC-Run \
-               devel/p5-Try-Tiny \
-               devel/p5-AnyEvent \
-               x11/p5-AnyEvent-I3
+BUILD_DEPENDS =        devel/bison \
+               devel/flex
+RUN_DEPENDS =  x11/dmenu
 
 USE_GMAKE =    Yes
 
@@ -48,9 +43,13 @@ FAKE_FLAGS = PREFIX=${PREFIX} \
                INSTALL_SCRIPT="${INSTALL_SCRIPT}"
 
 pre-configure:
-       ${SUBST_CMD} ${WRKSRC}/i3.config ${WRKSRC}/src/config.c
+       ${SUBST_CMD} ${WRKSRC}/i3.config \
+               ${WRKSRC}/i3.config.keycodes \
+                       ${WRKSRC}/src/config.c
 
 post-install:
-       ${INSTALL_MAN} ${WRKBUILD}/man/*.1 ${PREFIX}/man/man1/
+       @rm -f ${WRKBUILD}/man/i3-wsbar.1
+       ${INSTALL_MAN} ${WRKBUILD}/{i3bar/doc,man}/*.1 \
+               ${PREFIX}/man/man1/
 
 .include <bsd.port.mk>
Index: distinfo
===================================================================
RCS file: /cvs/ports/x11/i3/distinfo,v
retrieving revision 1.4
diff -u -p -r1.4 distinfo
--- distinfo    9 May 2011 11:03:40 -0000       1.4
+++ distinfo    14 Sep 2011 13:20:51 -0000
@@ -1,5 +1,5 @@
-MD5 (i3-3.e-bf3.tar.bz2) = B6ZuBLx1TQwWsDPtnfgMZQ==
-RMD160 (i3-3.e-bf3.tar.bz2) = hY2SAg4lGzr9NLywAI18zCXQRmk=
-SHA1 (i3-3.e-bf3.tar.bz2) = fDX0n6FKIbYGuxArQcXwzq1Ok6M=
-SHA256 (i3-3.e-bf3.tar.bz2) = 4KewMOu60OvyrDnyNd1eCtNO8P9bg+MVAaNh+S6Fxo8=
-SIZE (i3-3.e-bf3.tar.bz2) = 360704
+MD5 (i3-4.0.2.tar.bz2) = ixc1BIJNMSqVTMsysJKwaA==
+RMD160 (i3-4.0.2.tar.bz2) = Sl6s7G8SsPsV9sGycRUgs9nUF0I=
+SHA1 (i3-4.0.2.tar.bz2) = M3OaYGsGJW9xqgVRaHM24BZEoNU=
+SHA256 (i3-4.0.2.tar.bz2) = 5laXfahqBRscEDJ8yk9AChynzL0GcOowfywb4cEm/EY=
+SIZE (i3-4.0.2.tar.bz2) = 475512
Index: patches/patch-Makefile
===================================================================
RCS file: /cvs/ports/x11/i3/patches/patch-Makefile,v
retrieving revision 1.3
diff -u -p -r1.3 patch-Makefile
--- patches/patch-Makefile      14 Sep 2010 08:54:18 -0000      1.3
+++ patches/patch-Makefile      14 Sep 2011 13:20:51 -0000
@@ -1,39 +1,57 @@
 $OpenBSD: patch-Makefile,v 1.3 2010/09/14 08:54:18 dcoppa Exp $
---- Makefile.orig      Wed Jun  9 09:58:15 2010
-+++ Makefile   Mon Jul 19 17:07:45 2010
-@@ -20,20 +20,14 @@ endif
+--- Makefile.orig      Wed Sep 14 11:28:41 2011
++++ Makefile   Wed Sep 14 11:34:03 2011
+@@ -22,24 +22,19 @@ SUBDIRS=i3-msg i3-input i3-nagbar i3-config-wizard i3b
  
  # Depend on the specific file (.c for each .o) and on all headers
  src/%.o: src/%.c ${HEADERS}
 -      echo "CC $<"
-       $(CC) $(CFLAGS) -DLOGLEVEL="(1 << $(shell awk '/$(shell basename $< 
.c)/ { print NR }' loglevels.tmp))" -c -o $@ $<
+       $(CC) $(CPPFLAGS) $(CFLAGS) -DLOGLEVEL="((uint64_t)1 << $(shell awk 
'/$(shell basename $< .c)/ { print NR; exit 0; }' loglevels.tmp))" -c -o $@ $<
  
- all: src/cfgparse.y.o src/cfgparse.yy.o ${FILES}
+ all: i3 subdirs
+ 
+ i3: src/cfgparse.y.o src/cfgparse.yy.o src/cmdparse.y.o src/cmdparse.yy.o 
${FILES}
 -      echo "LINK i3"
-       $(CC) -o i3 ${FILES} src/cfgparse.y.o src/cfgparse.yy.o $(LDFLAGS)
--      echo ""
--      echo "SUBDIR i3-msg"
-       $(MAKE) TOPDIR=$(TOPDIR) -C i3-msg
--      echo "SUBDIR i3-input"
-       $(MAKE) TOPDIR=$(TOPDIR) -C i3-input
+       $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
+ 
+ subdirs:
+       for dir in $(SUBDIRS); do \
+-              echo ""; \
+-              echo "MAKE $$dir"; \
+               $(MAKE) -C $$dir; \
+       done
  
  loglevels.h:
 -      echo "LOGLEVELS"
        for file in $$(ls src/*.c src/*.y src/*.l | grep -v 
'cfgparse.\(tab\|yy\).c'); \
        do \
                echo $$(basename $$file .c); \
-@@ -45,27 +39,24 @@ loglevels.h:
+@@ -51,40 +46,35 @@ loglevels.h:
        echo "};") > include/loglevels.h;
  
  src/cfgparse.yy.o: src/cfgparse.l src/cfgparse.y.o ${HEADERS}
 -      echo "LEX $<"
-       flex -i -o$(@:.o=.c) $<
-       $(CC) $(CFLAGS) -DLOGLEVEL="(1 << $(shell awk '/cfgparse.l/ { print NR 
}' loglevels.tmp))" -c -o $@ $(@:.o=.c)
+-      flex -i -o$(@:.o=.c) $<
++      gflex -i -o$(@:.o=.c) $<
+       $(CC) $(CPPFLAGS) $(CFLAGS) -DLOGLEVEL="(1 << $(shell awk '/cfgparse.l/ 
{ print NR }' loglevels.tmp))" -c -o $@ $(@:.o=.c)
+ 
+ src/cmdparse.yy.o: src/cmdparse.l src/cmdparse.y.o ${HEADERS}
+-      echo "LEX $<"
+-      flex -Pcmdyy -i -o$(@:.o=.c) $<
++      gflex -Pcmdyy -i -o$(@:.o=.c) $<
+       $(CC) $(CPPFLAGS) $(CFLAGS) -DLOGLEVEL="(1 << $(shell awk '/cmdparse.l/ 
{ print NR }' loglevels.tmp))" -c -o $@ $(@:.o=.c)
+ 
  
  src/cfgparse.y.o: src/cfgparse.y ${HEADERS}
 -      echo "YACC $<"
        bison --debug --verbose -b $(basename $< .y) -d $<
-       $(CC) $(CFLAGS) -DLOGLEVEL="(1 << $(shell awk '/cfgparse.y/ { print NR 
}' loglevels.tmp))" -c -o $@ $(<:.y=.tab.c)
+       $(CC) $(CPPFLAGS) $(CFLAGS) -DLOGLEVEL="(1 << $(shell awk '/cfgparse.y/ 
{ print NR }' loglevels.tmp))" -c -o $@ $(<:.y=.tab.c)
+ 
+ src/cmdparse.y.o: src/cmdparse.y ${HEADERS}
+-      echo "YACC $<"
+       bison -p cmdyy --debug --verbose -b $(basename $< .y) -d $<
+       $(CC) $(CPPFLAGS) $(CFLAGS) -DLOGLEVEL="(1 << $(shell awk '/cmdparse.y/ 
{ print NR }' loglevels.tmp))" -c -o $@ $(<:.y=.tab.c)
+ 
  
  install: all
 -      echo "INSTALL"
@@ -42,17 +60,36 @@ $OpenBSD: patch-Makefile,v 1.3 2010/09/1
        $(INSTALL) -d -m 0755 $(DESTDIR)$(PREFIX)/include/i3
        $(INSTALL) -d -m 0755 $(DESTDIR)$(PREFIX)/share/xsessions
 -      $(INSTALL) -m 0755 i3 $(DESTDIR)$(PREFIX)/bin/
--      $(INSTALL) -m 0755 i3-wsbar $(DESTDIR)$(PREFIX)/bin/
+-      $(INSTALL) -m 0755 i3-migrate-config-to-v4 $(DESTDIR)$(PREFIX)/bin/
 -      test -e $(DESTDIR)$(SYSCONFDIR)/i3/config || $(INSTALL) -m 0644 
i3.config $(DESTDIR)$(SYSCONFDIR)/i3/config
+-      test -e $(DESTDIR)$(SYSCONFDIR)/i3/config.keycodes || $(INSTALL) -m 
0644 i3.config.keycodes $(DESTDIR)$(SYSCONFDIR)/i3/config.keycodes
 -      $(INSTALL) -m 0644 i3.welcome $(DESTDIR)$(SYSCONFDIR)/i3/welcome
 -      $(INSTALL) -m 0644 i3.desktop $(DESTDIR)$(PREFIX)/share/xsessions/
 -      $(INSTALL) -m 0644 include/i3/ipc.h $(DESTDIR)$(PREFIX)/include/i3/
 +      ${INSTALL_PROGRAM} i3 $(DESTDIR)$(PREFIX)/bin/
-+      ${INSTALL_SCRIPT} i3-wsbar $(DESTDIR)$(PREFIX)/bin/
++      ${INSTALL_SCRIPT} i3-migrate-config-to-v4 $(DESTDIR)$(PREFIX)/bin/
 +      test -e $(DESTDIR)$(SYSCONFDIR)/i3/config || ${INSTALL_DATA} i3.config 
$(DESTDIR)$(SYSCONFDIR)/i3/config
++      test -e $(DESTDIR)$(SYSCONFDIR)/i3/config.keycodes || ${INSTALL_DATA} 
i3.config.keycodes $(DESTDIR)$(SYSCONFDIR)/i3/config.keycodes
 +      ${INSTALL_DATA} i3.welcome $(DESTDIR)$(SYSCONFDIR)/i3/welcome
 +      ${INSTALL_DATA} i3.desktop $(DESTDIR)$(PREFIX)/share/xsessions/
 +      ${INSTALL_DATA} include/i3/ipc.h $(DESTDIR)$(PREFIX)/include/i3/
-       $(MAKE) TOPDIR=$(TOPDIR) -C i3-msg install
-       $(MAKE) TOPDIR=$(TOPDIR) -C i3-input install
+       for dir in $(SUBDIRS); do \
+               $(MAKE) -C $$dir install; \
+       done
+@@ -120,16 +110,12 @@ clean:
+       $(MAKE) -C docs clean
+       $(MAKE) -C man clean
+       for dir in $(SUBDIRS); do \
+-              echo ""; \
+-              echo "CLEAN $$dir"; \
+               $(MAKE) TOPDIR=$(TOPDIR) -C $$dir distclean; \
+       done
+ 
+ distclean: clean
+       rm -f i3
+       for dir in $(SUBDIRS); do \
+-              echo ""; \
+-              echo "DISTCLEAN $$dir"; \
+               $(MAKE) TOPDIR=$(TOPDIR) -C $$dir distclean; \
+       done
  
Index: patches/patch-common_mk
===================================================================
RCS file: /cvs/ports/x11/i3/patches/patch-common_mk,v
retrieving revision 1.4
diff -u -p -r1.4 patch-common_mk
--- patches/patch-common_mk     9 May 2011 11:03:40 -0000       1.4
+++ patches/patch-common_mk     14 Sep 2011 13:20:51 -0000
@@ -1,46 +1,101 @@
 $OpenBSD: patch-common_mk,v 1.4 2011/05/09 11:03:40 dcoppa Exp $
---- common.mk.orig     Sun May  8 14:20:48 2011
-+++ common.mk  Mon May  9 12:01:55 2011
-@@ -1,12 +1,12 @@
+--- common.mk.orig     Sun Aug 28 19:48:21 2011
++++ common.mk  Wed Sep 14 12:06:18 2011
+@@ -1,31 +1,18 @@
  UNAME=$(shell uname)
 -DEBUG=1
 +DEBUG=0
+ COVERAGE=0
  INSTALL=install
--PREFIX=/usr
--ifeq ($(PREFIX),/usr)
--SYSCONFDIR=/etc
--else
--SYSCONFDIR=$(PREFIX)/etc
-+ifndef PREFIX
-+  PREFIX=/usr
+ ifndef PREFIX
+   PREFIX=/usr
  endif
-+ifndef SYSCONFDIR
+ ifndef SYSCONFDIR
+-  ifeq ($(PREFIX),/usr)
+-    SYSCONFDIR=/etc
+-  else
+-    SYSCONFDIR=$(PREFIX)/etc
+-  endif
 +  SYSCONFDIR=/etc
-+endif
- GIT_VERSION="3.e-bf3 (2011-05-08)"
- VERSION=3.e-bf3
+ endif
+-TERM_EMU=xterm
++TERM_EMU=${X11BASE}/bin/xterm
+ # The escaping is absurd, but we need to escape for shell, sed, make, define
+ GIT_VERSION:="4.0.2 (2011-08-28, branch \\\"release-4.0.2\\\")"
+ VERSION:=4.0.2
  
-@@ -17,7 +17,7 @@ CFLAGS += -Wall
+-ifeq ($(shell which pkg-config 2>/dev/null 1>/dev/null || echo 1),1)
+-$(error "pkg-config was not found")
+-endif
+-
+-# An easier way to get CFLAGS and LDFLAGS falling back in case there's
+-# no pkg-config support for certain libraries
+-cflags_for_lib = $(shell pkg-config --silence-errors --cflags $(1))
+-ldflags_for_lib = $(shell pkg-config --exists $(1) && pkg-config --libs $(1) 
|| echo -l$(2))
+-
+ CFLAGS += -std=c99
+ CFLAGS += -pipe
+ CFLAGS += -Wall
+@@ -33,43 +20,12 @@ CFLAGS += -Wall
  # We don???t want unused-parameter because of the use of many callbacks
  CFLAGS += -Wunused-value
  CFLAGS += -Iinclude
--CFLAGS += -I/usr/local/include
-+CFLAGS += -I${LOCALBASE}/include
- CFLAGS += -DI3_VERSION=\"${GIT_VERSION}\"
+-CFLAGS += $(call cflags_for_lib, xcb-keysyms)
+-ifeq ($(shell pkg-config --exists xcb-util || echo 1),1)
+ CPPFLAGS += -DXCB_COMPAT
+-CFLAGS += $(call cflags_for_lib, xcb-atom)
+-CFLAGS += $(call cflags_for_lib, xcb-aux)
+-else
+-CFLAGS += $(call cflags_for_lib, xcb-util)
+-endif
+-CFLAGS += $(call cflags_for_lib, xcb-icccm)
+-CFLAGS += $(call cflags_for_lib, xcb-xinerama)
+-CFLAGS += $(call cflags_for_lib, xcb-randr)
+-CFLAGS += $(call cflags_for_lib, xcb)
+-CFLAGS += $(call cflags_for_lib, xcursor)
+-CFLAGS += $(call cflags_for_lib, x11)
+-CFLAGS += $(call cflags_for_lib, yajl)
+-CFLAGS += $(call cflags_for_lib, libev)
+ CPPFLAGS += -DI3_VERSION=\"${GIT_VERSION}\"
+ CPPFLAGS += -DSYSCONFDIR=\"${SYSCONFDIR}\"
+ CPPFLAGS += -DTERM_EMU=\"$(TERM_EMU)\"
+ 
+-LIBS += -lm
+-LIBS += $(call ldflags_for_lib, xcb-event, xcb-event)
+-LIBS += $(call ldflags_for_lib, xcb-keysyms, xcb-keysyms)
+-ifeq ($(shell pkg-config --exists xcb-util || echo 1),1)
+-LIBS += $(call ldflags_for_lib, xcb-atom, xcb-atom)
+-LIBS += $(call ldflags_for_lib, xcb-aux, xcb-aux)
+-else
+-LIBS += $(call ldflags_for_lib, xcb-util)
+-endif
+-LIBS += $(call ldflags_for_lib, xcb-icccm, xcb-icccm)
+-LIBS += $(call ldflags_for_lib, xcb-xinerama, xcb-xinerama)
+-LIBS += $(call ldflags_for_lib, xcb-randr, xcb-randr)
+-LIBS += $(call ldflags_for_lib, xcb, xcb)
+-LIBS += $(call ldflags_for_lib, xcursor, Xcursor)
+-LIBS += $(call ldflags_for_lib, x11, X11)
+-LIBS += $(call ldflags_for_lib, yajl, yajl)
+-LIBS += $(call ldflags_for_lib, libev, ev)
++LIBS += -lX11 -lXcursor -lev -lm -lxcb -lxcb-atom -lxcb-aux -lxcb-event 
-lxcb-icccm -lxcb-keysyms -lxcb-property -lxcb-randr -lxcb-xinerama -lyajl
+ 
+ # 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)
+@@ -84,9 +40,9 @@ LDFLAGS += -Wl,-rpath,/usr/local/lib -Wl,-rpath,/usr/p
+ endif
  
- # Check if pkg-config is installed, because without pkg-config, the following
-@@ -53,7 +53,7 @@ LDFLAGS += -lxcb
- LDFLAGS += -lyajl
- LDFLAGS += -lX11
- LDFLAGS += -lev
--LDFLAGS += -L/usr/local/lib -L/usr/pkg/lib
-+LDFLAGS += -L${LOCALBASE}/lib -L/usr/pkg/lib
+ ifeq ($(UNAME),OpenBSD)
+-CFLAGS += -I${X11BASE}/include
++CFLAGS += -I${X11BASE}/include -I${LOCALBASE}/include
+ LIBS += -liconv
+-LDFLAGS += -L${X11BASE}/lib
++LDFLAGS += -L${X11BASE}/lib -L${LOCALBASE}/lib
+ endif
  
- ifeq ($(UNAME),NetBSD)
- # We need -idirafter instead of -I to prefer the system???s iconv over GNU 
libiconv
-@@ -86,9 +86,6 @@ CFLAGS += -g3
- else
- CFLAGS += -O2
+ ifeq ($(UNAME),FreeBSD)
+@@ -118,9 +74,6 @@ ifeq ($(COVERAGE),1)
+ CFLAGS += -fprofile-arcs -ftest-coverage
+ LIBS += -lgcov
  endif
 -
 -# Don???t print command lines which are run
Index: patches/patch-i3-config-wizard_Makefile
===================================================================
RCS file: patches/patch-i3-config-wizard_Makefile
diff -N patches/patch-i3-config-wizard_Makefile
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-i3-config-wizard_Makefile     14 Sep 2011 13:20:51 -0000
@@ -0,0 +1,36 @@
+$OpenBSD$
+--- i3-config-wizard/Makefile.orig     Wed Sep 14 12:32:31 2011
++++ i3-config-wizard/Makefile  Wed Sep 14 12:33:33 2011
+@@ -10,30 +10,25 @@ HEADERS:=$(wildcard *.h)
+ 
+ # Depend on the specific file (.c for each .o) and on all headers
+ %.o: %.c ${HEADERS}
+-      echo "CC $<"
+       $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
+ 
+ all: i3-config-wizard
+ 
+ i3-config-wizard: cfgparse.y.o cfgparse.yy.o ${FILES}
+-      echo "LINK i3-config-wizard"
+       $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
+ 
+ cfgparse.yy.o: cfgparse.l cfgparse.y.o ${HEADERS}
+-      echo "LEX $<"
+-      flex -i -o$(@:.o=.c) $<
++      gflex -i -o$(@:.o=.c) $<
+       $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $(@:.o=.c)
+ 
+ cfgparse.y.o: cfgparse.y ${HEADERS}
+-      echo "YACC $<"
+       bison --debug --verbose -b $(basename $< .y) -d $<
+       $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $(<:.y=.tab.c)
+ 
+ 
+ install: all
+-      echo "INSTALL"
+       $(INSTALL) -d -m 0755 $(DESTDIR)$(PREFIX)/bin
+-      $(INSTALL) -m 0755 i3-config-wizard $(DESTDIR)$(PREFIX)/bin/
++      ${INSTALL_PROGRAM} i3-config-wizard $(DESTDIR)$(PREFIX)/bin/
+ 
+ clean:
+       rm -f *.o cfgparse.tab.{c,h} cfgparse.output cfgparse.yy.c
Index: patches/patch-i3-config-wizard_main_c
===================================================================
RCS file: patches/patch-i3-config-wizard_main_c
diff -N patches/patch-i3-config-wizard_main_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-i3-config-wizard_main_c       14 Sep 2011 13:20:51 -0000
@@ -0,0 +1,54 @@
+$OpenBSD$
+
+getline() is a GNU extension
+
+--- i3-config-wizard/main.c.orig       Wed Sep 14 12:16:22 2011
++++ i3-config-wizard/main.c    Wed Sep 14 12:22:41 2011
+@@ -74,6 +74,47 @@ Display *dpy;
+ char *rewrite_binding(const char *bindingline);
+ static void finish();
+ 
++#if defined(__OpenBSD__)
++
++ssize_t
++getline(char ** __restrict buf, size_t * __restrict buflen,
++    FILE * __restrict fp)
++{
++      size_t bytes, newlen;
++      char *newbuf, *p;
++      
++      if (buf == NULL || buflen == NULL) {
++              errno = EINVAL;
++              return -1;
++      }
++      if (*buf == NULL)
++              *buflen = 0;
++      
++      bytes = 0;
++      do {
++              if (feof(fp))
++                      break;
++              if (*buf == NULL || bytes != 0) {
++                      newlen = *buflen + BUFSIZ;
++                      newbuf = realloc(*buf, newlen);
++                      if (newbuf == NULL)
++                              return -1;
++                      *buf = newbuf;
++                      *buflen = newlen;
++              }
++              p = *buf + bytes;
++              memset(p, 0, BUFSIZ);
++              if (fgets(p, BUFSIZ, fp) == NULL)
++                      break;
++              bytes += strlen(p);
++      } while (bytes == 0 || *(*buf + (bytes - 1)) != '\n');
++      if (bytes == 0)
++              return -1;
++      return bytes;
++}
++
++#endif
++
+ #if defined(__APPLE__)
+ 
+ /*
Index: patches/patch-i3-input_Makefile
===================================================================
RCS file: /cvs/ports/x11/i3/patches/patch-i3-input_Makefile,v
retrieving revision 1.1
diff -u -p -r1.1 patch-i3-input_Makefile
--- patches/patch-i3-input_Makefile     14 Sep 2010 08:54:18 -0000      1.1
+++ patches/patch-i3-input_Makefile     14 Sep 2011 13:20:51 -0000
@@ -1,16 +1,18 @@
 $OpenBSD: patch-i3-input_Makefile,v 1.1 2010/09/14 08:54:18 dcoppa Exp $
---- i3-input/Makefile.orig     Wed Jun  9 09:58:21 2010
-+++ i3-input/Makefile  Mon Jul 19 17:08:51 2010
-@@ -9,17 +9,14 @@ HEADERS=$(wildcard *.h)
+--- i3-input/Makefile.orig     Wed Sep 14 12:33:42 2011
++++ i3-input/Makefile  Wed Sep 14 12:34:12 2011
+@@ -9,19 +9,16 @@ HEADERS=$(wildcard *.h)
  
  # Depend on the specific file (.c for each .o) and on all headers
  %.o: %.c ${HEADERS}
 -      echo "CC $<"
-       $(CC) $(CFLAGS) -c -o $@ $<
+       $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
  
- all: ${FILES}
+ all: i3-input
+ 
+ i3-input: ${FILES}
 -      echo "LINK i3-input"
-       $(CC) -o i3-input ${FILES} $(LDFLAGS)
+       $(CC) $(LDFLAGS) -o $@ ${FILES} $(LIBS)
  
  install: all
 -      echo "INSTALL"
Index: patches/patch-i3-input_ipc_c
===================================================================
RCS file: patches/patch-i3-input_ipc_c
diff -N patches/patch-i3-input_ipc_c
--- patches/patch-i3-input_ipc_c        14 Sep 2010 08:54:18 -0000      1.1
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,12 +0,0 @@
-$OpenBSD: patch-i3-input_ipc_c,v 1.1 2010/09/14 08:54:18 dcoppa Exp $
---- i3-input/ipc.c.orig        Wed Jun  9 09:58:21 2010
-+++ i3-input/ipc.c     Thu Jul 15 14:43:03 2010
-@@ -60,7 +60,7 @@ int connect_ipc(char *socket_path) {
-         struct sockaddr_un addr;
-         memset(&addr, 0, sizeof(struct sockaddr_un));
-         addr.sun_family = AF_LOCAL;
--        strcpy(addr.sun_path, socket_path);
-+        strncpy(addr.sun_path, socket_path, sizeof(addr.sun_path) - 1);
-         if (connect(sockfd, (const struct sockaddr*)&addr, sizeof(struct 
sockaddr_un)) < 0)
-                 err(EXIT_FAILURE, "Could not connect to i3");
- 
Index: patches/patch-i3-msg_Makefile
===================================================================
RCS file: /cvs/ports/x11/i3/patches/patch-i3-msg_Makefile,v
retrieving revision 1.2
diff -u -p -r1.2 patch-i3-msg_Makefile
--- patches/patch-i3-msg_Makefile       14 Sep 2010 08:54:18 -0000      1.2
+++ patches/patch-i3-msg_Makefile       14 Sep 2011 13:20:51 -0000
@@ -1,16 +1,18 @@
 $OpenBSD: patch-i3-msg_Makefile,v 1.2 2010/09/14 08:54:18 dcoppa Exp $
---- i3-msg/Makefile.orig       Wed Jun  9 09:58:15 2010
-+++ i3-msg/Makefile    Mon Jul 19 17:08:57 2010
-@@ -11,17 +11,14 @@ HEADERS=$(wildcard *.h)
+--- i3-msg/Makefile.orig       Wed Sep 14 12:34:19 2011
++++ i3-msg/Makefile    Wed Sep 14 12:34:50 2011
+@@ -11,19 +11,16 @@ HEADERS=$(wildcard *.h)
  
  # Depend on the specific file (.c for each .o) and on all headers
  %.o: %.c ${HEADERS}
 -      echo "CC $<"
-       $(CC) $(CFLAGS) -c -o $@ $<
+       $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
  
- all: ${FILES}
+ all: i3-msg
+ 
+ i3-msg: ${FILES}
 -      echo "LINK i3-msg"
-       $(CC) -o i3-msg ${FILES} $(LDFLAGS)
+       $(CC) $(LDFLAGS) -o i3-msg ${FILES} $(LIBS)
  
  install: all
 -      echo "INSTALL"
Index: patches/patch-i3-msg_main_c
===================================================================
RCS file: patches/patch-i3-msg_main_c
diff -N patches/patch-i3-msg_main_c
--- patches/patch-i3-msg_main_c 14 Sep 2010 08:54:18 -0000      1.1
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,12 +0,0 @@
-$OpenBSD: patch-i3-msg_main_c,v 1.1 2010/09/14 08:54:18 dcoppa Exp $
---- i3-msg/main.c.orig Wed Jun  9 09:58:15 2010
-+++ i3-msg/main.c      Thu Jul 15 14:43:03 2010
-@@ -175,7 +175,7 @@ int main(int argc, char *argv[]) {
-         struct sockaddr_un addr;
-         memset(&addr, 0, sizeof(struct sockaddr_un));
-         addr.sun_family = AF_LOCAL;
--        strcpy(addr.sun_path, socket_path);
-+        strncpy(addr.sun_path, socket_path, sizeof(addr.sun_path) - 1);
-         if (connect(sockfd, (const struct sockaddr*)&addr, sizeof(struct 
sockaddr_un)) < 0)
-                 err(EXIT_FAILURE, "Could not connect to i3");
- 
Index: patches/patch-i3-nagbar_Makefile
===================================================================
RCS file: patches/patch-i3-nagbar_Makefile
diff -N patches/patch-i3-nagbar_Makefile
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-i3-nagbar_Makefile    14 Sep 2011 13:20:51 -0000
@@ -0,0 +1,24 @@
+$OpenBSD$
+--- i3-nagbar/Makefile.orig    Wed Sep 14 12:34:56 2011
++++ i3-nagbar/Makefile Wed Sep 14 12:35:16 2011
+@@ -9,19 +9,16 @@ HEADERS=$(wildcard *.h)
+ 
+ # Depend on the specific file (.c for each .o) and on all headers
+ %.o: %.c ${HEADERS}
+-      echo "CC $<"
+       $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
+ 
+ all: i3-nagbar
+ 
+ i3-nagbar: ${FILES}
+-      echo "LINK i3-nagbar"
+       $(CC) $(LDFLAGS) -o $@ ${FILES} $(LIBS)
+ 
+ install: all
+-      echo "INSTALL"
+       $(INSTALL) -d -m 0755 $(DESTDIR)$(PREFIX)/bin
+-      $(INSTALL) -m 0755 i3-nagbar $(DESTDIR)$(PREFIX)/bin/
++      ${INSTALL_PROGRAM} i3-nagbar $(DESTDIR)$(PREFIX)/bin/
+ 
+ clean:
+       rm -f *.o
Index: patches/patch-i3_config
===================================================================
RCS file: /cvs/ports/x11/i3/patches/patch-i3_config,v
retrieving revision 1.3
diff -u -p -r1.3 patch-i3_config
--- patches/patch-i3_config     14 Mar 2011 12:55:18 -0000      1.3
+++ patches/patch-i3_config     14 Sep 2011 13:20:51 -0000
@@ -1,26 +1,37 @@
 $OpenBSD: patch-i3_config,v 1.3 2011/03/14 12:55:18 dcoppa Exp $
---- i3.config.orig     Wed Jan 19 21:26:37 2011
-+++ i3.config  Mon Mar 14 13:39:50 2011
-@@ -101,14 +101,14 @@ bind Mod1+Shift+18 m9
- bind Mod1+Shift+19 m10
- 
- # Mod1+Enter starts a new terminal
--bind Mod1+36 exec /usr/bin/urxvt
-+bind Mod1+36 exec ${X11BASE}/bin/xterm
- 
- # Mod1+Shift+q kills the current client
- bind Mod1+Shift+24 kill
- 
- # Mod1+v starts dmenu and launches the selected application
- # for now, we don???t have a launcher of our own.
--bind Mod1+55 exec /usr/bin/dmenu_run
-+bind Mod1+55 exec ${LOCALBASE}/bin/dmenu_run
- 
- # Mod1+Shift+e exits i3
- bind Mod1+Shift+26 exit
-@@ -123,4 +123,4 @@ ipc-socket ~/.i3/ipc.sock
- #############################################################
- # DELETE THE FOLLOWING LINES TO DISABLE THE WELCOME MESSAGE #
- #############################################################
--exec xmessage -file /etc/i3/welcome
-+exec ${X11BASE}/bin/xmessage -file ${SYSCONFDIR}/i3/welcome
+--- i3.config.orig     Wed Sep 14 13:31:05 2011
++++ i3.config  Wed Sep 14 13:33:05 2011
+@@ -16,13 +16,13 @@ font -misc-fixed-medium-r-normal--13-120-75-75-C-70-is
+ floating_modifier Mod1
+ 
+ # start a terminal
+-bindsym Mod1+Return exec urxvt
++bindsym Mod1+Return exec ${X11BASE}/bin/xterm
+ 
+ # kill focused window
+ bindsym Mod1+Shift+q kill
+ 
+ # start dmenu (a program launcher)
+-bindsym Mod1+d exec dmenu_run
++bindsym Mod1+d exec ${LOCALBASE}/bin/dmenu_run
+ 
+ # change focus
+ bindsym Mod1+j focus left
+@@ -145,9 +145,8 @@ mode "resize" {
+ 
+ bindsym Mod1+r mode "resize"
+ 
+-# Start i3bar to display a workspace bar (plus the system information i3status
+-# finds out, if available)
+-exec i3status | i3bar -d
++# Start i3bar to display a workspace bar
++exec ${TRUEPREFIX}/bin/i3bar -d
+ 
+ #######################################################################
+ # automatically start i3-config-wizard to offer the user to create a
+@@ -158,4 +157,4 @@ exec i3status | i3bar -d
+ #
+ # Please remove the following exec line:
+ #######################################################################
+-exec i3-config-wizard
++exec ${TRUEPREFIX}/bin/i3-config-wizard
Index: patches/patch-i3_config_keycodes
===================================================================
RCS file: patches/patch-i3_config_keycodes
diff -N patches/patch-i3_config_keycodes
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-i3_config_keycodes    14 Sep 2011 13:20:51 -0000
@@ -0,0 +1,28 @@
+$OpenBSD$
+--- i3.config.keycodes.orig    Wed Sep 14 13:31:09 2011
++++ i3.config.keycodes Wed Sep 14 13:34:07 2011
+@@ -17,13 +17,13 @@ font -misc-fixed-medium-r-normal--13-120-75-75-C-70-is
+ floating_modifier $mod
+ 
+ # start a terminal
+-bindcode $mod+36 exec urxvt
++bindcode $mod+36 exec ${X11BASE}/bin/xterm
+ 
+ # kill focused window
+ bindcode $mod+Shift+24 kill
+ 
+ # start dmenu (a program launcher)
+-bindcode $mod+40 exec dmenu_run
++bindcode $mod+40 exec ${LOCALBASE}/bin/dmenu_run
+ 
+ # change focus
+ bindcode $mod+44 focus left
+@@ -146,6 +146,5 @@ mode "resize" {
+ 
+ bindcode $mod+27 mode "resize"
+ 
+-# Start i3bar to display a workspace bar (plus the system information i3status
+-# finds out, if available)
+-exec i3status | i3bar -d
++# Start i3bar to display a workspace bar
++exec ${TRUEPREFIX}/bin/i3bar -d
Index: patches/patch-i3bar_Makefile
===================================================================
RCS file: patches/patch-i3bar_Makefile
diff -N patches/patch-i3bar_Makefile
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-i3bar_Makefile        14 Sep 2011 13:20:51 -0000
@@ -0,0 +1,27 @@
+$OpenBSD$
+--- i3bar/Makefile.orig        Wed Sep 14 12:35:25 2011
++++ i3bar/Makefile     Wed Sep 14 12:35:57 2011
+@@ -11,22 +11,17 @@ CPPFLAGS += -I$(TOPDIR)/include
+ all: i3bar doc
+ 
+ i3bar: ${FILES}
+-      echo "LINK"
+       $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
+ 
+ doc:
+-      echo ""
+-      echo "SUBDIR doc"
+       $(MAKE) -C doc
+ 
+ src/%.o: src/%.c ${HEADERS}
+-      echo "CC $<"
+       $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
+ 
+ install: all
+-      echo "INSTALL"
+       $(INSTALL) -d -m 0755 $(DESTDIR)$(PREFIX)/bin
+-      $(INSTALL) -m 0755 i3bar $(DESTDIR)$(PREFIX)/bin
++      ${INSTALL_PROGRAM} i3bar $(DESTDIR)$(PREFIX)/bin
+ 
+ clean:
+       rm -f src/*.o
Index: patches/patch-include_config_h
===================================================================
RCS file: patches/patch-include_config_h
diff -N patches/patch-include_config_h
--- patches/patch-include_config_h      14 Mar 2011 12:55:18 -0000      1.2
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,16 +0,0 @@
-$OpenBSD: patch-include_config_h,v 1.2 2011/03/14 12:55:18 dcoppa Exp $
---- include/config.h.orig      Wed Jan 19 21:26:37 2011
-+++ include/config.h   Thu Mar 10 14:23:42 2011
-@@ -127,9 +127,11 @@ struct Config {
- 
- /**
-  * This function resolves ~ in pathnames.
-+ * It may resolve wildcards in the first part of the path, but if no match
-+ * or multiple matches are found, it just returns a copy of path as given.
-  *
-  */
--char *glob_path(const char *path);
-+char *resolve_tilde(const char *path);
- 
- /**
-  * Checks if the given path exists by calling stat().
Index: patches/patch-man_i3-migrate-config-to-v4_1
===================================================================
RCS file: patches/patch-man_i3-migrate-config-to-v4_1
diff -N patches/patch-man_i3-migrate-config-to-v4_1
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-man_i3-migrate-config-to-v4_1 14 Sep 2011 13:20:51 -0000
@@ -0,0 +1,15 @@
+$OpenBSD$
+
+fix fatal error
+
+--- man/i3-migrate-config-to-v4.1.orig Wed Sep 14 14:22:38 2011
++++ man/i3-migrate-config-to-v4.1      Wed Sep 14 14:22:51 2011
+@@ -7,7 +7,7 @@
+ .\"    Source: i3 4.0.2
+ .\"  Language: English
+ .\"
+-.TH "I3\-MIGRATE\-CONFIG\" "1" "08/28/2011" "i3 4\&.0\&.2" "i3 Manual"
++.TH "I3\-MIGRATE\-CONFIG" "1" "08/28/2011" "i3 4\&.0\&.2" "i3 Manual"
+ .\" -----------------------------------------------------------------
+ .\" * Define some portability stuff
+ .\" -----------------------------------------------------------------
Index: patches/patch-man_i3_1
===================================================================
RCS file: patches/patch-man_i3_1
diff -N patches/patch-man_i3_1
--- patches/patch-man_i3_1      9 May 2011 11:33:35 -0000       1.1
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,21 +0,0 @@
-$OpenBSD: patch-man_i3_1,v 1.1 2011/05/09 11:33:35 dcoppa Exp $
---- man/i3.1.orig      Mon May  9 13:16:58 2011
-+++ man/i3.1   Mon May  9 13:17:26 2011
-@@ -252,7 +252,7 @@ When starting, i3 looks for configuration files in the
- .sp
- You can specify a custom path using the \-c option\&.
- .PP
--\fBSample configuration\fR. 
-+\fBSample configuration\fR.
- .sp
- .if n \{\
- .RS 4
-@@ -349,7 +349,7 @@ bind Mod1+Shift+11 2
- .sp
- This file is where you should configure your locales and start i3\&. It is 
run by your login manager (xdm, slim, gdm, \&...) as soon as you login\&.
- .PP
--\fBSample xsession\fR. 
-+\fBSample xsession\fR.
- .sp
- .if n \{\
- .RS 4
Index: patches/patch-src_cfgparse_y
===================================================================
RCS file: patches/patch-src_cfgparse_y
diff -N patches/patch-src_cfgparse_y
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_cfgparse_y        14 Sep 2011 13:20:51 -0000
@@ -0,0 +1,29 @@
+$OpenBSD$
+
+bugfix: properly free memory/close fd upon errors
+(upstream git commit e1631d6320cf6b47c3b46f0b56ae970986c9c20c)
+
+bugfix: ignore for_window commands with empty (invalid) criteria
+(upstream git commit 2a215fd7e22f5d8e9f82fb5a1d610e56afa99fe7)
+
+--- src/cfgparse.y.orig        Sun Aug 28 19:48:13 2011
++++ src/cfgparse.y     Wed Sep 14 13:54:51 2011
+@@ -188,6 +188,7 @@ static char *migrate_config(char *input, off_t size) {
+         ret = read(readpipe[0], converted + read_bytes, conv_size - 
read_bytes);
+         if (ret == -1) {
+             warn("Cannot read from pipe");
++            FREE(converted);
+             return NULL;
+         }
+         read_bytes += ret;
+@@ -658,6 +659,10 @@ bindsym:
+ for_window:
+     TOK_FOR_WINDOW match command
+     {
++        if (match_is_empty(&current_match)) {
++            ELOG("Match is empty, ignoring this for_window statement\n");
++            break;
++        }
+         printf("\t should execute command %s for the criteria mentioned 
above\n", $3);
+         Assignment *assignment = scalloc(sizeof(Assignment));
+         assignment->type = A_COMMAND;
Index: patches/patch-src_config_c
===================================================================
RCS file: /cvs/ports/x11/i3/patches/patch-src_config_c,v
retrieving revision 1.4
diff -u -p -r1.4 patch-src_config_c
--- patches/patch-src_config_c  14 Mar 2011 12:55:18 -0000      1.4
+++ patches/patch-src_config_c  14 Sep 2011 13:20:51 -0000
@@ -1,104 +1,12 @@
 $OpenBSD: patch-src_config_c,v 1.4 2011/03/14 12:55:18 dcoppa Exp $
---- src/config.c.orig  Wed Jan 19 21:26:37 2011
-+++ src/config.c       Thu Mar 10 14:23:42 2011
-@@ -18,7 +18,6 @@
- #include <sys/types.h>
- #include <stdlib.h>
- #include <glob.h>
--#include <wordexp.h>
- #include <unistd.h>
+--- src/config.c.orig  Wed Sep 14 12:11:00 2011
++++ src/config.c       Wed Sep 14 12:11:48 2011
+@@ -215,7 +215,7 @@ static char *get_config_path(const char *override_conf
+ 
+     /* 4: check for $XDG_CONFIG_DIRS/i3/config */
+     if ((xdg_config_dirs = getenv("XDG_CONFIG_DIRS")) == NULL)
+-        xdg_config_dirs = "/etc/xdg";
++        xdg_config_dirs = "${SYSCONFDIR}/xdg";
  
- /* We need Xlib for XStringToKeysym */
-@@ -39,27 +38,34 @@ struct modes_head modes;
- 
- /*
-  * This function resolves ~ in pathnames.
-+ * It may resolve wildcards in the first part of the path, but if no match
-+ * or multiple matches are found, it just returns a copy of path as given.
-  *
-  */
--char *glob_path(const char *path) {
-+char *resolve_tilde(const char *path) {
-         static glob_t globbuf;
--        if (glob(path, GLOB_NOCHECK | GLOB_TILDE, NULL, &globbuf) < 0)
-+        char *head, *tail, *result;
-+
-+      tail = strchr(path, '/');
-+      head = strndup(path, tail ? tail - path : strlen(path));
-+
-+      int res = glob(head, GLOB_TILDE, NULL, &globbuf);
-+      free(head);
-+      /* no match, or many wildcard matches are bad */
-+      if(res == GLOB_NOMATCH || globbuf.gl_pathc != 1)
-+              result = strdup(path);
-+      else if (res != 0) {
-                 die("glob() failed");
--        char *result = sstrdup(globbuf.gl_pathc > 0 ? globbuf.gl_pathv[0] : 
path);
-+                    result = NULL; /* don't complain about uninitialized */
-+      }
-+      else {
-+              head = globbuf.gl_pathv[0];
-+              result = malloc(strlen(head) + (tail ? strlen(tail) : 0) + 1);
-+              strncpy(result, head, strlen(head)+1);
-+              strncat(result, tail, strlen(tail));
-+      }
-         globfree(&globbuf);
- 
--        /* If the file does not exist yet, we still may need to resolve tilde,
--         * so call wordexp */
--        if (strcmp(result, path) == 0) {
--                wordexp_t we;
--                wordexp(path, &we, WRDE_NOCMD);
--                if (we.we_wordc > 0) {
--                        free(result);
--                        result = sstrdup(we.we_wordv[0]);
--                }
--                wordfree(&we);
--        }
--
-         return result;
- }
- 
-@@ -239,7 +245,7 @@ static char *get_config_path() {
-         if ((xdg_config_home = getenv("XDG_CONFIG_HOME")) == NULL)
-                 xdg_config_home = "~/.config";
- 
--        xdg_config_home = glob_path(xdg_config_home);
-+        xdg_config_home = resolve_tilde(xdg_config_home);
-         if (asprintf(&config_path, "%s/i3/config", xdg_config_home) == -1)
-                 die("asprintf() failed");
-         free(xdg_config_home);
-@@ -250,12 +256,12 @@ static char *get_config_path() {
- 
-         /* 2: check for $XDG_CONFIG_DIRS/i3/config */
-         if ((xdg_config_dirs = getenv("XDG_CONFIG_DIRS")) == NULL)
--                xdg_config_dirs = "/etc/xdg";
-+                xdg_config_dirs = "${SYSCONFDIR}/xdg";
- 
-         char *buf = sstrdup(xdg_config_dirs);
-         char *tok = strtok(buf, ":");
-         while (tok != NULL) {
--                tok = glob_path(tok);
-+                tok = resolve_tilde(tok);
-                 if (asprintf(&config_path, "%s/i3/config", tok) == -1)
-                         die("asprintf() failed");
-                 free(tok);
-@@ -269,15 +275,15 @@ static char *get_config_path() {
-         free(buf);
- 
-         /* 3: check traditional paths */
--        config_path = glob_path("~/.i3/config");
-+        config_path = resolve_tilde("~/.i3/config");
-         if (path_exists(config_path))
-                 return config_path;
- 
--        config_path = sstrdup("/etc/i3/config");
-+        config_path = sstrdup("${SYSCONFDIR}/i3/config");
-         if (!path_exists(config_path))
-                 die("Neither $XDG_CONFIG_HOME/i3/config, nor "
-                     "$XDG_CONFIG_DIRS/i3/config, nor ~/.i3/config nor "
--                    "/etc/i3/config exist.");
-+                    "${SYSCONFDIR}/i3/config exist.");
- 
-         return config_path;
- }
+     char *buf = sstrdup(xdg_config_dirs);
+     char *tok = strtok(buf, ":");
Index: patches/patch-src_ipc_c
===================================================================
RCS file: /cvs/ports/x11/i3/patches/patch-src_ipc_c,v
retrieving revision 1.4
diff -u -p -r1.4 patch-src_ipc_c
--- patches/patch-src_ipc_c     9 May 2011 11:03:40 -0000       1.4
+++ patches/patch-src_ipc_c     14 Sep 2011 13:20:51 -0000
@@ -1,57 +1,29 @@
 $OpenBSD: patch-src_ipc_c,v 1.4 2011/05/09 11:03:40 dcoppa Exp $
 
---- src/ipc.c.orig     Sun May  8 14:20:41 2011
-+++ src/ipc.c  Mon May  9 11:30:45 2011
-@@ -92,7 +92,7 @@ static void ipc_send_message(int fd, const unsigned ch
-         char msg[buffer_size];
-         char *walk = msg;
- 
--        strcpy(walk, "i3-ipc");
-+        strncpy(walk, "i3-ipc", buffer_size - 1);
-         walk += strlen("i3-ipc");
-         memcpy(walk, &message_size, sizeof(uint32_t));
-         walk += sizeof(uint32_t);
-@@ -530,20 +530,20 @@ void ipc_new_client(EV_P_ struct ev_io *w, int revents
- int ipc_create_socket(const char *filename) {
-         int sockfd;
- 
--        char *globbed = glob_path(filename);
--        DLOG("Creating IPC-socket at %s\n", globbed);
--        char *copy = sstrdup(globbed);
-+        char *resolved = resolve_tilde(filename);
-+        DLOG("Creating IPC-socket at %s\n", resolved);
-+        char *copy = sstrdup(resolved);
-         const char *dir = dirname(copy);
-         if (!path_exists(dir))
-                 mkdirp(dir);
-         free(copy);
- 
-         /* Unlink the unix domain socket before */
--        unlink(globbed);
-+        unlink(resolved);
- 
-         if ((sockfd = socket(AF_LOCAL, SOCK_STREAM, 0)) < 0) {
-                 perror("socket()");
--                free(globbed);
-+                free(resolved);
-                 return -1;
-         }
- 
-@@ -552,14 +552,14 @@ int ipc_create_socket(const char *filename) {
-         struct sockaddr_un addr;
-         memset(&addr, 0, sizeof(struct sockaddr_un));
-         addr.sun_family = AF_LOCAL;
--        strcpy(addr.sun_path, globbed);
-+        strncpy(addr.sun_path, resolved, sizeof(addr.sun_path) - 1);
-         if (bind(sockfd, (struct sockaddr*)&addr, sizeof(struct sockaddr_un)) 
< 0) {
-                 perror("bind()");
--                free(globbed);
-+                free(resolved);
-                 return -1;
-         }
- 
--        free(globbed);
-+        free(resolved);
-         set_nonblock(sockfd);
- 
-         if (listen(sockfd, 5) < 0) {
+missing header
+
+bugfix: properly free memory/close fd upon errors
+(upstream git commit e1631d6320cf6b47c3b46f0b56ae970986c9c20c)
+
+--- src/ipc.c.orig     Sun Aug 28 19:48:13 2011
++++ src/ipc.c  Wed Sep 14 13:54:30 2011
+@@ -10,6 +10,7 @@
+  * ipc.c: Everything about the UNIX domain sockets for IPC
+  *
+  */
++#include <sys/types.h>
+ #include <sys/socket.h>
+ #include <sys/un.h>
+ #include <fcntl.h>
+@@ -59,8 +60,10 @@ static bool mkdirp(const char *path) {
+         copy[strlen(copy)-1] = '\0';
+ 
+     char *sep = strrchr(copy, '/');
+-    if (sep == NULL)
++    if (sep == NULL) {
++        FREE(copy);
+         return false;
++    }
+     *sep = '\0';
+     bool result = false;
+     if (mkdirp(copy))
Index: patches/patch-src_util_c
===================================================================
RCS file: patches/patch-src_util_c
diff -N patches/patch-src_util_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_util_c    14 Sep 2011 13:20:51 -0000
@@ -0,0 +1,21 @@
+$OpenBSD$
+
+bugfix: properly free memory/close fd upon errors
+(upstream git commit e1631d6320cf6b47c3b46f0b56ae970986c9c20c)
+
+--- src/util.c.orig    Sun Aug 28 19:48:13 2011
++++ src/util.c Wed Sep 14 13:54:30 2011
+@@ -374,11 +374,13 @@ char *store_restart_layout() {
+         if (n == -1) {
+             perror("write()");
+             free(filename);
++            close(fd);
+             return NULL;
+         }
+         if (n == 0) {
+             printf("write == 0?\n");
+             free(filename);
++            close(fd);
+             return NULL;
+         }
+         written += n;
Index: pkg/PLIST
===================================================================
RCS file: /cvs/ports/x11/i3/pkg/PLIST,v
retrieving revision 1.2
diff -u -p -r1.2 PLIST
--- pkg/PLIST   14 Sep 2010 08:54:18 -0000      1.2
+++ pkg/PLIST   14 Sep 2011 13:20:51 -0000
@@ -1,18 +1,27 @@
 @comment $OpenBSD: PLIST,v 1.2 2010/09/14 08:54:18 dcoppa Exp $
+@conflict i3bar-*
 @bin bin/i3
+@bin bin/i3-config-wizard
 @bin bin/i3-input
+bin/i3-migrate-config-to-v4
 @bin bin/i3-msg
-bin/i3-wsbar
+@bin bin/i3-nagbar
+@bin bin/i3bar
 include/i3/
 include/i3/ipc.h
+@man man/man1/i3-config-wizard.1
 @man man/man1/i3-input.1
+@man man/man1/i3-migrate-config-to-v4.1
 @man man/man1/i3-msg.1
-@man man/man1/i3-wsbar.1
+@man man/man1/i3-nagbar.1
 @man man/man1/i3.1
+@man man/man1/i3bar.1
 share/examples/i3/
 @sample ${SYSCONFDIR}/i3/
 share/examples/i3/config
 @sample ${SYSCONFDIR}/i3/config
+share/examples/i3/config.keycodes
+@sample ${SYSCONFDIR}/i3/config.keycodes
 share/examples/i3/welcome
 @sample ${SYSCONFDIR}/i3/welcome
 share/xsessions/

Reply via email to