summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--mh/mh_format.c17
-rw-r--r--mh/tests/fmtfunc.at12
2 files changed, 23 insertions, 6 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,7 +1905,8 @@ 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;
while (!stop)
@@ -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.