Skip to contentSkip to conversation

lk-changelog.pl 0.77

DISCUSSION Matthias Andree 1 participant 1 message Feb 27, 2003

lore
Share & tools
lore
#0 lore raw

This is a semi-automatic announcement.

lk-changelog.pl aka. shortlog version 0.77 has been released. The changes are listed at the end of the script below.

You can always download this script and GPG signatures from
http://mandree.home.pages.de/linux/kernel/

My thanks go to Vitezslav Samel who has spent a lot of time on digging out the real names for addresses sending in BK ChangeSets.

Note that your mailer must be MIME-capable to save this mail properly, because it is in the "quoted-printable" encoding.

= <- if you see just an equality sign, but no "3D", your mailer is fine. = <- if you see 3D on this line, then upgrade your mailer or pipe this mail = <- into metamail.

Signature · 1,802 lines
A sh script on behalf of Matthias Andree
-------------------------------------------------------------------------
Changes since last release:

----------------------------
revision 0.77
date: 2003/02/27 10:52:59;  author: vita;  state: Exp;  lines: +11 -1
Added 7 new names for addresses from both current BK trees.
----------------------------
revision 0.76
date: 2003/02/24 20:04:23;  author: vita;  state: Exp;  lines: +12 -1
Added 7 new names for addresses from current linux-2.5 BK tree.
----------------------------
revision 0.75
date: 2003/02/21 12:41:18;  author: vita;  state: Exp;  lines: +9 -1
Added 5 new names for addresses from current linux-2.4 BK tree.
----------------------------
revision 0.74
date: 2003/02/19 11:15:14;  author: vita;  state: Exp;  lines: +11 -1
Added 7 new addresses found by Google.
----------------------------
revision 0.73
date: 2003/02/14 10:45:45;  author: vita;  state: Exp;  lines: +9 -1
Added 5 new addresses found by Google.
=============================================================================
-------------------------------------------------------------------------
#! /usr/bin/perl -wT

# This Perl script is meant to simplify/beautify BK ChangeLogs for the linux
# kernel.
#
# (C) Copyright 2002 by Matthias Andree <[email protected]>
#			Marcus Alanen <[email protected]>
#			Tomas Szepe <[email protected]>
#			Vitezslav Samel <[email protected]>
#
# $Id: lk-changelog.pl,v 0.77 2003/02/27 10:52:59 vita Exp $
# ----------------------------------------------------------------------
# Distribution of this script is permitted under the terms of the
# GNU General Public License (GNU GPL) v2.
# ----------------------------------------------------------------------

# This program expects its input in the following format:
# (E-Mail Addresses MUST NOT bear leading whitespace!)
#
# <[email protected]>
#	changelog text
#	more changelog text
# <[email protected]>
#	yet another changelog
# <[email protected]>
#	changelog #3
#	more lines
#
# and discards all changelog lines but the first after an email address,
# and groups and sorts the entries by email address:
#
# [email protected]:
#	changelog #3
# [email protected]
#	changelog text
#	yet another changelog

require 5.005;
use strict;

use Carp;
use Getopt::Long;
use IO::File;
eval 'use Pod::Usage;';
if ($@) {
  eval 'sub pod2usage {
    print STDERR "Usage information would be presented here if you had Pod::Usage installed.\n"
      . "Try: perl -MCPAN -e \'install Pod::Usage\'\nAbort.\n";
    exit 2;
  }';
}
use Text::ParseWords;
use Text::Tabs;
use Text::Wrap;

# --------------------------------------------------------------------
# customize the following line to change the indentation of the change
# lines, $indent1 is used for the first line of an entry, $indent for
# all subsequent lines. $indent is auto-generated from $indent1.
my $indent1 = "  o ";
my $indent  = " " x length($indent1);
# change this to enable some debugging stuff:
my $debug = 0;
# --------------------------------------------------------------------

