Hi.

The previous Y2K patch to this script was wrong - it was placed in front
the line setting the 'date' variable. I've attatched an amended patch
which correctly handles the 19XX and 20XX years, plus the top of the
patch closes an 'echo' statement, so syntax highlighting in Emacs
works better.

Index: contrib/sccs2rcs.csh
===================================================================
RCS file: /home2/cvsroot/ccvs/contrib/sccs2rcs.csh,v
retrieving revision 1.3
diff -u -r1.3 sccs2rcs.csh
--- sccs2rcs.csh        2000/01/24 17:08:38     1.3
+++ sccs2rcs.csh        2000/04/02 18:36:35
@@ -69,7 +69,7 @@
 if (-d RCS) then
     echo "Warning: RCS directory exists"
     if (`ls -a RCS | wc -l` > 2) then
-        echo "Error: RCS directory not empty
+        echo "Error: RCS directory not empty"
         exit 1
     endif
 else
@@ -177,12 +177,7 @@
         if ($status != 0) goto ERROR
 
         # get file into current dir and get stats
-       set year = `echo $date | cut -c3-4`
-       if ($year < 70) then
-               # Y2K Bug, change century to 20
-               set date = `echo $date | sed -e s/19/20/`
-       endif
-        set date = `sccs prs -r$rev $file | grep "^D " | awk '{printf("19%s %s", $3, 
$4); exit}'`
+        set date = `sccs prs -r$rev $file | grep "^D " | awk '{printf("%s%s %s", ($3 
+~/^[789]/ ? "19" : "20"), $3, $4); exit}'`
         set author = `sccs prs -r$rev $file | grep "^D " | awk '{print $5; exit}'`
         echo ""
         echo "==> file $file, rev=$rev, date=$date, author=$author"

