Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/mail PR/47453: Martin Branderburg: Mail (mail, mailx...



details:   https://anonhg.NetBSD.org/src/rev/1576739429ec
branches:  trunk
changeset: 784037:1576739429ec
user:      christos <christos%NetBSD.org@localhost>
date:      Tue Jan 15 17:25:42 2013 +0000

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

diffstat:

 usr.bin/mail/head.c |  31 +++++++++++++++++++++----------
 1 files changed, 21 insertions(+), 10 deletions(-)

diffs (72 lines):

diff -r 04973d5a413c -r 1576739429ec usr.bin/mail/head.c
--- a/usr.bin/mail/head.c       Tue Jan 15 17:23:39 2013 +0000
+++ b/usr.bin/mail/head.c       Tue Jan 15 17:25:42 2013 +0000
@@ -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 @@
  * 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 @@
                        if (*cp++ != '\n')
                                return 0;
                        break;
+               case '+':
+                       if (*cp != '+' && *cp != '-')
+                               return 0;
+                       cp++;
+                       break;
                }
        if (*cp || *tp)
                return 0;
@@ -108,19 +113,25 @@
  * '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



Home | Main Index | Thread Index | Old Index