# the key is the email address in ALL LOWER CAPS!
# the value is the real name of the person
#
# Unless otherwise noted, the addresses below have been obtained using
# lbdb.
my %addresses = (
'[email protected]' => 'Abraham van der Merwe',
'[email protected]' => 'Lucio Maciel',
'[email protected]' => 'Albert Cranford',
'[email protected]' => 'Georg Acher',
'[email protected]' => 'Javier Achirica',
'[email protected]' => 'Arnaldo Carvalho de Melo',
'[email protected]' => 'Arnaldo Carvalho de Melo',
'[email protected]' => 'Arnaldo Carvalho de Melo',
'[email protected]' => 'Adam Radford', # google
'[email protected]' => 'Adam Radford', # google
'[email protected]' => 'Adam J. Richter',
'[email protected]' => 'Antonino Daplas',
'[email protected]' => 'Andreas Dilger',
'[email protected]' => 'Andries E. Brouwer',
'agrover@acpi3.(none)' => 'Andy Grover',
'[email protected]' => 'Andy Grover', # guessed
'[email protected]' => 'Andy Grover',
'[email protected]' => 'Andy Grover',
'[email protected]' => 'Andreas Gruenbacher',
'[email protected]' => 'Art Haas',
'[email protected]' => 'Art Haas',
'[email protected]' => 'Anton Altaparmakov',
'[email protected]' => 'Anton Altaparmakov',
'[email protected]' => 'Anton Altaparmakov',
'[email protected]' => 'Ani Joshi',
'[email protected]' => 'Ani Joshi',
'[email protected]' => 'Andi Kleen',
'[email protected]' => 'Andi Kleen',
'[email protected]' => 'Andrew Morton',
'[email protected]' => 'Andrew Morton',
'[email protected]' => 'Adam Kropelin', # lbdb
'[email protected]' => 'Alan Cox',
'[email protected]' => 'Alan Cox',
'[email protected]' => 'Alan Cox',
'[email protected]' => 'Alexander Atanasov',
'[email protected]' => 'Alex Williamson', # lbdb
'[email protected]' => 'Alex Williamson', # google
'[email protected]' => 'Alexander Riesen',
'[email protected]' => 'Alfredo Sanju�n',
'[email protected]' => 'Adam Belay',
'[email protected]' => 'Alberto Munoz',
'[email protected]' => 'Erik Andersen',
'[email protected]' => 'Anders Gustafsson',
'[email protected]' => 'Mike Anderson', # lbdb
'[email protected]' => 'Andrea Arcangeli',
'[email protected]' => 'Andrew Wood',
'[email protected]' => 'Andries E. Brouwer',
'[email protected]' => 'Andy Adamson',
'[email protected]' => 'Angus Sawyer',
'[email protected]' => 'Andrzej Krzysztofowicz',
'[email protected]' => 'Anton Blanchard',
'[email protected]' => 'Aristeu Sergio Rozanski Filho',
'[email protected]' => 'Arjan van de Ven',
'[email protected]' => 'Arjan van de Ven',
'[email protected]' => 'Arnd Bergmann',
'[email protected]' => 'Arnd Bergmann',
'[email protected]' => 'Arun Sharma',
'[email protected]' => 'Asit K. Mallick', # by Kristian Peters
'[email protected]' => 'Jens Axboe', # guessed
'[email protected]' => 'Jens Axboe',
'[email protected]' => 'Jens Axboe',
'[email protected]' => 'Brent Baccala',
'[email protected]' => 'Duncan Sands',
'[email protected]' => 'Dario Ballabio',
'[email protected]' => 'D. J. Barrow',
'[email protected]' => 'Barry K. Nathan', # lbdb
'[email protected]' => 'Bart De Schuymer',
'[email protected]' => 'Ben Collins',
'[email protected]' => 'Benjamin LaHaise',
'[email protected]' => 'Benjamin LaHaise',
'[email protected]' => 'Benjamin LaHaise', # guessed
'[email protected]' => 'Bart De Schuymer',
'[email protected]' => 'Brian Beattie', # from david.nelson
'[email protected]' => 'Benjamin Herrenschmidt',
'[email protected]' => 'Benjamin Herrenschmidt',
'[email protected]' => 'Peter Bergner',
'[email protected]' => 'Bernhard Rosenkraenzer',
'[email protected]' => 'Ben Fennema',
'[email protected]' => 'Brian Gerst',
'[email protected]' => 'Brad Hards',
'[email protected]' => 'Bhavesh P. Davda',
'[email protected]' => 'Brad Heilbrun', # by himself
'[email protected]' => 'Bj�rn Andersson', # google, guessed �
'[email protected]' => 'Bjorn Wesen',
'[email protected]' => 'Bjorn Helgaas',
'[email protected]' => 'Oskar Andreasson',
'[email protected]' => 'Blake Matheny', # google
'[email protected]' => 'Boris Itkis', # by Kristian Peters
'[email protected]' => 'Peter Braam',
'[email protected]' => 'Brett Pemberton',
'[email protected]' => 'Brian Hall', # google
'[email protected]' => 'Brian Murphy',
'[email protected]' => 'Ken Brownfield',
'[email protected]' => 'Adrian Bunk',
'[email protected]' => 'Lennert Buytenhek',
'[email protected]' => 'Bruce Allan',
'[email protected]' => 'Bj�rn A. Zeeb', # lbdb
'[email protected]' => 'Carl-Daniel Hailfinger',
'[email protected]' => 'Carl-Daniel Hailfinger', # himself
'[email protected]' => 'Russell Cattelan', # google
'[email protected]' => 'Chris Caputo',
'[email protected]' => 'Chuck Lever',
'[email protected]' => 'Celso Gonz�lez', # google
'[email protected]' => 'Christopher Hoover', # by Kristian Peters
'[email protected]' => 'Charles White',
'[email protected]' => 'Chas Williams',
'[email protected]' => 'Chas Williams',
'[email protected]' => 'Samuel S. Chessman',
'[email protected]' => 'Chris Wilson',
'[email protected]' => 'Chris Wright',
'[email protected]' => 'Christer Weinigel', # from shortlog
'[email protected]' => 'Christopher Leech',
'[email protected]' => 'Jochen Karrer', # from shortlog
'[email protected]' => 'Craig Kulesa',
'[email protected]' => 'James H. Cloos Jr.',
'[email protected]' => 'Corey Minyard',
'[email protected]' => 'Carsten Niehaus',
'[email protected]' => 'Kevin Brosius',
'[email protected]' => 'Colin Gibbs',
'[email protected]' => 'Matthew Dobson',
'[email protected]' => 'Cort Dougan',
'[email protected]' => 'Chris Hanson',
'[email protected]' => 'Christoph Rohland',
'[email protected]' => 'Charles-Edouard Ruault',
'[email protected]' => 'Chad N. Tindel',
'[email protected]' => 'Ruslan U. Zakirov',
'[email protected]' => 'Chris Wedgwood',
'[email protected]' => 'Christopher Yeoh',
'[email protected]' => 'David M�ller',
'[email protected]' => 'Bj�rn Augustsson',
'[email protected]' => 'Dan Aloni',
'[email protected]' => 'Daisy Chang', # from shortlog
'[email protected]' => 'Dale Farnsworth',
'[email protected]' => 'Martin Dalecki',
'[email protected]' => 'Martin Dalecki',
'[email protected]' => 'Dan Zink',
'[email protected]' => 'Daniel Jacobowitz',
'[email protected]' => 'Dana Lacoste',
'[email protected]' => 'Dan Cox', # some CREDITS patch found by google
'[email protected]' => 'Daniel Ritz',
'[email protected]' => 'Dave Maietta',
'[email protected]' => 'David Dillow',
'[email protected]' => 'Dave Jones',
'[email protected]' => 'Dave Jones',
'[email protected]' => 'Dave Jones',
'[email protected]' => 'Dave Jones',
'davej@tetrachloride.(none)' => 'Dave Jones',
'[email protected]' => 'David S. Miller',
'[email protected]' => 'David S. Miller',
'[email protected]' => 'David S. Miller',
'[email protected]' => 'David S. Miller', # guessed
'[email protected]' => 'David S. Miller',
'[email protected]' => 'David Brownell',
'[email protected]' => 'David Nelson',
'[email protected]' => 'David Gibson',
'[email protected]' => 'David Jeffery',
'[email protected]' => 'Davide Libenzi',
'[email protected]' => 'David Mosberger',
'[email protected]' => 'David Mosberger',
'[email protected]' => 'David Mosberger',
'[email protected]' => 'David Mosberger',
'[email protected]' => 'David Schwartz', # google
'[email protected]' => 'David Brownell',
'[email protected]' => 'Dan Streetman',
'[email protected]' => 'Dan Streetman',
'[email protected]' => 'Jeff DeFouw',
'[email protected]' => "Thomas 'Dent' Mirlacher",
'[email protected]' => 'Dominik Brodowski',
'[email protected]' => 'Martin Devera',
'[email protected]' => 'David Gibson',
'[email protected]' => 'David Hinds', # google
'[email protected]' => 'Dave Hollis',
'[email protected]' => 'David Howells',
'[email protected]' => 'David Howells',
'[email protected]' => 'Dipankar Sarma',
'[email protected]' => 'Dirk Uffmann',
'[email protected]' => 'Doug Ledford',
'[email protected]' => 'Doug Ledford',
'[email protected]' => 'Doug Ledford',
'[email protected]' => 'Doug Ledford',
'[email protected]' => 'Dave McCracken',
'[email protected]' => 'Denis Oliver Kropp',
'[email protected]' => 'Douglas Gilbert',
'[email protected]' => 'Ulrich Drepper',
'[email protected]' => 'Bryan B. Whitehead', # google
'[email protected]' => 'Daniel Jacobowitz',
'[email protected]' => 'Daniel Jacobowitz',
'[email protected]' => 'Deepak Saxena',
'[email protected]' => 'Duncan Sands',
'[email protected]' => 'David Woodhouse',
'[email protected]' => 'David Woodhouse',
'[email protected]' => 'David Woodhouse',
'[email protected]' => 'Massimo Dal Zotto',
'[email protected]' => 'Eric Biederman',
'[email protected]' => 'Eric Brower',
'[email protected]' => 'Eric Brower',
'[email protected]' => 'Eddie C. Dost',
'[email protected]' => 'Ed Vance',
'[email protected]' => 'Edward Peng',
'[email protected]' => 'Erich Focht',
'[email protected]' => 'Rolf Eike Beer', # sent by himself
'[email protected]' => 'Rolf Eike Beer',
'[email protected]' => 'Steven Cole',
'[email protected]' => 'Dave Engebretsen',
'[email protected]' => 'St�phane Eranian',
'[email protected]' => 'St�phane Eranian',
'[email protected]' => 'Erik Arneson',
'[email protected]' => 'Erik Habbinga',
'[email protected]' => 'Eyal Lebedinsky', # lbdb
'[email protected]' => 'Falk Hueffner',
'[email protected]' => 'Faik Uygur',
'[email protected]' => 'Fl�vio Bruno Leitner', # google
'[email protected]' => 'Frank Davis',
'[email protected]' => 'Felipe Damasio', # by self (did not ask to include the W.)
'[email protected]' => 'Fenghua Yu', # google
'[email protected]' => 'Bakonyi Ferenc',
'[email protected]' => 'Filip Sneppe',
'[email protected]' => 'J�rgen E. Fischer',
'[email protected]' => 'Martin J. Bligh',
'[email protected]' => 'Florian Lohoff',
'[email protected]' => 'Florian Thiel', # from shortlog
'[email protected]' => 'Nick Fedchik',
'[email protected]' => 'Erich Focht',
'[email protected]' => 'Rolf Fokkens',
'[email protected]' => 'Franz Sirl',
'[email protected]' => 'Franz Sirl',
'[email protected]' => 'Paulo Andr�',
'[email protected]' => 'Jay Vosburgh',
'[email protected]' => 'Florian Weimer', # lbdb
'[email protected]' => 'Frank Zago', # google
'[email protected]' => 'Cha Young-Ho',
'[email protected]' => 'Martin Josefsson',
'[email protected]' => 'Ganesh Varadarajan',
'[email protected]' => 'Ganesh Varadarajan',
'[email protected]' => 'Ganesh Varadarajan',
'[email protected]' => 'Kurt Garloff',
'[email protected]' => 'Geert Uytterhoeven',
'[email protected]' => 'George Anzinger',
'[email protected]' => 'Georg Nikodym',
'[email protected]' => 'Greg Ungerer',
'[email protected]' => 'Greg Ungerer',
'[email protected]' => 'Ghozlane Toumi',
'[email protected]' => 'Justin T. Gibbs',
'[email protected]' => 'Justin T. Gibbs',
'[email protected]' => 'Dr. David Alan Gilbert',
'[email protected]' => 'Guennadi Liakhovetski',
'[email protected]' => 'Geoffrey Lee', # lbdb
'[email protected]' => 'Greg Banks',
'[email protected]' => 'Go Taniguchi',
'[email protected]' => 'Patricia Guaghen',
'[email protected]' => 'Goto Masanori', # from shortlog
'[email protected]' => 'Cory Watson',
'[email protected]' => 'Ben Greear',
'[email protected]' => 'Oleg Drokin',
'[email protected]' => 'Oleg Drokin',
'[email protected]' => 'Oleg Drokin',
'[email protected]' => 'Greg Kroah-Hartman',
'[email protected]' => 'George Ronkin',
'[email protected]' => 'Grant Grundler',
'[email protected]' => 'Michael Grundy',
'[email protected]' => 'Guillermo S. Romero',
'[email protected]' => 'Ghozlane Toumi',
'[email protected]' => 'Jamal Hadi Salim',
'[email protected]' => 'Hanna Linder',
'[email protected]' => 'Dave Hansen',
'[email protected]' => 'Christoph Hellwig',
'[email protected]' => 'Christoph Hellwig',
'[email protected]' => 'Christoph Hellwig',
'[email protected]' => 'Christoph Hellwig',
'[email protected]' => 'Christoph Hellwig',
'[email protected]' => 'Christoph Hellwig',
'[email protected]' => 'Christoph Hellwig',
'[email protected]' => 'Christoph Hellwig', # by Kristian Peters
'[email protected]' => 'Christoph Hellwig',
'[email protected]' => 'Bjorn Helgaas', # doesn't want �/�
'[email protected]' => 'Henning Meier-Geinitz',
'[email protected]' => 'Henrique Gobbi',
'[email protected]' => 'Henrique Gobbi',
'[email protected]' => 'David Gibson',
'[email protected]' => 'Hirofumi Ogawa', # corrected by himself
'[email protected]' => 'Colin Slater',
'[email protected]' => 'H. Peter Anvin',
'[email protected]' => 'Hugh Dickins',
'[email protected]' => 'Thiemo Seufer', # google
'[email protected]' =>  'Adams IT Services',
'[email protected]' => 'Ivan Kokshaysky',
'[email protected]' => 'Ion Badulescu',
'[email protected]' => 'Ion Badulescu',
'[email protected]' => 'Ishan O. Jayawardena',
'[email protected]' => 'Ingo Rohlfs',
'[email protected]' => 'Ishikawa Mutsumi',
'[email protected]' => 'Ivan Gyurdiev',
'[email protected]' => 'Jan Kara',
'[email protected]' => 'Jack Hammer',
'[email protected]' => 'Jan Harkes',
'[email protected]' => 'Jakob Kemi',
'[email protected]' => 'Jakub Jel�nek',
'[email protected]' => 'J. A. Magallon',
'[email protected]' => 'James Bottomley',
'[email protected]' => 'James Mayer',
'[email protected]' => 'James McMechan',
'[email protected]' => 'Jamey Hicks',
'[email protected]' => 'Jamey Hicks',
'[email protected]' => 'Jamie Lokier',
'[email protected]' => 'Jani Monoses',
'[email protected]' => 'Jani Monoses',
'[email protected]' => 'Julien Blache',
'[email protected]' => 'Jesse Barnes',
'[email protected]' => 'Jan-Benedict Glaw',
'[email protected]' => 'James Blackwell',
'[email protected]' => 'David Ruggiero',
'[email protected]' => 'Jeff Dike',
'[email protected]' => 'Jeff Dike',
'[email protected]' => 'Jeff Dike',
'[email protected]' => 'David Ruggiero',
'[email protected]' => 'Thomas Hood',
'[email protected]' => 'Jeb J. Cramer',
'[email protected]' => 'Jeff Wiedemeier',
'[email protected]' => 'Jeff Sutherland', # lbdb
'jejb@malley.(none)' => 'James Bottomley',
'jejb@mulgrave.(none)' => 'James Bottomley', # from shortlog
'[email protected]' => 'James Bottomley',
'[email protected]' => 'Jenna S. Hall', # google
'[email protected]' => 'Jes Sorensen',
'[email protected]' => 'Jes Sorensen',
'[email protected]' => 'Jeff Garzik',
'[email protected]' => 'Jeff Garzik',
'[email protected]' => 'Jeff Garzik',
'[email protected]' => 'Jeff Garzik',
'[email protected]' => 'Jeff Garzik',
'[email protected]' => 'Jeff Garzik',
'[email protected]' => 'Jon Grimm',
'[email protected]' => 'Jon Grimm', # google
'[email protected]' => 'Jon Grimm', # google
'[email protected]' => 'Jon Grimm', # google
'[email protected]' => 'John Hesterberg',
'[email protected]' => 'Jack Hammer',
'[email protected]' => 'Jack Thomasson',
'[email protected]' => 'James Morris',
'[email protected]' => 'Jochen Suckfuell',
'[email protected]' => 'Jochen Hein',
'[email protected]' => 'Jochen Friedrich',
'[email protected]' => 'Joe Thornber',
'[email protected]' => 'Joe Burks',
'[email protected]' => 'Joel Buckley',
'[email protected]' => 'J�rg Prante',
'[email protected]' => 'Johann Deneux',
'[email protected]' => 'Johannes Erdfelt',
'[email protected]' => 'John Clemens',
'[email protected]' => 'John Bradford',
'[email protected]' => 'John Kim',
'[email protected]' => 'Evgeniy Polyakov',
'[email protected]' => 'John Stultz',
'[email protected]' => 'Josef Siemes',
'[email protected]' => 'James Simmons',
'[email protected]' => 'James Simmons',
'jsimmons@kozmo.(none)' => 'James Simmons',
'[email protected]' => 'James Simmons',
'[email protected]' => 'James Simmons',
'[email protected]' => 'John Marvin',
'[email protected]' => 'Jean Tourrilhes',
'[email protected]' => 'Jean Tourrilhes',
'[email protected]' => 'John Tyner',
'[email protected]' => 'Jun Nakajima',
'[email protected]' => 'J.I. Lee',
'[email protected]' => 'Jonathan Woithe',
'[email protected]' => 'Kimio Suganuma',
'[email protected]' => 'Karol Kasprzak', # by Kristian Peters
'[email protected]' => 'Patrick McHardy',
'[email protected]' => 'Jozsef Kadlecsik',
'[email protected]' => 'Kai Germaschewski',
'[email protected]' => 'Kai Makisara',
'[email protected]' => 'Kai Reichert',
'[email protected]' => 'Kai Germaschewski',
'[email protected]' => 'Kai Germaschewski',
'[email protected]' => 'Tomas Szepe',
'[email protected]' => 'Kanoj Sarcar', # sent by Arnaldo Carvalho de Melo
'[email protected]' => 'Kanoj Sarcar',
'[email protected]' => 'Keith Owens',
'[email protected]' => 'Keith Owens', # sent by himself
'[email protected]' => 'K�re S�rs',
'[email protected]' => 'Kasper Dupont',
'[email protected]' => 'Keith Underwood',
'[email protected]' => 'Kenneth W. Chen',
'[email protected]' => 'Paul Clements',
'[email protected]' => 'Kent Yoder',
'[email protected]' => 'Ari Juhani H�meenaho',
'[email protected]' => 'Khalid Aziz',
'[email protected]' => 'Khalid Aziz',
'[email protected]' => 'Krzysztof Halasa',
'[email protected]' => 'Ravikiran G. Thirumalai',
'[email protected]' => 'Andras Kis-Szabo', # google (netfilter-ext HOWTO)
'[email protected]' => 'Karsten Keil',
'[email protected]' => 'Kendrick M. Smith',
'[email protected]' => 'Erik Inge Bols�',
'[email protected]' => 'Kochi Takayoshi',
'[email protected]' => 'Jun Komuro', # google
'[email protected]' => 'Gerd Knorr',
'[email protected]' => 'Gerd Knorr',
'[email protected]' => 'Krishna Kumar',
'[email protected]' => 'Luca Tettamanti',
'[email protected]' => 'Kuba Ober',
'[email protected]' => 'Robert Kuebel',
'[email protected]' => 'Kunihiro Ishiguro',
'[email protected]' => 'Alexey Kuznetsov',
'[email protected]' => 'Alexey Kuznetsov',
'[email protected]' => 'Ladislav Michl',
'[email protected]' => 'Harald Welte',
'[email protected]' => 'Joy Latten',
'[email protected]' => 'Laurent Latil',
'[email protected]' => 'Lawrence Walton',
'[email protected]' => 'Luca Barbieri',
'[email protected]' => 'Richard Russon',
'[email protected]' => 'Lee Nash', # lbdb
'[email protected]' => 'Leigh Brown', # lbdb
'[email protected]' => 'John Levon',
'[email protected]' => 'Dominik Brodowski',
'[email protected]' => 'Jan Marek',
'[email protected]' => 'Lionel Bouton',
'[email protected]' => 'Martin Diehl',
'[email protected]' => 'Liyang Hu',
'[email protected]' => 'Larry McVoy',
'[email protected]' => 'Stephen Lord',
'[email protected]' => 'Louis Zhuang',
'[email protected]' => 'Bruce B. Lowekamp', # lbdb
'[email protected]' => 'Luben Tuikov',
'[email protected]' => 'Luc Van Oostenryck', # lbdb
'[email protected]' => 'Lucas Correia Villa Real', # google
'[email protected]' => 'Marc-Christian Petersen',
'[email protected]' => 'Marcus Alanen',
'[email protected]' => 'Armin Schindler',
'[email protected]' => 'Maciej W. Rozycki',
'[email protected]' => 'Maneesh Soni',
'[email protected]' => 'Manfred Spraul',
'[email protected]' => 'Manik Raina',
'[email protected]' => 'Manish Lachwani',
'[email protected]' => 'Keith Mannthey',
'[email protected]' => 'Marc Boucher',
'[email protected]' => 'Marcel Holtmann', # sent by himself
'[email protected]' => 'Marcelo Tosatti',
'[email protected]' => 'Marcelo Tosatti', # guessed
'[email protected]' => 'Marcelo Tosatti',
'[email protected]' => 'Marcus Sundberg',
'[email protected]' => 'Marek Michalkiewicz',
'[email protected]' => 'Mark W. McClelland',
'[email protected]' => 'Mark W. McClelland',
'[email protected]' => 'Mark Haverkamp',
'[email protected]' => 'Martin J. Bligh',
'[email protected]' => 'Martin Brulisauer',
'[email protected]' => 'Martin Schwenke',
'[email protected]' => 'Chris Mason',
'[email protected]' => 'Matt Domsch', # sent by himself
'[email protected]' => 'Matthew Wilcox',
'[email protected]' => 'Heinz J. Mauelshagen',
'[email protected]' => 'Maksim Krasnyanskiy',
'maxk@viper.(none)' => 'Maksim Krasnyanskiy', # from shortlog
'[email protected]' => 'Maksim Krasnyanskiy',
'[email protected]' => 'Martin J. Bligh',
'[email protected]' => 'Marc-Christian Petersen',
'[email protected]' => 'Matthew Dharm',
'[email protected]' => 'Matthew Dharm',
'[email protected]' => 'Matthew Dharm',
'[email protected]' => 'Michael Elizabeth Chastain',
'[email protected]' => 'Marcus Meissner',
'[email protected]' => 'Mark A. Greer', # lbdb
'[email protected]' => 'Michael Weber', # google
'[email protected]' => 'Michal Jaegermann',
'[email protected]' => 'Michael Still',
'[email protected]' => 'Mikael Starvik',
'[email protected]' => 'Michael Hayes',
'[email protected]' => 'Mike Phillips',
'[email protected]' => 'Mikael Pettersson',
'[email protected]' => 'Mikael Pettersson',
'[email protected]' => 'Mikulas Patocka',
'[email protected]' => 'Miles Bader',
'[email protected]' => 'Miles Lane',
'[email protected]' => 'Michael Milligan',
'[email protected]' => 'Milton Miller', # by Kristian Peters
'[email protected]' => 'Ingo Molnar',
'[email protected]' => 'Ingo Molnar',
'[email protected]' => 'Martin Mares',
'[email protected]' => 'Mitsuru Kanda',
'[email protected]' => 'Martin K. Petersen', # lbdb
'[email protected]' => 'Mario Lang', # google
'[email protected]' => 'Mirko Lindner',
'[email protected]' => 'Montavista Software, Inc.',
'[email protected]' => 'Mark McClelland',
'[email protected]' => 'Patrick Mochel',
'[email protected]' => 'Patrick Mochel',
'[email protected]' => 'Patrick Mochel',
'[email protected]' => 'Michal Ostrowski',
'[email protected]' => 'Matt Porter',
'[email protected]' => 'Matt Wilson',
'[email protected]' => 'Mufasa Yang', # sent by himself
'[email protected]' => 'Muli Ben-Yehuda', # sent by himself
'[email protected]' => 'Muli Ben-Yehuda',
'[email protected]' => 'Michael Westermann',
'[email protected]' => 'Marc Zyngier',
'[email protected]' => 'Don Dugger',
'[email protected]' => 'Itai Nahshon',
'[email protected]' => 'Nathan Scott',
'[email protected]' => 'Neil Brown',
'[email protected]' => 'Neil Turton',
'[email protected]' => 'Nemosoft Unv.',
'[email protected]' => 'Brian J. Murrell',
'[email protected]' => 'Nick Holloway',
'[email protected]' => 'Nicolas Pitre',
'[email protected]' => 'Nicolas Aspert',
'[email protected]' => 'Nicolas Mailhot',
'[email protected]' => 'Niels Kristian Bech Jensen',
'[email protected]' => 'Nathan Laredo',
'[email protected]' => 'Nicholas Miell',
'[email protected]' => 'Andreas Busch',
'[email protected]' => 'Olaf Kirch', # lbdb
'olaf.dietsche#[email protected]' => 'Olaf Dietsche',
'olaf.dietsche' => 'Olaf Dietsche',
'[email protected]' => 'Oleg Nesterov',
'[email protected]' => 'Olaf Hering',
'[email protected]' => 'Dave Olien',
'[email protected]' => 'Oliver Neukum',
'[email protected]' => 'Oliver Neukum',
'[email protected]' => 'Oliver Neukum',
'[email protected]' => 'Oliver Neukum',
'[email protected]' => 'Orjan Friberg',
'[email protected]' => 'Oskar Schirmer', # sent by himself
'[email protected]' => 'Willem Riede',
'[email protected]' => 'Owen Taylor',
'[email protected]' => 'Glen Overby',
'[email protected]' => 'Philipp G�hring',
'[email protected]' => 'Peter De Shrijver',
'[email protected]' => 'Paul Gortmaker',
'[email protected]' => 'Pamela Delaney',
'[email protected]' => 'Petr Baudis',
'[email protected]' => 'Patrick Mansfield',
'[email protected]' => 'Gabriel Paubert',
'[email protected]' => 'Paul Mundt', # google
'[email protected]' => 'Paul Fulghum',
'[email protected]' => 'Paul Mackerras',
'[email protected]' => 'Paul Mackerras',
'[email protected]' => 'Paul Mackerras',
'[email protected]' => 'Paul Mackerras',
'[email protected]' => 'Pavel Jan�k',
'[email protected]' => 'Pavel Machek',
'[email protected]' => 'Pavel Machek',
'[email protected]' => 'Andrey Panin',
'[email protected]' => 'Badari Pulavarty',
'[email protected]' => 'Pam Delaney',
'[email protected]' => 'Jeroen Vreeken',
'[email protected]' => 'Petr Konecny',
'[email protected]' => 'Jaroslav Kysela',
'[email protected]' => 'Jaroslav Kysela',
'[email protected]' => 'Jaroslav Kysela',
'[email protected]' => 'Peter Bergner',
'[email protected]' => 'Peter Samuelson',
'[email protected]' => 'Peter Chubb',
'[email protected]' => 'Peter Chubb',
'[email protected]' => 'Peter Osterlund',
'[email protected]' => 'Petko Manolov',
'[email protected]' => 'Petko Manolov',
'[email protected]' => 'Petko Manolov',
'[email protected]' => 'Petko Manolov',
'[email protected]' => 'Petko Manolov',
'[email protected]' => 'Petr Vandrovec',
'[email protected]' => 'Petri Koistinen',
'[email protected]' => 'Mike Phillips',
'[email protected]' => 'Pawel Kot',
'[email protected]' => 'Paul Larson',
'[email protected]' => 'Pedro Lopez-Cabanillas',
'[email protected]' => 'Paul Menage',
'[email protected]' => 'Matt Porter',
'[email protected]' => 'Ingo Albrecht',
'[email protected]' => 'Pavel Roskin',
'[email protected]' => 'Peter W�chtler',
'[email protected]' => 'Daniel Quinlan',
'[email protected]' => 'Juan Quintela',
'[email protected]' => 'Rogier Wolff', # lbdbq
'[email protected]' => 'Ralf B�chle',
'[email protected]' => 'Ralf B�chle',
'[email protected]' => 'Daniel A. Nobuto',
'[email protected]' => 'Randy Dunlap',
'[email protected]' => 'Raul Nunez de Arenas Coronado',
'[email protected]' => 'Ray Lee',
'[email protected]' => 'Richard Hitt', # asked him, he prefers Richard
'[email protected]' => 'Robert Cardell',
'[email protected]' => 'Bob Tracy',
'[email protected]' => 'Randy Dunlap',
'[email protected]' => 'Udo A. Steinberg',
'[email protected]' => 'Hans Reiser',
'[email protected]' => 'Bob Miller',
'[email protected]' => 'Richard Gooch',
'[email protected]' => 'Richard Gooch',
'[email protected]' => 'Roberto Gordo Saez',
'[email protected]' => 'Richard Hirst',
'[email protected]' => 'Riley Williams',
'[email protected]' => 'Richard Brunner',
'[email protected]' => 'Rik van Riel',
'[email protected]' => 'Rob Weryk',
'[email protected]' => 'Roger Luethi',
'[email protected]' => 'Romain Lievin',
'[email protected]' => 'Russell King',
'[email protected]' => 'Russell King',
'[email protected]' => 'Robert Love',
'[email protected]' => 'Rob Radez',
'[email protected]' => 'Robert Olsson',
'[email protected]' => 'Rohit Seth',
'[email protected]' => 'Paul Rolland',
'[email protected]' => 'Roland McGrath',
'[email protected]' => 'Roland McGrath',
'[email protected]' => 'Roland Dreier',
'[email protected]' => 'Fran�ois Romieu',
'[email protected]' => 'Fran�ois Romieu',
'root@viper.(none)' => 'Maxim Krasnyansky',
'[email protected]' => 'Robert Read',
'[email protected]' => 'Rob Scott',
'[email protected]' => 'Richard Henderson',
'[email protected]' => 'Richard Henderson',
'[email protected]' => 'Richard Henderson',
'[email protected]' => 'Richard Henderson',
'[email protected]' => 'Richard Henderson',
'[email protected]' => 'Richard Henderson',
'[email protected]' => 'Richard Henderson',
'[email protected]' => 'Rui Sousa',
'[email protected]' => 'Rusty Russell',
'[email protected]' => 'Randy Vinson',
'[email protected]' => 'Randy Hron',
'[email protected]' => 'Richard Zidlicky',
'[email protected]' => 'Michal Sabala', # google
'[email protected]' => 'Thomas Sailer',
'[email protected]' => 'Sam Ravnborg',
'[email protected]' => 'Sam Ravnborg',
'[email protected]' => 'Vitezslav Samel',
'[email protected]' => 'Samuel Thibault',
'[email protected]' => 'Eric Sandeen',
'[email protected]' => 'Santiago A. Nullo', # sent by self
'[email protected]' => 'Pasi Sarolahti',
'[email protected]' => 'sawa',
'[email protected]' => 'Erik Schoenfelder',
'[email protected]' => 'Andreas Schwab',
'[email protected]' => 'Martin Schwidefsky',
'[email protected]' => 'Scott Feldman',
'[email protected]' => 'Scott Anderson',
'[email protected]' => 'Scott Murray',
'[email protected]' => 'Stephen C. Tweedie',
'[email protected]' => 'Stephen D. Smalley',
'[email protected]' => 'Stephen D. Smalley',
'[email protected]' => 'Sebastian Dr�ge',
'[email protected]' => 'Steve Best',
'[email protected]' => 'Stephen Rothwell',
'[email protected]' => 'Dave Kleikamp',
'[email protected]' => 'Dave Kleikamp',
'[email protected]' => 'Dave Kleikamp', # lbdb
'[email protected]' => 'Stephen Hemminger',
'[email protected]' => 'Michael Shields',
'[email protected]' => 'Shing Chuang',
'[email protected]' => 'Szil�rd P�sztor', # google
'[email protected]' => 'Simon Burley',
'[email protected]' => 'Skip Ford',
'[email protected]' => 'Stuart Lynne',
'[email protected]' => 'Nathan Dabney',
'[email protected]' => 'Geoffrey Lee', # by himself
'[email protected]' => 'Solar Designer',
'[email protected]' => 'Steven Parker', # by Duncan Laurie
'[email protected]' => 'Jeremie Koenig',
'[email protected]' => 'Simon Evans', # by Kristian Peters
'[email protected]' => 'Sridhar Samudrala',
'[email protected]' => 'Sridhar Samudrala',
'[email protected]' => 'Sridhar Samudrala',
'[email protected]' => 'Sridhar Samudrala',
'[email protected]' => 'Stefan Rompf',
'[email protected]' => 'Stanley Wang',
'[email protected]' => 'Jack Steiner',
'[email protected]' => 'Daniel Stekloff',
'[email protected]' => 'Stelian Pop',
'[email protected]' => 'Stelian Pop',
'[email protected]' => 'Alan Stern',
'[email protected]' => 'Alan Stern', # lbdb
'[email protected]' => 'Stephen Cameron',
'[email protected]' => 'Steven Whitehouse',
'[email protected]' => 'Steven Whitehouse',
'[email protected]' => 'SL Baur',
'[email protected]' => 'Steve French',
'[email protected]' => 'Steve French',
'[email protected]' => 'Stuart MacDonald',
'[email protected]' => 'Mike Sullivan',
'[email protected]' => 'Tim Hockin', # by Duncan Laurie
'[email protected]' => 'Sunil Saxena',
'[email protected]' => 'Alan Swanson',
'[email protected]' => 'Tomas Szepe',
'[email protected]' => 'Takayoshi Kouchi',
'[email protected]' => 'Taisuke Yamada',
'[email protected]' => 'Hirokazu Takahashi',
'[email protected]' => 'Todd Inglett',
'[email protected]' => 'David Weinehall', # by himself
'[email protected]' => 'David Weinehall', # by himself
'[email protected]' => 'Tom Callaway',
'[email protected]' => 'Tero Pirkkanen', # by Kristian Peters
'[email protected]' => 'Tim Hockin', # by Duncan Laurie
'[email protected]' => 'Tim Hockin', # by Duncan Laurie
'[email protected]' => 'Florian Thiel', # lbdb
'[email protected]' => 'Tim Hockin',
'[email protected]' => 'Tim Hockin',
'[email protected]' => 'Thomas Walpuski',
'[email protected]' => 'Tigran Aivazian',
'[email protected]' => 'Tim Schmielau',
'[email protected]' => 'Tom McReynolds',
'[email protected]' => 'Thomas Molina',
'[email protected]' => 'Tom Lendacky',
'[email protected]' => 'Osamu Tomita',
'[email protected]' => 'Ed Tomlinson',
'[email protected]' => 'Tony Luck',
'[email protected]' => 'Anthony J. Breeds-Taurima',
'[email protected]' => 'Linus Torvalds',
'[email protected]' => 'Linus Torvalds',
'[email protected]' => 'Linus Torvalds',
'[email protected]' => 'Linus Torvalds',
'[email protected]' => 'Linus Torvalds',
'[email protected]' => 'Linus Torvalds',
'[email protected]' => 'Tom Rini',
'[email protected]' => 'Tom Rini',
'[email protected]' => 'Trond Myklebust',
'[email protected]' => 'Thierry Vignaud',
'[email protected]' => 'Tvrtko A. Ursulin',
'[email protected]' => 'Tim Waugh',
'[email protected]' => "Theodore Ts'o", # web.mit.edu/tytso/www/home.html
'[email protected]' => "Theodore Ts'o",
'[email protected]' => "Theodore Ts'o", # guessed
'[email protected]' => 'Urban Widmark',
'[email protected]' => 'Joshua Uziel',
'[email protected]' => 'Laszlo Valko',
'[email protected]' => 'Petr Vandrovec',
'[email protected]' => 'Martin H. VanLeeuwen',
'[email protected]' => 'Thibaut Varene',
'[email protected]' => 'Vincent B�ron',
'[email protected]' => 'Venkatesh Pallipadi',
'[email protected]' => 'Alexander Viro',
'[email protected]' => 'Paul Vojta',
'[email protected]' => 'Vojtech Pavlik',
'[email protected]' => 'Vojtech Pavlik',
'[email protected]' => 'Vojtech Pavlik', # added by himself
'[email protected]' => 'Werner Almesberger',
'[email protected]' => 'Thomas Wahrenbruch',
'[email protected]' => 'Derek Atkins',
'[email protected]' => 'Wolfgang Denk',
'[email protected]' => 'Wes Schreiner',
'[email protected]' => 'Wolfram Gloger', # lbdb
'[email protected]' => 'Wayne Whitney',
'[email protected]' => 'William R. Sowerbutts',
'[email protected]' => 'Matthew Wilcox',
'[email protected]' => 'Matthew Wilcox',
'[email protected]' => 'Willy Tarreau',
'[email protected]' => 'Wilson Chen', # google
'[email protected]' => 'Wim Van Sebroeck',
'[email protected]' => 'William Lee Irwin III',
'[email protected]' => 'Wolfgang Fritz', # by Kristian Peters
'[email protected]' => 'Wolfgang Muees',
'[email protected]' => 'Willem Riede',
'[email protected]' => 'Willem Riede',
'[email protected]' => 'William Stinson',
'[email protected]' => 'William Stinson',
'[email protected]' => 'Tomas Kasparek',
'[email protected]' => 'Yaacov Akiba Slama',
'[email protected]' => 'Yokota Hiroshi',
'[email protected]' => 'Hideaki Yoshifuji', # lbdb
'[email protected]' => 'Yuri Per', # lbdb
'[email protected]' => 'Pete Zaitcev',
'[email protected]' => 'Zinx Verituse',
'[email protected]' => 'Roman Zippel',
'[email protected]' => 'Irene Zubarev', # google
'[email protected]' => 'Zwane Mwaikambo',
'[email protected]' => 'Zwane Mwaikambo',
'[email protected]' => 'Zwane Mwaikambo',
'[email protected]' => 'Zwane Mwaikambo',
'~~~~~~thisentrylastforconvenience~~~~~' => 'Cesar Brutus Anonymous'
);

