summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2020-11-27 17:21:44 +0200
committerSergey Poznyakoff <gray@gnu.org>2020-11-27 17:21:44 +0200
commit4eb3d0724550303cc27867112a167df7534ccb70 (patch)
tree0436c7ca94a503a1b6c8198cc0198c727090b7e5
parentcc9b15377689b27756597c32f32cd8ac89b84e72 (diff)
downloadmailutils-4eb3d0724550303cc27867112a167df7534ccb70.tar.gz
mailutils-4eb3d0724550303cc27867112a167df7534ccb70.tar.bz2
Improve mbox data/time handling
* libproto/mbox/mboxrb.c (scan_message_begin): Use a single scan format for parsing all possible variants of the date/time.
-rw-r--r--libproto/mbox/mboxrb.c38
1 files changed, 1 insertions, 37 deletions
diff --git a/libproto/mbox/mboxrb.c b/libproto/mbox/mboxrb.c
index a64a5f1ce..78b9664a5 100644
--- a/libproto/mbox/mboxrb.c
+++ b/libproto/mbox/mboxrb.c
@@ -533,47 +533,11 @@ scan_message_begin (struct mu_mboxrb_mailbox *dmp, mu_stream_t stream,
* a normalized form (ctime(3)).
*/
struct tm tm;
- char const *fmt;
+ static char const fmt[] = "%a %b %e %H:%M%[:%S%] %(%Z %Y%|%Y%[ %Z%]%)";
struct mu_timezone tz;
char *te;
time_t t;
- int numeric_zone = zn[1] == '+' || zn[1] == '-' || mu_isdigit (zn[1]);
- if (zn[-3] == ':')
- {
- if (zn[-6] == ':')
- {
- if (numeric_zone)
- fmt = "%a %b %e %H:%M:%S %z %Y";
- else
- fmt = "%a %b %e %H:%M:%S %Z %Y";
- }
- else
- {
- if (numeric_zone)
- fmt = "%a %b %e %H:%M %z %Y";
- else
- fmt = "%a %b %e %H:%M %Z %Y";
- }
- }
- else
- {
- if (zn[-11] == ':')
- {
- if (numeric_zone)
- fmt = "%a %b %e %H:%M:%S %Y %z";
- else
- fmt = "%a %b %e %H:%M:%S %Y %Z";
- }
- else
- {
- if (numeric_zone)
- fmt = "%a %b %e %H:%M %Y %z";
- else
- fmt = "%a %b %e %H:%M %Y %Z";
- }
- }
-
if (mu_scan_datetime (ti - 10, fmt, &tm, &tz, &te) == 0)
t = mu_datetime_to_utc (&tm, &tz);
else

Return to:

Send suggestions and report system problems to the System administrator.