httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n.@apache.org
Subject cvs commit: httpd-2.0/support apxs.in
Date Wed, 19 Feb 2003 14:39:39 GMT
nd          2003/02/19 06:39:39

  Modified:    support  apxs.in
  Log:
  break down the beast and explain the obvious >:->
  
  Also catch the case that the substitution may fail.
  
  Revision  Changes    Path
  1.53      +40 -1     httpd-2.0/support/apxs.in
  
  Index: apxs.in
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/support/apxs.in,v
  retrieving revision 1.52
  retrieving revision 1.53
  diff -u -r1.52 -r1.53
  --- apxs.in	19 Feb 2003 03:01:21 -0000	1.52
  +++ apxs.in	19 Feb 2003 14:39:39 -0000	1.53
  @@ -581,6 +581,10 @@
                   # directive always appears *outside* of an <container>.
   
                   my $before = ($content =~ m|^(.*\n)#?\s*LoadModule\s+[^\n]+\n|s)[0];
  +
  +                # the '()=' trick forces list context and the scalar
  +                # assignment counts the number of list members (aka number
  +                # of matches) then
                   my $cntopen = () = ($before =~ m|^\s*<[^/].*$|mg);
                   my $cntclose = () = ($before =~ m|^\s*</.*$|mg);
   
  @@ -596,7 +600,42 @@
                   else {
                       # put our cmd after the section containing the last
                       # LoadModule.
  -                    $content =~ s!\A((?:(?:^\s*(?:[^<]|<[^/]).*(?:$)\n)*^\s*</.*(?:$)\n?){$cntopen})!$1$c$lmd\n!m;
  +                    my $found =
  +                    $content =~ s!\A (               # string and capture start
  +                                  (?:(?:
  +                                    ^\s*             # start of conf line with a
  +                                    (?:[^<]|<[^/])   # directive which does not
  +                                                     # start with '</'
  +
  +                                    .*(?:$)\n        # rest of the line.
  +                                                     # the '$' is in parentheses
  +                                                     # to avoid misinterpreting
  +                                                     # the string "$\" as
  +                                                     # perl variable.
  +
  +                                    )*               # catch as much as possible
  +                                                     # of such lines. (including
  +                                                     # zero)
  +
  +                                    ^\s*</.*(?:$)\n? # after the above, we
  +                                                     # expect a config line with
  +                                                     # a closing container (</)
  +
  +                                  ) {$cntopen}       # the whole pattern (bunch
  +                                                     # of lines that end up with
  +                                                     # a closing directive) must
  +                                                     # be repeated $cntopen
  +                                                     # times. That's it.
  +                                                     # Simple, eh? ;-)
  +
  +                                  )                  # capture end
  +                                 !$1$c$lmd\n!mx;
  +
  +                    unless ($found) {
  +                        error('Configuration file is not valid. There are '
  +                              . 'sections opened and not closed.');
  +                        exit(1);
  +                    }
                   }
               } else {
                   # replace already existing LoadModule line
  
  
  

Mime
View raw message