# HG changeset patch # User William Pitcock # Date 1189574572 18000 # Node ID 3a2ee00bc962b3f4bdd3ff2ade28b7563227acd3 # Parent b747ad540903b61050188dda6e168c58e5b1082a ${?field:...} -> check if there's data in it, making it the opposite of the (empty)? expression. diff -r b747ad540903 -r 3a2ee00bc962 src/audacious/tuple_formatter.c --- a/src/audacious/tuple_formatter.c Tue Sep 11 20:34:55 2007 -0500 +++ b/src/audacious/tuple_formatter.c Wed Sep 12 00:22:52 2007 -0500 @@ -379,11 +379,32 @@ tuple_formatter_func_list = g_list_append(tuple_formatter_func_list, expr); } -/* builtin-keyword: ${?arg}, returns TRUE if exists. */ +/* builtin-keyword: ${?arg}, returns TRUE if exists and is not empty. */ static gboolean tuple_formatter_expression_exists(Tuple *tuple, const gchar *expression) { - return (tuple_get_value_type(tuple, -1, expression) != TUPLE_UNKNOWN) ? TRUE : FALSE; + gboolean ret = FALSE; + TupleValueType type = tuple_get_value_type(tuple, -1, expression); + const gchar *iter; + + if (type == TUPLE_UNKNOWN) + return FALSE; + + /* TBD: check if zero? --nenolod */ + if (type == TUPLE_INT) + return TRUE; + + iter = tuple_get_string(tuple, -1, expression); + + while (ret && *iter != '\0') + { + if (*iter == ' ') + iter++; + else + ret = TRUE; + } + + return ret; } /* builtin-keyword: ${==arg1,arg2}, returns TRUE if and match.