diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2001-01-19 04:11:30 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2001-01-19 04:11:30 +0000 |
commit | 1ec03c593543ff3451fb2102f094e2e24f111e46 (patch) | |
tree | 303fe19a67b8109fe4705e54afbebd2c5ebe2cd2 /usr.bin | |
parent | b437ae218247a3d530da3d58127427977617d279 (diff) |
More fixes from Don Beusee:
- edit and other interactive commands have no stdin (making the
command completely broken).
- messages with "From " line having date format with -0800 type of timezone
are not recognized correctly.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/mail/cmd3.c | 8 | ||||
-rw-r--r-- | usr.bin/mail/edit.c | 6 | ||||
-rw-r--r-- | usr.bin/mail/head.c | 45 | ||||
-rw-r--r-- | usr.bin/mail/popen.c | 13 |
4 files changed, 50 insertions, 22 deletions
diff --git a/usr.bin/mail/cmd3.c b/usr.bin/mail/cmd3.c index 07a3bec4040..7b9d878c6f6 100644 --- a/usr.bin/mail/cmd3.c +++ b/usr.bin/mail/cmd3.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd3.c,v 1.14 2001/01/16 05:36:08 millert Exp $ */ +/* $OpenBSD: cmd3.c,v 1.15 2001/01/19 04:11:28 millert Exp $ */ /* $NetBSD: cmd3.c,v 1.8 1997/07/09 05:29:49 mikel Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)cmd3.c 8.2 (Berkeley) 4/20/95"; #else -static char rcsid[] = "$OpenBSD: cmd3.c,v 1.14 2001/01/16 05:36:08 millert Exp $"; +static char rcsid[] = "$OpenBSD: cmd3.c,v 1.15 2001/01/19 04:11:28 millert Exp $"; #endif #endif /* not lint */ @@ -70,7 +70,7 @@ shell(v) if (bangexp(cmd, sizeof(cmd)) < 0) return(1); shell = value("SHELL"); - (void)run_command(shell, 0, -1, -1, "-c", cmd, NULL); + (void)run_command(shell, 0, 0, -1, "-c", cmd, NULL); (void)signal(SIGINT, sigint); puts("!"); return(0); @@ -88,7 +88,7 @@ dosh(v) char *shell; shell = value("SHELL"); - (void)run_command(shell, 0, -1, -1, NULL, NULL, NULL); + (void)run_command(shell, 0, 0, -1, NULL, NULL, NULL); (void)signal(SIGINT, sigint); putchar('\n'); return(0); diff --git a/usr.bin/mail/edit.c b/usr.bin/mail/edit.c index 04e7ace6ea5..90cf18607fc 100644 --- a/usr.bin/mail/edit.c +++ b/usr.bin/mail/edit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: edit.c,v 1.8 2000/06/30 16:00:18 millert Exp $ */ +/* $OpenBSD: edit.c,v 1.9 2001/01/19 04:11:28 millert Exp $ */ /* $NetBSD: edit.c,v 1.5 1996/06/08 19:48:20 christos Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)edit.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: edit.c,v 1.8 2000/06/30 16:00:18 millert Exp $"; +static char rcsid[] = "$OpenBSD: edit.c,v 1.9 2001/01/19 04:11:28 millert Exp $"; #endif #endif /* not lint */ @@ -196,7 +196,7 @@ run_editor(fp, size, type, readonly) nf = NULL; if ((edit = value(type == 'e' ? "EDITOR" : "VISUAL")) == NULL) edit = type == 'e' ? _PATH_EX : _PATH_VI; - if (run_command(edit, 0, -1, -1, tempname, NULL, NULL) < 0) { + if (run_command(edit, 0, 0, -1, tempname, NULL, NULL) < 0) { (void)rm(tempname); goto out; } diff --git a/usr.bin/mail/head.c b/usr.bin/mail/head.c index 421a849120e..ebeb418e9fc 100644 --- a/usr.bin/mail/head.c +++ b/usr.bin/mail/head.c @@ -1,4 +1,4 @@ -/* $OpenBSD: head.c,v 1.5 1997/11/14 00:23:48 millert Exp $ */ +/* $OpenBSD: head.c,v 1.6 2001/01/19 04:11:28 millert Exp $ */ /* $NetBSD: head.c,v 1.6 1996/12/28 07:11:03 tls Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)head.c 8.2 (Berkeley) 4/20/95"; #else -static char rcsid[] = "$OpenBSD: head.c,v 1.5 1997/11/14 00:23:48 millert Exp $"; +static char rcsid[] = "$OpenBSD: head.c,v 1.6 2001/01/19 04:11:28 millert Exp $"; #endif #endif /* not lint */ @@ -163,26 +163,44 @@ 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"; + /* * Yuck. If the mail file is created by Sys V (Solaris), * there are no seconds in the time... */ -char SysV_ctype[] = "Aaa Aaa O0 00:00 0000"; -char SysV_tmztype[] = "Aaa Aaa O0 00:00 AAA 0000"; + +/* + * If the mail is created by another program such as imapd, it might + * have timezone as <-|+>nnnn (-0800 for instance) at the end. + */ + +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 */ + "" +}; int isdate(date) char date[]; { + int i; - return(cmatch(date, ctype) || cmatch(date, tmztype) - || cmatch(date, SysV_tmztype) || cmatch(date, SysV_ctype)); + for(i = 0; *date_formats[i]; i++) { + if (cmatch(date, date_formats[i])) + return 1; + } + return 0; } /* @@ -217,6 +235,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); diff --git a/usr.bin/mail/popen.c b/usr.bin/mail/popen.c index 786b28441ed..35c97c26718 100644 --- a/usr.bin/mail/popen.c +++ b/usr.bin/mail/popen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: popen.c,v 1.25 2001/01/16 05:36:08 millert Exp $ */ +/* $OpenBSD: popen.c,v 1.26 2001/01/19 04:11:29 millert Exp $ */ /* $NetBSD: popen.c,v 1.6 1997/05/13 06:48:42 mikel Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)popen.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: popen.c,v 1.25 2001/01/16 05:36:08 millert Exp $"; +static char rcsid[] = "$OpenBSD: popen.c,v 1.26 2001/01/19 04:11:29 millert Exp $"; #endif #endif /* not lint */ @@ -224,7 +224,8 @@ file_pid(fp) /* * Run a command without a shell, with optional arguments and splicing - * of stdin and stdout. The command name can be a sequence of words. + * of stdin (-1 means none) and stdout. The command name can be a sequence + * of words. * Signals must be handled by the caller. * "nset" contains the signals to ignore in the new process. * SIGINT is enabled unless it's in "nset". @@ -321,14 +322,14 @@ prepare_child(nset, infd, outfd) * All file descriptors other than 0, 1, and 2 are supposed to be * close-on-exec. */ - if (infd >= 0) { + if (infd > 0) { dup2(infd, 0); - } else { + } else if (infd != 0) { /* we don't want the child stealing my stdin input */ close(0); open(_PATH_DEVNULL, O_RDONLY, 0); } - if (outfd >= 0) + if (outfd >= 0 && outfd != 1) dup2(outfd, 1); if (nset == NULL) return; |