#!/usr/bin/perl -w ##------------------------------------------------------------------------## ## File: ## $Id: cvs-kwstrip,v 1.4 2002/07/31 04:20:14 ehood Exp $ ## Author: ## Earl Hood earl@earlhood.com ## Description: ## Program to strip out CVS keyword delimiters. ##------------------------------------------------------------------------## ## Copyright (C) 2001-2002 Earl Hood, earl@earlhood.com ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 2 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program; if not, write to the Free Software ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA ## 02111-1307, USA ##------------------------------------------------------------------------## package Devtools::cvs_kwstrip; use FindBin; use lib "$FindBin::Bin/../lib"; # Add relative lib to search path use Getopt::Long; use CommandUtil; ## CVS keywords my @keywords = qw( Author Date Header Id Name Locker Log RCSfile Revision Source State ); my $keyword_pattern = '(?:' . join('|', @keywords) . ')'; ############################################################################ MAIN: { ## Command-line parsing my %opt = (); my $status = GetOptions(\%opt, 'version-name', # Name keyword represents a version 'help|?', # Brief help message 'man' ); if (!$status) { die qq/Use -help for usage information\n/; } usage(1,0) if ($opt{'help'}); usage(2,0) if ($opt{'man'}); ## Initialize variables my $date = scalar(gmtime) . ' GMT'; my $version_name = $opt{'version-name'}; ## Process input while (<>) { s/[\$]CurrentDate:?[^\$]*\$/$date/g; if ($version_name) { s/[\$]Name:?\s*([^\$]*)\$/cvs_tag_to_version($1)/ge; } s/[\$]$keyword_pattern:?\s*([^\$]*)\$/$1/g; } continue { print; } } # END: MAIN ############################################################################ ## Routines ############################################################################ sub cvs_tag_to_version { my $tag = shift; $tag =~ s/-/./g; $tag =~ s/[^\d\.]//g; $tag; } ############################################################################ __END__ =head1 NAME cvs-kwstrip - Strip CVS keyword delimiters. =head1 SYNOPSIS cvs-kwstrip [options] file =head1 DESCRIPTION This program strips out CVS keywords, but leaves behind the contents of the keywords. For example, $XXX: Some text $ would be converted to, Some text where C is one of the following CVS keywords: C. The special non-CVS keyword of C<$CurrentDate$> will be replaced with the current GMT date. If no input files are specified, input is read from standard input. All output goes to standard out. =head1 OPTIONS =over =item C<-help> Display help message. =item C<-man> Display manpage. =item C<-version-name> The CVS keyword C value will be treated as a product version number. Hyphens, 'C<->'s, will be translated to 'C<.>'s and any non-numeric character will be stripped. =back =head1 VERSION C<$Id: cvs-kwstrip,v 1.4 2002/07/31 04:20:14 ehood Exp $> =head1 AUTHOR Earl Hood, earl@earlhood.com This program comes with ABSOLUTELY NO WARRANTY and may be copied only under the terms of the GNU General Public License. =cut