From 016a180889afc782f8623f7e5da350d91da1d032 Mon Sep 17 00:00:00 2001 From: mikeh Date: Mon, 18 Jun 2001 04:28:03 +0000 Subject: Support mail boxes that have dates without seconds (SysV) and those that have a timezone as <-|+>nnnn (eg. imapd). PR: bin/11746 Obtained from: OpenBSD MFC after: 2 weeks --- usr.bin/mail/head.c | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) (limited to 'usr.bin') diff --git a/usr.bin/mail/head.c b/usr.bin/mail/head.c index b3a3b71..0f214d7 100644 --- a/usr.bin/mail/head.c +++ b/usr.bin/mail/head.c @@ -150,6 +150,11 @@ copyin(src, space) * below is used as the criterion of correctness. * Also, we check for a possible trailing time zone using * the tmztype template. + * + * If the mail file is created by Sys V (Solaris), there are + * no seconds in the time. If the mail is created by another + * program such as imapd, it might have timezone as + * <-|+>nnnn (-0800 for instance) at the end. */ /* @@ -157,19 +162,34 @@ copyin(src, space) * 'a' A lower case char * ' ' A space * '0' A digit - * 'O' An optional digit or space + * 'O' A digit or space + * 'p' A punctuation char + * 'P' A punctuation char or space * ':' A colon * 'N' A new line */ -char ctype[] = "Aaa Aaa O0 00:00:00 0000"; -char tmztype[] = "Aaa Aaa O0 00:00:00 AAA 0000"; + +static char *date_formats[] = { + "Aaa Aaa O0 00:00:00 0000", /* Mon Jan 01 23:59:59 2001 */ + "Aaa Aaa O0 00:00:00 AAA 0000", /* Mon Jan 01 23:59:59 PST 2001 */ + "Aaa Aaa O0 00:00:00 0000 p0000", /* Mon Jan 01 23:59:59 2001 -0800 */ + "Aaa Aaa O0 00:00 0000", /* Mon Jan 01 23:59 2001 */ + "Aaa Aaa O0 00:00 AAA 0000", /* Mon Jan 01 23:59 PST 2001 */ + "Aaa Aaa O0 00:00 0000 p0000", /* Mon Jan 01 23:59 2001 -0800 */ + NULL +}; int isdate(date) char date[]; { + int i; - return (cmatch(date, ctype) || cmatch(date, tmztype)); + for(i = 0; date_formats[i] != NULL; i++) { + if (cmatch(date, date_formats[i])) + return (1); + } + return (0); } /* @@ -204,6 +224,15 @@ cmatch(cp, tp) return (0); cp++; break; + case 'p': + if (!ispunct(*cp++)) + return (0); + break; + case 'P': + if (*cp != ' ' && !ispunct(*cp)) + return (0); + cp++; + break; case ':': if (*cp++ != ':') return (0); -- cgit v1.1