summaryrefslogtreecommitdiffstats
path: root/usr.bin/sed/process.c
diff options
context:
space:
mode:
authoryar <yar@FreeBSD.org>2007-06-12 12:05:24 +0000
committeryar <yar@FreeBSD.org>2007-06-12 12:05:24 +0000
commit64e06b67c3cf285a62f1f8cdbed2f005b02418a1 (patch)
tree1fc5aa0c7aed36e9c671f4752d0a3f9b2ac0c3fd /usr.bin/sed/process.c
parent36ecaa8cd6cf4939ee6d5692193c12bf400fcbf6 (diff)
downloadFreeBSD-src-64e06b67c3cf285a62f1f8cdbed2f005b02418a1.zip
FreeBSD-src-64e06b67c3cf285a62f1f8cdbed2f005b02418a1.tar.gz
Don't forget to clear out the hold space for each subsequent file
when in -i mode so that each file gets a clean context of its own. Add a regression test for the bug. Tested with: regression tests
Diffstat (limited to 'usr.bin/sed/process.c')
-rw-r--r--usr.bin/sed/process.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/usr.bin/sed/process.c b/usr.bin/sed/process.c
index c8b62c0..ca21ec7 100644
--- a/usr.bin/sed/process.c
+++ b/usr.bin/sed/process.c
@@ -234,6 +234,12 @@ redirect:
err(1, "%s", cp->t);
break;
case 'x':
+ /*
+ * If the hold space is null, make it empty
+ * but not null. Otherwise the pattern space
+ * will become null after the swap, which is
+ * an abnormal condition.
+ */
if (hs == NULL)
cspace(&HS, "", 0, REPLACE);
tspace = PS;
@@ -317,16 +323,24 @@ applies(struct s_command *cp)
}
/*
- * Reset all inrange markers.
+ * Reset the sed processor to its initial state.
*/
void
-resetranges(void)
+resetstate(void)
{
struct s_command *cp;
+ /*
+ * Reset all inrange markers.
+ */
for (cp = prog; cp; cp = cp->code == '{' ? cp->u.c : cp->next)
if (cp->a2)
cp->inrange = 0;
+
+ /*
+ * Clear out the hold space.
+ */
+ cspace(&HS, "", 0, REPLACE);
}
/*
OpenPOWER on IntegriCloud