linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matthias Andree <matthias.andree@gmx.de>
To: Linus Torvalds <torvalds@transmeta.com>
Cc: Matthias Andree <matthias.andree@gmx.de>,
	linux-kernel@vger.kernel.org, samel@mail.cz,
	ma@dt.e-technik.uni-dortmund.de
Subject: Re: BK-kernel-tools/shortlog update
Date: Wed, 26 Mar 2003 22:14:14 +0100	[thread overview]
Message-ID: <20030326211414.GA32316@merlin.emma.line.org> (raw)
In-Reply-To: <Pine.LNX.4.44.0303260917320.15530-100000@home.transmeta.com>

On Wed, 26 Mar 2003, Linus Torvalds wrote:

> I don't know whether you can force perl to do something like this, but if 
> somebody were to try...

How about this (search for 'Alan Cox' to see the syntax):

Index: lk-changelog.pl
===================================================================
RCS file: /var/CVS/lk-changelog/lk-changelog.pl,v
retrieving revision 0.85
retrieving revision 0.88
diff -u -r0.85 -r0.88
--- lk-changelog.pl	26 Mar 2003 08:22:11 -0000	0.85
+++ lk-changelog.pl	26 Mar 2003 21:12:23 -0000	0.88
@@ -8,7 +8,7 @@
 #			Tomas Szepe <szepe@pinerecords.com>
 #			Vitezslav Samel <samel@mail.cz>
 #
-# $Id: lk-changelog.pl,v 0.85 2003/03/26 08:22:11 vita Exp $
+# $Id: lk-changelog.pl,v 0.88 2003/03/26 21:12:23 emma Exp $
 # ----------------------------------------------------------------------
 # Distribution of this script is permitted under the terms of the
 # GNU General Public License (GNU GPL) v2.
@@ -53,6 +53,8 @@
 use Text::Tabs;
 use Text::Wrap;
 
+sub selftest();
+
 # --------------------------------------------------------------------
 # customize the following line to change the indentation of the change
 # lines, $indent1 is used for the first line of an entry, $indent for
@@ -63,6 +65,11 @@
 my $debug = 0;
 # --------------------------------------------------------------------
 
+# Perl syntax magic here, "=>" is equivalent to ","
+my @addrregexps = (
+[ 'alan@.*\.swansea\.linux\.org\.uk' => 'Alan Cox', ],
+[ '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~' => '~~~~~~~~' ]);
+
 # the key is the email address in ALL LOWER CAPS!
 # the value is the real name of the person
 #
@@ -101,8 +108,6 @@
 'akpm@digeo.com' => 'Andrew Morton',
 'akpm@zip.com.au' => 'Andrew Morton',
 'akropel1@rochester.rr.com' => 'Adam Kropelin', # lbdb
-'alan@hraefn.swansea.linux.org.uk' => 'Alan Cox',
-'alan@irongate.swansea.linux.org.uk' => 'Alan Cox',
 'alan@lxorguk.ukuu.org.uk' => 'Alan Cox',
 'alan@redhat.com' => 'Alan Cox',
 'alex@ssi.bg' => 'Alexander Atanasov',
@@ -889,12 +894,27 @@
 
 my %address_unknown;
 
-# get name associated to an email address
-sub rmap_address {
-  my @o = map {defined $addresses{$_} ? $addresses{$_} :
-		 scalar (($address_unknown{$_} = 1), $_); }
-          map { lc; } @_;
-  return wantarray ? @o : $o[0];
+# get name associated with an "email address" formatted
+# BK_USER,BK_HOST tuple
+sub rmap_address($) {
+    my $in = shift;
+    my $key = lc $in;
+    # try hash lookup first, return result if any
+    if (defined $addresses{$key}) {
+	return $addresses{$key};
+    }
+    # try matching against all regexps in listed order
+    # return result if any
+    foreach my $ar (@addrregexps) {
+	if ($in =~ m/$ar->[0]/) {
+	    return $ar->[1];
+	}
+    }
+    # when the address is unknown, return the unchanged input
+    # and mark the address as unknown (so it can be printed in --warn
+    # mode).
+    $address_unknown{$key} = 1;
+    return $in;
 }
 
 # case insensitive string comparison
@@ -1274,12 +1294,26 @@
   return print $opt{width} ? expand(wrap("", "", ($a))) : $a, "\n";
 }
 
