dougm 01/12/13 20:21:44
Modified: perl-framework/Apache-Test/lib/Apache TestConfig.pm
Log:
more noise reduction in file generation methods
Revision Changes Path
1.103 +18 -32
httpd-test/perl-framework/Apache-Test/lib/Apache/TestConfig.pm
Index: TestConfig.pm
===================================================================
RCS file:
/home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestConfig.pm,v
retrieving revision 1.102
retrieving revision 1.103
diff -u -r1.102 -r1.103
--- TestConfig.pm 2001/12/14 02:44:57 1.102
+++ TestConfig.pm 2001/12/14 04:21:44 1.103
@@ -621,9 +621,17 @@
$self->trace("generating $name");
}
-sub genfile_open {
- my($self, $file) = @_;
+sub genfile_warning {
+ my($self, $file, $fh) = @_;
+ if (my $msg = $self->genwarning($file)) {
+ print $fh $msg, "\n";
+ }
+}
+
+sub genfile {
+ my($self, $file, $nowarning) = @_;
+
# create the parent dir if it doesn't exist yet
my $dir = dirname $file;
$self->makepath($dir);
@@ -633,19 +641,9 @@
my $fh = Symbol::gensym();
open $fh, ">$file" or die "open $file: $!";
- $self->clean_add_file($file);
-
- return $fh;
-}
-
-sub genfile {
- my($self, $file) = @_;
+ $self->genfile_warning($file, $fh) unless $nowarning;
- my $fh = $self->genfile_open($file);
-
- if (my $msg = $self->genwarning($file)) {
- print $fh $msg, "\n";
- }
+ $self->clean_add_file($file);
return $fh;
}
@@ -653,38 +651,26 @@
# gen + write file
sub writefile {
my($self, $file, $content, $nowarning) = @_;
-
- my $fh = $self->genfile_open($file);
- unless ($nowarning) {
- if (my $msg = $self->genwarning($file)) {
- print $fh $msg, "\n";
- }
- }
+ my $fh = $self->genfile($file, $nowarning);
- if ($content) {
- print $fh $content;
- }
+ print $fh $content if $content;
close $fh;
}
-# gen + write excutable perl script file
+# gen + write executable perl script file
sub write_perlscript {
my($self, $file, $content) = @_;
- my $fh = $self->genfile_open($file);
+ my $fh = $self->genfile($file, 1);
# shebang
print $fh "#!$Config{perlpath}\n";
- if (my $msg = $self->genwarning($file)) {
- print $fh $msg, "\n";
- }
+ $self->genfile_warning($file, $fh);
- if ($content) {
- print $fh $content;
- }
+ print $fh $content if $content;
close $fh;
chmod 0555, $file;