1#!/usr/bin/perl 2# $OpenBSD: setdate.pl,v 1.1 2008/03/10 20:03:21 tobias Exp $ 3# 4# Sets "date x;" of specified revision in rcsfile to date. 5# This script is needed to make -D checks available. CVS adjusts dates 6# to gmt, so it is impossible to write tests which can be used in 7# all timezones. 8# 9# usage: setdate.pl rcsfile revision date 10 11my $gotrev; 12my @lines; 13 14die "usage: setdate.pl file revision date\n" if ($#ARGV != 2); 15 16open FILE, "< $ARGV[0]" or die "cannot open file $ARGV[0] for reading\n"; 17@lines = <FILE>; 18close FILE; 19 20$gotrev = 0; 21open FILE, "> $ARGV[0]" or die "cannot open file $ARGV[0] for writing\n"; 22for (@lines) { 23 if ($gotrev) { 24 if (m/^date\s+(.*?);/) { 25 s/$1/$ARGV[2]/; 26 break; 27 } 28 $gotrev = 0; 29 } 30 $gotrev = 1 if (m/^$ARGV[1]\n$/); 31 print FILE "$_"; 32} 33close FILE; 34 35