diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2017-07-04 17:04:37 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2017-07-04 17:04:37 +0300 |
commit | 9dfd5bfbeb2af9142c11d4a0f9ed94ac44726268 (patch) | |
tree | 28fdde84f75c3cb6e1fb056aea3929713b3d8dc7 | |
parent | 0603f581fc6048cabbb25a01ee912a77b0bac6d5 (diff) | |
download | mailutils-9dfd5bfbeb2af9142c11d4a0f9ed94ac44726268.tar.gz mailutils-9dfd5bfbeb2af9142c11d4a0f9ed94ac44726268.tar.bz2 |
Add more fmtfunc tests
-rw-r--r-- | mh/mh_format.c | 24 | ||||
-rw-r--r-- | mh/tests/fmtfunc.at | 79 |
2 files changed, 98 insertions, 5 deletions
diff --git a/mh/mh_format.c b/mh/mh_format.c index 1278bfa28..5b7607234 100644 --- a/mh/mh_format.c +++ b/mh/mh_format.c @@ -1308,4 +1308,17 @@ builtin_proper (struct mh_fvm *mach) { - /*FIXME: noop*/ - builtin_str_noop (mach); + int rc; + char const *str; + mu_address_t addr; + + rc = mu_address_create (&addr, mh_string_value (&mach->str[R_ARG])); + if (rc) + { + mh_string_copy (mach, R_REG, R_ARG); + return; + } + if (mu_address_sget_printable (addr, &str) == 0) + mh_string_load (&mach->str[R_REG], str); + else + mh_string_copy (mach, R_REG, R_ARG); + mu_address_destroy (&addr); } @@ -1325,5 +1338,6 @@ builtin_friendly (struct mh_fvm *mach) if (mu_address_sget_personal (addr, 1, &str) == 0 && str) - { - mh_string_load (&mach->str[R_REG], str); - } + mh_string_load (&mach->str[R_REG], str); + else + mh_string_copy (mach, R_REG, R_ARG); + mu_address_destroy (&addr); diff --git a/mh/tests/fmtfunc.at b/mh/tests/fmtfunc.at index e3793c49f..bb81f8a01 100644 --- a/mh/tests/fmtfunc.at +++ b/mh/tests/fmtfunc.at @@ -592,2 +592,81 @@ X-Date: Mon, 3 Jul 2017 13:17:58 +FMTFUNC([proper], +[%(proper{From}) +], +[From: Sergey <gray@gnu.org> + +text +], +[Sergey <gray@gnu.org> +]) + +FMTFUNC([friendly], +[%(friendly{From}) +%(friendly{To}) +], +[From: Sergey <gray@gnu.org> +To: root@example.com + +text +], +[Sergey +root@example.com +]) + +FMTFUNC([addr], +[%(addr{From}) +%(addr{To}) +], +[From: Sergey <gray@gnu.org> +To: root@example.com + +text +], +[gray@gnu.org +root@example.com +]) + +FMTFUNC([pers], +[from=%(pers{From}) +to=%(pers{To}) +], +[From: Sergey <gray@gnu.org> +To: root@example.com + +text +], +[from=Sergey +to= +]) + +# FIXME: note + +FMTFUNC([mbox], +[%(mbox{From}) +], +[From: Sergey <gray@gnu.org> + +], +[gray +]) + +# FIXME: mymbox + +FMTFUNC([host], +[%(host{From}) +], +[From: Sergey <gray@gnu.org> + +], +[gnu.org +]) + +# FIXME: nohost + +# FIXME: path + +# FIXME: ingrp + +# FIXME: gname + m4_popdef([FMTFUNC])
\ No newline at end of file |