+sub selftest() {
+    my $rc = 0;
+    foreach my $address (keys %addresses) {
+	foreach my $ar (@addrregexps) {
+	    if ($address =~ m/$ar->[0]/) {
+		print STDERR "Warning: address '$address'\n";
+		print STDERR "  shadows regexp '$ar->[0]'\n";
+		$rc = 1;
+	    }
+	}
+    }
+    return $rc;
+}
+
 # === MAIN PROGRAM ===============================================
 # Command line arguments
 # What options do we support?
 my @opts = ("help|?|h", "man", "mode=s", "compress!", "count!", "width:i",
 	    "swap!", "merge!", "warn!", "multi!", "abbreviate-names!",
-	    "by-surname!");
+	    "by-surname!", "selftest");
 #	    "bitkeeper|bk!");
 
 # How do we parse them?
@@ -1311,7 +1345,8 @@
   unless defined $table{$opt{mode}};
 pod2usage(-verbose => 0,
 	  -message => "$0: No files given, refusing to read from a TTY.")
-  if (not $opt{bitkeeper} and (@ARGV == 0) and (-t STDIN));
+  if (not $opt{selftest} and not $opt{bitkeeper}
+	  and (@ARGV == 0) and (-t STDIN));
 pod2usage(-verbose => 0,
 	  -message => "$0: Must have one or two arguments in --bitkeeper mode.")
   if ($opt{bitkeeper} && (@ARGV < 1 || @ARGV > 2));
@@ -1358,6 +1393,10 @@
   foreach (@ARGV) { print STDERR "DEBUG:   '$_'\n"; }
 }
 
+if ($opt{selftest}) {
+    exit selftest;
+}
+
 # Main program
 my @prolog;
 my %log;
@@ -1406,6 +1445,18 @@
 __END__
 # --------------------------------------------------------------------
 # $Log: lk-changelog.pl,v $
+# Revision 0.88  2003/03/26 21:12:23  emma
+# Add selftest mode check:
+# * check all addresses against all regexps to find addresses shadowing
+#   regular expressions.
+#
+# Revision 0.87  2003/03/26 21:02:53  emma
+# Fix broken regexp for Alan's swansea.linux.org.uk addresses. Add some comments.
+#
+# Revision 0.86  2003/03/26 20:57:49  emma
+# Support regexp queries (but try hash lookups first for efficiency).
+# Requested by Linus Torvalds.
+#
 # Revision 0.85  2003/03/26 08:22:11  vita
 # Added 6 names for new addresses.
 #
@@ -1737,6 +1788,8 @@
      --width[=WIDTH] specify the line length, if omitted: $COLUMNS or 80.
                      text lines will not exceed this length.
 
+     --selftest      perform some self tests (for developers of this script)
+
 Warning: Neither --compress nor --count are currently functional with
 --mode=full.
 
@@ -1825,6 +1878,8 @@
 =head1 TODO
 
 =over
+
+=item * OBFUSCATE ADDRESSES (requested by Solar Designer)
 
 =item * --compress-me-harder
 

-- 
Matthias Andree

  parent reply	other threads:[~2003-03-26 21:03 UTC|newest]

