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) (unidiff)
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) (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)
1319static void 1319static void
1320builtin_nodate (struct mh_fvm *mach) 1320builtin_nodate (struct mh_fvm *mach)
1321{ 1321{
1322 char const *date = mh_string_value (&mach->str[R_ARG]);
1323 const char *p = date;
1322 struct tm tm; 1324 struct tm tm;
1323 struct mu_timezone tz; 1325 struct mu_timezone tz;
1324 1326
1325 mach->num[R_REG] = _parse_date (mach, &tm, &tz); 1327 mach->num[R_REG] =
1328 mu_parse822_date_time (&p, date + strlen (date), &tm, &tz) != 0;
1326} 1329}
1327 1330
1328/* proper addr string official 822 rendering */ 1331/* proper addr string official 822 rendering */
@@ -1902,7 +1905,8 @@ mh_format_dump_disass (mh_format_t fmt)
1902 [R_REG] = "reg", 1905 [R_REG] = "reg",
1903 [R_ARG] = "arg" 1906 [R_ARG] = "arg"
1904 }; 1907 };
1905 1908 static char c_trans[] = "\\\\\"\"a\ab\bf\fn\nr\rt\tv\v";
1909
1906 if (!prog) 1910 if (!prog)
1907 return; 1911 return;
1908 while (!stop) 1912 while (!stop)
@@ -1953,9 +1957,7 @@ mh_format_dump_disass (mh_format_t fmt)
1953 char const *str = MHI_STR (prog[pc]); 1957 char const *str = MHI_STR (prog[pc]);
1954 char *prt; 1958 char *prt;
1955 1959
1956 MU_ASSERT (mu_c_str_escape_trans (str, 1960 MU_ASSERT (mu_c_str_escape_trans (str, c_trans, &prt));
1957 "\\\\\"\"a\ab\bf\fn\nr\rt\tv\v",
1958 &prt));
1959 1961
1960 pc += skip; 1962 pc += skip;
1961 printf ("sets %s, \"%s\"", regname[reg], prt); 1963 printf ("sets %s, \"%s\"", regname[reg], prt);
@@ -2023,8 +2025,11 @@ mh_format_dump_disass (mh_format_t fmt)
2023 { 2025 {
2024 size_t skip = MHI_NUM (prog[pc++]); 2026 size_t skip = MHI_NUM (prog[pc++]);
2025 char const *str = MHI_STR (prog[pc]); 2027 char const *str = MHI_STR (prog[pc]);
2028 char *prt;
2026 pc += skip; 2029 pc += skip;
2027 printf ("printlit \"%s\"", str); 2030 MU_ASSERT (mu_c_str_escape_trans (str, c_trans, &prt));
2031 printf ("printlit \"%s\"", prt);
2032 free (prt);
2028 } 2033 }
2029 break; 2034 break;
2030 2035
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],
383[010 383[010
384?35 384?35
385]) 385])
386
386# FIXME: putlit 387# FIXME: putlit
387 388
389FMTFUNC([nodate],
390[%(nodate{date})
391%(nodate{from})
392],
393[From: foo@example.org
394Date: Sat, 01 Jul 2017 08:00:01 +0300
388 395
396body
397],
398[0
3991
400])
389 401
390m4_popdef([FMTFUNC]) \ No newline at end of file 402m4_popdef([FMTFUNC]) \ No newline at end of file

Return to:

Send suggestions and report system problems to the System administrator.