]> git.treefish.org Git - fex.git/blobdiff - bin/fpg
Original release 20160328
[fex.git] / bin / fpg
diff --git a/bin/fpg b/bin/fpg
index be610fe3bf8062ed86a76773be00f0ea88da9835..5f2f7511734dce91bb76771ac19448539778be3e 100755 (executable)
--- a/bin/fpg
+++ b/bin/fpg
@@ -8,7 +8,7 @@
 #   2003-02-27 Framstag                initial version
 #   2003-02-28 Framstag                added exit status
 #   2007-03-09 Framstag                added option -Q
-#   2007-06-01 Framstag                added options -s and -c 
+#   2007-06-01 Framstag                added options -s and -c
 #                               and changed default output mode
 #   2007-06-03 Framstag                added ReadLine-support
 #   2007-08-31 Framstag                added option -x
@@ -27,7 +27,7 @@ sub usage {
   die <<EOD
 usage: $0 [options] 'EXP' [file...]
    or: $0 [options] -Q file...
-options: -r        recursively scan through directories   
+options: -r        recursively scan through directories
          -i        ignore case
         -v        print only lines that do NOT match
         -s        verbose scanning/searching
@@ -88,7 +88,7 @@ if ($opt_o and ($opt_v or $opt_l or $opt_L or $opt_c or $opt_F or $opt_C)) {
 $opt_XX = 0;
 if (not ${'opt_~'}) {
   @bfiles = grep(/~$|^#.*#$/,@ARGV);
-  if (@bfiles and 
+  if (@bfiles and
       (grep(/[^~]$/,@ARGV) or grep(/(^|\/)#[^\/]*#$/,@ARGV))) {
     $opt_XX = 1;
     warn "$0: ignoring @bfiles\n"; # unless $opt_r;
@@ -105,7 +105,7 @@ if (-t STDOUT) {
 if ($opt_p) { $/ = '' }
 else        { $/ = $opt_R }
 #else        { eval '$/ = "'.$opt_R.'"' }
-  
+
 $opt_h = 1 if not $opt_r and @ARGV < 2;
 
 if ($opt_Q) {
@@ -132,9 +132,9 @@ sub scan {
     $exp = '(?s)'.$exp if $opt_p or $opt_R;
     #? $exp =~ s/\.\*\*/[.\n]*/g;
   }
-  
+
   $found = 0;
-  
+
   if (@ARGV) {
     foreach $file (@ARGV) {
       next if $opt_X  and $file =~ /$opt_X/;
@@ -192,7 +192,7 @@ sub grepd {
   my $dir = shift;
   my $file;
   my $found = 0;
-  
+
   opendir $dir,$dir or return;
   while (defined($file = readdir $dir)) {
     next if $file eq '.' or $file eq '..';
@@ -208,7 +208,7 @@ sub grepd {
     }
     next unless -f $file or -c $file or -S $file or -p $file or -z $file;
     $fileq = quotemeta $file;
-    if (-T $file and open $file,$file or 
+    if (-T $file and open $file,$file or
         open $file,"strings -a -n $opt_S $fileq|") {
       $found += grepf($file,$file);
       close $file;
@@ -224,9 +224,9 @@ sub grepf {
   my $file = shift;
   my $found = 0;
   my ($n,$l,$c);
-  
+
   warn $B."scanning $file".$N."\n" if -t STDOUT and $opt_s;
-  
+
   while (<$F>) {
     $_ .= "\n" unless /\n$/;
     if ($opt_M) {
@@ -248,9 +248,9 @@ sub grepf {
       $C{0} = [$l,$_];
     }
     if ($opt_e) {
-      if ($opt_v) { 
+      if ($opt_v) {
         next if &$egrep;
-      } else { 
+      } else {
         unless (&$egrep) {
           if ($opt_C and $c) {
             print "$l:" if $opt_n;
@@ -276,16 +276,16 @@ sub grepf {
           if ($opt_Q) { $n++ while /$exp/mg }
           else       { $n++ while /$exp/omg }
         } else {
-          if ($opt_o) { 
+          if ($opt_o) {
             my $m = '';
             while (s/($exp)//) {
               $n++;
               $m .= "$1\n";
             }
             $_ = $m;
-          } elsif ($opt_Q) { 
+          } elsif ($opt_Q) {
             $n += s/($exp)/$B$1$N/mg;
-          } else { 
+          } else {
             $n += s/($exp)/$B$1$N/omg;
           }
         }
@@ -309,7 +309,7 @@ sub grepf {
       $file = '';
     }
     if ($opt_x and $n) {
-      if ($opt_i) { s/($opt_x)/$B$1$N/ogi } 
+      if ($opt_i) { s/($opt_x)/$B$1$N/ogi }
       else        { s/($opt_x)/$B$1$N/og }
     }
     for (my $i=$opt_C;$i;$i--) {
@@ -327,7 +327,7 @@ sub grepf {
     $L{$l} = $l;
     $c = $opt_C;
   }
-  
+
   if ($opt_c) {
     print "$file:" if @ARGV>1;
     print "$found\n";