#!/usr/bin/perl # # $Header: /cvsroot/arsperl/ARSperl/infra/mkchanges.pl,v 1.8 2007/03/13 13:20:33 jeffmurphy Exp $ # # mkchanges.pl [-t] -f changes.dat # # generate a "CHANGES" or "changes.html" file # based on the "changes.dat" file # # jeff murphy # jcmurphy@hot-sauce.org # # this code is available under the terms of the GNU license or the # Perl Artistic License (your choice). use strict; use FileHandle; use vars qw{$opt_t $opt_f}; require 'getopts.pl'; Getopts('tf:'); my ($html) = defined($opt_t)?0:1; if((!defined($opt_f)) || (! -e "$opt_f")) { die "usage: mkchanges.pl [-t] -f changes.dat > outputfile -t text output (default = html) -f changes.dat input file "; } my($f) = new FileHandle($opt_f, "r"); die "open($opt_f) failed: $!" if !defined($f); if($html) { headerHTML(); } else { headerTXT(); } while(<$f>) { next if /^\#/; if(/^released=(\S+)\s+version=(.*)/) { if($html) { spewHTML($f, $1, $2); } else { spewTXT($f, $1, $2); } } } $f->close(); if($html) { footerHTML(); } else { footerTXT(); } exit 0; sub spewHTML { my ($f, $rel, $ver) = (shift, shift, shift); my ($first) = 1; my ($beenthere) = 0; my ($count) = 0; while(<$f>) { chomp; if(/^$/) { print "\n\n
\n\n"; return; } if(/^(\S+)/) { my $who = $1; my $cc = ' '; s/^$who//; if($who =~ /^\!/) { $cc = '!'; $who =~ s/^\!//; } s/^\s+//g; if($first) { $first = 0; print "
| |||||||||||||||||||||