dougm       2002/06/29 12:43:51

  Modified:    lib/ModPerl Code.pm
  Log:
  provide mechanism to #ifdef constants
  add APLOG_TOCLIENT to the list of #ifdef constants
  
  Revision  Changes    Path
  1.84      +20 -2     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.83
  retrieving revision 1.84
  diff -u -r1.83 -r1.84
  --- Code.pm   21 Jun 2002 00:05:49 -0000      1.83
  +++ Code.pm   29 Jun 2002 19:43:51 -0000      1.84
  @@ -718,6 +718,18 @@
        REDIRECT => 'HTTP_MOVED_TEMPORARILY',
   );
   
  +my %ifdef = map { $_, 1 } qw(APLOG_TOCLIENT);
  +
  +sub constants_ifdef {
  +    my $name = shift;
  +
  +    if ($ifdef{$name}) {
  +        return ("#ifdef $name\n", "#endif /* $name */\n");
  +    }
  +
  +    ("", "");
  +}
  +
   sub constants_lookup_code {
       my($h_fh, $c_fh, $constants, $class) = @_;
   
  @@ -761,10 +773,13 @@
           print $c_fh "      case '$key':\n";
   
           for my $name (@$names) {
  +            my @ifdef = constants_ifdef($alias{$name});
               print $c_fh <<EOF;
  +$ifdef[0]
             if (strEQ(name, "$name")) {
                 return $alias{$name};
             }
  +$ifdef[1]
   EOF
           }
           print $c_fh "      break;\n";
  @@ -806,8 +821,11 @@
        push @tags, $group;
           my $name = join '_', 'MP_constants', $class, $group;
        print $c_fh "\nstatic const char *$name [] = { \n",
  -          (map { s/^($constant_prefixes)_?//o;
  -                 qq(   "$_",\n) } @$constants), "   NULL,\n};\n";
  +          (map {
  +              my @ifdef = constants_ifdef($_);
  +              s/^($constant_prefixes)_?//o;
  +              qq($ifdef[0]   "$_",\n$ifdef[1])
  +          } @$constants), "   NULL,\n};\n";
       }
   
       my %switch;
  
  
  


Reply via email to