util: tokenize a_strtobool()
This commit is contained in:
parent
9caa9fc96f
commit
425c8ea635
|
@ -1,3 +1,4 @@
|
|||
1
|
||||
align
|
||||
all
|
||||
auto
|
||||
|
@ -26,6 +27,7 @@ left
|
|||
line
|
||||
max_value
|
||||
min_value
|
||||
on
|
||||
resize
|
||||
reverse
|
||||
right
|
||||
|
@ -45,6 +47,8 @@ ticks_gap
|
|||
top
|
||||
topleft
|
||||
topright
|
||||
true
|
||||
vertical
|
||||
vertical_gradient
|
||||
width
|
||||
yes
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
#include <assert.h>
|
||||
#include <alloca.h>
|
||||
|
||||
#include "tokenize.h"
|
||||
|
||||
/** A list of possible position, not sex related */
|
||||
typedef enum
|
||||
{
|
||||
|
@ -295,15 +297,19 @@ a_strncat(char *dst, ssize_t n, const char *src, ssize_t l)
|
|||
* \return true if the string is recognized as possibly true, false otherwise.
|
||||
*/
|
||||
static inline bool
|
||||
a_strtobool(const char *s)
|
||||
a_strtobool(const char *s, ssize_t len)
|
||||
{
|
||||
if(!strcasecmp(s, "true")
|
||||
|| !strcasecmp(s, "on")
|
||||
|| !strcasecmp(s, "yes")
|
||||
|| !strcasecmp(s, "1"))
|
||||
switch(a_tokenize(s, len))
|
||||
{
|
||||
case A_TK_TRUE:
|
||||
case A_TK_YES:
|
||||
case A_TK_ON:
|
||||
case A_TK_1:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#define fatal(string, ...) _fatal(__LINE__, \
|
||||
__FUNCTION__, \
|
||||
|
|
|
@ -414,10 +414,10 @@ graph_tell(widget_t *widget, const char *property, const char *new_value)
|
|||
graph_pcolor_set(&graph->pcolor_end, setting);
|
||||
break;
|
||||
case A_TK_VERTICAL_GRADIENT:
|
||||
graph->vertical_gradient = a_strtobool(setting);
|
||||
graph->vertical_gradient = a_strtobool(setting, -1);
|
||||
break;
|
||||
case A_TK_SCALE:
|
||||
graph->scale = a_strtobool(setting);
|
||||
graph->scale = a_strtobool(setting, -1);
|
||||
break;
|
||||
case A_TK_MAX_VALUE:
|
||||
graph->max_value = atof(setting);
|
||||
|
|
|
@ -81,7 +81,7 @@ iconbox_tell(widget_t *widget, const char *property, const char *new_value)
|
|||
d->image = draw_image_new(new_value);
|
||||
break;
|
||||
case A_TK_RESIZE:
|
||||
d->resize = a_strtobool(new_value);
|
||||
d->resize = a_strtobool(new_value, -1);
|
||||
break;
|
||||
default:
|
||||
return WIDGET_ERROR;
|
||||
|
|
|
@ -436,7 +436,7 @@ progressbar_tell(widget_t *widget, const char *property, const char *new_value)
|
|||
d->height = atof(new_value);
|
||||
return WIDGET_NOERROR;
|
||||
case A_TK_VERTICAL:
|
||||
d->vertical = a_strtobool(new_value);
|
||||
d->vertical = a_strtobool(new_value, -1);
|
||||
return WIDGET_NOERROR;
|
||||
|
||||
/* following properties need a datasection */
|
||||
|
@ -514,7 +514,7 @@ progressbar_tell(widget_t *widget, const char *property, const char *new_value)
|
|||
bar->value = bar->max_value;
|
||||
break;
|
||||
case A_TK_REVERSE:
|
||||
bar->reverse = a_strtobool(setting);
|
||||
bar->reverse = a_strtobool(setting, -1);
|
||||
break;
|
||||
default:
|
||||
return WIDGET_ERROR;
|
||||
|
|
|
@ -274,7 +274,7 @@ taglist_tell(widget_t *widget, const char *property, const char *new_value)
|
|||
d->text_urgent = a_strdup(new_value);
|
||||
break;
|
||||
case A_TK_SHOW_EMPTY:
|
||||
d->show_empty = a_strtobool(new_value);
|
||||
d->show_empty = a_strtobool(new_value, -1);
|
||||
break;
|
||||
default:
|
||||
return WIDGET_ERROR;
|
||||
|
|
|
@ -277,7 +277,7 @@ tasklist_tell(widget_t *widget, const char *property, const char *new_value)
|
|||
d->text_urgent = a_strdup(new_value);
|
||||
break;
|
||||
case A_TK_SHOW_ICONS:
|
||||
d->show_icons = a_strtobool(new_value);
|
||||
d->show_icons = a_strtobool(new_value, -1);
|
||||
break;
|
||||
case A_TK_SHOW:
|
||||
switch(a_tokenize(new_value, -1))
|
||||
|
|
Loading…
Reference in New Issue