summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/regression/usr.bin/sed/regress.b2a.out3
-rw-r--r--tools/regression/usr.bin/sed/regress.sh4
-rw-r--r--usr.bin/sed/process.c13
3 files changed, 17 insertions, 3 deletions
diff --git a/tools/regression/usr.bin/sed/regress.b2a.out b/tools/regression/usr.bin/sed/regress.b2a.out
new file mode 100644
index 0000000..a44df51
--- /dev/null
+++ b/tools/regression/usr.bin/sed/regress.b2a.out
@@ -0,0 +1,3 @@
+data
+for validation
+of sed(1)
diff --git a/tools/regression/usr.bin/sed/regress.sh b/tools/regression/usr.bin/sed/regress.sh
index 3e7ba5f..5e06b11 100644
--- a/tools/regression/usr.bin/sed/regress.sh
+++ b/tools/regression/usr.bin/sed/regress.sh
@@ -2,7 +2,7 @@
REGRESSION_START($1)
-echo '1..15'
+echo '1..16'
REGRESSION_TEST(`G', `sed G < regress.in')
REGRESSION_TEST(`P', `sed P < regress.in')
@@ -27,5 +27,7 @@ foo
REGRESSION_TEST(`c3', `sed ''`3,/no such string/c\
foo
''`< regress.in')
+REGRESSION_TEST(`b2a', `sed ''`2,3b
+1,2d''` < regress.in')
REGRESSION_END()
diff --git a/usr.bin/sed/process.c b/usr.bin/sed/process.c
index c609908..44c75f6 100644
--- a/usr.bin/sed/process.c
+++ b/usr.bin/sed/process.c
@@ -285,8 +285,17 @@ applies(struct s_command *cp)
if (MATCH(cp->a2)) {
cp->inrange = 0;
lastaddr = 1;
- }
- r = 1;
+ r = 1;
+ } else if (cp->a2->type == AT_LINE &&
+ linenum > cp->a2->u.l) {
+ /*
+ * We missed the 2nd address due to a branch,
+ * so just close the range and return false.
+ */
+ cp->inrange = 0;
+ r = 0;
+ } else
+ r = 1;
} else if (MATCH(cp->a1)) {
/*
* If the second address is a number less than or
OpenPOWER on IntegriCloud