dougm       01/02/21 19:49:22

  Modified:    lib/Apache Build.pm
               lib/ModPerl Code.pm
  Log:
  make noedit_warning routines more usable elsewhere
  
  Revision  Changes    Path
  1.31      +9 -2      modperl-2.0/lib/Apache/Build.pm
  
  Index: Build.pm
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/lib/Apache/Build.pm,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- Build.pm  2001/02/08 19:30:44     1.30
  +++ Build.pm  2001/02/22 03:49:22     1.31
  @@ -333,6 +333,13 @@
       chmod 0755, $file;
   }
   
  +my $noedit_warning_hash;
  +
  +#we are use'd by ModPerl::Code, so delay this until after compilation
  +CHECK {
  +    $noedit_warning_hash = ModPerl::Code::noedit_warning_hash(__PACKAGE__);
  +}
  +
   sub save {
       my($self, $file) = @_;
   
  @@ -347,7 +354,7 @@
       #work around autosplit braindeadness
       my $package = 'package Apache::BuildConfig';
   
  -    print $fh ModPerl::Code::noedit_warning_hash();
  +    print $fh $noedit_warning_hash;
   
       print $fh <<EOF;
   $package;
  @@ -641,7 +648,7 @@
   
       open my $fh, '>', $mf or die "open $mf: $!";
   
  -    print $fh ModPerl::Code::noedit_warning_hash();
  +    print $fh $noedit_warning_hash;
   
       $self->make_tools($fh);
   
  
  
  
  1.41      +23 -11    modperl-2.0/lib/ModPerl/Code.pm
  
  Index: Code.pm
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/lib/ModPerl/Code.pm,v
  retrieving revision 1.40
  retrieving revision 1.41
  diff -u -r1.40 -r1.41
  --- Code.pm   2001/02/18 21:57:50     1.40
  +++ Code.pm   2001/02/22 03:49:22     1.41
  @@ -469,10 +469,20 @@
       [(map { "$_.c" } @g_c_names), (map { "$_.h" } @g_h_names)];
   }
   
  -sub noedit_warning {
  -    my $v = join '/', __PACKAGE__, $VERSION;
  -    return <<EOF;
  +my %warnings;
   
  +sub classname {
  +    my $self = shift || __PACKAGE__;
  +    ref($self) || $self;
  +}
  +
  +sub noedit_warning_c {
  +    my $class = classname(shift);
  +    my $warning = \$warnings{C}->{$class};
  +    return $$warning if $$warning;
  +    my $v = join '/', $class, $class->VERSION;
  +    $$warning = <<EOF;
  +
   /*
    * *********** WARNING **************
    * This file generated by $v
  @@ -482,14 +492,16 @@
   
   EOF
   }
  -
  -my $noedit_warning = noedit_warning();
  -my $noedit_warning_hash = noedit_warning_hash();
   
  +#this is named hash after the `#' character
  +#rather than named perl, since #comments are used
  +#non-Perl files, e.g. Makefile, typemap, etc.
   sub noedit_warning_hash {
  -    return $noedit_warning_hash if $noedit_warning_hash;
  -    (my $warning = noedit_warning()) =~ s/^/\# /mg;
  -    $warning;
  +    my $class = classname(shift);
  +    my $warning = \$warnings{hash}->{$class};
  +    return $$warning if $$warning;
  +    ($$warning = noedit_warning_c($class)) =~ s/^/\# /mg;
  +    $$warning;
   }
   
   sub init_file {
  @@ -512,7 +524,7 @@
       warn "generating...$file\n";
       unlink $file;
       open my $fh, '>>', $file or die "open $file: $!";
  -    print $fh @preamble, $noedit_warning;
  +    print $fh @preamble, noedit_warning_c();
   
       $self->{fh}->{$name} = $fh;
   }
  @@ -576,7 +588,7 @@
   
       my $package = 'package Apache2';
   
  -    print $fh ModPerl::Code::noedit_warning_hash();
  +    print $fh noedit_warning_hash();
   
       print $fh <<EOF;
   $package;
  
  
  

Reply via email to