Here's a similar patch for the 'rcs2sccs.sh' script - this corrects the year
extraction from RCS (it wouldn't handle 20XX right)

Index: contrib/rcs2sccs.sh
===================================================================
RCS file: /home2/cvsroot/ccvs/contrib/rcs2sccs.sh,v
retrieving revision 1.2
diff -u -r1.2 rcs2sccs.sh
--- rcs2sccs.sh 1997/02/12 15:35:07     1.2
+++ rcs2sccs.sh 2000/04/02 18:41:34
@@ -55,7 +55,7 @@
                exit
        fi
         # get file into current dir and get stats
-        date=`rlog -r$rev $file | grep "^date: " | awk '{print $2; exit}' | sed -e 
's/^19//'`
+        date=`rlog -r$rev $file | grep "^date: " | awk '{print substr($2,3); exit}'`
         time=`rlog -r$rev $file | grep "^date: " | awk '{print $3; exit}' | sed -e 
's/;//'`
         author=`rlog -r$rev $file | grep "^date: " | awk '{print $5; exit}' | sed -e 
's/;//'`
        date="$date $time"

A ChangeLog is provided (if necessary).

Index: contrib/ChangeLog
===================================================================
RCS file: /home2/cvsroot/ccvs/contrib/ChangeLog,v
retrieving revision 1.54
diff -u -r1.54 ChangeLog
--- ChangeLog   2000/02/25 18:47:35     1.54
+++ ChangeLog   2000/04/02 18:43:19
@@ -1,3 +1,15 @@
+2000-04-02  Art Haas  <[EMAIL PROTECTED]>
+
+       * rcs2sccs.sh: Date conversion from RCS to SCCS assumed '19XX' type
+       dates. Fixed to handle '2XXX' dates.
+
+       * sccs2rcs.csh: Previous Y2K fix was wrong - corrected
+       and simplified. Also added `"' at end of echo command - thank
+       Emacs syntax highlighting for pointing this out.
+       
 2000-02-25  Larry Jones  <[EMAIL PROTECTED]>
 
        * log.pl: Get committer from command line instead of getlogin

I've also cleaned up the 'log.pl' script, but I haven't tested it. The
patch cleans up all the warnings from 'perl -cw log.pl', and makes
the script run with the 'use strict' directive.

Apply at your discretion.

This is untested!!!
Index: contrib/log.pl
===================================================================
RCS file: /home2/cvsroot/ccvs/contrib/log.pl,v
retrieving revision 1.8
diff -u -r1.8 log.pl
--- log.pl      2000/02/25 18:47:35     1.8
+++ log.pl      2000/04/02 18:45:19
@@ -52,30 +52,36 @@
 #      CVS-1_4A1                       (revision: 1.1.1.1)
 #      CVS                             (branch: 1.1.1)
 
-$cvsroot = $ENV{'CVSROOT'};
+use strict;
 
 # turn off setgid
 #
 $) = $(;
 
-$dostatus = 1;
+my $dostatus = 1;
 
 # parse command line arguments
 #
-while (@ARGV) {
-        $arg = shift @ARGV;
 
+my @users = ();
+my @files = ();
+my $login = '';
+my $logfile = '';
+my $donefiles = 0;
+
+while (@ARGV) {
+        my $arg = shift @ARGV;
        if ($arg eq '-m') {
-                $users = "$users " . shift @ARGV;
+               push(@users, shift(@ARGV));
        } elsif ($arg eq '-u') {
                $login = shift @ARGV;
        } elsif ($arg eq '-f') {
-               ($logfile) && die "Too many '-f' args";
+               die "Too many '-f' args!\n" if ($logfile ne '');
                $logfile = shift @ARGV;
        } elsif ($arg eq '-s') {
                $dostatus = 0;
        } else {
-               ($donefiles) && die "Too many arguments!\n";
+               die "Too many arguments!\n" if ($donefiles);
                $donefiles = 1;
                @files = split(/ /, $arg);
        }
@@ -83,17 +89,17 @@
 
 # the first argument is the module location relative to $CVSROOT
 #
-$modulepath = shift @files;
+my $modulepath = shift @files;
 
-$mailcmd = "| Mail -s 'CVS update: $modulepath'";
+# $mailcmd = "| Mail -s 'CVS update: $modulepath'";
 
 # Initialise some date and time arrays
 #
-@mos = (January,February,March,April,May,June,July,August,September,
-        October,November,December);
-@days = (Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday);
+my @mos = qw(January February March April May June July August September
+            October November December);
+my @days = qw(Sunday Monday Tuesday Wednesday Thursday Friday Saturday);
 
-($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime;
+my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime;
 $year += 1900;
 
 # get a login name for the guy doing the commit....
@@ -104,14 +110,7 @@
 
 # open log file for appending
 #
-open(OUT, ">>" . $logfile) || die "Could not open(" . $logfile . "): $!\n";
-
-# send mail, if there's anyone to send to!
-#
-if ($users) {
-       $mailcmd = "$mailcmd $users";
-       open(MAIL, $mailcmd) || die "Could not Exec($mailcmd): $!\n";
-}
+open(OUT, ">>$logfile") || die "Could not append to '$logfile': $!\n";
 
 # print out the log Header
 # 
@@ -120,7 +119,11 @@
 print OUT "Date:\t$days[$wday] $mos[$mon] $mday, $year @ $hour:" . sprintf("%02d", 
$min) . "\n";
 print OUT "Author:\t$login\n\n";
 
-if (MAIL) {
+# start a pipe to mail if we've got users to send to
+#
+if (scalar(@users)) {
+       my $userlist = join(" ", @users);
+       open(MAIL,"| Mail -s 'CVS update: $modulepath' $userlist") || die "Can't pipe 
+to 'Mail'! $!\n";
        print MAIL "\n";
        print MAIL "Date:\t$days[$wday] $mos[$mon] $mday, $year @ $hour:" . 
sprintf("%02d", $min) . "\n";
        print MAIL "Author:\t$login\n\n";
@@ -128,30 +131,29 @@
 
 # print the stuff from logmsg that comes in on stdin to the logfile
 #
-open(IN, "-");
-while (<IN>) {
+while (<>) {
        print OUT $_;
-       if (MAIL) {
+       if (scalar(@users)) {
                print MAIL $_;
        }
 }
-close(IN);
 
 print OUT "\n";
 
-# after log information, do an 'cvs -Qq status -v' on each file in the arguments.
+# after log information, do an 'cvs -Qq status -v' on each file
+# in the arguments.
 #
-if ($dostatus != 0) {
+unless ($dostatus) {
        while (@files) {
-               $file = shift @files;
+               my $file = shift @files;
                if ($file eq "-") {
                        print OUT "[input file was '-']\n";
-                       if (MAIL) {
+                       if (scalar(@users)) {
                                print MAIL "[input file was '-']\n";
                        }
                        last;
                }
-               $pid = open(RCS, "-|");
+               my $pid = open(RCS, "-|");
                if ( !defined $pid )
                {
                        die "fork failed: $!";
@@ -163,19 +165,27 @@
                }
                while (<RCS>) {
                        print OUT;
-                       if (MAIL) {
+                       if (scalar(@users)) {
                                print MAIL;
                        }
+               }
+               unless (close(RCS)) {
+                       my $res = $? >> 8;
+                       die "Pipe from cvs bombed! Exit code $res!\n";
                }
-               close(RCS);
        }
 }
 
-close(OUT);
-die "Write to $logfile failed" if $?;
+unless (close(OUT)) {
+       die "Write to $logfile failed! $!\n";
+}
 
-close(MAIL);
-die "Pipe to $mailcmd failed" if $?;
+if (scalar(@users)) {
+       unless (close(MAIL)) {
+               my $res = $? >> 8;
+               die "Pipe to 'Mail' bombed! Exit code $res!\n";
+       }
+}
 
 ## must exit cleanly
 ##

Thanks for your work on CVS.

Reply via email to