summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCharles Levert <charles_levert@gna.org>2005-06-21 06:19:44 +0000
committerCharles Levert <charles_levert@gna.org>2005-06-21 06:19:44 +0000
commit143f885e02eb98ab88a1f18e0aa8d069781bc813 (patch)
treed58252eb89ae7da80421a877688c14bf12876301 /tests
parent06574409465598d5e28d4f675a915830dd2c9d57 (diff)
downloadgrep-143f885e02eb98ab88a1f18e0aa8d069781bc813.tar.gz
* tests/foad1.sh: Add tests combining -o, -n/-b/-H, and -i,
since there are separate code paths for -i. Add tests combining -o, -n/-b/-H, and -3, since any context line specification should be ignored when combined with -o. * src/grep.c (print_line_head): New function, culled off the top content of prline(). Adds a guard against "lastnl" having already reached "lim", which can happen when if the function is called more than once per line. * src/grep.c (prline): Now calls print_line_head(), not only at the beginning to replace the moved code when -o is not specified, but also for each match when -o is specified (two code paths with this). Patch #3770, more or less. This makes all tests combining -o and -n/-b/-H pass, which they didn't before. Fixes bug #12727.
Diffstat (limited to 'tests')
-rwxr-xr-xtests/foad1.sh8
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/foad1.sh b/tests/foad1.sh
index 26263e67..96e1242f 100755
--- a/tests/foad1.sh
+++ b/tests/foad1.sh
@@ -40,9 +40,17 @@ grep_test "WordA/wordB/WORDC/" "Word/word/WORD/" "WORD" -o -i
# Should display the line number (-n), octet offset (-b), or file name
# (-H) of every match, not just of the first match on each input line.
+# Check it both with and without -i because of the separate code paths.
+# Also check what it does when lines of context are specified.
grep_test "wA wB/wC/" "1:wA/1:wB/2:wC/" "w." -o -n
+grep_test "wA wB/wC/" "1:wA/1:wB/2:wC/" "w." -o -n -i
+grep_test "wA wB/wC/" "1:wA/1:wB/2:wC/" "w." -o -n -3 2>/dev/null
grep_test "XwA YwB/ZwC/" "1:wA/5:wB/9:wC/" "w." -o -b
+grep_test "XwA YwB/ZwC/" "1:wA/5:wB/9:wC/" "w." -o -b -i
+grep_test "XwA YwB/ZwC/" "1:wA/5:wB/9:wC/" "w." -o -b -3 2>/dev/null
grep_test "wA wB/" "(standard input):wA/(standard input):wB/" "w." -o -H
+grep_test "wA wB/" "(standard input):wA/(standard input):wB/" "w." -o -H -i
+grep_test "wA wB/" "(standard input):wA/(standard input):wB/" "w." -o -H -3 2>/dev/null
# End of a previous match should not match a "start of ..." expression.
grep_test "word_word/" "word_/" "^word_*" -o