summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org.ua>2017-07-02 13:14:56 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2017-07-02 13:14:56 (GMT)
commit1c5b3cd3999a19b4ef404d7aafa557ae55461a48 (patch) (side-by-side diff)
treefc52239549b3ca36db1feff59a97bed798b57bf3
parent45533be53dacd60ee8fa0c648e60dcc76bc83e1f (diff)
downloadmailutils-1c5b3cd3999a19b4ef404d7aafa557ae55461a48.tar.gz
mailutils-1c5b3cd3999a19b4ef404d7aafa557ae55461a48.tar.bz2
MH: fix the nodate format function
* mh/mh_format.c (builtin_nodate): Call mu_parse822_date_time directly. (mh_format_dump_disass): Escape literal strings on output. * mh/tests/fmtfunc.at: Test nodate.
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--mh/mh_format.c15
-rw-r--r--mh/tests/fmtfunc.at12
2 files changed, 22 insertions, 5 deletions
diff --git a/mh/mh_format.c b/mh/mh_format.c
index 48ac3a3..89a9b68 100644
--- a/mh/mh_format.c
+++ b/mh/mh_format.c
@@ -1319,10 +1319,13 @@ builtin_pretty (struct mh_fvm *mach)
static void
builtin_nodate (struct mh_fvm *mach)
{
+ char const *date = mh_string_value (&mach->str[R_ARG]);
+ const char *p = date;
struct tm tm;
struct mu_timezone tz;
- mach->num[R_REG] = _parse_date (mach, &tm, &tz);
+ mach->num[R_REG] =
+ mu_parse822_date_time (&p, date + strlen (date), &tm, &tz) != 0;
}
/* proper addr string official 822 rendering */
@@ -1902,6 +1905,7 @@ mh_format_dump_disass (mh_format_t fmt)
[R_REG] = "reg",
[R_ARG] = "arg"
};
+ static char c_trans[] = "\\\\\"\"a\ab\bf\fn\nr\rt\tv\v";
if (!prog)
return;
@@ -1953,9 +1957,7 @@ mh_format_dump_disass (mh_format_t fmt)
char const *str = MHI_STR (prog[pc]);
char *prt;
- MU_ASSERT (mu_c_str_escape_trans (str,
- "\\\\\"\"a\ab\bf\fn\nr\rt\tv\v",
- &prt));
+ MU_ASSERT (mu_c_str_escape_trans (str, c_trans, &prt));
pc += skip;
printf ("sets %s, \"%s\"", regname[reg], prt);
@@ -2023,8 +2025,11 @@ mh_format_dump_disass (mh_format_t fmt)
{
size_t skip = MHI_NUM (prog[pc++]);
char const *str = MHI_STR (prog[pc]);
+ char *prt;
pc += skip;
- printf ("printlit \"%s\"", str);
+ MU_ASSERT (mu_c_str_escape_trans (str, c_trans, &prt));
+ printf ("printlit \"%s\"", prt);
+ free (prt);
}
break;
diff --git a/mh/tests/fmtfunc.at b/mh/tests/fmtfunc.at
index 113b588..28c109a 100644
--- a/mh/tests/fmtfunc.at
+++ b/mh/tests/fmtfunc.at
@@ -383,8 +383,20 @@ FMTFUNC([putnumf],
[010
?35
])
+
# FIXME: putlit
+FMTFUNC([nodate],
+[%(nodate{date})
+%(nodate{from})
+],
+[From: foo@example.org
+Date: Sat, 01 Jul 2017 08:00:01 +0300
+body
+],
+[0
+1
+])
m4_popdef([FMTFUNC]) \ No newline at end of file

Return to:

Send suggestions and report system problems to the System administrator.