From aa71bf00f9baf67fc52db600c09f280f34758b38 Mon Sep 17 00:00:00 2001 From: Martin Duquesnoy Date: Fri, 27 Jan 2012 18:26:18 +0100 Subject: [PATCH] Allow ']' char in string of \s[] sequences, by adding a \ before --- src/client.c | 5 ++--- src/status.c | 12 ++++++++++-- src/util.c | 2 +- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/client.c b/src/client.c index dd7efcb..521115f 100644 --- a/src/client.c +++ b/src/client.c @@ -446,7 +446,6 @@ client_frame_update(struct client *c, struct colpair *cp) } } - void client_tab_focus(struct client *c) { @@ -490,7 +489,7 @@ client_tab_focus(struct client *c) void _client_tab(struct client *c, struct client *cm) { - int m[2] = { CLIENT_TILED, CLIENT_FREE }; + long m[2] = { CLIENT_TILED, CLIENT_FREE }; /* Do not tab already tabed client */ if(c->flags & (CLIENT_TABBED | CLIENT_TABMASTER) @@ -1147,7 +1146,7 @@ _fac_check_to_reverse(struct client *c) * Reverse back the flag and the window geo * in previous affected clients */ - SLIST_FOREACH(cc, &c->tag->clients, tnext) + FOREACH_NFCLIENT(cc, &c->tag->clients, tnext) { cc->tgeo = cc->ttgeo; cc->flags &= ~CLIENT_DID_WINSIZE; diff --git a/src/status.c b/src/status.c index deb253b..732a6e3 100644 --- a/src/status.c +++ b/src/status.c @@ -92,7 +92,7 @@ status_parse(struct status_ctx *ctx) struct status_seq *sq, *prev = NULL; int i, shift = 0; char *dstr = xstrdup(ctx->status), *sauv = dstr; - char type, *p, *end, *arg[6] = { NULL }; + char type, *p, *pp, *end, *arg[6] = { NULL }; for(; *dstr; ++dstr) { @@ -102,7 +102,11 @@ status_parse(struct status_ctx *ctx) p = ++dstr; - if(!(strchr("sRi", *p)) || !(end = strchr(p, ']'))) + /* Search end of sequence (] without \ behind) */ + for(end = strchr(p, ']'); *(end - 1) == '\\';) + end = strchr(end + 1, ']'); + + if(!(strchr("sRi", *p)) || !end ) continue; /* Then parse & list it */ @@ -119,6 +123,10 @@ status_parse(struct status_ctx *ctx) sq->color = color_atoh(arg[1 + shift]); sq->str = xstrdup(arg[2 + shift]); + /* Remove \ from string */ + for(pp = sq->str; (pp = strchr(sq->str, '\\'));) + memmove(pp, pp + 1, strlen(pp)); + break; /* diff --git a/src/util.c b/src/util.c index cb72a9a..69c73ef 100644 --- a/src/util.c +++ b/src/util.c @@ -126,7 +126,7 @@ parse_args(char *str, char delim, char end, int narg, char *args[]) { int i = 0; - for(args[0] = str; *str && *str != end && i < narg; ++str) + for(args[0] = str; *str && (*str != end || *(str - 1) == '\\') && i < narg; ++str) if(*str == delim) { *str = '\0';