From 9530e8f7f96f79ebe9afaeeecf0f2a2b373bb429 Mon Sep 17 00:00:00 2001 From: Ken Hornstein Date: Fri, 22 Mar 2019 11:59:04 -0400 Subject: [PATCH] Add support for %(trimr) format function Add support for a %(trimr) format function, which behaves exactly like %(trim) but also returns a string. Turns out this is literally a one-line change that does not require a new format instruction. --- man/mh-format.man | 1 + sbr/fmt_compile.c | 1 + 2 files changed, 2 insertions(+) diff --git a/man/mh-format.man b/man/mh-format.man index 104b8212..8b43eda6 100644 --- a/man/mh-format.man +++ b/man/mh-format.man @@ -285,6 +285,7 @@ decode expr string decode \fIstr\fR as RFC 2047 (MIME-encoded) component unquote expr string remove RFC 2822 quotes from \fIstr\fR trim expr trim trailing whitespace from \fIstr\fR +trimr expr string Like %(trim), also returns string kilo expr string express in SI units: 15.9K, 2.3M, etc. %(kilo) scales by factors of 1000, kibi expr string express in IEC units: 15.5Ki, 2.2Mi. diff --git a/sbr/fmt_compile.c b/sbr/fmt_compile.c index e8a80279..3ada1d41 100644 --- a/sbr/fmt_compile.c +++ b/sbr/fmt_compile.c @@ -160,6 +160,7 @@ static struct ftable functable[] = { { "decodecomp", TF_COMP, FT_LS_DECODECOMP, 0, TFL_PUTS }, { "decode", TF_EXPR, FT_LS_DECODE, 0, TFL_PUTS }, { "trim", TF_EXPR, FT_LS_TRIM, 0, 0 }, + { "trimr", TF_EXPR, FT_LS_TRIM, 0, TFL_PUTS }, { "kilo", TF_EXPR, FT_LS_KILO, 0, TFL_PUTS }, { "kibi", TF_EXPR, FT_LS_KIBI, 0, TFL_PUTS }, { "compval", TF_COMP, FT_LV_COMP, 0, TFL_PUTN }, -- 2.56.0