diff --git a/CHANGELOG.md b/CHANGELOG.md index da20255..f3d8642 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,46 @@ ### Changed * Minimum required meson version is now 0.58. +* **BREAKING CHANGE**: overhaul of the `map` particle. Instead of + specifying a `tag` and then an array of `values`, you must now + simply use an array of `conditions`, that consist of: + + ` ` + + where `` is one of: + + `== != < <= > >=` + + Note that boolean tags must be used as is: + + `online` + + `~online # use '~' to match for their falsehood` + + As an example, if you previously had something like: + + ``` + map: + tag: State + values: + unrecognized: + ... + ``` + + You would now write it as: + + ``` + map: + conditions: + State == unrecognized: + ... + ``` + + For a more thorough explanation, see the updated map section in the + man page for yambar-particles([#137][137] and [#175][175]). + + [137]: https://codeberg.org/dnkl/yambar/issues/137 + [175]: https://codeberg.org/dnkl/yambar/issues/172 ### Deprecated @@ -48,6 +88,8 @@ ### Security ### Contributors +* Horus + ## 1.8.0 diff --git a/particles/map.c b/particles/map.c index 2c610c8..c748bea 100644 --- a/particles/map.c +++ b/particles/map.c @@ -101,7 +101,7 @@ eval_map_condition(const struct map_condition* map_cond, const struct tag_set *t char *end; const long cond_value = strtol(map_cond->value, &end, 0); - if (errno==ERANGE) { + if (errno == ERANGE) { LOG_WARN("value %s is too large", map_cond->value); return false; } else if (*end != '\0') { @@ -117,7 +117,7 @@ eval_map_condition(const struct map_condition* map_cond, const struct tag_set *t char *end; const double cond_value = strtod(map_cond->value, &end); - if (errno==ERANGE) { + if (errno == ERANGE) { LOG_WARN("value %s is too large", map_cond->value); return false; } else if (*end != '\0') { @@ -205,10 +205,11 @@ map_condition_from_str(const char *str) cond->tag = strdup(trim(tag)); cond->value = NULL; - if (value != NULL){ + if (value != NULL) { value = trim(value); - if (value[0] == '"' && value[strlen(value) - 1] == '"'){ - value[strlen(value) - 1] = '\0'; + const size_t value_len = strlen(value); + if (value[0] == '"' && value[value_len - 1] == '"') { + value[value_len - 1] = '\0'; ++value; } cond->value = strdup(value);