Diff for /rat/lonuserstate.pm between versions 1.2 and 1.3

version 1.2, 2000/08/02 15:27:10 version 1.3, 2000/08/06 03:25:24
Line 10 Line 10
 # 7/1 Gerd Kortemeyer)  # 7/1 Gerd Kortemeyer)
 # 7/1,7/3,7/4,7/7,7/8,7/10 Gerd Kortemeyer)  # 7/1,7/3,7/4,7/7,7/8,7/10 Gerd Kortemeyer)
 #  #
 # 7/15,7/17,7/18,8/1,8/2 Gerd Kortemeyer  # 7/15,7/17,7/18,8/1,8/2,8/4,8/5 Gerd Kortemeyer
   
 package Apache::lonuserstate;  package Apache::lonuserstate;
   
Line 175  sub loadmap { Line 175  sub loadmap {
     }      }
 }  }
   
   # --------------------------------------------------------- Simplify expression
   
   sub simplify {
      my $expression=shift;
   # "True and" is nothing 
      $expression=~s/0\&//g;
   # (8)=8
      $expression=~s/\((\d+)\)/$1/g;
   # 8&8=8
      $expression=~s/(\d+)\&\1/$1/g;
   # 8|8=8
      $expression=~s/(\d+)\|\1/$1/g;
   # (5&3)&4=5&3&4
      $expression=~s/\((\d+)\&(\d+)\)\&(\d+)/$1\&$2\&$3/g;
   # (((5&3)|(4&6)))=((5&3)|(4&6))
      $expression=~
          s/\((\(\(\d+(?:\&\d+)*\)(?:\|\(\d+(?:\&\d+)*\))+\))\)/$1/g;
   # ((5&3)|(4&6))|(1&2)=(5&3)|(4&6)|(1&2)
      $expression=~
          s/\((\(\d+(?:\&\d+)*\))((?:\|\(\d+(?:\&\d+)*\))+)\)\|(\(\d+(?:\&\d+)*\))/\($1$2\|$3\)/g;
      return $expression;
   }
   
 # -------------------------------------------------------- Build condition hash  # -------------------------------------------------------- Build condition hash
   
 sub traceroute {  sub traceroute {
     my ($sofar,$rid,$beenhere)=shift;      my ($sofar,$rid,$beenhere)=@_;
       $sofar=simplify($sofar);
     unless ($beenhere=~/\&$rid\&/) {      unless ($beenhere=~/\&$rid\&/) {
        $beenhere.=$rid.'&';           $beenhere.=$rid.'&';  
        if (defined($hash{'conditions_'.$rid})) {         if (defined($hash{'conditions_'.$rid})) {
    $hash{'conditions_'.$rid}=     $hash{'conditions_'.$rid}=simplify(
        '('.$hash{'conditions_'.$rid}.')|('.$sofar.')';             '('.$hash{'conditions_'.$rid}.')|('.$sofar.')');
        } else {         } else {
            $hash{'conditions_'.$rid}=$sofar;             $hash{'conditions_'.$rid}=$sofar;
        }         }
        if (defined($hash{'is_map_'.$rid})) {         if (defined($hash{'is_map_'.$rid})) {
            if () {             if (defined($hash{'map_start_'.$hash{'src_'.$rid}})) {
        &traceroute($sofar,$startrid,'&');         &traceroute($sofar,$hash{'map_start_'.$hash{'src_'.$rid}},'&');
                  if (defined($hash{'map_finish_'.$hash{'src_'.$rid}})) {
      $sofar=
                     $hash{'conditions_'.$hash{'map_finish_'.$hash{'src_'.$rid}}};
                  }
            }             }
        }         }
        if (defined($hash{'to_'.$rid})) {         if (defined($hash{'to_'.$rid})) {
Line 197  sub traceroute { Line 225  sub traceroute {
  my $further=$sofar;   my $further=$sofar;
                 if ($hash{'undercond_'.$_}) {                  if ($hash{'undercond_'.$_}) {
    if (defined($hash{'condid_'.$hash{'undercond_'.$_}})) {     if (defined($hash{'condid_'.$hash{'undercond_'.$_}})) {
         $further.='&'.$hash{'condid_'.$hash{'undercond_'.$_}};          $further=simplify('('.$further.')&('.
                                 $hash{'condid_'.$hash{'undercond_'.$_}}.')');
    } else {     } else {
                        $errtext.='Undefined condition ID: '                         $errtext.='Undefined condition ID: '
                                  .$hash{'undercond_'.$_}.'. ';                                   .$hash{'undercond_'.$_}.'. ';
Line 213  sub traceroute { Line 242  sub traceroute {
   
 sub readmap {  sub readmap {
    my $uri=shift;     my $uri=shift;
    @cond=();     @cond=('true:normal');
    %hash=();     %hash=();
    $errtext='';     $errtext='';
    $pc=0;     $pc=0;
    loadmap($uri);     loadmap($uri);
      if (defined($hash{'map_start_'.$uri})) {
          &traceroute('0',$hash{'map_start_'.$uri},'&');
      }
 }  }
   
 # ---------------------------------------------------------------- Testing only  # ---------------------------------------------------------------- Testing only

Removed from v.1.2  
changed lines
  Added in v.1.3


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>