From 0d878e8b5c956653cf15963d3b0bbc405aac2887 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Gibrowski=20Fa=C3=A9?= Date: Thu, 21 Apr 2022 01:06:04 -0300 Subject: [PATCH] Trimming outer '"' when parsing the values. --- doc/yambar-particles.5.scd | 4 ++++ particles/map.c | 11 ++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/doc/yambar-particles.5.scd b/doc/yambar-particles.5.scd index aaf8a92..0ac7e72 100644 --- a/doc/yambar-particles.5.scd +++ b/doc/yambar-particles.5.scd @@ -231,6 +231,10 @@ For boolean tags, negation is done with a preceding '~': ~ +To match for empty strings, use ' "" ': + + == "" + In addition to explicit tag values, you can also specify a default/fallback particle. diff --git a/particles/map.c b/particles/map.c index a0f0903..2c610c8 100644 --- a/particles/map.c +++ b/particles/map.c @@ -203,7 +203,16 @@ map_condition_from_str(const char *str) op_str[0] = '\0'; cond->tag = strdup(trim(tag)); - cond->value = value != NULL ? strdup(trim(value)) : NULL; + + cond->value = NULL; + if (value != NULL){ + value = trim(value); + if (value[0] == '"' && value[strlen(value) - 1] == '"'){ + value[strlen(value) - 1] = '\0'; + ++value; + } + cond->value = strdup(value); + } free(str_cpy); return cond;