sub doprint(\%@ ); # forward declaration

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];
}

# case insensitive string comparison
# FIXME: use locale?
sub caseicmp { uc($a) cmp uc($b) };

# case insensitive string comparison by surname
# Strings are of the form
# "Firstname Surname <mailaddress>"
# or
# "<mailaddress>"
sub caseicmpbysurname {
  my $alast = "";
  my $blast = "";
  if ($a =~ m/(\S+)\s*(\s\<|$)/) { $alast = $1; }
  if ($b =~ m/(\S+)\s*(\s\<|$)/) { $blast = $1; }
  return uc($alast . $a) cmp uc($blast . $b);
}

my ($author, $address, $name);
# * $address is always an email address
# * $author can be the email address or Joe N. Sixpack II <[email protected]>
#   (ready formatted to print)
# * $name is the name (Joe N. Sixpack II) or the mail address
#   (<[email protected]>) 

sub get_name()   { return $name; }
sub get_author() { return $author; }

# This table maps MODE => { myhash }
# myhash knows the keys "index" and "print" to choose the respective functions
my %table =
  (
   'oneline' => { 'index' => \&get_name,
		  'print' => \&print_oneline },
   'terse'   => { 'index' => \&get_name,
		  'print' => \&print_terse },
   'grouped' => { 'index' => \&get_author,
		  'print' => \&print_grouped },
   'full'    => { 'index' => \&get_author,
		  'print' => \&print_full }
  );

