summaryrefslogtreecommitdiffstats
path: root/debian/patches/01-filename.patch
blob: e78113e08503694c009b0556738c502a24b70986 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
Author: Antonio Diaz Diaz  <ant_diaz@teleline.es>
Description:
 Make 'grep_show_name' tri-state so that file name is no prefixed to output by
 default when searching one file.

diff -Naurp zutils.orig/doc/zutils.info zutils/doc/zutils.info
--- zutils.orig/doc/zutils.info	2012-12-10 11:18:56.507741935 +0100
+++ zutils/doc/zutils.info	2012-12-10 11:21:49.519773976 +0100
@@ -389,7 +389,8 @@ matches were found, and 2 means trouble.
 
 `-h'
 `--no-filename'
-     Suppress the prefixing filename on output.
+     Suppress the prefixing of filenames on output when multiple files
+     are searched.
 
 `-H'
 `--with-filename'
diff -Naurp zutils.orig/doc/zutils.texinfo zutils/doc/zutils.texinfo
--- zutils.orig/doc/zutils.texinfo	2012-12-10 11:18:56.507741935 +0100
+++ zutils/doc/zutils.texinfo	2012-12-10 11:21:49.519773976 +0100
@@ -432,7 +432,8 @@ Treat @var{pattern} as a set of newline-
 
 @item -h
 @itemx --no-filename
-Suppress the prefixing filename on output.
+Suppress the prefixing of filenames on output when multiple files are
+searched.
 
 @item -H
 @itemx --with-filename
diff -Naurp zutils.orig/main.cc zutils/main.cc
--- zutils.orig/main.cc	2012-12-10 11:18:56.507741935 +0100
+++ zutils/main.cc	2012-12-10 11:21:49.519773976 +0100
@@ -243,8 +243,8 @@ int main( const int argc, const char * c
       return ( program_mode == m_zcat ) ? 1 : 2; }
 
   int argind = 0;
+  int grep_show_name = -1;
   bool grep_list = false;
-  bool grep_show_name = true;
   bool grep_pattern_found = false;
   for( ; argind < parser.arguments(); ++argind )
     {
@@ -350,6 +350,9 @@ int main( const int argc, const char * c
 
   if( filenames.empty() ) filenames.push_back("-");
 
+  if( grep_show_name < 0 && filenames.size() == 1 )
+    grep_show_name = false;
+
   int retval = ( ( program_mode == m_zgrep ) ? 1 : 0 );
   while( !filenames.empty() )
     {