1
0
mirror of https://github.com/openbsd/src.git synced 2024-12-22 16:42:56 -08:00

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.
This commit is contained in:
millert 2001-01-19 04:11:28 +00:00
parent 2bee5f91d7
commit cd7f95d953
4 changed files with 50 additions and 22 deletions

View File

@ -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);

View File

@ -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;
}

View File

@ -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);

View File

@ -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;