# temp store
my $indexby;

# The sort function we will use
my $namesortfunc;

# Global store #############
# We store our options here.
my %opt;

# As we are parsing, the log is accumulated in the @cur array.  When
# we are done with one item (end of input or new mail address found),
# stuff a copy of this @cur array into the %log hash.
sub append_item(\%@)
# arguments: reference to hash
#            array to push
{
  my $log = shift;
  my @cur = @_;
  return unless @cur;
  return unless &$indexby;
  $log->{&$indexby} = () unless defined $log->{&$indexby};

  # strip trailing blank lines
  my $t;
  while (($t = pop(@cur)) eq '') { };
  push @cur, $t;

  # store the array
  push @{$log->{&$indexby}}, [@cur];
}

# Remove duplicates from hash, without changing the order.
# Prefix duplicates with the count.
sub countdups(@) {
  my %t;
  croak "do not call removedups() in scalar context" unless wantarray;
  my @u = grep (!$t{lc $_}++, @_);
  return map {
    $t{lc $_} > 1 ? sprintf("%d x ", $t{lc $_}) . $_ : $_; 
  } @u;
}

# Remove duplicates from array, without changing the order. The
# duplicates need not follow each other, so A B A is properly
# stripped down to A B
sub removedups(@) {
  my %t;
  croak "do not call removedups() in scalar context" unless wantarray;
  return grep (!$t{lc $_}++, @_);
}

