From 2a47c21c01a25dbf6f7f0a556c0cf0917b120e1b Mon Sep 17 00:00:00 2001 From: Martin Duquesnoy Date: Sat, 7 Jan 2012 11:02:08 +0100 Subject: [PATCH] Fix status & fifo parse and taglist width with border --- src/fifo.c | 8 ++++---- src/infobar.c | 2 +- src/infobar.h | 2 +- src/status.c | 16 +++++++--------- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/fifo.c b/src/fifo.c index 1454f36..26b3bfa 100644 --- a/src/fifo.c +++ b/src/fifo.c @@ -34,7 +34,7 @@ static void fifo_parse(char *cmd) { void (*func)(Uicb); - char *p = NULL, *arg; + char *p = NULL, *arg = NULL; /* remove trailing newline */ if((p = strchr(cmd, '\n'))) @@ -42,10 +42,10 @@ fifo_parse(char *cmd) /* If an argument is present, delimit function string */ if((p = strchr(cmd, ' '))) + { *p = '\0'; - - /* Avoid pointer out of bound if no arg */ - arg = ((p + 1 == 1) ? NULL : p + 1); + arg = p + 1; + } /* call the UICB function, p + 1 is command or NULL */ if((func = uicb_name_func(cmd))) diff --git a/src/infobar.c b/src/infobar.c index a18a387..30783e3 100644 --- a/src/infobar.c +++ b/src/infobar.c @@ -40,7 +40,7 @@ infobar_elem_tag_init(struct element *e) int s, j; /* Get final size before to use in placement */ - e->geo.w = 0; + e->geo.w = e->infobar->theme->tags_border_width << 1; TAILQ_FOREACH(t, &e->infobar->screen->tags, next) e->geo.w += draw_textw(e->infobar->theme, t->name) + PAD; diff --git a/src/infobar.h b/src/infobar.h index db9bee7..3e8b546 100644 --- a/src/infobar.h +++ b/src/infobar.h @@ -29,7 +29,7 @@ infobar_elem_placement(struct element *e) e->geo.h = e->infobar->geo.h; if(e->align == Left) - e->geo.x = (p ? p->geo.x + p->geo.w: 0); + e->geo.x = (p ? p->geo.x + p->geo.w : 0); else e->geo.x = ((p = TAILQ_NEXT(e, next)) ? p->geo.x - e->geo.w diff --git a/src/status.c b/src/status.c index 25fa0b9..54dbbba 100644 --- a/src/status.c +++ b/src/status.c @@ -31,24 +31,22 @@ uicb_status(Uicb cmd) { struct infobar *ib; struct screen *s; - int i = 0; - char si[128] = { 0 }; + char *p; - if(!cmd) + if(!cmd || !(p = strchr(cmd, ' '))) return; - /* Get infobar name */ - while(cmd[i] && cmd[i] != ' ') - si[i] = cmd[i++]; - ++i; + /* Get infobar name & status */ + *p = '\0'; + ++p; SLIST_FOREACH(s, &W->h.screen, next) { SLIST_FOREACH(ib, &s->infobars, next) - if(!strcmp(si, ib->name)) + if(!strcmp(cmd, ib->name)) { free(ib->status); - ib->status = xstrdup(cmd + i); + ib->status = xstrdup(p); infobar_elem_screen_update(s, ElemStatus); } }