summaryrefslogtreecommitdiff
path: root/textproc/nbsed
diff options
context:
space:
mode:
authorminskim <minskim>2004-06-12 05:18:23 +0000
committerminskim <minskim>2004-06-12 05:18:23 +0000
commit078bcf814195d5989936364f1a0b4a270d32a16c (patch)
treef3db490ae94a19221ac8dc60f465da5565973522 /textproc/nbsed
parent3698058a2ce72eb86b412c985054641364df3ae8 (diff)
downloadpkgsrc-078bcf814195d5989936364f1a0b4a270d32a16c.tar.gz
Sync nbsed with -current and bump its version to 20040612. This fixes
a bug reported in PR bin/25899 that makes sed(1) fail if the last character of the line buffer is a backslash.
Diffstat (limited to 'textproc/nbsed')
-rw-r--r--textproc/nbsed/Makefile4
-rw-r--r--textproc/nbsed/files/compile.c31
2 files changed, 28 insertions, 7 deletions
diff --git a/textproc/nbsed/Makefile b/textproc/nbsed/Makefile
index 4c42b7ae5d3..063cd8769f9 100644
--- a/textproc/nbsed/Makefile
+++ b/textproc/nbsed/Makefile
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.4 2003/10/16 12:07:02 grant Exp $
+# $NetBSD: Makefile,v 1.5 2004/06/12 05:18:31 minskim Exp $
-DISTNAME= nbsed-20031016
+DISTNAME= nbsed-20040612
CATEGORIES= textproc pkgtools
MASTER_SITES= # empty
DISTFILES= # empty
diff --git a/textproc/nbsed/files/compile.c b/textproc/nbsed/files/compile.c
index aa9bb118cfe..f572c4b49cf 100644
--- a/textproc/nbsed/files/compile.c
+++ b/textproc/nbsed/files/compile.c
@@ -1,4 +1,4 @@
-/* $NetBSD: compile.c,v 1.1.1.1 2003/08/18 17:34:55 agc Exp $ */
+/* $NetBSD: compile.c,v 1.2 2004/06/12 05:18:31 minskim Exp $ */
/*-
* Copyright (c) 1992 Diomidis Spinellis.
@@ -47,7 +47,7 @@
#if 0
static char sccsid[] = "@(#)compile.c 8.2 (Berkeley) 4/28/95";
#else
-__RCSID("$NetBSD: compile.c,v 1.1.1.1 2003/08/18 17:34:55 agc Exp $");
+__RCSID("$NetBSD: compile.c,v 1.2 2004/06/12 05:18:31 minskim Exp $");
#endif
#endif /* not lint */
@@ -466,6 +466,7 @@ compile_subst(char *p, struct s_subst *s)
static char lbuf[_POSIX2_LINE_MAX + 1];
int asize, ref, size;
char c, *text, *op, *sp;
+ int sawesc = 0;
c = *p++; /* Terminator character */
if (c == '\0')
@@ -479,9 +480,29 @@ compile_subst(char *p, struct s_subst *s)
do {
op = sp = text + size;
for (; *p; p++) {
- if (*p == '\\') {
- p++;
- if (strchr("123456789", *p) != NULL) {
+ if (*p == '\\' || sawesc) {
+ /*
+ * If this is a continuation from the last
+ * buffer, we won't have a character to
+ * skip over.
+ */
+ if (sawesc)
+ sawesc = 0;
+ else
+ p++;
+
+ if (*p == '\0') {
+ /*
+ * This escaped character is continued
+ * in the next part of the line. Note
+ * this fact, then cause the loop to
+ * exit w/ normal EOL case and reenter
+ * above with the new buffer.
+ */
+ sawesc = 1;
+ p--;
+ continue;
+ } else if (strchr("123456789", *p) != NULL) {
*sp++ = '\\';
ref = *p - '0';
if (s->re != NULL &&