Thread overview: 124+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-03-26 10:30 BK-kernel-tools/shortlog update Matthias Andree
2003-03-26 17:21 ` Linus Torvalds
2003-03-26 19:25   ` Olaf Dietsche
2003-03-26 20:10   ` Matthias Andree
2003-03-26 21:15     ` Jeff Garzik
2003-03-26 21:33       ` Jauder Ho
2003-03-27  0:46         ` jw schultz
2003-03-26 21:08   ` Matti Aarnio
2003-03-26 21:14   ` Matthias Andree [this message]
2003-03-26 10:33 Matthias Andree
2003-03-26 21:21 Matthias Andree
2003-03-28 11:00 Matthias Andree
2003-04-13 10:50 Matthias Andree
2003-04-27 13:24 Matthias Andree
2003-04-28 23:08 Matthias Andree
2003-05-15 14:11 Matthias Andree
2003-05-29 11:26 Matthias Andree
2003-06-04 19:04 Matthias Andree
2003-06-09 10:24 Matthias Andree
2003-06-09 10:26 Matthias Andree
2003-06-17 14:54 Matthias Andree
2003-06-17 14:57 Matthias Andree
2003-06-17 14:57 Matthias Andree
2003-06-20 23:06 Matthias Andree
2003-06-24 11:00 Matthias Andree
2003-06-30  8:32 Matthias Andree
2003-07-06 21:44 Matthias Andree
2003-07-11 12:12 Matthias Andree
2003-07-15 13:20 Matthias Andree
2003-07-21  9:17 Matthias Andree
2003-07-21  9:17 Matthias Andree
2003-07-21  9:30 John Bradford
2003-07-30  8:38 Matthias Andree
2003-08-08 22:51 Matthias Andree
2003-08-24 11:02 Matthias Andree
2003-08-28 16:29 Matthias Andree
2003-08-29 13:00 Matthias Andree
2003-08-31 14:16 Matthias Andree
2003-09-03 23:33 Matthias Andree
2003-09-04 16:05 ` Dave Jones
2003-09-04 16:09   ` Matthias Andree
2003-09-04 16:17     ` Dave Jones
2003-09-04 16:33     ` Linus Torvalds
2003-09-04 17:42       ` Matthias Andree
2003-09-04 19:49         ` Greg KH
2003-09-04 20:54           ` Matthias Andree
2003-09-04 20:32         ` Dave Dillow
2003-09-04 20:57 Matthias Andree
2003-09-11  9:18 Matthias Andree
2003-09-22 14:54 Matthias Andree
2003-10-08 21:59 Matthias Andree
2003-10-16 14:26 Matthias Andree
2003-10-27 12:09 Matthias Andree
2003-11-19 16:11 Matthias Andree
2003-11-22 15:05 Matthias Andree
2003-11-25  3:21 Matthias Andree
2003-11-27 11:03 Matthias Andree
2003-12-06 16:41 Matthias Andree
2003-12-20 23:36 Matthias Andree
2003-12-20 23:39 ` Matthias Andree
2003-12-20 23:36 Matthias Andree
2003-12-20 23:36 Matthias Andree
2003-12-21  3:19 Matthias Andree
2003-12-22  1:18 Matthias Andree
2003-12-30  2:16 Matthias Andree
2003-12-30  2:16 Matthias Andree
2004-01-07 11:29 Matthias Andree
2004-01-16 14:41 Matthias Andree
2004-01-19 17:01 Matthias Andree
2004-01-27 14:46 Matthias Andree
2004-03-04 17:09 Matthias Andree
2004-03-04 17:09 Matthias Andree
2004-03-09  0:16 Matthias Andree
2004-03-15 17:12 Matthias Andree
2004-03-23 11:51 Matthias Andree
2004-03-30  1:17 Matthias Andree
2004-03-30 14:05 Matthias Andree
2004-04-01 21:48 Matthias Andree
2004-04-15 16:10 Matthias Andree
2004-04-20 11:14 Matthias Andree
2004-04-26  8:40 Matthias Andree
2004-05-03  9:23 Matthias Andree
2004-05-14 20:08 Matthias Andree
2004-06-03  8:00 Matthias Andree
2004-06-07 11:36 Matthias Andree
2004-07-02 10:40 Matthias Andree
2004-07-12  9:06 Matthias Andree
2004-07-12  9:21 ` Matthias Andree
2004-07-16 13:51 Matthias Andree
2004-08-04  9:00 Matthias Andree
2004-08-10 12:24 Matthias Andree
2004-08-16 11:18 Matthias Andree
2004-08-23 10:43 Matthias Andree
2004-08-24 14:18 Matthias Andree
2004-08-25 16:10 Matthias Andree
2004-09-24 10:09 Matthias Andree
2004-10-06 10:48 Matthias Andree
2004-10-14  7:02 Matthias Andree
2004-10-19  1:43 Matthias Andree
2004-10-19  1:56 Matthias Andree
2004-10-21 22:38 Matthias Andree
2004-11-09  8:42 Matthias Andree
2004-11-09 10:06 ` Måns Rullgård
2004-11-12 10:10 Matthias Andree
2004-12-16 10:18 Matthias Andree
2004-12-20  9:53 Matthias Andree
2004-12-23 10:52 Matthias Andree
2005-01-05 11:58 Matthias Andree
2005-01-05 12:07 ` Matthias Andree
2005-01-08  1:38 Matthias Andree
2005-01-10 18:22 Matthias Andree
2005-01-20  9:27 Matthias Andree
2005-01-20 12:51 ` Adrian Bunk
2005-01-20 13:13   ` Matthias Andree
2005-01-21 14:30 Matthias Andree
2005-02-04 11:35 Matthias Andree
2005-02-07 12:45 Matthias Andree
2005-02-09  9:23 Matthias Andree
2005-02-23 14:43 Matthias Andree
2005-03-03 12:19 Matthias Andree
2005-03-07 13:50 Matthias Andree
2005-03-09  9:39 Matthias Andree
2005-03-11 10:21 Matthias Andree
2005-03-14  9:49 Matthias Andree

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030326211414.GA32316@merlin.emma.line.org \
    --to=matthias.andree@gmx.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ma@dt.e-technik.uni-dortmund.de \
    --cc=samel@mail.cz \
    --cc=torvalds@transmeta.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).