root/1.8.3/tags/p5rc1/utils/mkvershlp.pl

Revision 1030, 2.4 KB (checked in by shawnw, 18 months ago)

More prep for 1.8.3p4

  • Property svn:executable set to *
Line 
1#!/usr/bin/env perl
2#
3# Generate game/txt/hlp/ files from the CHANGES file(s).
4# Should be run by Makefile from top-level directory
5#
6# Usage: mkvershlp game/txt/hlp CHANGES.176 CHANGES.OLD ...
7#
8# Each file CHANGES.<blah> generates file pennv<blah>.hlp in the
9# specified directory.
10#
11use strict;
12use Sort::Versions;
13use Text::Wrap;
14
15my $targetdir = shift;
16my @sources = @ARGV;
17my $verspat = '^Version (\S+) patchlevel (\S+)';
18my %patchlevels;
19
20@sources = sort byrevision @sources;
21
22my $really_started = 0;
23foreach my $file (@sources) {
24  next if $file =~ /~$/o;
25  warn "Can't open $file!\n", next unless open(IN,"<$file");
26  my $target = $file;
27  $target =~ s/.*\.(.*)/pennv$1.hlp/;
28  open(OUT,">$targetdir/$target") or die "Unable to open $targetdir/$target\n";
29  my $started = 0;
30  while (<IN>) {
31    if (/$verspat/o) {
32      print OUT "& $1p$2\n";
33      push @{$patchlevels{$1}}, $2;
34      unless ($started) {
35        # This is the first one
36        unless ($really_started) {
37          print OUT <<'EOP';
38& changes
39This is a list of changes in this patchlevel which are probably of
40interest to players. More information about new commands and functions
41can probably be gotten via 'help <name of whatever>'. 'help credits'
42lists the [initials] of developers and porters that are used in the list
43of changes.
44
45Information about changes in prior releases can be found under
46help topics named for each release (e.g. 'help 1.7.2p30').
47A list of the patchlevels associated with each release can
48be read in 'help patchlevels'.
49
50EOP
51          $really_started = 1;
52        }
53        $started = 1;
54      }
55      print OUT;
56    } elsif ($started) {
57      print OUT;
58    } 
59  }
60  close IN;
61}
62
63# Now spew the patchlevels list. Special case for 1.50
64$patchlevels{'1.5.0'} = $patchlevels{'1.50'};
65delete($patchlevels{'1.50'});
66my @versions = reverse sort versions keys %patchlevels;
67print OUT <<EOP;
68& patchlevels
69For information on a specific patchlevel of one of the versions listed,
70type 'help <version>p<patchlevel>'. For example, 'help 1.7.2p3'
71
72EOP
73foreach (@versions) {
74  my @pls = sort {$a <=> $b} @{$patchlevels{$_}};
75  my $line;
76  if ($_ eq "1.5.0") {
77    $line = "1.50: ". join(", ",@pls). "\n";
78  } else {
79    $line = "$_: ". join(", ",@pls). "\n";
80  }
81  print OUT wrap("","       ",$line);
82}
83
84close OUT;
85
86
87# A sort subroutine to order CHANGES.<blah> in reverse chronological
88# order
89sub byrevision {
90  return $b cmp $a if ($a =~ /\d/ and $b =~ /\d/);
91  return $a cmp $b;
92}
Note: See TracBrowser for help on using the browser.