diff --git a/CHANGELOG.md b/CHANGELOG.md index 0562de4..dc20e43 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,9 @@ ### Changed * Minimum required meson version is now 0.58. +* Float tags are now treated as floats instead of integers when + formatted with the `kb`/`kib`/`mb`/`mib`/`gb`/`gib` string particle + formatters. * **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: @@ -69,8 +72,8 @@ 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 +[137]: https://codeberg.org/dnkl/yambar/issues/137 +[175]: https://codeberg.org/dnkl/yambar/issues/172 ### Deprecated diff --git a/tag.c b/tag.c index 5c5684b..0428223 100644 --- a/tag.c +++ b/tag.c @@ -582,7 +582,10 @@ tags_expand_template(const char *template, const struct tag_set *tags) 1; char str[24]; - snprintf(str, sizeof(str), "%lu", tag->as_int(tag) / divider); + if (tag->type(tag) == TAG_TYPE_FLOAT) + snprintf(str, sizeof(str), "%f", tag->as_float(tag) / (double)divider); + else + snprintf(str, sizeof(str), "%lu", tag->as_int(tag) / divider); sbuf_append(&formatted, str); break; }