diff options
author | ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15> | 2015-08-05 17:43:19 +0000 |
---|---|---|
committer | ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15> | 2015-08-05 17:43:19 +0000 |
commit | 8dda766e48f3bd16df6d8af870e9df4551b6216d (patch) | |
tree | a53c4fb5ddb0bb640c362406fad02549753decbc | |
parent | 7af8e8717def179fd7b69e173abd347c1a3547cb (diff) | |
download | pcre-8dda766e48f3bd16df6d8af870e9df4551b6216d.tar.gz |
Make pcregrep -q override -l and -c for compatibility with other greps.
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@1586 2f5784b3-3f2a-0410-8824-cb99058d5e15
-rw-r--r-- | ChangeLog | 3 | ||||
-rwxr-xr-x | RunGrepTest | 8 | ||||
-rw-r--r-- | pcregrep.c | 12 | ||||
-rw-r--r-- | testdata/grepoutput | 4 |
4 files changed, 21 insertions, 6 deletions
@@ -106,6 +106,9 @@ Version 8.38 xx-xxx-xxxx reference to become recursive if a later named group with the relevant number is encountered. This could lead to a buffer overflow. Wen Guanxing from Venustech ADLAB discovered this bug. + +28. If pcregrep was given the -q option with -c or -l, or when handling a + binary file, it incorrectly wrote output to stdout. Version 8.37 28-April-2015 diff --git a/RunGrepTest b/RunGrepTest index 62e2a9b..a6e93d3 100755 --- a/RunGrepTest +++ b/RunGrepTest @@ -512,6 +512,14 @@ echo "aaaaa" >>testtemp1grep (cd $srcdir; $valgrind $pcregrep --line-offsets '(?<=\Ka)' $builddir/testtemp1grep) >>testtrygrep 2>&1 echo "RC=$?" >>testtrygrep +echo "---------------------------- Test 108 ------------------------------" >>testtrygrep +(cd $srcdir; $valgrind $pcregrep -lq PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep +echo "RC=$?" >>testtrygrep + +echo "---------------------------- Test 109 -----------------------------" >>testtrygrep +(cd $srcdir; $valgrind $pcregrep -cq lazy ./testdata/grepinput*) >>testtrygrep +echo "RC=$?" >>testtrygrep + # Now compare the results. $cf $srcdir/testdata/grepoutput testtrygrep @@ -1692,9 +1692,13 @@ while (ptr < endptr) if (filenames == FN_NOMATCH_ONLY) return 1; + /* If all we want is a yes/no answer, stop now. */ + + if (quiet) return 0; + /* Just count if just counting is wanted. */ - if (count_only) count++; + else if (count_only) count++; /* When handling a binary file and binary-files==binary, the "binary" variable will be set true (it's false in all other cases). In this @@ -1715,10 +1719,6 @@ while (ptr < endptr) return 0; } - /* Likewise, if all we want is a yes/no answer. */ - - else if (quiet) return 0; - /* The --only-matching option prints just the substring that matched, and/or one or more captured portions of it, as long as these strings are not empty. The --file-offsets and --line-offsets options output offsets for @@ -2089,7 +2089,7 @@ if (filenames == FN_NOMATCH_ONLY) /* Print the match count if wanted */ -if (count_only) +if (count_only && !quiet) { if (count > 0 || !omit_zero_count) { diff --git a/testdata/grepoutput b/testdata/grepoutput index 4d61752..f23dac7 100644 --- a/testdata/grepoutput +++ b/testdata/grepoutput @@ -751,3 +751,7 @@ RC=0 2:3,1 2:4,1 RC=0 +---------------------------- Test 108 ------------------------------ +RC=0 +---------------------------- Test 109 ----------------------------- +RC=0 |