Merge patches for OpenBSD compatibility
This commit is contained in:
parent
ae2371ee58
commit
a8352a8988
|
@ -46,6 +46,13 @@ CFLAGS += -idirafter /usr/pkg/include
|
||||||
LDFLAGS += -Wl,-rpath,/usr/local/lib -Wl,-rpath,/usr/pkg/lib
|
LDFLAGS += -Wl,-rpath,/usr/local/lib -Wl,-rpath,/usr/pkg/lib
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(UNAME),OpenBSD)
|
||||||
|
CFLAGS += -ftrampolines
|
||||||
|
CFLAGS += -I${X11BASE}/include
|
||||||
|
LDFLAGS += -liconv
|
||||||
|
LDFLAGS += -L${X11BASE}/lib
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(UNAME),FreeBSD)
|
ifeq ($(UNAME),FreeBSD)
|
||||||
LDFLAGS += -liconv
|
LDFLAGS += -liconv
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -161,4 +161,9 @@ void switch_layout_mode(xcb_connection_t *conn, Container *container, int mode);
|
||||||
Client *get_matching_client(xcb_connection_t *conn,
|
Client *get_matching_client(xcb_connection_t *conn,
|
||||||
const char *window_classtitle, Client *specific);
|
const char *window_classtitle, Client *specific);
|
||||||
|
|
||||||
|
#if defined(__OpenBSD__)
|
||||||
|
/* OpenBSD does not provide memmem(), so we provide FreeBSD’s implementation */
|
||||||
|
void *memmem(const void *l, size_t l_len, const void *s, size_t s_len);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -312,7 +312,16 @@ void load_configuration(xcb_connection_t *conn, const char *override_configpath,
|
||||||
rest++;
|
rest++;
|
||||||
if (*rest != ' ')
|
if (*rest != ' ')
|
||||||
die("Invalid binding (keysym)\n");
|
die("Invalid binding (keysym)\n");
|
||||||
|
#if defined(__OpenBSD__)
|
||||||
|
size_t len = strlen(sym);
|
||||||
|
if (len > (rest - sym))
|
||||||
|
len = (rest - sym);
|
||||||
|
new->symbol = smalloc(len + 1);
|
||||||
|
memcpy(new->symbol, sym, len+1);
|
||||||
|
new->symbol[len]='\0';
|
||||||
|
#else
|
||||||
new->symbol = strndup(sym, (rest - sym));
|
new->symbol = strndup(sym, (rest - sym));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
rest++;
|
rest++;
|
||||||
LOG("keycode = %d, symbol = %s, modifiers = %d, command = *%s*\n", new->keycode, new->symbol, modifiers, rest);
|
LOG("keycode = %d, symbol = %s, modifiers = %d, command = *%s*\n", new->keycode, new->symbol, modifiers, rest);
|
||||||
|
|
40
src/util.c
40
src/util.c
|
@ -18,6 +18,9 @@
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <iconv.h>
|
#include <iconv.h>
|
||||||
|
#if defined(__OpenBSD__)
|
||||||
|
#include <sys/cdefs.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <xcb/xcb_icccm.h>
|
#include <xcb/xcb_icccm.h>
|
||||||
|
|
||||||
|
@ -472,3 +475,40 @@ done:
|
||||||
FREE(to_title_ucs);
|
FREE(to_title_ucs);
|
||||||
return matching;
|
return matching;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(__OpenBSD__)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Taken from FreeBSD
|
||||||
|
* Find the first occurrence of the byte string s in byte string l.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void *memmem(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
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue