[BACK]Return to cvsweb.cgi CVS log [TXT][DIR] Up to [cvsweb.bsd.lv] / cvsweb

Diff for /cvsweb/cvsweb.cgi between version 1.11 and 1.12

version 1.11, 1997/11/15 16:48:07 version 1.12, 1997/11/19 19:07:18
Line 76  $scriptname =~ s|/$||;
Line 76  $scriptname =~ s|/$||;
 $scriptwhere = $scriptname . '/' . $where;  $scriptwhere = $scriptname . '/' . $where;
 $scriptwhere =~ s|/$||;  $scriptwhere =~ s|/$||;
   
   
 if ($query = $ENV{'QUERY_STRING'}) {  if ($query = $ENV{'QUERY_STRING'}) {
     foreach (split(/&/, $query)) {      foreach (split(/&/, $query)) {
         s/%(..)/sprintf("%c", hex($1))/ge;      # unquote %-quoted          s/%(..)/sprintf("%c", hex($1))/ge;      # unquote %-quoted
Line 102  if ($input{'cvsroot'}) {
Line 101  if ($input{'cvsroot'}) {
 do "$config-$cvstree" if -f "$config-$cvstree";  do "$config-$cvstree" if -f "$config-$cvstree";
   
 $fullname = $cvsroot . '/' . $where;  $fullname = $cvsroot . '/' . $where;
   
 if (!-d $cvsroot) {  if (!-d $cvsroot) {
         &fatal("500 Internal Error",'$CVSROOT not found!');          &fatal("500 Internal Error",'$CVSROOT not found!<P>The server on which the CVS tree lives is probably down.  Please try again in a few minutes.');
 }  }
   
   
Line 130  if (-d $fullname) {
Line 130  if (-d $fullname) {
                         last lookingforattic;                          last lookingforattic;
                 }                  }
         }          }
           $haveattic = 1 if ($i <= $#dir);
         if (!$input{"showattic"} && ($i <= $#dir) &&          if (!$input{"showattic"} && ($i <= $#dir) &&
                                 opendir(DIR, $fullname . "/Attic")) {                                  opendir(DIR, $fullname . "/Attic")) {
                 splice(@dir, $i, 1,                  splice(@dir, $i, 1,
Line 155  if (-d $fullname) {
Line 156  if (-d $fullname) {
 #                   &link("Directory-wide diffs", $scriptwhere . '/*'), "<BR>";  #                   &link("Directory-wide diffs", $scriptwhere . '/*'), "<BR>";
             } elsif (-d $fullname . "/" . $_) {              } elsif (-d $fullname . "/" . $_) {
                 print "<IMG SRC=\"/icons/dir.gif\"> ",                  print "<IMG SRC=\"/icons/dir.gif\"> ",
                     &link($_ . "/", $scriptwhere . '/' . $_ . '/' . $query), $attic, "<BR>";                      &link($_ . "/", $scriptwhere . '/' . $_ . '/' . $query),
                               $attic, "<BR>";
             } elsif (s/,v$//) {              } elsif (s/,v$//) {
 # TODO: add date/time?  How about sorting?  # TODO: add date/time?  How about sorting?
                 print "<IMG SRC=\"/icons/text.gif\"> ",                  print "<IMG SRC=\"/icons/text.gif\"> ",
                     &link($_, $scriptwhere . '/' .                      &link($_, $scriptwhere . '/' .
                             ($attic ? "Attic/" : "") . $_ . $query),                              ($attic ? "Attic/" : "") . $_ . $query),
                     $attic, "<BR>";                              $attic, "<BR>";
             }              }
         }          }
         print "</MENU>\n";          print "</MENU>\n";
Line 177  if (-d $fullname) {
Line 179  if (-d $fullname) {
         }          }
         $formwhere = $scriptwhere;          $formwhere = $scriptwhere;
         $formwhere =~ s|Attic/?$|| if ($input{"showattic"});          $formwhere =~ s|Attic/?$|| if ($input{"showattic"});
         print "<HR><FORM METHOD=\"GET\" ACTION=\"${formwhere}\">\n";          if ($haveattic) {
         $input{"showattic"}=!$input{"showattic"};                  print "<HR><FORM METHOD=\"GET\" ACTION=\"${formwhere}\">\n";
         foreach $k (keys %input) {                  $input{"showattic"}=!$input{"showattic"};
             print "<INPUT TYPE=hidden NAME=$k VALUE=$input{$k}>\n" if $input{$k};                  foreach $k (keys %input) {
                       print "<INPUT TYPE=hidden NAME=$k VALUE=$input{$k}>\n" if $input{$k};
                   }
                   print "<INPUT TYPE=SUBMIT VALUE=\"";
                   print ($input{"showattic"} ? "Show" : "Hide");
                   print " attic directories\">\n";
                   print "</FORM>\n";
         }          }
         print "<INPUT TYPE=SUBMIT VALUE=\"";  
         print ($input{"showattic"} ? "Show" : "Hide");  
         print " attic directories\">\n";  
         print "</FORM>\n";  
         print &html_footer;          print &html_footer;
         print "</BODY></HTML>\n";          print "</BODY></HTML>\n";
 } elsif (-f $fullname . ',v') {  } elsif (-f $fullname . ',v') {
Line 198  if (-d $fullname) {
Line 202  if (-d $fullname) {
                         $input{'r2'}, $input{'tr2'}, $input{'f'});                          $input{'r2'}, $input{'tr2'}, $input{'f'});
                 exit;                  exit;
         }          }
   print("going to dolog($fullname)\n") if ($verbose);
           &dolog($fullname);
   } elsif ($fullname =~ s/\.diff$// && -f $fullname . ",v" &&
                                   $input{'r1'} && $input{'r2'}) {
           # Allow diffs using the ".diff" extension
           # so that browsers that default to the URL
           # for a save filename don't save diff's as
           # e.g. foo.c
           &dodiff($fullname, $input{'r1'}, $input{'tr1'},
                   $input{'r2'}, $input{'tr2'}, $input{'f'});
           exit;
   } elsif (($newname = $fullname) =~ s|/([^/]+)$|/Attic/$1| &&
                                    -f $newname . ",v") {
           # The file has been removed and is in the Attic.
           # Send a redirect pointing to the file in the Attic.
           ($newplace = $scriptwhere) =~ s|/([^/]+)$|/Attic/$1|;
           &redirect($newplace);
           exit;
   } elsif (0 && (@files = &safeglob($fullname . ",v"))) {
           print "Content-type: text/plain\n\n";
           print "You matched the following files:\n";
           print join("\n", @files);
           # Find the tags from each file
           # Display a form offering diffs between said tags
   } else {
           # Assume it's a module name with a potential path following it.
           ($module = $where) =~ s|/.*||;
           $xtra = $&;
           # Is there an indexed version of modules?
           if (open(MODULES, "$cvsroot/CVSROOT/modules")) {
                   while (<MODULES>) {
                           if (/^(\S+)\s+(\S+)/o && $module eq $1
                                   && -d "${cvsroot}/$2" && $module ne $2) {
                                   &redirect($scriptname . '/' . $2 . $xtra);
                           }
                   }
           }
           &fatal("404 Not Found","$where: no such file or directory");
   }
   
   sub htmlify {
           local($string, $pr) = @_;
   
           $string =~ s/&/&amp;/g;
           $string =~ s/</&lt;/g;
           $string =~ s/>/&gt;/g;
   
           if ($pr) {
                   $string =~ s|\bpr(\W+[a-z]+/\W*)(\d+)|<A HREF=/cgi/query-pr.cgi?pr=$2>$&</A>|ig;
           }
   
           $string;
   }
   
   sub link {
           local($name, $where) = @_;
   
           "<A HREF=\"$where\">$name</A>\n";
   }
   
   sub revcmp {
           local($rev1, $rev2) = @_;
           local(@r1) = split(/\./, $rev1);
           local(@r2) = split(/\./, $rev2);
           local($a,$b);
   
           while (($a = shift(@r1)) && ($b = shift(@r2))) {
               if ($a != $b) {
                   return $a <=> $b;
               }
           }
           if (@r1) { return 1; }
           if (@r2) { return -1; }
           return 0;
   }
   
   sub fatal {
           local($errcode, $errmsg) = @_;
           print "Status: $errcode\n";
           print &html_header("Error");
   #       print "Content-type: text/html\n";
   #       print "\n";
   #       print "<HTML><HEAD><TITLE>Error</TITLE></HEAD>\n";
   #       print "<BODY>Error: $errmsg</BODY></HTML>\n";
           print "Error: $errmsg\n";
           print &html_footer;
           exit(1);
   }
   
   sub redirect {
           local($url) = @_;
           print "Status: 301 Moved\n";
           print "Location: $url\n";
           print &html_header("Moved");
   #       print "Content-type: text/html\n";
   #       print "\n";
   #       print "<HTML><HEAD><TITLE>Moved</TITLE></HEAD>\n";
   #       print "<BODY>This document is located <A HREF=$url>here</A>.</BODY></HTML>\n";
           print "This document is located <A HREF=$url>here</A>.\n";
           print &html_footer;
           exit(1);
   }
   
   sub safeglob {
           local($filename) = @_;
           local($dirname);
           local(@results);
   
           ($dirname = $filename) =~ s|/[^/]+$||;
           $filename =~ s|.*/||;
   
           if (opendir(DIR, $dirname)) {
                   $glob = $filename;
           #       transform filename from glob to regex.  Deal with:
           #       [, {, ?, * as glob chars
           #       make sure to escape all other regex chars
                   $glob =~ s/([\.\(\)\|\+])/\\$1/g;
                   $glob =~ s/\*/.*/g;
                   $glob =~ s/\?/./g;
                   $glob =~ s/{([^}]+)}/($t = $1) =~ s-,-|-g; "($t)"/eg;
                   foreach (readdir(DIR)) {
                           if (/^${glob}$/) {
                                   push(@results, $dirname . "/" .$_);
                           }
                   }
           }
   
           @results;
   }
   
   sub checkout {
           local($fullname, $rev) = @_;
   
           open(RCS, "co -p$rev '$fullname' 2>&1 |") ||
               &fail("500 Internal Error", "Couldn't co: $!");
   # /home/ncvs/src/sys/netinet/igmp.c,v  -->  standard output
   # or
   # /home/ncvs/src/sys/netinet/igmp.c,v  -->  stdout
   # revision 1.1.1.2
   # /*
           $_ = <RCS>;
           if (/^(\S+),v\s+-->\s+st(andar)?d ?out(put)?\s*$/o && $1 eq $fullname) {
               # As expected
           } else {
               &fatal("500 Internal Error",
                   "Unexpected output from co: $_");
           }
           $_ = <RCS>;
           if (/^revision\s+$rev\s*$/) {
               # As expected
           } else {
               &fatal("500 Internal Error",
                   "Unexpected output from co: $_");
           }
           $| = 1;
           print "Content-type: text/plain\n\n";
           print <RCS>;
           close(RCS);
   }
   
   sub dodiff {
           local($fullname, $r1, $tr1, $r2, $tr2, $f) = @_;
   
           if ($r1 =~ /([^:]+)(:(.+))?/) {
               $rev1 = $1;
               $sym1 = $3;
           }
           if ($rev1 eq 'text') {
               $rev1 = $tr1;
           }
           if ($r2 =~ /([^:]+)(:(.+))?/) {
               $rev2 = $1;
               $sym2 = $3;
           }
           if ($rev2 eq 'text') {
               $rev2 = $tr2;
           }
           if (!($rev1 =~ /^[\d\.]+$/) || !($rev2 =~ /^[\d\.]+$/)) {
               &fatal("404 Not Found",
                       "Malformed query \"$ENV{'QUERY_STRING'}\"");
           }
   #
   # rev1 and rev2 are now both numeric revisions.
   # Thus we do a DWIM here and swap them if rev1 is after rev2.
   # XXX should we warn about the fact that we do this?
           if (&revcmp($rev1,$rev2) > 0) {
               ($tmp1, $tmp2) = ($rev1, $sym1);
               ($rev1, $sym1) = ($rev2, $sym2);
               ($rev2, $sym2) = ($tmp1, $tmp2);
           }
   #
   #       XXX Putting '-p' here is a personal preference
           if ($f eq 'c') {
               $difftype = '-p -c';
               $diffname = "Context diff";
           } elsif ($f eq 's') {
               $difftype = '--side-by-side --width=164';
               $diffname = "Side by Side";
           } else {
               $difftype = '-p -u';
               $diffname = "Unidiff";
           }
   # XXX should this just be text/plain
   # or should it have an HTML header and then a <pre>
           print "Content-type: text/plain\n\n";
           open(RCSDIFF, "rcsdiff $difftype -r$rev1 -r$rev2 '$fullname' 2>&1 |") ||
               &fail("500 Internal Error", "Couldn't rcsdiff: $!");
   #
   #===================================================================
   #RCS file: /home/ncvs/src/sys/netinet/tcp_output.c,v
   #retrieving revision 1.16
   #retrieving revision 1.17
   #diff -c -r1.16 -r1.17
   #*** /home/ncvs/src/sys/netinet/tcp_output.c     1995/11/03 22:08:08     1.16
   #--- /home/ncvs/src/sys/netinet/tcp_output.c     1995/12/05 17:46:35     1.17
   #
   # Ideas:
   # - nuke the stderr output if it's what we expect it to be
   # - Add "no differences found" if the diff command supplied no output.
   #
   #*** src/sys/netinet/tcp_output.c     1995/11/03 22:08:08     1.16
   #--- src/sys/netinet/tcp_output.c     1995/12/05 17:46:35     1.17 RELENG_2_1_0
   # (bogus example, but...)
   #
           if ($difftype eq '-u') {
               $f1 = '---';
               $f2 = '\+\+\+';
           } else {
               $f1 = '\*\*\*';
               $f2 = '---';
           }
           while (<RCSDIFF>) {
               if (m|^$f1 $cvsroot|o) {
                   s|$cvsroot/||o;
                   if ($sym1) {
                       chop;
                       $_ .= " " . $sym1 . "\n";
                   }
               } elsif (m|^$f2 $cvsroot|o) {
                   s|$cvsroot/||o;
                   if ($sym2) {
                       chop;
                       $_ .= " " . $sym2 . "\n";
                   }
               }
               print $_;
           }
           close(RCSDIFF);
   }
   
   sub dolog {
           local($fullname) = @_;
           local($curbranch,$symnames);    #...
   
           print("Going to rlog '$fullname'\n") if ($verbose);
         open(RCS, "rlog '$fullname'|") || &fatal("500 Internal Error",          open(RCS, "rlog '$fullname'|") || &fatal("500 Internal Error",
                                                 "Failed to spawn rlog");                                                  "Failed to spawn rlog");
         while (<RCS>) {          while (<RCS>) {
Line 236  if (-d $fullname) {
Line 495  if (-d $fullname) {
         logentry:          logentry:
         while (!/^=========/) {          while (!/^=========/) {
             $_ = <RCS>;              $_ = <RCS>;
               last logentry if (!defined($_));    # EOF
             print "R:", $_ if ($verbose);              print "R:", $_ if ($verbose);
             if (/^revision ([\d\.]+)/) {              if (/^revision ([\d\.]+)/) {
                 $rev = $1;                  $rev = $1;
             } elsif (/^========/ || /^----------------------------$/) {              } elsif (/^========/ || /^----------------------------$/) {
                 next logentry;                  next logentry;
             } else {              } else {
                 &fatal("500 Internal Error","Error parsing RCS output: $_");                  # The rlog output is syntactically ambiguous.  We must
                   # have guessed wrong about where the end of the last log
                   # message was.
                   # Since this is likely to happen when people put rlog output
                   # in their commit messages, don't even bother keeping
                   # these lines since we don't know what revision they go with
                   # any more.
                   next logentry;
   #               &fatal("500 Internal Error","Error parsing RCS output: $_");
             }              }
             $_ = <RCS>;              $_ = <RCS>;
             print "D:", $_ if ($verbose);              print "D:", $_ if ($verbose);
Line 371  if (-d $fullname) {
Line 639  if (-d $fullname) {
             }              }
             print "\n";              print "\n";
             print "<A HREF=\"$scriptwhere?rev=$_" .              print "<A HREF=\"$scriptwhere?rev=$_" .
                 &cvsroot . qq{"><b>$_</b></A>};                  &cvsroot . "\"><b>$_</b></A>";
             if (/^1\.1\.1\.\d+$/) {              if (/^1\.1\.1\.\d+$/) {
                 print " <i>(vendor branch)</i>";                  print " <i>(vendor branch)</i>";
             }              }
Line 414  if (-d $fullname) {
Line 682  if (-d $fullname) {
             if ($prevrev[$#prevrev] != 0) {              if ($prevrev[$#prevrev] != 0) {
                 $prev = join(".", @prevrev);                  $prev = join(".", @prevrev);
                 print "<BR><A HREF=\"${scriptwhere}.diff?r1=$prev";                  print "<BR><A HREF=\"${scriptwhere}.diff?r1=$prev";
                 print "&r2=$_" . &cvsroot . qq{">Diffs to $prev</A>\n};                  print "&r2=$_" . &cvsroot . "\">Diffs to $prev</A>\n";
                 #                  #
                 # Plus, if it's on a branch, and it's not a vendor branch,                  # Plus, if it's on a branch, and it's not a vendor branch,
                 # offer to diff with the immediately-preceding commit if it                  # offer to diff with the immediately-preceding commit if it
Line 429  if (-d $fullname) {
Line 697  if (-d $fullname) {
                     if ($#tmp1 < $#tmp2) {                      if ($#tmp1 < $#tmp2) {
                         print "; <A HREF=\"${scriptwhere}.diff?r1=$revorder[$i+1]";                          print "; <A HREF=\"${scriptwhere}.diff?r1=$revorder[$i+1]";
                         print "&r2=$_" . &cvsroot .                          print "&r2=$_" . &cvsroot .
                             qq{">Diffs to $revorder[$i+1]</A>\n};                              "\">Diffs to $revorder[$i+1]</A>\n";
                     }                      }
                 }                  }
             }              }
Line 447  if (-d $fullname) {
Line 715  if (-d $fullname) {
         print "name using the type-in text box.\n";          print "name using the type-in text box.\n";
         print "</A><P>\n";          print "</A><P>\n";
         print "<FORM METHOD=\"GET\" ACTION=\"${scriptwhere}.diff\">\n";          print "<FORM METHOD=\"GET\" ACTION=\"${scriptwhere}.diff\">\n";
         print qq{<input type=hidden name=cvsroot value=$cvstree>\n}          print "<INPUT TYPE=HIDDEN NAME=\"cvsroot\" VALUE=\"$cvstree\">\n"
              if &cvsroot;               if &cvsroot;
         print "Diffs between \n";          print "Diffs between \n";
         print "<SELECT NAME=\"r1\">\n";          print "<SELECT NAME=\"r1\">\n";
Line 489  if (-d $fullname) {
Line 757  if (-d $fullname) {
         print "</FORM>\n";          print "</FORM>\n";
         print &html_footer;          print &html_footer;
         print "</BODY></HTML>\n";          print "</BODY></HTML>\n";
 } elsif ($fullname =~ s/\.diff$// && -f $fullname . ",v" &&  
                                 $input{'r1'} && $input{'r2'}) {  
         # Allow diffs using the ".diff" extension  
         # so that browsers that default to the URL  
         # for a save filename don't save diff's as  
         # e.g. foo.c  
         &dodiff($fullname, $input{'r1'}, $input{'tr1'},  
                 $input{'r2'}, $input{'tr2'}, $input{'f'});  
         exit;  
 } elsif (($newname = $fullname) =~ s|/([^/]+)$|/Attic/$1| &&  
                                  -f $newname . ",v") {  
         # The file has been removed and is in the Attic.  
         # Send a redirect pointing to the file in the Attic.  
         ($newplace = $scriptwhere) =~ s|/([^/]+)$|/Attic/$1|;  
         &redirect($newplace);  
         exit;  
 } elsif (0 && (@files = &safeglob($fullname . ",v"))) {  
         print "Content-type: text/plain\n\n";  
         print "You matched the following files:\n";  
         print join("\n", @files);  
         # Find the tags from each file  
         # Display a form offering diffs between said tags  
 } else {  
         # Assume it's a module name with a potential path following it.  
         ($module = $where) =~ s|/.*||;  
         $xtra = $&;  
         # Is there an indexed version of modules?  
         if (open(MODULES, "$cvsroot/CVSROOT/modules")) {  
                 while (<MODULES>) {  
                         if (/^(\S+)\s+(\S+)/o && $module eq $1  
                                 && -d "${cvsroot}/$2" && $module ne $2) {  
                                 &redirect($scriptname . '/' . $2 . $xtra);  
                         }  
                 }  
         }  
         &fatal("404 Not Found","$where: no such file or directory");  
 }  
   
 sub htmlify {  
         local($string, $pr) = @_;  
   
         $string =~ s/&/&amp;/g;  
         $string =~ s/</&lt;/g;  
         $string =~ s/>/&gt;/g;  
   
         if ($pr) {  
                 $string =~ s|\bpr(\W+[a-z]+/\W*)(\d+)|<A HREF=/cgi/query-pr.cgi?pr=$2>$&</A>|ig;  
         }  
   
         $string;  
 }  
   
 sub link {  
         local($name, $where) = @_;  
   
         "<A HREF=\"$where\">$name</A>\n";  
 }  
   
 sub revcmp {  
         local($rev1, $rev2) = @_;  
         local(@r1) = split(/\./, $rev1);  
         local(@r2) = split(/\./, $rev2);  
         local($a,$b);  
   
         while (($a = shift(@r1)) && ($b = shift(@r2))) {  
             if ($a != $b) {  
                 return $a <=> $b;  
             }  
         }  
         if (@r1) { return 1; }  
         if (@r2) { return -1; }  
         return 0;  
 }  
   
 sub fatal {  
         local($errcode, $errmsg) = @_;  
         print "Status: $errcode\n";  
         print &html_header("Error");  
 #       print "Content-type: text/html\n";  
 #       print "\n";  
 #       print "<HTML><HEAD><TITLE>Error</TITLE></HEAD>\n";  
 #       print "<BODY>Error: $errmsg</BODY></HTML>\n";  
         print "Error: $errmsg\n";  
         print &html_footer;  
         exit(1);  
 }  
   
 sub redirect {  
         local($url) = @_;  
         print "Status: 301 Moved\n";  
         print "Location: $url\n";  
         print &html_header("Moved");  
 #       print "Content-type: text/html\n";  
 #       print "\n";  
 #       print "<HTML><HEAD><TITLE>Moved</TITLE></HEAD>\n";  
 #       print "<BODY>This document is located <A HREF=$url>here</A>.</BODY></HTML>\n";  
         print "This document is located <A HREF=$url>here</A>.\n";  
         print &html_footer;  
         exit(1);  
 }  
   
 sub safeglob {  
         local($filename) = @_;  
         local($dirname);  
         local(@results);  
   
         ($dirname = $filename) =~ s|/[^/]+$||;  
         $filename =~ s|.*/||;  
   
         if (opendir(DIR, $dirname)) {  
                 $glob = $filename;  
         #       transform filename from glob to regex.  Deal with:  
         #       [, {, ?, * as glob chars  
         #       make sure to escape all other regex chars  
                 $glob =~ s/([\.\(\)\|\+])/\\$1/g;  
                 $glob =~ s/\*/.*/g;  
                 $glob =~ s/\?/./g;  
                 $glob =~ s/{([^}]+)}/($t = $1) =~ s-,-|-g; "($t)"/eg;  
                 foreach (readdir(DIR)) {  
                         if (/^${glob}$/) {  
                                 push(@results, $dirname . "/" .$_);  
                         }  
                 }  
         }  
   
         @results;  
 }  
   
 sub checkout {  
         local($fullname, $rev) = @_;  
   
         open(RCS, "co -p$rev '$fullname' 2>&1 |") ||  
             &fail("500 Internal Error", "Couldn't co: $!");  
 # /home/ncvs/src/sys/netinet/igmp.c,v  -->  standard output  
 # or  
 # /home/ncvs/src/sys/netinet/igmp.c,v  -->  stdout  
 # revision 1.1.1.2  
 # /*  
         $_ = <RCS>;  
         if (/^(\S+),v\s+-->\s+st(andar)?d ?out(put)?\s*$/o && $1 eq $fullname) {  
             # As expected  
         } else {  
             &fatal("500 Internal Error",  
                 "Unexpected output from co: $_");  
         }  
         $_ = <RCS>;  
         if (/^revision\s+$rev\s*$/) {  
             # As expected  
         } else {  
             &fatal("500 Internal Error",  
                 "Unexpected output from co: $_");  
         }  
         $| = 1;  
         print "Content-type: text/plain\n\n";  
         print <RCS>;  
         close(RCS);  
 }  
   
 sub dodiff {  
         local($fullname, $r1, $tr1, $r2, $tr2, $f) = @_;  
   
         if ($r1 =~ /([^:]+)(:(.+))?/) {  
             $rev1 = $1;  
             $sym1 = $3;  
         }  
         if ($rev1 eq 'text') {  
             $rev1 = $tr1;  
         }  
         if ($r2 =~ /([^:]+)(:(.+))?/) {  
             $rev2 = $1;  
             $sym2 = $3;  
         }  
         if ($rev2 eq 'text') {  
             $rev2 = $tr2;  
         }  
         if (!($rev1 =~ /^[\d\.]+$/) || !($rev2 =~ /^[\d\.]+$/)) {  
             &fatal("404 Not Found",  
                     "Malformed query \"$ENV{'QUERY_STRING'}\"");  
         }  
 #  
 # rev1 and rev2 are now both numeric revisions.  
 # Thus we do a DWIM here and swap them if rev1 is after rev2.  
 # XXX should we warn about the fact that we do this?  
         if (&revcmp($rev1,$rev2) > 0) {  
             ($tmp1, $tmp2) = ($rev1, $sym1);  
             ($rev1, $sym1) = ($rev2, $sym2);  
             ($rev2, $sym2) = ($tmp1, $tmp2);  
         }  
 #  
 #       XXX Putting '-p' here is a personal preference  
         if ($f eq 'c') {  
             $difftype = '-p -c';  
             $diffname = "Context diff";  
         } elsif ($f eq 's') {  
             $difftype = '--side-by-side --width=164';  
             $diffname = "Side by Side";  
         } else {  
             $difftype = '-p -u';  
             $diffname = "Unidiff";  
         }  
 # XXX should this just be text/plain  
 # or should it have an HTML header and then a <pre>  
         print "Content-type: text/plain\n\n";  
         open(RCSDIFF, "rcsdiff $difftype -r$rev1 -r$rev2 '$fullname' 2>&1 |") ||  
             &fail("500 Internal Error", "Couldn't rcsdiff: $!");  
 #  
 #===================================================================  
 #RCS file: /home/ncvs/src/sys/netinet/tcp_output.c,v  
 #retrieving revision 1.16  
 #retrieving revision 1.17  
 #diff -c -r1.16 -r1.17  
 #*** /home/ncvs/src/sys/netinet/tcp_output.c     1995/11/03 22:08:08     1.16  
 #--- /home/ncvs/src/sys/netinet/tcp_output.c     1995/12/05 17:46:35     1.17  
 #  
 # Ideas:  
 # - nuke the stderr output if it's what we expect it to be  
 # - Add "no differences found" if the diff command supplied no output.  
 #  
 #*** src/sys/netinet/tcp_output.c     1995/11/03 22:08:08     1.16  
 #--- src/sys/netinet/tcp_output.c     1995/12/05 17:46:35     1.17 RELENG_2_1_0  
 # (bogus example, but...)  
 #  
         if ($difftype eq '-u') {  
             $f1 = '---';  
             $f2 = '\+\+\+';  
         } else {  
             $f1 = '\*\*\*';  
             $f2 = '---';  
         }  
         while (<RCSDIFF>) {  
             if (m|^$f1 $cvsroot|o) {  
                 s|$cvsroot/||o;  
                 if ($sym1) {  
                     chop;  
                     $_ .= " " . $sym1 . "\n";  
                 }  
             } elsif (m|^$f2 $cvsroot|o) {  
                 s|$cvsroot/||o;  
                 if ($sym2) {  
                     chop;  
                     $_ .= " " . $sym2 . "\n";  
                 }  
             }  
             print $_;  
         }  
         close(RCSDIFF);  
 }  }
   
 sub cvsroot {  sub cvsroot {

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.12

CVSweb