Updates CHANGELOG.md and changes map.c formatting

This commit is contained in:
Leonardo Gibrowski Faé 2022-04-21 11:48:38 -03:00
parent 0d878e8b5c
commit 82a3b2ae11
2 changed files with 48 additions and 5 deletions

View file

@ -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:
`<tag> <operation> <value>`
where `<operation>` 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

View file

@ -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);