summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org>2017-07-04 14:04:37 (GMT)
committer Sergey Poznyakoff <gray@gnu.org>2017-07-04 14:04:37 (GMT)
commit9dfd5bfbeb2af9142c11d4a0f9ed94ac44726268 (patch) (side-by-side diff)
tree28fdde84f75c3cb6e1fb056aea3929713b3d8dc7
parent0603f581fc6048cabbb25a01ee912a77b0bac6d5 (diff)
downloadmailutils-9dfd5bfbeb2af9142c11d4a0f9ed94ac44726268.tar.gz
mailutils-9dfd5bfbeb2af9142c11d4a0f9ed94ac44726268.tar.bz2
Add more fmtfunc tests
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--mh/mh_format.c24
-rw-r--r--mh/tests/fmtfunc.at79
2 files changed, 98 insertions, 5 deletions
diff --git a/mh/mh_format.c b/mh/mh_format.c
index 1278bfa..5b76072 100644
--- a/mh/mh_format.c
+++ b/mh/mh_format.c
@@ -1306,8 +1306,21 @@ builtin_nodate (struct mh_fvm *mach)
static void
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);
}
/* friendly addr string user-friendly rendering*/
@@ -1323,9 +1336,10 @@ builtin_friendly (struct mh_fvm *mach)
return;
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 e3793c4..bb81f8a 100644
--- a/mh/tests/fmtfunc.at
+++ b/mh/tests/fmtfunc.at
@@ -590,4 +590,83 @@ X-Date: Mon, 3 Jul 2017 13:17:58
# FIXME: pretty
+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

Return to:

Send suggestions and report system problems to the System administrator.