list-youtube: Delete `height` and `filesize` columns from output
[sunny256-utils.git] / sortcvs
blob75079bde7f57820cacc02d6a67d6d0edeb293b75
1 #!/usr/bin/env perl
3 #==============================================================================
4 # sortcvs
5 # File ID: 440141ba-5d44-11df-8e85-90e6ba3022ac
6 # Sorts the output from "cvs log" into chronological order.
7 # Made by Øyvind A. Holm <sunny@sunbase.org>
8 # License: GNU General Public License version 2 or later.
9 #==============================================================================
11 use strict;
12 use warnings;
13 use Getopt::Std;
15 our ($opt_a, $opt_h) =
16 ( 0, 0);
18 getopts('ah');
20 $opt_h && print_help(0);
22 my ($curr_date, $curr_rev) = ("", "");
23 my @Curr = ();
24 my %Entry = ();
25 my $Rev = "";
26 my $Line = "";
28 while (<>) {
29 $Line = $_;
30 if ($Line =~ /^----------------------------$/) {
31 if (length($Rev) && scalar(@Curr)) {
32 $Entry{$Rev} = join("", @Curr);
34 @Curr = ();
35 push(@Curr, $Line);
36 $Line = <>;
37 if ($Line =~ /^revision (\S+)/) {
38 $curr_rev = $1;
39 } else {
40 warn("Expected \"revision: \", got \"$Line\".\"");
42 push(@Curr, $Line);
43 $Line = <>;
44 if ($Line =~ /^date: (\S+\s+\S+) .*/) {
45 $curr_date = $1;
46 } else {
47 warn("Expected \"date: \", got \"$Line\".\"");
49 push(@Curr, $Line);
50 # $Rev = unpack("H*", "$curr_date$curr_rev");
51 $Rev = "$curr_date$curr_rev";
52 } elsif ($Line =~ /^=============================================================================$/ && !$opt_a) {
53 if (length($Rev) && scalar(@Curr)) {
54 $Entry{$Rev} = join("", @Curr);
56 my @Arr = ();
57 while (my ($l_name, $l_val) = each %Entry) {
58 push(@Arr, $l_name);
60 for (sort @Arr) {
61 print($Entry{$_});
63 ($curr_date, $curr_rev, $Rev) = ("", "", "");
64 %Entry = ();
65 @Curr = ();
66 print("$Line");
67 } else {
68 if (length($Rev)) {
69 push(@Curr, $_);
70 } else {
71 print("$Line");
76 sub print_help {
77 my $Retval = shift;
78 print("No help yet.\n");
79 exit($Retval);
82 =pod
84 =head1 LICENCE
86 This program is free software; you can redistribute it and/or modify it
87 under the terms of the GNU General Public License as published by the
88 Free Software Foundation; either version 2 of the License, or (at your
89 option) any later version.
91 This program is distributed in the hope that it will be useful, but
92 WITHOUT ANY WARRANTY; without even the implied warranty of
93 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
94 See the GNU General Public License for more details.
96 You should have received a copy of the GNU General Public License along
97 with this program; if not, write to the Free Software Foundation, Inc.,
98 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
100 =cut
102 __END__