Module Name:    src
Committed By:   christos
Date:           Tue Jan 15 17:25:42 UTC 2013

Modified Files:
        src/usr.bin/mail: head.c

Log Message:
PR/47453: Martin Branderburg: Mail (mail, mailx) does not recognize messages
which have RFC 822 format dates.
XXX: Pullup 6


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/usr.bin/mail/head.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/mail/head.c
diff -u src/usr.bin/mail/head.c:1.22 src/usr.bin/mail/head.c:1.23
--- src/usr.bin/mail/head.c:1.22	Sat Dec  1 06:41:50 2012
+++ src/usr.bin/mail/head.c	Tue Jan 15 12:25:42 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: head.c,v 1.22 2012/12/01 11:41:50 mbalmer Exp $	*/
+/*	$NetBSD: head.c,v 1.23 2013/01/15 17:25:42 christos Exp $	*/
 
 /*
  * Copyright (c) 1980, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)head.c	8.2 (Berkeley) 4/20/95";
 #else
-__RCSID("$NetBSD: head.c,v 1.22 2012/12/01 11:41:50 mbalmer Exp $");
+__RCSID("$NetBSD: head.c,v 1.23 2013/01/15 17:25:42 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -52,7 +52,7 @@ __RCSID("$NetBSD: head.c,v 1.22 2012/12/
  * Return 1 if they match, 0 if they don't
  */
 static int
-cmatch(const char *cp, char *tp)
+cmatch(const char *cp, const char *tp)
 {
 
 	while (*cp && *tp)
@@ -86,6 +86,11 @@ cmatch(const char *cp, char *tp)
 			if (*cp++ != '\n')
 				return 0;
 			break;
+		case '+':
+			if (*cp != '+' && *cp != '-')
+				return 0;
+			cp++;
+			break;
 		}
 	if (*cp || *tp)
 		return 0;
@@ -108,19 +113,25 @@ cmatch(const char *cp, char *tp)
  * 'O'	An optional digit or space
  * ':'	A colon
  * 'N'	A new line
+ * '+'	A plus or minus sign
  */
-static char ctype[] = "Aaa Aaa O0 00:00:00 0000";
-static char SysV_ctype[] = "Aaa Aaa O0 00:00 0000";
-static char tmztype[] = "Aaa Aaa O0 00:00:00 AAA 0000";
-static char SysV_tmztype[] = "Aaa Aaa O0 00:00 AAA 0000";
+static const char *datetypes[] = {
+ 	"Aaa Aaa O0 00:00:00 0000",		/* BSD ctype */
+	"Aaa Aaa O0 00:00 0000",		/* SysV ctype */
+	"Aaa Aaa O0 00:00:00 AAA 0000",		/* BSD tmztype */
+	"Aaa Aaa O0 00:00 AAA 0000",		/* SysV tmztype */
+	"Aaa Aaa O0 00:00:00 0000 +0000",	/* RFC822 type */
+	"Aaa Aaa O0 00:00:00 0000 AAA",		/* RFC822 alttype */
+};
 
 static int
 isdate(const char date[])
 {
 
-	return cmatch(date, ctype) ||
-	       cmatch(date, tmztype) ||
-	       cmatch(date, SysV_tmztype) || cmatch(date, SysV_ctype);
+	for (size_t i = 0; i < __arraycount(datetypes); i++)
+		if (cmatch(date, datetypes[i]))
+			return 1;
+	return 0;
 }
 
 static void

Reply via email to