nmh-workers
[Top] [All Lists]

Re: [nmh-workers] Handling empty components

2019-03-23 10:07:45
... Though, if you would like me to test this (and see if I can
come up with format code that is not ridiculously complex/long)
to see if it solves my particular issue (which it seems like it
should), I'm happy to pull down and build from sources!

If you want to build from HEAD, that's an option (we don't run that
through testing like we do for a release, though).  But you could always
pull down the sources from 1.7.1 and apply the patch; it really is one
line (see below).  I think wrapping every component in a %(trimr) function
would do it.

--Ken

commit 9530e8f7f96f79ebe9afaeeecf0f2a2b373bb429
Author: Ken Hornstein <kenh@pobox.com>
Date:   Fri Mar 22 11:59:04 2019 -0400

    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.

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 },

-- 
nmh-workers
https://lists.nongnu.org/mailman/listinfo/nmh-workers

<Prev in Thread] Current Thread [Next in Thread>