summaryrefslogtreecommitdiff
path: root/mh
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2017-07-05 18:06:35 +0300
committerSergey Poznyakoff <gray@gnu.org>2017-07-05 18:06:35 +0300
commit9e78589f35c4610a896609368a8ea187e54dac87 (patch)
tree7a4d64e395676afa86d24f09b7cb8a20a90a5b2d /mh
parent57e392b38ccf9132f6e5640766825e71a2397819 (diff)
downloadmailutils-9e78589f35c4610a896609368a8ea187e54dac87.tar.gz
mailutils-9e78589f35c4610a896609368a8ea187e54dac87.tar.bz2
Fix the nohost MH format functionmhfmt
Diffstat (limited to 'mh')
-rw-r--r--mh/mh_format.c21
-rw-r--r--mh/tests/fmtfunc.at14
2 files changed, 25 insertions, 10 deletions
diff --git a/mh/mh_format.c b/mh/mh_format.c
index 5b7607234..05d6d5511 100644
--- a/mh/mh_format.c
+++ b/mh/mh_format.c
@@ -1471,19 +1471,22 @@ builtin_host (struct mh_fvm *mach)
static void
builtin_nohost (struct mh_fvm *mach)
{
+ struct mu_address hint;
mu_address_t addr;
- const char *str;
-
- int rc = mu_address_create (&addr, mh_string_value (&mach->str[R_ARG]));
+ const char *dom;
+ int rc;
+
+ hint.domain = NULL;
+ rc = mu_address_create_hint (&addr, mh_string_value (&mach->str[R_ARG]),
+ &hint, MU_ADDR_HINT_DOMAIN);
mh_string_clear (&mach->str[R_REG]);
if (rc)
- return;
-
- if (mu_address_sget_email (addr, 1, &str) == 0 && str)
- mach->num[R_REG] = strchr (str, '@') != NULL;
+ mach->num[R_REG] = 1;
else
- mach->num[R_REG] = 0;
- mu_address_destroy (&addr);
+ {
+ mach->num[R_REG] = !(mu_address_sget_domain (addr, 1, &dom) == 0 && dom);
+ mu_address_destroy (&addr);
+ }
}
/* type addr integer host type* (0=local,1=network,
diff --git a/mh/tests/fmtfunc.at b/mh/tests/fmtfunc.at
index b8eb66a08..844a7779a 100644
--- a/mh/tests/fmtfunc.at
+++ b/mh/tests/fmtfunc.at
@@ -685,7 +685,19 @@ FMTFUNC([host],
[gnu.org
])
-# FIXME: nohost
+FMTFUNC([nohost],
+[%(nohost{From})
+%(nohost{To})
+%(nohost{Sender})
+],
+[From: gray
+To: mu@example.org
+
+],
+[1
+0
+1
+])
# FIXME: path

Return to:

Send suggestions and report system problems to the System administrator.