]> diplodocus.org Git - nmh/commitdiff
Add support for %(trimr) format function
authorKen Hornstein <kenh@pobox.com>
Fri, 22 Mar 2019 15:59:04 +0000 (11:59 -0400)
committerKen Hornstein <kenh@pobox.com>
Fri, 22 Mar 2019 16:00:41 +0000 (12:00 -0400)
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
sbr/fmt_compile.c

index 104b8212505a7d906dcafe6cb689f76a4d82974d..8b43eda6ac74487effa92108703c6cc9bc3d4c0a 100644 (file)
@@ -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.
index e8a80279dec461b0486d9afd9ca96726510f8d45..3ada1d41dbfee2fd62843ccaee5b5d717014dbb1 100644 (file)
@@ -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 },