diff --git a/widget.c b/widget.c index 122fb131..16502948 100644 --- a/widget.c +++ b/widget.c @@ -217,10 +217,14 @@ uicb_widget_tell(int screen, char *arg) } property = p; + p = p + a_strlen(p) + 1; /* could be out of 'arg' now */ - if(p + a_strlen(p) < arg + len) + /* arg + len points to the finishing \0. + * p to the char right of the first space (strtok delimiter) + * + * \0 is on the right(>) of p pointer => some text (command) */ + if(arg + len > p) { - p = p + a_strlen(p) + 1; len = a_strlen(p); command = p_new(char, len + 1); a_strncpy(command, len + 1, p, len); diff --git a/widgets/textbox.c b/widgets/textbox.c index ec8e017b..a8473ec5 100644 --- a/widgets/textbox.c +++ b/widgets/textbox.c @@ -67,15 +67,15 @@ textbox_tell(Widget *widget, char *property, char *command) Data *d = widget->data; XftFont *newfont; - if(!command) - return WIDGET_ERROR_NOVALUE; - if(!a_strcmp(property, "text")) { if (d->text) p_delete(&d->text); d->text = a_strdup(command); } + /* !command means a not existing string. So return here */ + else if(!command) + return WIDGET_ERROR_NOVALUE; else if(!a_strcmp(property, "fg")) if(draw_color_new(globalconf.display, widget->statusbar->screen, command, &d->colors.fg)) return WIDGET_NOERROR; @@ -88,9 +88,8 @@ textbox_tell(Widget *widget, char *property, char *command) return WIDGET_ERROR_FORMAT_COLOR; else if(!a_strcmp(property, "font")) { - if(a_strlen(command) - && (newfont = XftFontOpenName(globalconf.display, - get_phys_screen(widget->statusbar->screen), command))) + if((newfont = XftFontOpenName(globalconf.display, + get_phys_screen(widget->statusbar->screen), command))) { if(widget->font != globalconf.screens[widget->statusbar->screen].font) XftFontClose(globalconf.display, widget->font);