#!/usr/local/bin/perl5
#
#   Copyright (C) 1998,1999
#   Associated Universities, Inc. Washington DC, USA.
# 
#   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.,
#   675 Massachusetts Ave, Cambridge, MA 02139, USA.
# 
#   Correspondence concerning AIPS++ should be addressed as follows:
#          Internet email: aips2-request@nrao.edu.
#          Postal address: AIPS++ Project Office
#                          National Radio Astronomy Observatory
#                          520 Edgemont Road
#                          Charlottesville, VA 22903-2475 USA
#

require "find.pl";

$CO = "ao";

sub fullpath {
    open(SYS,"(cd $dir; pwd) |");
    local @CWD = <SYS>;
    close(SYS);
    chop $CWD[0];
    $CWD[0];
}
	
sub shify {
    local($str) = @_[0];
    $str =~ s/^['"]+//;
    $str =~ s/['"]+$//;
    $str =~ s/\\/\\\\/g;
    $str =~ s/\"/\\\"/g;
    $str =~ s/\$/\\\$/g;
    $str;
}

sub wanted {
    
    if ( /^RCS$/ &&  (($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_)) &&
	-l _ ) {
	opendir(RCS,$_);
	@files = readdir(RCS);
	closedir(RCS);
	foreach (@files) {
	    next unless /,v$/;
	    s/,v$//;
	    print "#: $dir $_\n";
	    open(SYS, "$CO $_ 2>&1 |");
	    while (<SYS>) { print; }
	    close(SYS);
	    print "\n";
	}
    }
}

while ( ($_ = shift(@ARGV)) ) {
    m/^-co$/i && ($CO = "co", next);
}

$| = 1;
find(".");
