Index: ossp-pkg/shiela/ChangeLog RCS File: /v/ossp/cvs/ossp-pkg/shiela/ChangeLog,v rcsdiff -q -kk '-r1.14' '-r1.15' -u '/v/ossp/cvs/ossp-pkg/shiela/ChangeLog,v' 2>/dev/null --- ChangeLog 2002/12/21 09:53:16 1.14 +++ ChangeLog 2002/12/21 10:32:39 1.15 @@ -11,6 +11,10 @@ Changes between 0.9.2 and 0.9.3 (19-Aug-2002 to 21-Dec-2002): + *) Consistently use IO objects instead of the anchient direct + fiddling with Perl's filedescriptor symbol globs. + [Ralf S. Engelschall] + *) Correctly determine CVS version and optional RSE patches (from OpenPKG "cvs" package). [Ralf S. Engelschall] Index: ossp-pkg/shiela/shiela.pl RCS File: /v/ossp/cvs/ossp-pkg/shiela/shiela.pl,v rcsdiff -q -kk '-r1.19' '-r1.20' -u '/v/ossp/cvs/ossp-pkg/shiela/shiela.pl,v' 2>/dev/null --- shiela.pl 2002/12/21 09:53:16 1.19 +++ shiela.pl 2002/12/21 10:32:40 1.20 @@ -32,6 +32,7 @@ use strict; # shipped with Perl since 5.000 use POSIX; # shipped with Perl since 5.000 +use IO::File; # shipped with Perl since 5.003 use IO::Handle; # shipped with Perl since 5.003 use IPC::Open2; # shipped with Perl since 5.003 use Data::Dumper; # shipped with Perl since 5.005 @@ -361,10 +362,10 @@ my ($file) = @_; # read configuration file - open(CFG, "<$file") || die "unable to open configuration file `$file'"; + my $io = new IO::File "<$file" || die "unable to open configuration file `$file'"; my $t = ''; - $t .= $_ while (); - close(CFG); + $t .= $_ while (<$io>); + $io->close; # parse configuration syntax into nested internal structure and # in parallel (through a callback function) create the final @@ -794,24 +795,24 @@ # append to or override a file with lines from an array if ($op eq 'append' or $op eq 'write') { - open(FP, ($op eq 'append' ? ">" : "").">$file") or - die "unable to open `$file' for $op"; + my $io = new IO::File ($op eq 'append' ? ">>" : ">").$file + || die "unable to open `$file' for $op"; foreach my $line (@lines) { $line =~ s|\n+$||s; - print FP $prefix . $line . "\n"; + $io->print($prefix . $line . "\n"); } - close(FP); + $io->close; } # read a file line by line into an array elsif ($op eq 'read') { my @text = (); - open(FP, "<$file") or - die "unable to open `$file' for $op"; - while () { + my $io = new IO::File "<$file" + || die "unable to open `$file' for $op"; + while (<$io>) { s|\n$||s; push(@text, $prefix . $_); } - close(FP); + $io->close; return @text; } } @@ -843,10 +844,10 @@ $O .= ",".$e->{delta}; $O .= "\n"; } - open(HDB, ">>".$RT->{historydb}) + my $io = new IO::File ">>".$RT->{historydb} || die "cannot store information to history db `$file'"; - print HDB $O; - close(HDB); + $io->print($O); + $io->close; return; } @@ -1169,9 +1170,10 @@ # annotate the files with the branch they stay on my $cvsstat = ''; if (not $RT->{useserver}) { - open(CVSS, "$RT->{cvs} -f -l -Q -n status ".join(' ', @cvsfiles)."|"); - $cvsstat .= $_ while (); - close(CVSS); + my $io = new IO::File "$RT->{cvs} -f -l -Q -n status ".join(' ', @cvsfiles)."|" + || die "unable to open CVS command pipe for reading"; + $cvsstat .= $_ while (<$io>); + $io->close; } else { my $cvs = new CVS ($RT->{cvs}, $RT->{cvsroot}); @@ -1262,19 +1264,21 @@ # suck in the log message my $logfile = $PA->{ARG}->[0]; - open(FP, "<$logfile") || die "cannot open message file `$logfile' for reading"; + my $io = new IO::File "<$logfile" + || die "cannot open message file `$logfile' for reading"; my $data = ''; - $data .= $_ while (); - close(FP); + $data .= $_ while (<$io>); + $io->close; # filter the log message $data = &compress_message($data); # update the log message # (CVS with RSE patches reads in this again, stock CVS ignores it) - open(FP, ">$logfile") || die "cannot open message file `$logfile' for writing"; - print FP $data; - close(FP); + $io = new IO::File ">$logfile" + || die "cannot open message file `$logfile' for writing"; + $io->print($data); + $io->close; # nuke possibly existing editor backup files unlink("${logfile}~"); @@ -1409,9 +1413,10 @@ print STDERR "cvs import: Ignoring this operation - don't expect log messages!\n"; exit(0); } - open(CVSS, "$RT->{cvs} -f -l -Q -n log -r$It '$Is'|"); - $rcslog = $_ while (); - close(CVSS); + my $io = new IO::File "$RT->{cvs} -f -l -Q -n log -r$It '$Is'|" + || die "unable to open CVS command pipe for reading"; + $rcslog = $_ while (<$io>); + $io->close; } else { my $cvs = new CVS ($RT->{cvs}, $RT->{cvsroot}); @@ -1525,9 +1530,10 @@ my $rcslog = ''; if ($Io eq 'A' or $Io eq 'M') { if (not $RT->{useserver}) { - open(CVSS, "$RT->{cvs} -f -l -Q -n log -r$Iv '$Is'|"); - $rcslog .= $_ while (); - close(CVSS); + my $io = new IO::File "$RT->{cvs} -f -l -Q -n log -r$Iv '$Is'|" + || die "unable to open CVS command pipe for reading"; + $rcslog .= $_ while (<$io>); + $io->close; } else { my $cvs = new CVS ($RT->{cvs}, $RT->{cvsroot}); @@ -1560,10 +1566,10 @@ } else { if ($Io eq 'A') { - open(FP, "<$Is"); + my $io = new IO::File "<$Is" || die "unable open $Is for reading"; my $l = 0; - $l++ while (); - close(FP); + $l++ while (<$io>); + $io->close; $Id = sprintf("+%d/-%d", $l, 0); } elsif ($Io eq 'M') { @@ -1597,9 +1603,10 @@ "============================================================\n" . "\$ cvs update -p -r$Iv $Is | uuencode $Is\n"; if (not $RT->{useserver}) { - open(CVSS, "$RT->{cvs} -f -l -Q -n update -p -r$Iv '$Is' | uuencode '$Is' |"); - $cvsdiff .= $_ while (); - close(CVSS); + my $io = new IO::File "$RT->{cvs} -f -l -Q -n update -p -r$Iv '$Is' | uuencode '$Is' |" + || die "unable to open CVS command pipe for reading"; + $cvsdiff .= $_ while (<$io>); + $io->close; } else { my $cvs = new CVS ($RT->{cvs}, $RT->{cvsroot}); @@ -1620,9 +1627,10 @@ "============================================================\n" . "\$ cvs update -p -r$Iv $Is\n"; if (not $RT->{useserver}) { - open(CVSS, "$RT->{cvs} -f -l -Q -n update -p -r$Iv '$Is'|"); - $cvsdiff .= $_ while (); - close(CVSS); + my $io = new IO::File "$RT->{cvs} -f -l -Q -n update -p -r$Iv '$Is'|" + || die "unable to open CVS command pipe for reading"; + $cvsdiff .= $_ while (<$io>); + $io->close; } else { my $cvs = new CVS ($RT->{cvs}, $RT->{cvsroot}); @@ -1657,29 +1665,31 @@ $cvs->arguments("-p", "-r$IV", $Is); $cvs->send("update"); my $data = scalar $cvs->result; - open(FP, ">$Is.old") || die "cannot write to $Is.old"; - print FP $data; - close(FP); + my $io = new IO::File ">$Is.old" || die "cannot write to $Is.old"; + $io->print($data); + $io->close; $cvs->arguments("-p", "-r$Iv", $Is); $cvs->send("update"); $data = scalar $cvs->result; - open(FP, ">$Is.new") || die "cannot write to $Is.old"; - print FP $data; - close(FP); + $io = new IO::File ">$Is.new" || die "cannot write to $Is.old"; + $io->print($data); + $io->close; $cvs->close; } - open(FP, "diff -u $Is.old $Is.new|"); - $cvsdiff .= $_ while (); - close(FP); + my $io = new IO::File "diff -u $Is.old $Is.new|" + || die "unable to open diff command pipe for reading"; + $cvsdiff .= $_ while (<$io>); + $io->close; $cvsdiff .= "\n"; } else { # file was modified, so we show the changed contents only my $d = ''; if (not $RT->{useserver}) { - open(FP, "$RT->{cvs} -f -l -Q -n diff -u -r$IV -r$Iv '$Is'|"); - $d .= $_ while (); - close(FP); + my $io = new IO::File "$RT->{cvs} -f -l -Q -n diff -u -r$IV -r$Iv '$Is'|" + || die "unable to open CVS command pipe for reading"; + $d .= $_ while (<$io>); + $io->close; } else { my $cvs = new CVS ($RT->{cvs}, $RT->{cvsroot}); @@ -1852,9 +1862,9 @@ my $logmsg = &produce_log_message($PA, $RT, $CF, $IN, $logtype, @files); $logurl = $RT->{cvsroot}."/".$logurl if ($logurl !~ m|^/|); print "cvs commit: Writing commit message to $logurl\n"; - open(LOG, ">>$logurl") || die "cannot append log message to `$logurl'"; - print LOG $logmsg; - close(LOG); + my $io = new IO::File ">>$logurl" || die "cannot append log message to `$logurl'"; + $io->print($logmsg); + $io->close; } } }