summaryrefslogtreecommitdiffstats
path: root/usr.bin/sed/compile.c
diff options
context:
space:
mode:
authorarchie <archie@FreeBSD.org>1998-12-08 21:29:22 +0000
committerarchie <archie@FreeBSD.org>1998-12-08 21:29:22 +0000
commite11c48f4b11b75b26ff4f5bd1a3a16a9a0934561 (patch)
treed1e77bd59cef6652d070bd1547a2ad21c6b3c287 /usr.bin/sed/compile.c
parent80e25474dbac23ca21683a91ee989a5db243b32b (diff)
downloadFreeBSD-src-e11c48f4b11b75b26ff4f5bd1a3a16a9a0934561.zip
FreeBSD-src-e11c48f4b11b75b26ff4f5bd1a3a16a9a0934561.tar.gz
Fix a new bug introduced by the previous bug fix
Diffstat (limited to 'usr.bin/sed/compile.c')
-rw-r--r--usr.bin/sed/compile.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/usr.bin/sed/compile.c b/usr.bin/sed/compile.c
index bf0b56f..1313fca 100644
--- a/usr.bin/sed/compile.c
+++ b/usr.bin/sed/compile.c
@@ -40,7 +40,7 @@
static char sccsid[] = "@(#)compile.c 8.1 (Berkeley) 6/6/93";
#endif
static const char rcsid[] =
- "$Id: compile.c,v 1.10 1998/09/22 18:39:47 brian Exp $";
+ "$Id: compile.c,v 1.11 1998/12/07 05:35:54 archie Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -160,7 +160,7 @@ compile_stream(link)
stack = 0;
for (;;) {
- if ((p = cu_fgets(lbuf, sizeof(lbuf))) == NULL) {
+ if ((p = cu_fgets(lbuf, sizeof(lbuf), NULL)) == NULL) {
if (stack != 0)
errx(1, "%lu: %s: unexpected EOF (pending }'s)",
linenum, fname);
@@ -456,6 +456,7 @@ compile_subst(p, s)
static char lbuf[_POSIX2_LINE_MAX + 1];
int asize, ref, size;
char c, *text, *op, *sp;
+ int more = 0;
c = *p++; /* Terminator character */
if (c == '\0')
@@ -483,8 +484,8 @@ compile_subst(p, s)
} else if (*p == '&' || *p == '\\')
*sp++ = '\\';
} else if (*p == c) {
- if (*++p == '\0') {
- if (cu_fgets(lbuf, sizeof(lbuf)))
+ if (*++p == '\0' && more) {
+ if (cu_fgets(lbuf, sizeof(lbuf), &more))
p = lbuf;
}
*sp++ = '\0';
@@ -503,7 +504,7 @@ compile_subst(p, s)
asize *= 2;
text = xrealloc(text, asize);
}
- } while (cu_fgets(p = lbuf, sizeof(lbuf)));
+ } while (cu_fgets(p = lbuf, sizeof(lbuf), &more));
errx(1, "%lu: %s: unterminated substitute in regular expression",
linenum, fname);
/* NOTREACHED */
@@ -636,7 +637,7 @@ compile_text()
asize = 2 * _POSIX2_LINE_MAX + 1;
text = xmalloc(asize);
size = 0;
- while (cu_fgets(lbuf, sizeof(lbuf))) {
+ while (cu_fgets(lbuf, sizeof(lbuf), NULL)) {
op = s = text + size;
p = lbuf;
EATSPACE();
OpenPOWER on IntegriCloud