Fix the P command, and optimize D slightly.

This commit is contained in:
mycroft 1995-03-15 11:25:10 +00:00
parent 9a90db1e8e
commit c92e174d74

View File

@ -37,7 +37,7 @@
#ifndef lint #ifndef lint
/* from: static char sccsid[] = "@(#)process.c 8.1 (Berkeley) 6/6/93"; */ /* from: static char sccsid[] = "@(#)process.c 8.1 (Berkeley) 6/6/93"; */
static char *rcsid = "$Id: process.c,v 1.14 1995/03/15 11:13:30 mycroft Exp $"; static char *rcsid = "$Id: process.c,v 1.15 1995/03/15 11:25:10 mycroft Exp $";
#endif /* not lint */ #endif /* not lint */
#include <sys/types.h> #include <sys/types.h>
@ -90,8 +90,8 @@ process()
{ {
struct s_command *cp; struct s_command *cp;
SPACE tspace; SPACE tspace;
size_t len; size_t len, oldpsl;
char oldc, *p; char *p;
for (linenum = 0; mf_fgets(&PS, REPLACE);) { for (linenum = 0; mf_fgets(&PS, REPLACE);) {
pd = 0; pd = 0;
@ -131,7 +131,7 @@ redirect:
case 'D': case 'D':
if (pd) if (pd)
goto new; goto new;
if ((p = memchr(ps, '\n', psl)) == NULL) if ((p = memchr(ps, '\n', psl - 1)) == NULL)
pd = 1; pd = 1;
else { else {
psl -= (p + 1) - ps; psl -= (p + 1) - ps;
@ -180,13 +180,13 @@ redirect:
case 'P': case 'P':
if (pd) if (pd)
break; break;
if ((p = memchr(ps, '\n', psl)) != NULL) { if ((p = memchr(ps, '\n', psl - 1)) != NULL) {
oldc = *p; oldpsl = psl;
*p = '\0'; psl = (p + 1) - ps;
} }
OUT(ps) OUT(ps)
if (p != NULL) if (p != NULL)
*p = oldc; psl = oldpsl;
break; break;
case 'q': case 'q':
if (!nflag && !pd) if (!nflag && !pd)