Diff for /db/prgsrc/updatedb.pl between versions 1.13 and 1.18

version 1.13, 2000/10/22 04:44:53 version 1.18, 2000/11/11 03:58:59
Line 78  sub getField { Line 78  sub getField {
         }          }
         next if (/^\s*$/);          next if (/^\s*$/);
                   
         if (s/^(.*?)[:\.]\s*// && !$key) {          if (!$key && /^(.*?)[:\.]\s*(.*)$/s) {
             $key = $1;              $key = $1;
             $value=$_;              $value=$2;
             next;              next;
         }          }
         if ($key) {          if ($key) {
Line 199  sub GetTours { Line 199  sub GetTours {
 }  }
   
 sub CreateTour {  sub CreateTour {
     my ($dbh,$title,$ParentId,$rh_defaults)=@_;      my ($dbh,$title,$ParentId,$TourNum,$rh_defaults)=@_;
     my $sth = $dbh->prepare("INSERT INTO Tournaments      my $sth = $dbh->prepare("INSERT INTO Tournaments
                              (Title, Type, ParentId)                                (Title, Type, ParentId, Number) 
                              VALUES ($title, 'ô', $ParentId)");                               VALUES ($title, 'ô', $ParentId, $TourNum)");
     $sth->execute;      $sth->execute;
     my $TourId = $sth->{mysql_insertid};      my $TourId = $sth->{mysql_insertid};
     while (my ($key,$value)=each %$rh_defaults) {      while (my ($key,$value)=each %$rh_defaults) {
Line 227  MAIN: Line 227  MAIN:
     # Inherited fields for a Question      # Inherited fields for a Question
     #      #
     my %QuestionFields = ('ôÉÐ'=> 'Type', '÷ÉÄ'=> 'Type',       my %QuestionFields = ('ôÉÐ'=> 'Type', '÷ÉÄ'=> 'Type', 
                           'á×ÔÏÒ' => 'Authors',                             'á×ÔÏÒ' => 'Authors', 'òÅÊÔÉÎÇ'=>'Rating', 
                           'éÓÔÏÞÎÉË' => 'Source');                            'éÓÔÏÞÎÉË' => 'Sources');
                                                       
                                               
     my($source);      my($source);
Line 237  MAIN: Line 237  MAIN:
         or die "Can't connect to DB chgk\n";          or die "Can't connect to DB chgk\n";
           
     while ($source = shift) {      while ($source = shift) {
           my $TourNum=0;
         my($PlayedAt) = '';          my($PlayedAt) = '';
         my($QuestionId, $TourId, $TournamentId, $ParentId) = (0, 0, 0, 0);          my($QuestionId, $TourId, $TournamentId, $ParentId) = (0, 0, 0, 0);
         my($tournum, $qnum, $all_qnum, $qtype) = (0, 0, 0, 'þ');          my($tournum, $qnum, $all_qnum) = (0, 0, 0);
         my (@d) = (localtime((stat($source))[9]))[5,4,3];          my (@d) = (localtime((stat($source))[9]))[5,4,3];
         $d[1]++;          $d[1]++;
         $d[0]+=1900;          $d[0]+=1900;
Line 253  MAIN: Line 254  MAIN:
         print STDERR "æÁÊÌ: $source, ÄÁÔÁ: $CreatedAt ";          print STDERR "æÁÊÌ: $source, ÄÁÔÁ: $CreatedAt ";
         my %TourDefaults=('CreatedAt'=>$CreatedAt);          my %TourDefaults=('CreatedAt'=>$CreatedAt);
         my %QuestionDefaults=();          my %QuestionDefaults=();
         my %QuestionGlobalDefaults=();          my %QuestionGlobalDefaults=('Type'=>$dbh->quote('þ'));
         while (($key, $value) = getField(\*INFD, $dbh)) {          while (($key, $value) = getField(\*INFD, $dbh)) {
             last if (!$key);              last if (!$key);
                           
Line 281  MAIN: Line 282  MAIN:
                               WHERE Id=$TourId");                                WHERE Id=$TourId");
                 }                  }
                 $qnum = 0;                  $qnum = 0;
                 $TourId=CreateTour($dbh,$value,$TournamentId,\%TourDefaults);                  $TourNum++;
                   $TourId=CreateTour($dbh,$value,$TournamentId,$TourNum,
                                      \%TourDefaults);
                 %QuestionDefaults=%QuestionGlobalDefaults;                  %QuestionDefaults=%QuestionGlobalDefaults;
                 $QuestionId=0;                  $QuestionId=0;
                 next;                     next;   
Line 294  MAIN: Line 297  MAIN:
                     %QuestionDefaults=%QuestionGlobalDefaults;                      %QuestionDefaults=%QuestionGlobalDefaults;
                 }                  }
                 my $query = "INSERT INTO Questions                   my $query = "INSERT INTO Questions 
                              (ParentId, Number, Type)                                (ParentId, Number) 
                              VALUES ($TourId, $qnum+1, \'$qtype\')";                               VALUES ($TourId, $qnum+1)";
                 $sth = $dbh->prepare($query);                  $sth = $dbh->prepare($query);
                 $sth->execute or print $query;;                  $sth->execute or print $query;;
                 $QuestionId = $sth->{mysql_insertid};                  $QuestionId = $sth->{mysql_insertid};
Line 318  MAIN: Line 321  MAIN:
                 next;                  next;
             }              }
                           
             my @Fields = grep /$key/, keys %QuestionFields;              my @Fields = grep { $key =~ /$_/ } keys %QuestionFields;
   
             if (scalar @Fields) {              if (scalar @Fields) {
                 my $word = shift @Fields;                  my $word = shift @Fields;
Line 333  MAIN: Line 336  MAIN:
                 next;                  next;
             }              }
   
             @Fields = grep /$key/, keys %TourFields;              @Fields = grep { $key =~ /$_/ } keys %TourFields;
   
             if (scalar @Fields) {              if (scalar @Fields) {
                 my $word = shift @Fields;                  my $word = shift @Fields;

Removed from v.1.13  
changed lines
  Added in v.1.18


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