# Compress the hash passed in, depending on the --compress and --count
# options in the %opt hash.
sub compress(@) {
  croak "do not call compress() in scalar context" unless wantarray;
  if ($opt{compress}) {
    if ($opt{count}) {
      return countdups(@_);
    } else {
      return removedups(@_);
    }
  } else {
    return @_;
  }
}

# report write error, exit
# do not return
sub write_error() {
  croak "Write error: $!\nAborting";
  exit (1);
}

# implementation of "grouped" output:
# author:
#   first line of log1
#   first line of log2
sub print_grouped(\%) {
  my $log = shift;
  for (sort $namesortfunc keys %$log) {
    my @lines = compress(map { $_->[0] . "\n"; } @{$log->{$_}});
    if ($opt{width}) {
      @lines = map { expand(wrap($indent1, $indent, ($_))); } @lines;
    } else {
      @lines = map { "$indent1$_" } @lines;
    }
    printtag($_) or write_error();
    print join("", @lines), "\n" or write_error();
  }
}

# implementation of "full" output
# author:
#   o log1
#     more information on changeset1
#   o log2
#     more information on changeset2
sub print_full(\%) {
  my $log = shift;
  for (sort $namesortfunc keys %$log) {
    printtag($_) or write_error();
    foreach (compress(@{$log->{$_}})) {
      my @lines = map { s/^\t//; "$_\n"; } @$_;
      if ($opt{width}) {
	@lines = expand(wrap($indent1, $indent, @lines));
      } else {
	@lines = map { "$indent$_"; } @lines;
	substr($lines[0], $[, length($indent1)) = $indent1;
      }
      print join("", @lines), "\n"  or write_error();
    }
  }
  print "\n"  or write_error();
}

# implementation of "terse" output
# with --swap          without --swap
# author1: log1        log1    (author1)
# author1: log2        log2    (author2)
# author2: log3        log3    (author3)
sub print_terse(\%) {
  my $log = shift;
  for (sort $namesortfunc keys %$log) {
    my $a = $_;
    if ($opt{width}) {
      if ($opt{swap}) {
	foreach (compress(map { $_->[0]; } @{$log->{$_}})) {
	  my @lines = expand(wrap($indent1, $indent, ("$a: $_")));
	  print join("\n", @lines), "\n"  or write_error();
	}
      } else {
	# width, but not swap set
	foreach (compress(map { $_->[0]; } @{$log->{$_}})) {
	  my @addr = expand(split(/\n/, wrap('', $indent, " ($a)")));
	  my @lines = expand(split(/\n/, wrap($indent1, $indent, ($_))));

	  if (length($lines[$#lines]) + length($addr[0]) > $opt{width}) {
	    push @lines, '';
	  }
	  $lines[$#lines] .= sprintf("%*s", $opt{width}
				     - length($lines[$#lines]), $addr[0]);
	  shift @addr;
	  print join("\n", @lines), "\n"  or write_error();
	  foreach (@addr) {
	    printf "%*s\n", $opt{width}, $_  or write_error();
	  }
	}
      }
    } else {
      # using the ?: operator within the map is more maintainable, but
      # less efficient.
      if ($opt{swap}) {
	print join("\n", map { "$indent1$a: $_" }
		   compress(map { $_->[0]; } @{$log->{$_}})), "\n"
		     or write_error();
      } else {
	print join("\n", map { "$indent1$_ ($a)" } 
		   compress(map { $_->[0]; } @{$log->{$_}})), "\n"
		     or write_error();
      }
    }
  }
}

# implementation of "oneline" output
# which is similar to terse but reformats to one line exactly
# with --swap          without --swap
# author1: log1        log1    (author1)
# author1: log2        log2    (author2)
# author2: log3        log3    (author3)
sub print_oneline(\%) {
  my $log = shift;
  for (sort $namesortfunc keys %$log) {
    my $a = $_;
    if ($opt{width}) {
      if ($opt{swap}) {
	foreach (compress(map { $_->[0]; } @{$log->{$_}})) {
	  my $str = "$a: $_";
	  if (length($str) > $opt{width}) {
	    printf "%-.*s...\n", $opt{width}-3, $indent1 . "$a: $_"
	      or write_error();
	  } else {
	    printf "%-.*s\n", $opt{width}, $indent1 . "$a: $_"
	      or write_error();
	  }
	}
      } else { # not swapping
	foreach (compress(map { $_->[0]; } @{$log->{$_}})) {
	  my $l = $opt{width} - length($indent1) - length($a) - 3;
	  if (length($_) > $l) {
	    $l -= 3;
	    printf "%s%-*.*s... (%s)\n", $indent1, $l, $l, $_, $a;
	  } else {
	    printf "%s%-*.*s (%s)\n", $indent1, $l, $l, $_, $a;
	  }
	}
      }
    } else {
      # not $opt{width} -> same as print_terse
      print_terse(%$log);
    }
  }
}

# Abbreviate all components of the name except the last.  If capital
# Roman numerals form the last component, leave that and the previous
# component alone.
sub abbreviate_name($ ) {
  my @a = split /\s+/, $_[0];

  # treat Roman numerals as last part of name
  my $off = 0;
  $off = 1 if ($a[$#a] =~ /^[IVXLCMD]+$/);

  for (my $i = 0; $i < $#a - $off; $i++) {
    $a[$i] =~ s/^(.).*/$1./;
  }
  return join(" ", @a);
}

# Read a file and parse it into the %log hash.
sub parse_file(\%$$ ) {
# arguments: %log hash
#            file name
#            file handle (IO::Handle or IO::File)
  croak unless wantarray;
  my $log = shift;
  my $fn = shift;
  my $fh = shift;
  my @prolog;
  local $_;

  # initialize
  my @cur = ();
  my $first = 0;
  my $firstpar = 0;
  undef $address;

  # now go!

  # NOTE: the first @cur item can consist of multiple lines in the
  # source file which are joined together. This happens when the first
  # paragraph is longer than a single line.
  while($_ = $fh -> getline) {
    chomp;
    s/^  (\S)/\t$1/;
    # expand all tabs but the first
    $_ = expand($_);
    s/^        /\t/;

    if (defined $address and $opt{multi}
	and m{^[^<[:space:]]} and not m{^ChangeSet@}) {
      # if we are in multi mode, if we encounter a non-address
      # left-justified line, flush all data and print the header. The
      # defined $address trick lets this only trigger to switch back
      # from "log entry" to "prolog" mode
      append_item(%$log, @cur); @cur = ();
      doprint(%$log, @prolog);
      print "\n" or write_error(); # print blank line between changelogs
      @prolog = ($_);
      undef %$log;
      undef $address;
    } elsif (m{^<([^>]+)>} or m{^ChangeSet@[0-9.]+,\s*[-0-9:+ ]+,\s*(.*)}) {
      # go figure if a line starts with an address, if so, take it
      # resolve the address to a name if possible
      append_item(%$log, @cur); @cur = ();
      $address = lc($1);
      $address =~ s/\[[^]]+\]$//;
      $name = rmap_address($address);
      if ($name ne $address) {
	if ($opt{'abbreviate-names'}) {
	  $name = abbreviate_name($name);
	}
	$author = $name . ' <' . $address . '>';
      } else {
	$author = '<' . $address . '>';
      }
      $first = 1;
      $firstpar = 1;
    } elsif ($first) {
      # we have a "first" line after an address, take it, 
      # strip common redundant tags

      # kill "PATCH" tag
      s/^\s*\[PATCH\]//;
      s/^\s*PATCH//;
      s/^\s*[-:]+\s*//;

      # strip trailing colon or period, and if we strip one,
      # we don't parse further lines as part of the first paragraph
      if (s/[:.]+\s*$//) { $firstpar = 0; }

      # kill leading and trailing whitespace for consistent indentation
      s/^\s+//; s/\s+$//;

      push @cur, $_;
      $first = 0;
    } elsif (defined $address) {
      # second or subsequent lines -- if in first paragraph,
      # append this line to the first log line.
      if (m/^\s*$/) { $firstpar = 0; }
      elsif (m/^\s*[-*o\#]/) { $firstpar = 0; }
      if ($firstpar) {
	s/^\s*/ /;
	$cur[0] .= $_;
      } else {
	push @cur, $_;
      }
      # we don't parse further lines as part of the first paragraph
      if (s/[:.]+\s*$//) { $firstpar = 0; }
    } else {
      # store header before a changelog
      push @prolog, $_;
    }
  }

  if ($fh -> error) {
    die "Error while reading from \"$fn\": $!";
  }

  # at file end, flush @cur array to %log.
  append_item(%$log, @cur);

  return @prolog;
}

# print a word-wrapped name or mail address, followed by a trailing colon.
# used by print_grouped and print_full
# passes the return value of print back up
sub printtag($ ) {
  my $a = shift;
  $a .= ':';
  return print $opt{width} ? expand(wrap("", "", ($a))) : $a, "\n";
}

# === 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!");
#	    "bitkeeper|bk!");

# How do we parse them?
if ($Getopt::Long::VERSION gt '2.24') {
  Getopt::Long::Configure("gnu_getopt");
}

# set default options
$opt{mode} = 'grouped';
$opt{warn} = 1;

# Parse from environment, temporarily storing the original @ARGV.
if (defined $ENV{LINUXKERNEL_BK_FMT}) {
  my @savedargs = @ARGV;
  @ARGV = parse_line('\s+', 0, $ENV{LINUXKERNEL_BK_FMT});
  GetOptions(\%opt, @opts)
    or pod2usage(-verbose => 0,
		 -message => $0 . ': error in $LINUXKERNEL_BK_FMT');
  push @ARGV, @savedargs;
}

# Parse command line. Handle help, check for errors.
GetOptions(\%opt, @opts) or pod2usage(-verbose => 0);
pod2usage(-verbose => 1) if $opt{help};
pod2usage(-verbose => 2) if $opt{man};
pod2usage(-verbose => 0,
	  -message => ("$0: Unknown mode specified.\nValid modes are:\n    "
		       . join(" ", sort keys %table) . "\n"))
  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));
pod2usage(-verbose => 0,
	  -message => "$0: Must have one or two arguments in --bitkeeper mode.")
  if ($opt{bitkeeper} && (@ARGV < 1 || @ARGV > 2));
pod2usage(-verbose => 0,
	  -message => "$0: You cannot use --merge and --multi at the same time.")
  if ($opt{merge} and $opt{multi});

# Shortcut for programmer convenience :-)
$indexby = $table{$opt{mode}}->{'index'};

# --count implies --compress
if ($opt{count}) { $opt{compress} = 1; }

# Set the sort function
$namesortfunc = \&caseicmp;
if ($opt{'by-surname'}) { $namesortfunc = \&caseicmpbysurname; }

# if --width is without argument or the argument is zero,
# try to figure $COLUMNS or fall back to 80.
if (exists $opt{width} and not $opt{width}) {
  $opt{width} = $ENV{COLUMNS} ? $ENV{COLUMNS} : 80;
}

# Print the passed-in array linewise, checking for write errors
# Then call the configured function to print %log formatted
sub doprint(\%@ ) {
  my $log = shift;
  print join("\n", @_), "\n" or write_error();
  $table{$opt{mode}}->{print}->($log);
}

# --------------------------------------------------------------------
# Global initializations
$Text::Tabs::tabstop = 8;
$Text::Wrap::huge = 'wrap';
if ($opt{width}) {
  $Text::Wrap::columns = $opt{width};
}

if ($debug) {
  print STDERR "DEBUG: Options summary:\n";
  while (my ($k, $v) = each %opt) { print STDERR "DEBUG:   '$k' => '$v'\n"; }
  print STDERR "DEBUG: Arguments summary:\n";
  foreach (@ARGV) { print STDERR "DEBUG:   '$_'\n"; }
}

# Main program
my @prolog;
my %log;

if($opt{bitkeeper}) {
  # in Bitkeeper mode, try to figure the change set, and connect the
  # bk program to our stdin.
  die "not yet implemented";
} elsif (@ARGV) {
  # file names
  foreach my $fn (@ARGV) {
    my $fh = new IO::File;
    $fh->open($fn, "r")
      or die "cannot open \"$fn\": $!\nAborting";
    push @prolog, parse_file(%log, $fn, $fh);
    if (not $opt{merge}) {
      doprint(%log, @prolog);
      undef %log;
    }
    undef @prolog;
  }

  if ($opt{merge}) {
    doprint(%log, ());
  }
} else {
  # stdin
  my @prolog;
  my $fh = new IO::Handle;
  $fh->fdopen(fileno(STDIN), "r")
    or die "cannot open stdin: $!\nAborting";
  @prolog = parse_file(%log, "stdin", $fh);
  doprint(%log, @prolog);
}

# Flush STDOUT to prevent clobbering STDOUT with 2>&1-style redirections.
$| = 1;

# Warn about unknown addresses
if ($opt{warn}) {
  foreach (sort caseicmp keys %address_unknown) {
    print STDERR "Warning: unknown address \"$_\"\n" or write_error();
  }
}

__END__
# --------------------------------------------------------------------
# $Log: lk-changelog.pl,v $
# Revision 0.77  2003/02/27 10:52:59  vita
# Added 7 new names for addresses from both current BK trees.
#
# Revision 0.76  2003/02/24 20:04:23  vita
# Added 7 new names for addresses from current linux-2.5 BK tree.
#
# Revision 0.75  2003/02/21 12:41:18  vita
# Added 5 new names for addresses from current linux-2.4 BK tree.
#
# Revision 0.74  2003/02/19 11:15:14  vita
# Added 7 new addresses found by Google.
#
# Revision 0.73  2003/02/14 10:45:45  vita
# Added 5 new addresses found by Google.
#
# Revision 0.72  2003/02/06 16:10:23  vita
# Added 6 new addresses found by Google.
#
# Revision 0.71  2003/02/05 11:22:06  emma
# New addresses Vita pulled out.
#
# Revision 0.70  2003/02/03 14:58:04  emma
# Vita dug out more addresses.
#
# Revision 0.69  2003/01/28 23:30:02  emma
# Another four addresses by Vita.
#
# Revision 0.68  2003/01/20 10:22:08  emma
# Add new address for Rolf Eike Beer.
#
# Revision 0.67  2003/01/19 14:32:55  emma
# Further addresses figured out by Vita.
#
# Revision 0.66  2003/01/18 12:44:33  emma
# New addresses found out by Vita.
#
# Revision 0.65  2003/01/13 14:12:09  emma
# New addresses dug out by Vita.
#
# Revision 0.64  2003/01/08 14:48:50  emma
# New addresses by Vita.
#
# Revision 0.63  2003/01/08 14:47:37  emma
# New addresses by Vita.
#
# Revision 0.62  2002/12/27 16:59:28  emma
# Another ten addresses sent by Vitezslav Samel.
#
# Revision 0.61  2002/12/14 14:28:49  emma
# Bjorn Helgaas only uses the transscribed version of his name himself.
#
# Revision 0.60  2002/12/13 14:51:35  emma
# Next dozen of addresses digged out by Vita.
#
# Revision 0.59  2002/12/11 12:11:51  emma
# Workaround: strip trailing [tag] from mail addresses, reported by Marcel
#     Holtmann.
# Add some new addresses.
#
# Revision 0.58  2002/12/07 15:14:57  emma
# More addresses figured by Vitezslav Samel.
#
# Revision 0.57  2002/12/07 15:08:34  emma
# 3 more addresses.
#
# Revision 0.56  2002/11/28 02:32:11  emma
# List David Weinehall.
#
# Revision 0.55  2002/11/27 04:44:54  emma
# Add [email protected] for Keith Owens as per his own request.
#
# Revision 0.54  2002/11/26 23:27:11  emma
# Merge changes from Linus' version.
#
# Revision 0.53  2002/11/25 17:12:08  emma
# Add Lee Nash's address
#
# Revision 0.52  2002/11/14 14:50:21  emma
# Bugfix --by-surname for some modes. Add two addresses. Fix Carl-Daniel Hailfinger's address to lower case.
#
# Revision 0.51  2002/11/14 14:31:10  emma
# Add Carl-Daniel Hailfinger's new address. Add TODO item to see if regexp/wildcard match in address list is possible.
#
# Revision 0.50  2002/11/09 14:24:21  emma
# Add comment to Richard Hitt's address.
#
# Revision 0.49  2002/11/04 17:13:21  emma
# Add 4 addresses sent by Duncan Laurie.
#
# Revision 0.48  2002/11/04 12:37:38  emma
# Another four dozen addresses, courtesy of Vitezslav Samel.
#
# Revision 0.47  2002/11/04 12:19:17  emma
# Vitezslav Samel: Merge bugfix to treat addresses with upper-case characters in ChangeSet.
#
# Revision 0.46  2002/11/04 11:37:33  emma
# 7 new addresses.
#
# Revision 0.45  2002/11/04 11:26:41  emma
# 18 new addresses.
#
# Revision 0.44  2002/10/04 03:37:51  emma
# Track BK-kernel-tools changes to Jes Sorensen's name.
#
# Revision 0.43  2002/10/04 03:33:47  emma
# 4 new addresses.
#
# Revision 0.42  2002/10/01 20:20:33  emma
# Another 25 addresses for ChangeLog 2.5.3?, from google and lbdb.
#
# Revision 0.41  2002/10/01 19:45:20  emma
# Some detective work on google found another 19 addresses.
#
# Revision 0.40  2002/09/30 01:44:51  emma
# Drop bogus [email protected] address.
#
# Revision 0.39  2002/09/26 23:07:13  emma
# 46 new addresses from lbdb
#
# Revision 0.38  2002/09/26 22:37:29  emma
# 23 new addresses
#
# Revision 0.37  2002/09/26 22:27:37  emma
# Fix --multi mode.
#
# Revision 0.36  2002/08/29 09:13:40  emma
# Correct Vojtech Pavlik's addresses after mail from him.
#
# Revision 0.35  2002/08/21 13:49:46  emma
# Many new addresses and one correction by Vitezslav 'Vita' Samel <[email protected]>
#
# Revision 0.34  2002/08/21 13:45:53  emma
# 2 new names
#
# Revision 0.33  2002/08/20 01:29:34  emma
# The usual set of new addresses.
#
# Revision 0.32  2002/08/20 01:14:40  emma
# Add Marcel Holtmann, who sent a patch.
#
# Revision 0.31  2002/08/12 22:34:41  emma
# Patch by Marcus Alanen <[email protected]>:
# Hi, patch to sort by developer surname, and a couple of more
# developers. Use if you want to.
#
# Revision 0.30  2002/07/20 17:18:28  emma
# Add one new address
#
# Revision 0.29  2002/07/17 23:10:13  emma
# 23 new addresses.
#
# Revision 0.28  2002/06/25 09:46:57  emma
# New mail addresses.
#
# Revision 0.27  2002/06/14 17:05:23  emma
# three new addresses
#
# Revision 0.26  2002/06/06 10:26:51  emma
# Get rid of global %log, pass it to sub functions by reference.
# Move IO::Handle/IO::File treatment back into main program.
# Prepare for integrating Bitkeeper.
#
# Revision 0.25  2002/06/04 00:01:23  emma
# Recognize "bk changes" output format (that is: "[email protected],
# date, programmer" tag line and body indented by two spaces). Reported
# by Marcelo Tosatti <[email protected]>. Former versions would
# only recognize the BK-kernel-tools/changelog format (see
# http://gkernel.bkbits.net:8080/BK-kernel-tools/anno/[email protected]?nav=index.html|src/).
#
# Revision 0.24  2002/06/03 13:33:00  emma
# * Fix 'grouped', 'terse', 'oneline' modes (change to parse_file()). We
#   now take the first paragraph instead of the first line as log
#   entry. We also guess where the paragraph ends, it ends at a line with
#   trailing dot or colon, or if the next line is empty or starts with a
#   "bullet" (that is -, *, o or #).
# * New option --abbreviate-names.
# * Fix 'full' mode indentation, broken in v0.21 by expanding the tabs.
#   Now, the first tab is unexpanded again.
# * Enhance 'online' mode: if the log is truncated, append an ellipsis ("...").
# * Add more mail addresses.
# * Fix Brian Beattie's name (was "Michael Beattie").
#
# Revision 0.23  2002/06/03 12:36:01  emma
# More e-mail addresses.
#
# Revision 0.22  2002/05/29 20:28:20  emma
# Mail addresses added.
#
# Revision 0.21  2002/05/29 11:45:48  emma
# * Implement --mode=oneline.
# * Expand tabs in input lines (tab stops are spaced 8 columns away from each other).
# * Bugfix --multi mode: all append_item to flush @cur before printing.
# * Restore prolog detection in --multi mode for efficiency.
# * Undo the "unexpand()" that Text::Wrap does, it breaks our line width
#   calculation. In the long run, a replacement for Text::Wrap must be
#   found that does not unexpand().
#
# Revision 0.20  2002/05/29 10:44:35  emma
# New --multi option that states multiple changelogs are in the same file.
#
# Revision 0.19  2002/05/29 10:27:21  emma
# New option: --[no]warn: Warn about unknown addresses. By default
# enabled, use --nowarn to suppress.
#
# Revision 0.18  2002/05/29 10:17:00  emma
# New addresses.
#
# Revision 0.17  2002/05/25 23:32:49  emma
# Four new addresses.
#
# Revision 0.16  2002/05/22 15:52:26  emma
# Fix deliberate typo in use Pod::Usage that was left over from debugging.
#
# Revision 0.15  2002/05/22 14:05:13  emma
# Sort addresses/names case insensitively (not locale aware).
# Heed quotes when parsing $ENV{LINUXKERNEL_BK_FMT}. As I don't
# currently have Perl 5.004 to test the older Text::ParseWords
# implementation, script now requires Perl 5.005.
# Do not require Pod::Usage, but warn if it's missing.
#
# Revision 0.14  2002/05/22 12:39:59  emma
# Fold the print function dispatcher into %table.
# Parse files on command line individually, but allow to treat them as
# one with a new --merge option.
# Make @cur local to the parse function.
# Die on read errors on input files. Use IO::Handle to read files.
#
# Revision 0.13  2002/05/21 12:42:46  emma
# Add 3 mail addresses.
# Add commentary to the code.
# Check for write errors on STDOUT and die if one happens.
#
# Revision 0.12  2002/05/18 16:54:50  emma
# Make --compress work in terse mode.
# New feature: --swap in terse mode swaps address and log entry.
#
# Revision 0.11  2002/05/18 16:43:30  emma
# Support 'terse' mode.
#
# Revision 0.10  2002/05/18 16:15:10  emma
# Another set of addresses.
#
# Revision 0.9  2002/05/18 16:06:43  emma
# Dozens of new addresses.
#
# Revision 0.8  2002/05/18 15:46:01  emma
# 21 new addresses.
#
# Revision 0.7  2002/05/16 13:57:37  emma
# Add some documentation.
#
# Revision 0.6  2002/05/16 13:55:24  emma
# Fix shift ambiguity in printtag().
#
# Revision 0.5  2002/05/16 13:51:43  emma
# Implement grouped and full modes.
#
# Revision 0.4  2002/05/16 12:07:17  emma
# Add some POD.
# Do options and environment parsing.
# Prepare multiple output modes (only grouped supported at the moment.)
#
# Revision 0.3  2002/05/13 16:11:34  emma
# Compress identical ChangeLog lines (they need not be subsequent, note
# this feature has O(n^2) behaviour, where n is the number of stored
# ChangeLog lines per respective author):
#   Soft-fp fix:
#   Soft-fp fix:
# becomes:
#   2 x Soft-fp fix:
#
# Revision 0.2  2002/05/13 10:40:32  emma
# Only consider e-mail addresses that are left-justified.
# Suggested by Greg Kroah-Hartman <[email protected]>.
#
=head1 NAME

lk-changelog.pl - Reformat BitKeeper ChangeLog for Linux Kernel

=head1 SYNOPSIS

lk-changelog.pl [options] [file [...]]

Try lk-changelog.pl --help or lk-changelog.pl --man for more information.

=head1 OPTIONS

 -h, --help          print this short help
     --man           print the manual page for this program

     --[no]compress  if true, suppress duplicate entries
     --[no]count     if true, fold duplicate entries into one,
                     prefixing it with the count. Implies --compress.
     --[no]swap      in terse and oneline mode, swap address and log entry.
     --[no]merge     treat all files on command line as one big file
                     and suppress the prolog
     --[no]multi     states that multiple changelogs are in one file
     --[no]warn      warn about unknown addresses. Default: set!
     --[no]abbreviate-names
                     abbreviate all but the last name
     --[no]by-surname
                     sort entries by surname

     --mode=MODE     specify the output format (use --man to find out more)
     --width[=WIDTH] specify the line length, if omitted: $COLUMNS or 80.
                     text lines will not exceed this length.

Warning: Neither --compress nor --count are currently functional with
--mode=full.

=head1 DESCRIPTION

Summarizes or reformats BitKeeper ChangeLogs for Linux Kernel 2.X.

=head1 ENVIRONMENT

=over

=item LINUXKERNEL_BK_FMT

Default options. These have the same meaning and syntax as the command
line options and are parsed before them, so you can override defaults
set in this variable on the command line. B<Example:> If you put
--swap here and --noswap on your command line, --noswap takes
precedence.

=back



=head1 EXAMPLES

=over

=item Reformat ChangeLog-2.5.17, displaying all changes grouped by
  their author (that is the default mode, but we specify it anyways),
  with 76 character wide lines:

 lk-changelog.pl --mode=grouped --width=76 ChangeLog-2.5.17

=item Reformat ChangeLog-2.5.18, displaying all changes and their
      author on in "-ac changelog style", with 80 character wide lines:

 lk-changelog.pl --mode=terse --width=80 ChangeLog-2.5.18

=item Reformat 2.4.19-pre ChangeLogs (several in one file) from your mailer:

Use the pipe command to pipe the mail into:

 lk-changelog.pl --multi --mode=terse --width=80

=back

=head1 AUTHOR

=over

=item * Matthias Andree <[email protected]>

Main developer

=item * Marcus Alanen <[email protected]>

=item * Tomas Szepe <[email protected]>

=item * Further help from:

Albert D. Cahalan <[email protected]>, Robinson Maureira Castillo
<[email protected]>, Greg Kroah-Hartman <[email protected]>.

=back

=head1 BUGS

=over

=item * The header is not wrapped for --width character wide lines.

=item * The implementation is not yet finished.

=item * This manual page is incomplete.

=item * --compress does not currently work with --mode=full.

=item * does not detect if the changelog is already summarized (as in Marcelo's 2.4.19-pre9 announcement on the list)

=back

=head1 TODO

=over

=item * --compress-me-harder

 To merge
   o iget_locked  [1/6]
   o iget_locked  [2/6]
   ...
   o iget_locked  [6/6]
 into
   o iget_locked  [1..6/6]

=item * Integrate Bitkeeper

=item * See if the map can be made to use or accompanied by regexp.

=back

=cut