summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Hazel <ph10@hermes.cam.ac.uk>2007-03-13 11:06:48 +0000
committerPhilip Hazel <ph10@hermes.cam.ac.uk>2007-03-13 11:06:48 +0000
commitb2d5182ba3c9c24a92edc47d9e4f8bae41c6ca0a (patch)
treec46fbba1d04f653036786f853d61ee49dbd4f243
parentd2ee61144850b8e20cbf9017e94e2184e33fc0f6 (diff)
Add -v functionality to exigrep.
-rw-r--r--doc/doc-txt/ChangeLog4
-rw-r--r--doc/doc-txt/NewStuff5
-rw-r--r--src/ACKNOWLEDGMENTS3
-rw-r--r--src/src/exigrep.src27
4 files changed, 28 insertions, 11 deletions
diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog
index 5c72b0ca8..24632a291 100644
--- a/doc/doc-txt/ChangeLog
+++ b/doc/doc-txt/ChangeLog
@@ -1,4 +1,4 @@
-$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.490 2007/03/13 10:05:16 ph10 Exp $
+$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.491 2007/03/13 11:06:48 ph10 Exp $
Change log file for Exim from version 4.21
-------------------------------------------
@@ -154,6 +154,8 @@ PH/34 Change HDA_SIZE in oracle.c from 256 to 512. This is needed for 64-bit
PH/35 Applied a patch from the Sieve maintainer which fixes a bug in "notify".
+PH/36 Applied John Jetmore's patch to add -v functionality to exigrep.
+
Exim version 4.66
-----------------
diff --git a/doc/doc-txt/NewStuff b/doc/doc-txt/NewStuff
index d39c6d3e2..37368ac4d 100644
--- a/doc/doc-txt/NewStuff
+++ b/doc/doc-txt/NewStuff
@@ -1,4 +1,4 @@
-$Cambridge: exim/doc/doc-txt/NewStuff,v 1.143 2007/02/26 14:07:04 ph10 Exp $
+$Cambridge: exim/doc/doc-txt/NewStuff,v 1.144 2007/03/13 11:06:48 ph10 Exp $
New Features in Exim
--------------------
@@ -391,6 +391,9 @@ Version 4.67
is set as the separator. Two such characters in succession are interpreted
as enclosing an empty list item.
+19. The exigrep utility now has a -v option, which inverts the matching
+ condition.
+
Version 4.66
------------
diff --git a/src/ACKNOWLEDGMENTS b/src/ACKNOWLEDGMENTS
index 4172a5b0e..899c346b0 100644
--- a/src/ACKNOWLEDGMENTS
+++ b/src/ACKNOWLEDGMENTS
@@ -1,4 +1,4 @@
-$Cambridge: exim/src/ACKNOWLEDGMENTS,v 1.75 2007/03/13 09:50:22 ph10 Exp $
+$Cambridge: exim/src/ACKNOWLEDGMENTS,v 1.76 2007/03/13 11:06:48 ph10 Exp $
EXIM ACKNOWLEDGEMENTS
@@ -180,6 +180,7 @@ John Jetmore Writing and maintaining the 'exipick' utility
Much helpful testing of the test suite & elsewhere
Patch for -Mset
Patch for TLS testing with -bh/-bhc/-bs
+ Patch for exigrep -v functionality
Bob Johannessen Patch for Sieve envelope tests bug
Patch for negative uid/gid bug
Brad Jorsch Patch for bitwise logical operators
diff --git a/src/src/exigrep.src b/src/src/exigrep.src
index b0fdbfe1a..aa03eb489 100644
--- a/src/src/exigrep.src
+++ b/src/src/exigrep.src
@@ -1,5 +1,5 @@
#! PERL_COMMAND -w
-# $Cambridge: exim/src/src/exigrep.src,v 1.6 2007/02/14 16:44:22 ph10 Exp $
+# $Cambridge: exim/src/src/exigrep.src,v 1.7 2007/03/13 11:06:48 ph10 Exp $
use strict;
@@ -59,7 +59,7 @@ return $seconds;
# This subroutine processes a single line (in $_) from a log file. Program
# defensively against short lines finding their way into the log.
-my (%saved, %id_list, $pattern, $queue_time, $insensitive);
+my (%saved, %id_list, $pattern, $queue_time, $insensitive, $invert);
sub do_line {
@@ -84,8 +84,16 @@ if (defined $id)
# Are we interested in this id ? Short circuit if we already were interested.
- $id_list{$id} = 1 if defined $id_list{$id} ||
- ($insensitive && /$pattern/io) || /$pattern/o;
+ if ($invert)
+ {
+ $id_list{$id} = 1 if (!defined($id_list{$id}));
+ $id_list{$id} = 0 if (($insensitive && /$pattern/io) || /$pattern/o);
+ }
+ else
+ {
+ $id_list{$id} = 1 if defined $id_list{$id} ||
+ ($insensitive && /$pattern/io) || /$pattern/o;
+ }
# See if this is a completion for some message. If it is interesting,
# print it, but in any event, throw away what was saved.
@@ -108,6 +116,7 @@ if (defined $id)
print "$saved{$id}\n";
}
+ delete $id_list{$id};
delete $saved{$id};
}
}
@@ -115,7 +124,8 @@ if (defined $id)
# Handle the case where the log line does not belong to a specific message.
# Print it if it is interesting.
-elsif (($insensitive && $_ =~ /$pattern/io) || $_ =~ /$pattern/o)
+elsif ( ($invert && (($insensitive && !/$pattern/io) || !/$pattern/o)) ||
+ (!$invert && (($insensitive && /$pattern/io) || /$pattern/o)) )
{ print "$_\n"; }
}
@@ -124,11 +134,12 @@ elsif (($insensitive && $_ =~ /$pattern/io) || $_ =~ /$pattern/o)
# are quoted if the -l flag is given. The -t flag gives a time-on-queue value
# which is an additional condition.
-getopts('Ilt:',\my %args);
-$queue_time = $args{'t'}? $args{'t'} : -1;
+getopts('Ilvt:',\my %args);
+$queue_time = $args{'t'}? $args{'t'} : -1;
$insensitive = $args{'I'}? 0 : 1;
+$invert = $args{'v'}? 1 : 0;
-die "usage: exigrep [-I] [-l] [-t <seconds>] <pattern> [<log file>]...\n"
+die "usage: exigrep [-I] [-l] [-t <seconds>] [-v] <pattern> [<log file>]...\n"
if ($#ARGV < 0);
$pattern = shift @ARGV;