lxr-commits Mailing List for LXR Cross Referencer (Page 21)
Brought to you by:
ajlittoz
You can subscribe to this list here.
2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(11) |
Sep
(13) |
Oct
(11) |
Nov
(19) |
Dec
(1) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2002 |
Jan
(11) |
Feb
(14) |
Mar
(10) |
Apr
|
May
|
Jun
|
Jul
(8) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2003 |
Jan
|
Feb
|
Mar
(10) |
Apr
|
May
(2) |
Jun
(4) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2004 |
Jan
|
Feb
|
Mar
|
Apr
(3) |
May
|
Jun
(26) |
Jul
(83) |
Aug
(4) |
Sep
(4) |
Oct
(9) |
Nov
|
Dec
(17) |
2005 |
Jan
(1) |
Feb
(71) |
Mar
(1) |
Apr
(3) |
May
(9) |
Jun
|
Jul
|
Aug
|
Sep
(4) |
Oct
(1) |
Nov
(6) |
Dec
|
2006 |
Jan
|
Feb
|
Mar
|
Apr
(35) |
May
|
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(12) |
2007 |
Jan
|
Feb
|
Mar
|
Apr
(2) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2009 |
Jan
|
Feb
|
Mar
(30) |
Apr
(55) |
May
(28) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2010 |
Jan
(5) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2012 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(5) |
2013 |
Jan
(35) |
Feb
|
Mar
(7) |
Apr
(12) |
May
(1) |
Jun
(2) |
Jul
|
Aug
(1) |
Sep
(32) |
Oct
|
Nov
(45) |
Dec
(18) |
2014 |
Jan
(9) |
Feb
|
Mar
(10) |
Apr
(2) |
May
(4) |
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
(7) |
Nov
(4) |
Dec
|
From: Dave B. <bro...@us...> - 2004-07-21 20:44:42
|
Update of /cvsroot/lxr/lxr/lib/LXR/Files In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25090/lib/LXR/Files Modified Files: CVS.pm Plain.pm Log Message: perltidy with options: -ce -pt=2 -nolq -nsfs Index: CVS.pm =================================================================== RCS file: /cvsroot/lxr/lxr/lib/LXR/Files/CVS.pm,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- CVS.pm 21 Jul 2004 14:08:38 -0000 1.30 +++ CVS.pm 21 Jul 2004 20:44:30 -0000 1.31 @@ -28,16 +28,17 @@ use vars qw(%cvs $cache_filename $gnu_diff); sub new { - my ( $self, $rootpath ) = @_; + my ($self, $rootpath) = @_; - $self = bless( {}, $self ); + $self = bless({}, $self); $self->{'rootpath'} = $rootpath; $self->{'rootpath'} =~ s@/*$@/@; unless (defined $gnu_diff) { + # the rcsdiff command (used in getdiff) uses parameters only supported by GNU diff $ENV{'PATH'} = '/bin:/usr/local/bin:/usr/bin:/usr/sbin'; - if ( `diff --version` =~ /GNU/ ) { + if (`diff --version` =~ /GNU/) { $gnu_diff = 1; } else { $gnu_diff = 0; @@ -48,11 +49,11 @@ } sub filerev { - my ( $self, $filename, $release ) = @_; + my ($self, $filename, $release) = @_; - if ( $release =~ /rev_([\d\.]+)/ ) { + if ($release =~ /rev_([\d\.]+)/) { return $1; - } elsif ( $release =~ /^([\d\.]+)$/ ) { + } elsif ($release =~ /^([\d\.]+)$/) { return $1; } else { $self->parsecvs($filename); @@ -61,17 +62,17 @@ } sub getfiletime { - my ( $self, $filename, $release ) = @_; + my ($self, $filename, $release) = @_; - return undef if $self->isdir( $filename, $release ); + return undef if $self->isdir($filename, $release); $self->parsecvs($filename); - my $rev = $self->filerev( $filename, $release ); + my $rev = $self->filerev($filename, $release); return undef unless defined($rev); - my @t = reverse( split( /\./, $cvs{'branch'}{$rev}{'date'} ) ); + my @t = reverse(split(/\./, $cvs{'branch'}{$rev}{'date'})); return undef unless @t; @@ -80,53 +81,53 @@ } sub getfilesize { - my ( $self, $filename, $release ) = @_; + my ($self, $filename, $release) = @_; - return length( $self->getfile( $filename, $release ) ); + return length($self->getfile($filename, $release)); } sub getfile { - my ( $self, $filename, $release ) = @_; + my ($self, $filename, $release) = @_; - my $fileh = $self->getfilehandle( $filename, $release ); + my $fileh = $self->getfilehandle($filename, $release); return undef unless $fileh; - return join( '', $fileh->getlines ); + return join('', $fileh->getlines); } sub getannotations { - my ( $self, $filename, $release ) = @_; + my ($self, $filename, $release) = @_; $self->parsecvs($filename); - my $rev = $self->filerev( $filename, $release ); + my $rev = $self->filerev($filename, $release); return () unless defined($rev); my $hrev = $cvs{'header'}{'head'}; my $lrev; my @anno; - my $headfh = $self->getfilehandle( $filename, $release ); + my $headfh = $self->getfilehandle($filename, $release); my @head = $headfh->getlines; while (1) { - if ( $rev eq $hrev ) { + if ($rev eq $hrev) { @head = 0 .. $#head; } $lrev = $hrev; $hrev = $cvs{'branch'}{$hrev}{'next'} || last; - my @diff = $self->getdiff( $filename, $lrev, $hrev ); + my @diff = $self->getdiff($filename, $lrev, $hrev); my $off = 0; while (@diff) { my $dir = shift(@diff); - if ( $dir =~ /^a(\d+)\s+(\d+)/ ) { - splice( @diff, 0, $2 ); - splice( @head, $1 - $off, 0, ('') x $2 ); + if ($dir =~ /^a(\d+)\s+(\d+)/) { + splice(@diff, 0, $2); + splice(@head, $1 - $off, 0, ('') x $2); $off -= $2; - } elsif ( $dir =~ /^d(\d+)\s+(\d+)/ ) { - map { $anno[$_] = $lrev if $_ ne ''; } splice( @head, $1 - $off - 1, $2 ); + } elsif ($dir =~ /^d(\d+)\s+(\d+)/) { + map { $anno[$_] = $lrev if $_ ne ''; } splice(@head, $1 - $off - 1, $2); $off += $2; } else { @@ -134,7 +135,7 @@ } } } - + if (@anno) { map { $anno[$_] = $lrev if $_ ne ''; } @head; } @@ -144,7 +145,7 @@ } sub getauthor { - my ( $self, $filename, $revision ) = @_; + my ($self, $filename, $revision) = @_; $self->parsecvs($filename); @@ -152,161 +153,161 @@ } sub getfilehandle { - my ( $self, $filename, $release ) = @_; + my ($self, $filename, $release) = @_; my ($fileh); $self->parsecvs($filename); - my $rev = $self->filerev( $filename, $release ); + my $rev = $self->filerev($filename, $release); return undef unless defined($rev); - return undef unless defined( $self->toreal( $filename, $release ) ); + return undef unless defined($self->toreal($filename, $release)); $rev =~ /([\d\.]*)/; $rev = $1; # untaint - my $clean_filename = $self->cleanstring( $self->toreal( $filename, $release ) ); + my $clean_filename = $self->cleanstring($self->toreal($filename, $release)); $clean_filename =~ /(.*)/; $clean_filename = $1; # technically untaint here (cleanstring did the real untainting) $ENV{'PATH'} = '/bin:/usr/local/bin:/usr/bin:/usr/sbin'; - open( $fileh, "-|", "co -q -p$rev $clean_filename" ); + open($fileh, "-|", "co -q -p$rev $clean_filename"); die("Error executing \"co\"; rcs not installed?") unless $fileh; return $fileh; } sub getdiff { - my ( $self, $filename, $release1, $release2 ) = @_; + my ($self, $filename, $release1, $release2) = @_; my ($fileh); - + return () if $gnu_diff == 0; $self->parsecvs($filename); - my $rev1 = $self->filerev( $filename, $release1 ); + my $rev1 = $self->filerev($filename, $release1); return () unless defined($rev1); - my $rev2 = $self->filerev( $filename, $release2 ); + my $rev2 = $self->filerev($filename, $release2); return () unless defined($rev2); $rev1 =~ /([\d\.]*)/; $rev1 = $1; # untaint $rev2 =~ /([\d\.]*)/; $rev2 = $1; # untaint - my $clean_filename = $self->cleanstring( $self->toreal( $filename, $release1 ) ); + my $clean_filename = $self->cleanstring($self->toreal($filename, $release1)); $clean_filename =~ /(.*)/; $clean_filename = $1; # technically untaint here (cleanstring did the real untainting) $ENV{'PATH'} = '/bin:/usr/local/bin:/usr/bin:/usr/sbin'; - open( $fileh, "-|", "rcsdiff -q -a -n -r$rev1 -r$rev2 $clean_filename" ); + open($fileh, "-|", "rcsdiff -q -a -n -r$rev1 -r$rev2 $clean_filename"); die("Error executing \"rcsdiff\"; rcs not installed?") unless $fileh; return $fileh->getlines; } sub tmpfile { - my ( $self, $filename, $release ) = @_; - my ( $tmp, $buf ); + my ($self, $filename, $release) = @_; + my ($tmp, $buf); - $buf = $self->getfile( $filename, $release ); + $buf = $self->getfile($filename, $release); return undef unless defined($buf); $tmp = $config->tmpdir . '/lxrtmp.' . time . '.' . $$ . '.' . &LXR::Common::tmpcounter; - open( TMP, "> $tmp" ) || return undef; - print( TMP $buf ); + open(TMP, "> $tmp") || return undef; + print(TMP $buf); close(TMP); return $tmp; } sub dirempty { - my ( $self, $pathname, $release ) = @_; - my ( $node, @dirs, @files ); + my ($self, $pathname, $release) = @_; + my ($node, @dirs, @files); my $DIRH = new IO::Handle; - my $real = $self->toreal( $pathname, $release ); + my $real = $self->toreal($pathname, $release); - opendir( $DIRH, $real ) || return 1; - while ( defined( $node = readdir($DIRH) ) ) { + opendir($DIRH, $real) || return 1; + while (defined($node = readdir($DIRH))) { next if $node =~ /^\.|~$|\.orig$/; next if $node eq 'CVS'; - if ( -d $real . $node ) { - push( @dirs, $node . '/' ); - } elsif ( $node =~ /(.*),v$/ ) { - push( @files, $1 ); + if (-d $real . $node) { + push(@dirs, $node . '/'); + } elsif ($node =~ /(.*),v$/) { + push(@files, $1); } } closedir($DIRH); foreach $node (@files) { - return 0 if $self->filerev( $pathname . $node, $release ); + return 0 if $self->filerev($pathname . $node, $release); } foreach $node (@dirs) { - return 0 unless $self->dirempty( $pathname . $node, $release ); + return 0 unless $self->dirempty($pathname . $node, $release); } return 1; } sub getdir { - my ( $self, $pathname, $release ) = @_; - my ( $node, @dirs, @files ); + my ($self, $pathname, $release) = @_; + my ($node, @dirs, @files); my $DIRH = new IO::Handle; - my $real = $self->toreal( $pathname, $release ); + my $real = $self->toreal($pathname, $release); - opendir( $DIRH, $real ) || return (); - FILE: while ( defined( $node = readdir($DIRH) ) ) { + opendir($DIRH, $real) || return (); + FILE: while (defined($node = readdir($DIRH))) { next if $node =~ /^\.|~$|\.orig$/; next if $node eq 'CVS'; - if ( -d $real . $node ) { - foreach my $ignoredir ( $config->ignoredirs ) { + if (-d $real . $node) { + foreach my $ignoredir ($config->ignoredirs) { next FILE if $node eq $ignoredir; } - if ( $node eq 'Attic' ) { - push( @files, $self->getdir( $pathname . $node . '/', $release ) ); + if ($node eq 'Attic') { + push(@files, $self->getdir($pathname . $node . '/', $release)); } else { - push( @dirs, $node . '/' ) + push(@dirs, $node . '/') unless defined($release) - && $self->dirempty( $pathname . $node . '/', $release ); + && $self->dirempty($pathname . $node . '/', $release); } - } elsif ( $node =~ /(.*),v$/ ) { - if ( !$$LXR::Common::HTTP{'param'}{'showattic'} ) { + } elsif ($node =~ /(.*),v$/) { + if (!$$LXR::Common::HTTP{'param'}{'showattic'}) { # you can't just check for 'Attic' because for certain versions the file is alive even if in Attic - $self->parsecvs( $pathname . substr( $node, 0, length($node) - 2 ) ) + $self->parsecvs($pathname . substr($node, 0, length($node) - 2)) ; # substr is to remove the ',v' my $rev = $cvs{'header'}{'symbols'}{$release}; - if ( $cvs{'branch'}{$rev}{'state'} eq "dead" ) { + if ($cvs{'branch'}{$rev}{'state'} eq "dead") { next; } } - push( @files, $1 ) + push(@files, $1) if !defined($release) - || $self->getfiletime( $pathname . $1, $release ); + || $self->getfiletime($pathname . $1, $release); } } closedir($DIRH); - return ( sort(@dirs), sort(@files) ); + return (sort(@dirs), sort(@files)); } sub toreal { - my ( $self, $pathname, $release ) = @_; + my ($self, $pathname, $release) = @_; my $real = $self->{'rootpath'} . $pathname; # nearly all (if not all) method calls eventually call toreal(), so this is a good place to block file access - foreach my $ignoredir ( $config->ignoredirs ) { + foreach my $ignoredir ($config->ignoredirs) { return undef if $real =~ m|/$ignoredir/|; } return $real if -d $real; - if ( !$$LXR::Common::HTTP{'param'}{'showattic'} ) { + if (!$$LXR::Common::HTTP{'param'}{'showattic'}) { # you can't just check for 'Attic' because for certain versions the file is alive even if in Attic $self->parsecvs($pathname); my $rev = $cvs{'header'}{'symbols'}{$release}; - if ( $cvs{'branch'}{$rev}{'state'} eq "dead" ) { + if ($cvs{'branch'}{$rev}{'state'} eq "dead") { return undef; } } @@ -322,11 +323,11 @@ } sub cleanstring { - my ( $self, $in ) = @_; + my ($self, $in) = @_; my $out = ''; - for ( split( '', $in ) ) { + for (split('', $in)) { s/[|&!`;\$%<>[:cntrl:]]// || # drop these in particular /[\w\/,.-_+=]/ || # keep these intact s/([ '"\x20-\x7E])/\\$1/ || # escape these out @@ -339,32 +340,32 @@ } sub isdir { - my ( $self, $pathname, $release ) = @_; + my ($self, $pathname, $release) = @_; - return -d $self->toreal( $pathname, $release ); + return -d $self->toreal($pathname, $release); } sub isfile { - my ( $self, $pathname, $release ) = @_; + my ($self, $pathname, $release) = @_; - return -f $self->toreal( $pathname, $release ); + return -f $self->toreal($pathname, $release); } sub getindex { - my ( $self, $pathname, $release ) = @_; + my ($self, $pathname, $release) = @_; - my $index = $self->getfile( $pathname, $release ); + my $index = $self->getfile($pathname, $release); return $index =~ /\n(\S*)\s*\n\t-\s*([^\n]*)/gs; } sub allreleases { - my ( $self, $filename ) = @_; + my ($self, $filename) = @_; $self->parsecvs($filename); # no header symbols for a directory, so we use the default and the current release - if ( defined %{ $cvs{'header'}{'symbols'} } ) { + if (defined %{ $cvs{'header'}{'symbols'} }) { return sort keys %{ $cvs{'header'}{'symbols'} }; } else { my @releases; @@ -384,15 +385,17 @@ my $ret = $one[$i] <=> $two[$i]; return $ret if $ret; } - return $#one <=> $#two; # if still no difference after we ran through all elements of @one, compare the length of the array + + # if still no difference after we ran through all elements of @one, compare the length of the array + return $#one <=> $#two; } sub allrevisions { - my ( $self, $filename ) = @_; + my ($self, $filename) = @_; $self->parsecvs($filename); - return sort byrevision keys( %{ $cvs{'branch'} } ); + return sort byrevision keys(%{ $cvs{'branch'} }); } sub parsecvs { @@ -400,7 +403,7 @@ # Actually, these days it just parses the header. # RCS tools are much better at parsing RCS files. # -pok - my ( $self, $filename ) = @_; + my ($self, $filename) = @_; return if $cache_filename eq $filename; $cache_filename = $filename; @@ -408,7 +411,7 @@ undef %cvs; my $file = ''; - open( CVS, $self->toreal( $filename, undef ) ); + open(CVS, $self->toreal($filename, undef)); close CVS and return if -d CVS; # we can't parse a directory while (<CVS>) { if (/^text\s*$/) { @@ -425,31 +428,31 @@ $cvs{'header'} = { map { s/@@/@/gs; - /^@/s && substr( $_, 1, -1 ) || $_ + /^@/s && substr($_, 1, -1) || $_ } shift(@cvs) =~ /(\w+)\s*((?:[^;@]+|@[^@]*@)*);/gs }; $cvs{'header'}{'symbols'} = { $cvs{'header'}{'symbols'} =~ /(\S+?):(\S+)/g }; - my ( $orel, $nrel, $rev ); - while ( ( $orel, $rev ) = each %{ $cvs{'header'}{'symbols'} } ) { + my ($orel, $nrel, $rev); + while (($orel, $rev) = each %{ $cvs{'header'}{'symbols'} }) { $nrel = $config->cvsversion($orel); next unless defined($nrel); - if ( $nrel ne $orel ) { - delete( $cvs{'header'}{'symbols'}{$orel} ); + if ($nrel ne $orel) { + delete($cvs{'header'}{'symbols'}{$orel}); $cvs{'header'}{'symbols'}{$nrel} = $rev if $nrel; } } $cvs{'header'}{'symbols'}{'head'} = $cvs{'header'}{'head'}; - while ( @cvs && $cvs[0] !~ /\s*desc/s ) { - my ( $r, $v ) = shift(@cvs) =~ /\s*(\S+)\s*(.*)/s; + while (@cvs && $cvs[0] !~ /\s*desc/s) { + my ($r, $v) = shift(@cvs) =~ /\s*(\S+)\s*(.*)/s; $cvs{'branch'}{$r} = { map { s/@@/@/gs; - /^@/s && substr( $_, 1, -1 ) || $_ + /^@/s && substr($_, 1, -1) || $_ } $v =~ /(\w+)\s*((?:[^;@]+|@[^@]*@)*);/gs }; } Index: Plain.pm =================================================================== RCS file: /cvsroot/lxr/lxr/lib/LXR/Files/Plain.pm,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- Plain.pm 19 Jul 2004 19:50:21 -0000 1.23 +++ Plain.pm 21 Jul 2004 20:44:31 -0000 1.24 @@ -25,9 +25,9 @@ use LXR::Common; sub new { - my ( $self, $rootpath ) = @_; + my ($self, $rootpath) = @_; - $self = bless( {}, $self ); + $self = bless({}, $self); $self->{'rootpath'} = $rootpath; $self->{'rootpath'} =~ s@/*$@/@; @@ -35,54 +35,53 @@ } sub filerev { - my ( $self, $filename, $release ) = @_; + my ($self, $filename, $release) = @_; # return $release; - return join( "-", - $self->getfiletime( $filename, $release ), - $self->getfilesize( $filename, $release ) ); + return + join("-", $self->getfiletime($filename, $release), $self->getfilesize($filename, $release)); } sub getfiletime { - my ( $self, $filename, $release ) = @_; + my ($self, $filename, $release) = @_; - return ( stat( $self->toreal( $filename, $release ) ) )[9]; + return (stat($self->toreal($filename, $release)))[9]; } sub getfilesize { - my ( $self, $filename, $release ) = @_; + my ($self, $filename, $release) = @_; - return -s $self->toreal( $filename, $release ); + return -s $self->toreal($filename, $release); } sub getfile { - my ( $self, $filename, $release ) = @_; + my ($self, $filename, $release) = @_; my ($buffer); local ($/) = undef; - open( FILE, "<", $self->toreal( $filename, $release ) ) || return undef; + open(FILE, "<", $self->toreal($filename, $release)) || return undef; $buffer = <FILE>; close(FILE); return $buffer; } sub getfilehandle { - my ( $self, $filename, $release ) = @_; + my ($self, $filename, $release) = @_; my ($fileh); - $fileh = new FileHandle( $self->toreal( $filename, $release ) ); + $fileh = new FileHandle($self->toreal($filename, $release)); return $fileh; } sub tmpfile { - my ( $self, $filename, $release ) = @_; - my ( $tmp, $tries ); + my ($self, $filename, $release) = @_; + my ($tmp, $tries); local ($/) = undef; $tmp = $config->tmpdir . '/lxrtmp.' . time . '.' . $$ . '.' . &LXR::Common::tmpcounter; - open( TMP, "> $tmp" ) || return undef; - open( FILE, "<", $self->toreal( $filename, $release ) ) || return undef; - print( TMP <FILE> ); + open(TMP, "> $tmp") || return undef; + open(FILE, "<", $self->toreal($filename, $release)) || return undef; + print(TMP <FILE>); close(FILE); close(TMP); @@ -98,22 +97,22 @@ } sub getdir { - my ( $self, $pathname, $release ) = @_; - my ( $dir, $node, @dirs, @files ); + my ($self, $pathname, $release) = @_; + my ($dir, $node, @dirs, @files); - $dir = $self->toreal( $pathname, $release ); - opendir( DIR, $dir ) || return (); - FILE: while ( defined( $node = readdir(DIR) ) ) { + $dir = $self->toreal($pathname, $release); + opendir(DIR, $dir) || return (); + FILE: while (defined($node = readdir(DIR))) { next if $node =~ /^\.|~$|\.orig$/; next if $node eq 'CVS'; - if ( -d $dir . $node ) { - foreach my $ignoredir ( $config->ignoredirs ) { + if (-d $dir . $node) { + foreach my $ignoredir ($config->ignoredirs) { next FILE if $node eq $ignoredir; } - push( @dirs, $node . '/' ); + push(@dirs, $node . '/'); } else { - push( @files, $node ); + push(@files, $node); } } closedir(DIR); @@ -127,35 +126,35 @@ # other possible File classes.) sub toreal { - my ( $self, $pathname, $release ) = @_; + my ($self, $pathname, $release) = @_; # nearly all (if not all) method calls eventually call toreal(), so this is a good place to block file access - foreach my $ignoredir ( $config->ignoredirs ) { + foreach my $ignoredir ($config->ignoredirs) { return undef if $pathname =~ m|/$ignoredir/|; } - return ( $self->{'rootpath'} . $release . $pathname ); + return ($self->{'rootpath'} . $release . $pathname); } sub isdir { - my ( $self, $pathname, $release ) = @_; + my ($self, $pathname, $release) = @_; - return -d $self->toreal( $pathname, $release ); + return -d $self->toreal($pathname, $release); } sub isfile { - my ( $self, $pathname, $release ) = @_; + my ($self, $pathname, $release) = @_; - return -f $self->toreal( $pathname, $release ); + return -f $self->toreal($pathname, $release); } sub getindex { - my ( $self, $pathname, $release ) = @_; - my ( $index, %index ); - my $indexname = $self->toreal( $pathname, $release ) . "00-INDEX"; + my ($self, $pathname, $release) = @_; + my ($index, %index); + my $indexname = $self->toreal($pathname, $release) . "00-INDEX"; - if ( -f $indexname ) { - open( INDEX, "<", $indexname ) + if (-f $indexname) { + open(INDEX, "<", $indexname) || warning("Existing $indexname could not be opened."); local ($/) = undef; $index = <INDEX>; @@ -166,13 +165,13 @@ } sub allreleases { - my ( $self, $filename ) = @_; + my ($self, $filename) = @_; - opendir( SRCDIR, $self->{'rootpath'} ); + opendir(SRCDIR, $self->{'rootpath'}); my @dirs = readdir(SRCDIR); closedir(SRCDIR); - return grep { /^[^\.]/ && -r $self->toreal( $filename, $_ ) } @dirs; + return grep { /^[^\.]/ && -r $self->toreal($filename, $_) } @dirs; } 1; |
From: Dave B. <bro...@us...> - 2004-07-21 20:44:42
|
Update of /cvsroot/lxr/lxr/lib/LXR/Lang In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25090/lib/LXR/Lang Modified Files: Generic.pm Java.pm Perl.pm Python.pm generic.conf Log Message: perltidy with options: -ce -pt=2 -nolq -nsfs Index: Generic.pm =================================================================== RCS file: /cvsroot/lxr/lxr/lib/LXR/Lang/Generic.pm,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- Generic.pm 20 Jul 2004 18:58:24 -0000 1.16 +++ Generic.pm 21 Jul 2004 20:44:31 -0000 1.17 @@ -35,15 +35,15 @@ @LXR::Lang::Generic::ISA = ('LXR::Lang'); sub new { - my ( $proto, $pathname, $release, $lang ) = @_; + my ($proto, $pathname, $release, $lang) = @_; my $class = ref($proto) || $proto; my $self = {}; - bless( $self, $class ); + bless($self, $class); $$self{'release'} = $release; $$self{'language'} = $lang; read_config() unless defined $generic_config; - %$self = ( %$self, %$generic_config ); + %$self = (%$self, %$generic_config); # Set langid $$self{'langid'} = $self->langinfo('langid'); @@ -56,23 +56,23 @@ # config file each time. Because it is only done once, we also use # this to check the version of ctags. sub read_config { - open( CONF, $config->genericconf ) || die "Can't open " . $config->genericconf . ", $!"; + open(CONF, $config->genericconf) || die "Can't open " . $config->genericconf . ", $!"; local ($/) = undef; my $config_contents = <CONF>; $config_contents =~ /(.*)/s; - $config_contents = $1; #untaint it - $generic_config = eval( "\n#line 1 \"generic.conf\"\n" . $config_contents ); + $config_contents = $1; #untaint it + $generic_config = eval("\n#line 1 \"generic.conf\"\n" . $config_contents); die($@) if $@; close CONF; # Setup the ctags to declid mapping my $langmap = $generic_config->{'langmap'}; - foreach my $lang ( keys %$langmap ) { + foreach my $lang (keys %$langmap) { my $typemap = $langmap->{$lang}{'typemap'}; - foreach my $type ( keys %$typemap ) { - $typemap->{$type} = $index->getdecid( $langmap->{$lang}{'langid'}, $typemap->{$type} ); + foreach my $type (keys %$typemap) { + $typemap->{$type} = $index->getdecid($langmap->{$lang}{'langid'}, $typemap->{$type}); } } @@ -81,50 +81,50 @@ $ENV{'PATH'} = '/bin:/usr/local/bin:/usr/bin:/usr/sbin'; my $version = `$ctags --version`; $version =~ /Exuberant ctags +(\d+)/i; - if ( $1 < 5 ) { + if ($1 < 5) { die "Exuberant ctags version 5 or above required, found $version\n"; } } sub indexfile { - my ( $self, $name, $path, $fileid, $index, $config ) = @_; + my ($self, $name, $path, $fileid, $index, $config) = @_; my $typemap = $self->langinfo('typemap'); my $langforce = ${ $self->eclangnamemapping }{ $self->language }; - if ( !defined $langforce ) { + if (!defined $langforce) { $langforce = $self->language; } - if ( $config->ectagsbin ) { - open( CTAGS, - join( " ", + if ($config->ectagsbin) { + open(CTAGS, + join(" ", $config->ectagsbin, $self->ectagsopts, "--excmd=number", - "--language-force=$langforce", "-f", "-", $path, "|" ) + "--language-force=$langforce", "-f", "-", $path, "|") ) or die "Can't run ectags, $!"; while (<CTAGS>) { chomp; - my ( $sym, $file, $line, $type, $ext ) = split( /\t/, $_ ); + my ($sym, $file, $line, $type, $ext) = split(/\t/, $_); $line =~ s/;\"$//; $ext =~ /language:(\w+)/; $type = $typemap->{$type}; - if ( !defined $type ) { - print "Warning: Unknown type ", ( split( /\t/, $_ ) )[3], "\n"; + if (!defined $type) { + print "Warning: Unknown type ", (split(/\t/, $_))[3], "\n"; next; } # TODO: can we make it more generic in parsing the extension fields? - if ( defined($ext) && $ext =~ /^(struct|union|class|enum):(.*)/ ) { + if (defined($ext) && $ext =~ /^(struct|union|class|enum):(.*)/) { $ext = $2; $ext =~ s/::<anonymous>//g; } else { $ext = undef; } - $index->index( $sym, $fileid, $line, $self->langid, $type, $ext ); + $index->index($sym, $fileid, $line, $self->langid, $type, $ext); } close(CTAGS); @@ -151,8 +151,8 @@ # TODO : Make the handling of identifier recognition language dependant sub processcode { - my ( $self, $code ) = @_; - my ( $start, $id ); + my ($self, $code) = @_; + my ($start, $id); $$code =~ s {(^|[^\w\#])([\w~][\w]*)\b} # Replace identifier by link unless it's a reserved word { @@ -169,23 +169,23 @@ # sub referencefile { - my ( $self, $name, $path, $fileid, $index, $config ) = @_; + my ($self, $name, $path, $fileid, $index, $config) = @_; require LXR::SimpleParse; # Use dummy tabwidth here since it doesn't matter for referencing - &LXR::SimpleParse::init( new FileHandle($path), 1, $self->parsespec ); + &LXR::SimpleParse::init(new FileHandle($path), 1, $self->parsespec); my $linenum = 1; - my ( $btype, $frag ) = &LXR::SimpleParse::nextfrag; + my ($btype, $frag) = &LXR::SimpleParse::nextfrag; my @lines; my $ls; - while ( defined($frag) ) { - @lines = ( $frag =~ /(.*?\n)/g, $frag =~ /([^\n]*)$/ ); + while (defined($frag)) { + @lines = ($frag =~ /(.*?\n)/g, $frag =~ /([^\n]*)$/); - if ( defined($btype) ) { - if ( $btype eq 'comment' or $btype eq 'string' or $btype eq 'include' ) { + if (defined($btype)) { + if ($btype eq 'comment' or $btype eq 'string' or $btype eq 'include') { $linenum += @lines - 1; } else { print "BTYPE was: $btype\n"; @@ -203,12 +203,12 @@ $string = $_; # print "considering $string\n"; - if ( !grep( /^$string$/, $self->langinfo('reserved') ) - && $index->issymbol($string) ) + if (!grep(/^$string$/, $self->langinfo('reserved')) + && $index->issymbol($string)) { # print "adding $string to references\n"; - $index->reference( $string, $fileid, $linenum ); + $index->reference($string, $fileid, $linenum); } } @@ -217,7 +217,7 @@ } $linenum--; } - ( $btype, $frag ) = &LXR::SimpleParse::nextfrag; + ($btype, $frag) = &LXR::SimpleParse::nextfrag; } print("+++ $linenum\n"); } @@ -227,7 +227,7 @@ # this works. sub variable { - my ( $self, $var, $val ) = @_; + my ($self, $var, $val) = @_; $self->{variables}{$var}{value} = $val if defined($val); return $self->{variables}{$var}{value} @@ -235,21 +235,21 @@ } sub varexpand { - my ( $self, $exp ) = @_; + my ($self, $exp) = @_; $exp =~ s/\$\{?(\w+)\}?/$self->variable($1)/ge; return $exp; } sub value { - my ( $self, $var ) = @_; + my ($self, $var) = @_; - if ( exists( $self->{$var} ) ) { + if (exists($self->{$var})) { my $val = $self->{$var}; - if ( ref($val) eq 'ARRAY' ) { + if (ref($val) eq 'ARRAY') { return map { $self->varexpand($_) } @$val; - } elsif ( ref($val) eq 'CODE' ) { + } elsif (ref($val) eq 'CODE') { return $val; } else { return $self->varexpand($val); @@ -261,11 +261,11 @@ sub AUTOLOAD { my $self = shift; - ( my $var = $AUTOLOAD ) =~ s/.*:://; + (my $var = $AUTOLOAD) =~ s/.*:://; my @val = $self->value($var); - if ( ref( $val[0] ) eq 'CODE' ) { + if (ref($val[0]) eq 'CODE') { return $val[0]->(@_); } else { return wantarray ? @val : $val[0]; @@ -273,19 +273,19 @@ } sub langinfo { - my ( $self, $item ) = @_; + my ($self, $item) = @_; my $val; my $map = $self->langmap; die if !defined $map; - if ( exists $$map{ $self->language } ) { + if (exists $$map{ $self->language }) { $val = $$map{ $self->language }; } else { return undef; } - if ( defined $val && defined $$val{$item} ) { - if ( ref( $$val{$item} ) eq 'ARRAY' ) { + if (defined $val && defined $$val{$item}) { + if (ref($$val{$item}) eq 'ARRAY') { return wantarray ? @{ $$val{$item} } : $$val{$item}; } return $$val{$item}; Index: Java.pm =================================================================== RCS file: /cvsroot/lxr/lxr/lib/LXR/Lang/Java.pm,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- Java.pm 19 Jul 2004 19:50:21 -0000 1.5 +++ Java.pm 21 Jul 2004 20:44:31 -0000 1.6 @@ -35,7 +35,7 @@ # and "import" keywords sub processinclude { - my ( $self, $frag, $dir ) = @_; + my ($self, $frag, $dir) = @_; # Deal with package declaration of the form # "package java.lang.util" Index: Perl.pm =================================================================== RCS file: /cvsroot/lxr/lxr/lib/LXR/Lang/Perl.pm,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- Perl.pm 19 Jul 2004 19:50:21 -0000 1.6 +++ Perl.pm 21 Jul 2004 20:44:31 -0000 1.7 @@ -34,20 +34,20 @@ @ISA = ('LXR::Lang'); my @spec = ( - 'atom' => ( '\$\W?', '' ), - 'atom' => ( '\\\\.', '' ), - 'include' => ( '\buse\s+', ';' ), - 'include' => ( '\brequire\s+', ';' ), - 'string' => ( '"', '"' ), - 'comment' => ( '#', "\$" ), - 'comment' => ( "^=\\w+", "^=cut" ), - 'string' => ( "'", "'" ) + 'atom' => ('\$\W?', ''), + 'atom' => ('\\\\.', ''), + 'include' => ('\buse\s+', ';'), + 'include' => ('\brequire\s+', ';'), + 'string' => ('"', '"'), + 'comment' => ('#', "\$"), + 'comment' => ("^=\\w+", "^=cut"), + 'string' => ("'", "'") ); sub new { - my ( $self, $pathname, $release ) = @_; + my ($self, $pathname, $release) = @_; - $self = bless( {}, $self ); + $self = bless({}, $self); $$self{'release'} = $release; @@ -59,7 +59,7 @@ } sub processcode { - my ( $self, $code, @itag ) = @_; + my ($self, $code, @itag) = @_; my $sym; # $$code =~ s#([\@\$\%\&\*])([a-z0-9_]+)|\b([a-z0-9_]+)(\s*\()# @@ -81,19 +81,19 @@ $file =~ s,::,/,g; $file .= ".pm"; - return &LXR::Common::incref( $mod, "include", $file ); + return &LXR::Common::incref($mod, "include", $file); } sub processinclude { - my ( $self, $frag, $dir ) = @_; + my ($self, $frag, $dir) = @_; $$frag =~ s/(use\s+|require\s+)([\w:]+)/$1.modref($2)/e; } sub processcomment { - my ( $self, $comm ) = @_; + my ($self, $comm) = @_; - if ( $$comm =~ /^=/s ) { + if ($$comm =~ /^=/s) { # Pod text @@ -102,11 +102,11 @@ map { if (/^=head(\d)\s*(.*)/s) { - "<span class=\"pod\"><font size=\"+" . ( 4 - $1 ) . "\">$2<\/font></span>"; + "<span class=\"pod\"><font size=\"+" . (4 - $1) . "\">$2<\/font></span>"; } elsif (/^=item\s*(.*)/s) { - "<span class=\"podhead\">* $1 " . ( "-" x ( 67 - length($1) ) ) . "<\/span>"; + "<span class=\"podhead\">* $1 " . ("-" x (67 - length($1))) . "<\/span>"; } elsif (/^=(pod|cut)/s) { - "<span class=\"podhead\">" . ( "-" x 70 ) . "<\/span>"; + "<span class=\"podhead\">" . ("-" x 70) . "<\/span>"; } elsif (/^=.*/s) { ""; } else { @@ -118,7 +118,7 @@ } $_; } - } split( /((?:\n[ \t]*)*\n)/, $$comm ) + } split(/((?:\n[ \t]*)*\n)/, $$comm) ); } else { $$comm =~ s|^(.*)$|<span class='comment'>$1</span>|gm; @@ -126,20 +126,20 @@ } sub indexfile { - my ( $self, $name, $path, $fileid, $index, $config ) = @_; + my ($self, $name, $path, $fileid, $index, $config) = @_; - open( PLTAG, $path ); + open(PLTAG, $path); while (<PLTAG>) { if (/^sub\s+(\w+)/) { - print( STDERR "Sub: $1\n" ); - $index->index( $1, $fileid, $., 'f' ); + print(STDERR "Sub: $1\n"); + $index->index($1, $fileid, $., 'f'); } elsif (/^package\s+([\w:]+)/) { - print( STDERR "Class: $1\n" ); - $index->index( $1, $fileid, $., 'c' ); + print(STDERR "Class: $1\n"); + $index->index($1, $fileid, $., 'c'); } elsif (/^=item\s+[\@\$\%\&\*]?(\w+)/) { - print( STDERR "Doc: $1\n" ); - $index->index( $1, $fileid, $., 'i' ); + print(STDERR "Doc: $1\n"); + $index->index($1, $fileid, $., 'i'); } } close(PLTAG); Index: Python.pm =================================================================== RCS file: /cvsroot/lxr/lxr/lib/LXR/Lang/Python.pm,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- Python.pm 19 Jul 2004 19:50:21 -0000 1.3 +++ Python.pm 21 Jul 2004 20:44:31 -0000 1.4 @@ -28,20 +28,20 @@ @ISA = ('LXR::Lang'); my @spec = ( - 'comment' => ( '#', "\$" ), - 'string' => ( '"', '"' ), - 'string' => ( "'", "'" ), - 'atom' => ( '\\\\.', '' ) + 'comment' => ('#', "\$"), + 'string' => ('"', '"'), + 'string' => ("'", "'"), + 'atom' => ('\\\\.', '') ); sub new { - my ( $self, $pathname, $release ) = @_; + my ($self, $pathname, $release) = @_; - $self = bless( {}, $self ); + $self = bless({}, $self); $$self{'release'} = $release; - if ( $pathname =~ /(\w+)\.py$/ || $pathname =~ /(\w+)$/ ) { + if ($pathname =~ /(\w+)\.py$/ || $pathname =~ /(\w+)$/) { $$self{'modulename'} = $1; } @@ -53,7 +53,7 @@ } sub processcode { - my ( $self, $code, @itag ) = @_; + my ($self, $code, @itag) = @_; $$code =~ s/([a-zA-Z_][a-zA-Z0-9_\.]*)/ ($index->issymbol( $$self{'modulename'}.".".$1, $$self{'release'} ) @@ -67,37 +67,37 @@ } sub indexfile { - my ( $self, $name, $path, $fileid, $index, $config ) = @_; + my ($self, $name, $path, $fileid, $index, $config) = @_; - my ( @ptag_lines, @single_ptag, $module_name ); + my (@ptag_lines, @single_ptag, $module_name); - if ( $name =~ m|/(\w+)\.py$| ) { + if ($name =~ m|/(\w+)\.py$|) { $module_name = $1; } - open( PYTAG, $path ); + open(PYTAG, $path); while (<PYTAG>) { chomp; # Function definitions - if ( $_ =~ /^\s*def\s+([^\(]+)/ ) { - $index->index( $module_name . "\.$1", $fileid, $., "f" ); + if ($_ =~ /^\s*def\s+([^\(]+)/) { + $index->index($module_name . "\.$1", $fileid, $., "f"); } # Class definitions - elsif ( $_ =~ /^\s*class\s+([^\(:]+)/ ) { - $index->index( $module_name . "\.$1", $fileid, $., "c" ); + elsif ($_ =~ /^\s*class\s+([^\(:]+)/) { + $index->index($module_name . "\.$1", $fileid, $., "c"); } # Targets that are identifiers if occurring in an assignment.. - elsif ( $_ =~ /^(\w+) *=.*/ ) { - $index->index( $module_name . "\.$1", $fileid, $., "v" ); + elsif ($_ =~ /^(\w+) *=.*/) { + $index->index($module_name . "\.$1", $fileid, $., "v"); } # ..for loop header. - elsif ( $_ =~ /^for\s+(\w+)\s+in.*/ ) { - $index->index( $module_name . "\.$1", $fileid, $., "v" ); + elsif ($_ =~ /^for\s+(\w+)\s+in.*/) { + $index->index($module_name . "\.$1", $fileid, $., "v"); } } close(PYTAG); Index: generic.conf =================================================================== RCS file: /cvsroot/lxr/lxr/lib/LXR/Lang/generic.conf,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- generic.conf 20 Jul 2004 15:28:46 -0000 1.15 +++ generic.conf 21 Jul 2004 20:44:31 -0000 1.16 @@ -1,686 +1,687 @@ -# -*- mode: perl; tab-width: 2 -*- +# -*- mode: perl; tab-width: 2 -*- # Configure options for the generic language support { - # Options to always feed to ectags - 'ectagsopts' => ["--options=".$config->ectagsconf, "--c-types=+px", "--eiffel-types=+l", - "--fortran-types=+L",], - # How to map a language name to the ectags language-force name - # if there is no mapping, then the language name is used [...1329 lines suppressed...] + 'f' => 'function', + 'c' => 'const', + 'n' => 'name', + 'l' => 'label', + 'e' => 'enum', + 'v' => 'variable', + 't' => 'type', + }, + 'langid' => '12', + }, + 'shell' => { + 'reserved' => [ + 'for', 'do', 'done', 'case', 'esac', 'while', 'in', 'if', + 'then', 'else', 'elif', 'fi', 'until', + ], + 'spec' => [ 'comment', '#', '$', 'string', '"', '"', 'string', "'", "'", ], + 'typemap' => { 'f' => 'function', }, + 'langid' => '13', + }, + } } |
From: Dave B. <bro...@us...> - 2004-07-21 20:44:41
|
Update of /cvsroot/lxr/lxr/lib/LXR In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25090/lib/LXR Modified Files: Common.pm Config.pm Files.pm Index.pm Lang.pm SimpleParse.pm Tagger.pm Log Message: perltidy with options: -ce -pt=2 -nolq -nsfs Index: Common.pm =================================================================== RCS file: /cvsroot/lxr/lxr/lib/LXR/Common.pm,v retrieving revision 1.48 retrieving revision 1.49 diff -u -d -r1.48 -r1.49 --- Common.pm 19 Jul 2004 19:50:20 -0000 1.48 +++ Common.pm 21 Jul 2004 20:44:30 -0000 1.49 @@ -40,7 +40,7 @@ &markupstring &httpinit &makeheader &makefooter &expandtemplate &httpclean); -%EXPORT_TAGS = ( 'html' => [@EXPORT_OK] ); +%EXPORT_TAGS = ('html' => [@EXPORT_OK]); require Local; require LXR::SimpleParse; @@ -54,23 +54,23 @@ $tmpcounter = 23; sub warning { - my $c = join( ", line ", (caller)[ 0, 2 ] ); - print( STDERR "[", scalar(localtime), "] warning: $c: $_[0]\n" ); + my $c = join(", line ", (caller)[ 0, 2 ]); + print(STDERR "[", scalar(localtime), "] warning: $c: $_[0]\n"); print("<h4 align=\"center\"><i>** Warning: $_[0]</i></h4>\n") if $wwwdebug; } sub fatal { - my $c = join( ", line ", (caller)[ 0, 2 ] ); - print( STDERR "[", scalar(localtime), "] fatal: $c: $_[0]\n" ); - print( STDERR '[@INC ', join( " ", @INC ), ' $0 ', $0, "\n" ); - print( STDERR '$config', join( " ", %$config ), "\n" ) if ref($config) eq "HASH"; + my $c = join(", line ", (caller)[ 0, 2 ]); + print(STDERR "[", scalar(localtime), "] fatal: $c: $_[0]\n"); + print(STDERR '[@INC ', join(" ", @INC), ' $0 ', $0, "\n"); + print(STDERR '$config', join(" ", %$config), "\n") if ref($config) eq "HASH"; print("<h4 align=\"center\"><i>** Fatal: $_[0]</i></h4>\n") if $wwwdebug; exit(1); } sub abortall { - my $c = join( ", line ", (caller)[ 0, 2 ] ); - print( STDERR "[", scalar(localtime), "] abortall: $c: $_[0]\n" ); + my $c = join(", line ", (caller)[ 0, 2 ]); + print(STDERR "[", scalar(localtime), "] abortall: $c: $_[0]\n"); print( "Content-Type: text/html; charset=iso-8859-1\n\n", "<html>\n<head>\n<title>Abort</title>\n</head>\n", @@ -101,62 +101,62 @@ } @args = (); - foreach ( $config->allvariables ) { + foreach ($config->allvariables) { $val = $args{$_} || $config->variable($_); - push( @args, "$_=$val" ) unless ( $val eq $config->vardefault($_) ); - delete( $args{$_} ); + push(@args, "$_=$val") unless ($val eq $config->vardefault($_)); + delete($args{$_}); } - foreach ( keys(%args) ) { - push( @args, "$_=$args{$_}" ); + foreach (keys(%args)) { + push(@args, "$_=$args{$_}"); } - return ( $#args < 0 ? '' : '?' . join( ';', @args ) ); + return ($#args < 0 ? '' : '?' . join(';', @args)); } sub fileref { - my ( $desc, $css, $path, $line, @args ) = @_; + my ($desc, $css, $path, $line, @args) = @_; # jwz: URL-quote any special characters. $path =~ s|([^-a-zA-Z0-9.\@/_\r\n])|sprintf("%%%02X", ord($1))|ge; - if ( $line > 0 && length($line) < 3 ) { - $line = ( '0' x ( 3 - length($line) ) ) . $line; + if ($line > 0 && length($line) < 3) { + $line = ('0' x (3 - length($line))) . $line; } return ("<a class='$css' href=\"$config->{virtroot}/source$path" . &urlargs(@args) - . ( $line > 0 ? "#$line" : "" ) - . "\"\>$desc</a>" ); + . ($line > 0 ? "#$line" : "") + . "\"\>$desc</a>"); } sub diffref { - my ( $desc, $css, $path, $darg ) = @_; + my ($desc, $css, $path, $darg) = @_; my $dval; - ( $darg, $dval ) = $darg =~ /(.*?)=(.*)/; + ($darg, $dval) = $darg =~ /(.*?)=(.*)/; return ("<a class='$css' href=\"$config->{virtroot}/diff$path" - . &urlargs( ( $darg ? "diffvar=$darg" : "" ), ( $dval ? "diffval=$dval" : "" ) ) - . "\"\>$desc</a>" ); + . &urlargs(($darg ? "diffvar=$darg" : ""), ($dval ? "diffval=$dval" : "")) + . "\"\>$desc</a>"); } sub idref { - my ( $desc, $css, $id, @args ) = @_; + my ($desc, $css, $id, @args) = @_; return ("<a class='$css' href=\"$config->{virtroot}/ident" - . &urlargs( ( $id ? "i=$id" : "" ), @args ) - . "\"\>$desc</a>" ); + . &urlargs(($id ? "i=$id" : ""), @args) + . "\"\>$desc</a>"); } sub incref { - my ( $name, $css, $file, @paths ) = @_; - my ( $dir, $path ); + my ($name, $css, $file, @paths) = @_; + my ($dir, $path); - push( @paths, $config->incprefix ); + push(@paths, $config->incprefix); foreach $dir (@paths) { $dir =~ s/\/+$//; - $path = $config->mappath( $dir . "/" . $file ); - return &fileref( $name, $css, $path ) if $files->isfile( $path, $release ); + $path = $config->mappath($dir . "/" . $file); + return &fileref($name, $css, $path) if $files->isfile($path, $release); } @@ -165,7 +165,7 @@ sub http_wash { my $t = shift; - if ( !defined($t) ) { + if (!defined($t)) { return (undef); } @@ -181,7 +181,7 @@ # dme: Smaller version of the markupfile function meant for marking up # the descriptions in source directory listings. sub markupstring { - my ( $string, $virtp ) = @_; + my ($string, $virtp) = @_; # Mark special characters so they don't get processed just yet. $string =~ s/([\&\<\>])/\0$1/g; @@ -212,7 +212,7 @@ # HTMLify file names, assuming file is in the current directory. $string =~ -s#\b(([\w\-_\/]+\.(c|h|cc|cp|hpp|cpp|java))|README)\b#<a href=\"$config->{virtroot}/source$virtp$1\">$1</a>#g; + s#\b(([\w\-_\/]+\.(c|h|cc|cp|hpp|cpp|java))|README)\b#<a href=\"$config->{virtroot}/source$virtp$1\">$1</a>#g; return ($string); } @@ -228,7 +228,7 @@ if ( $string =~ /....../ - && ( $string =~ /_/ || $string =~ /.[A-Z]/ ) + && ($string =~ /_/ || $string =~ /.[A-Z]/) # && defined($xref{$string}) FIXME ) @@ -260,55 +260,54 @@ #_PH_ supress block is here to avoid the <pre> tag output #while called from diff - my ( $fileh, $outfun ) = @_; + my ($fileh, $outfun) = @_; my ($dir) = $pathname =~ m|^(.*/)|; my $line = '001'; - my @ltag = &fileref( 1, "fline", $pathname, 1 ) =~ /^(<a)(.*\#)001(\">)1(<\/a>)$/; + my @ltag = &fileref(1, "fline", $pathname, 1) =~ /^(<a)(.*\#)001(\">)1(<\/a>)$/; $ltag[0] .= ' name='; $ltag[3] .= " "; - my @itag = &idref( 1, "fid", 1 ) =~ /^(.*=)1(\">)1(<\/a>)$/; - my $lang = new LXR::Lang( $pathname, $release, @itag ); + my @itag = &idref(1, "fid", 1) =~ /^(.*=)1(\">)1(<\/a>)$/; + my $lang = new LXR::Lang($pathname, $release, @itag); # A source code file if ($lang) { my $language = $lang->language; # To get back to the key to lookup the tabwidth. + &LXR::SimpleParse::init($fileh, $config->filetype->{$language}[3], $lang->parsespec); - &LXR::SimpleParse::init( $fileh, $config->filetype->{$language}[3], $lang->parsespec ); - - my ( $btype, $frag ) = &LXR::SimpleParse::nextfrag; + my ($btype, $frag) = &LXR::SimpleParse::nextfrag; #&$outfun("<pre class=\"file\">\n"); - &$outfun( join( $line++, @ltag ) ) if defined($frag); + &$outfun(join($line++, @ltag)) if defined($frag); - while ( defined($frag) ) { + while (defined($frag)) { &markspecials($frag); - if ( $btype eq 'comment' ) { + if ($btype eq 'comment') { # Comment # Convert mail adresses to mailto: &freetextmarkup($frag); - $lang->processcomment( \$frag ); - } elsif ( $btype eq 'string' ) { + $lang->processcomment(\$frag); + } elsif ($btype eq 'string') { # String $frag = "<span class='string'>$frag</span>"; - } elsif ( $btype eq 'include' ) { + } elsif ($btype eq 'include') { # Include directive - $lang->processinclude( \$frag, $dir ); + $lang->processinclude(\$frag, $dir); } else { # Code - $lang->processcode( \$frag ); + $lang->processcode(\$frag); } &htmlquote($frag); my $ofrag = $frag; - ( $btype, $frag ) = &LXR::SimpleParse::nextfrag; + ($btype, $frag) = &LXR::SimpleParse::nextfrag; $ofrag =~ s/\n$// unless defined($frag); $ofrag =~ s/\n/"\n".join($line++, @ltag)/ge; @@ -317,15 +316,15 @@ } #&$outfun("</pre>"); - } elsif ( $pathname =~ /$config->graphicfile/ ) { + } elsif ($pathname =~ /$config->graphicfile/) { &$outfun("<ul><table><tr><th valign=\"center\"><b>Image: </b></th>"); - &$outfun( "<img src=\"$config->{virtroot}/source" + &$outfun("<img src=\"$config->{virtroot}/source" . $pathname . &urlargs("raw=1") - . "\" border=\"0\" alt=\"$pathname\">\n" ); + . "\" border=\"0\" alt=\"$pathname\">\n"); &$outfun("</tr></td></table></ul>"); - } elsif ( $pathname =~ m|/CREDITS$| ) { - while ( defined( $_ = $fileh->getline ) ) { + } elsif ($pathname =~ m|/CREDITS$|) { + while (defined($_ = $fileh->getline)) { &LXR::SimpleParse::untabify($_); &markspecials($_); &htmlquote($_); @@ -334,16 +333,16 @@ s/^(W:\s+)(.*)/$1<a href=\"$2\">$2<\/a>/gm; # &$outfun("<a name=\"L$.\"><\/a>".$_); - &$outfun( join( $line++, @ltag ) . $_ ); + &$outfun(join($line++, @ltag) . $_); } } else { - return unless defined( $_ = $fileh->getline ); + return unless defined($_ = $fileh->getline); # If it's not a script or something with an Emacs spec header and # the first line is very long or containts control characters... if ( !/^\#!/ && !/-\*-.*-\*-/i - && ( length($_) > 132 || /[\000-\010\013\014\016-\037\200-]/ ) ) + && (length($_) > 132 || /[\000-\010\013\014\016-\037\200-]/)) { # We postulate that it's a binary file. @@ -353,7 +352,7 @@ my $uname = $pathname; $uname =~ s|([^-a-zA-Z0-9.\@/_\r\n])|sprintf("%%%02X", ord($1))|ge; - &$outfun( "<a href=\"$config->{virtroot}/source" . $uname . &urlargs("raw=1") . "\">" ); + &$outfun("<a href=\"$config->{virtroot}/source" . $uname . &urlargs("raw=1") . "\">"); &$outfun("$pathname</a></b>"); &$outfun("</ul>"); @@ -367,8 +366,8 @@ &htmlquote($_); # &$outfun("<a name=\"L$.\"><\/a>".$_); - &$outfun( join( $line++, @ltag ) . $_ ); - } while ( defined( $_ = $fileh->getline ) ); + &$outfun(join($line++, @ltag) . $_); + } while (defined($_ = $fileh->getline)); #&$outfun("</pre>"); } @@ -378,7 +377,7 @@ sub fixpaths { my $node = '/' . shift; - while ( $node =~ s|/[^/]+/\.\./|/|g ) { } + while ($node =~ s|/[^/]+/\.\./|/|g) { } $node =~ s|/\.\./|/|g; $node .= '/' if $files->isdir($node); @@ -400,8 +399,8 @@ # Todo: check lxr.conf. - my $time = $files->getfiletime( $pathname, $release ); - my $time2 = ( stat( $config->confpath ) )[9]; + my $time = $files->getfiletime($pathname, $release); + my $time2 = (stat($config->confpath))[9]; $time = $time2 if $time2 > $time; # Remove this to see if we get a speed increase by not stating all @@ -422,21 +421,21 @@ # $time = $time2 if $time2 > $time; # } - if ( $time > 0 ) { - my ( $sec, $min, $hour, $mday, $mon, $year, $wday ) = gmtime($time); - my @days = ( "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" ); + if ($time > 0) { + my ($sec, $min, $hour, $mday, $mon, $year, $wday) = gmtime($time); + my @days = ("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"); my @months = - ( "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ); + ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"); $year += 1900; $wday = $days[$wday]; $mon = $months[$mon]; # Last-Modified: Wed, 10 Dec 1997 00:55:32 GMT - printf( "Last-Modified: %s, %2d %s %d %02d:%02d:%02d GMT\n", - $wday, $mday, $mon, $year, $hour, $min, $sec ); + printf("Last-Modified: %s, %2d %s %d %02d:%02d:%02d GMT\n", + $wday, $mday, $mon, $year, $hour, $min, $sec); } - if ( $HTTP->{'param'}->{'raw'} ) { + if ($HTTP->{'param'}->{'raw'}) { #FIXME - need more types here my %type = ( @@ -444,8 +443,8 @@ 'html' => 'text/html' ); - if ( $pathname =~ /\.([^.]+)$/ && $type{$1} ) { - print( "Content-type: ", $type{$1}, "\n" ); + if ($pathname =~ /\.([^.]+)$/ && $type{$1}) { + print("Content-type: ", $type{$1}, "\n"); } else { print("Content-Type: text/plain\n"); } @@ -493,7 +492,7 @@ $SIG{__WARN__} = \&warning; $SIG{__DIE__} = \&fatal; - $HTTP->{'path_info'} = http_wash( $ENV{'PATH_INFO'} ); + $HTTP->{'path_info'} = http_wash($ENV{'PATH_INFO'}); $HTTP->{'this_url'} = 'http://' . $ENV{'SERVER_NAME'}; $HTTP->{'this_url'} .= ':' . $ENV{'SERVER_PORT'} @@ -509,19 +508,19 @@ $HTTP->{'param'}->{'i'} ||= $HTTP->{'param'}->{'identifier'}; $identifier = $HTTP->{'param'}->{'i'}; - $config = new LXR::Config( $HTTP->{'this_url'} ); + $config = new LXR::Config($HTTP->{'this_url'}); die "Can't find config for " . $HTTP->{'this_url'} if !defined($config); - $files = new LXR::Files( $config->sourceroot ); + $files = new LXR::Files($config->sourceroot); die "Can't create Files for " . $config->sourceroot if !defined($files); - $index = new LXR::Index( $config->dbname ); + $index = new LXR::Index($config->dbname); die "Can't create Index for " . $config->dbname if !defined($index); - foreach ( $config->allvariables ) { - $config->variable( $_, $HTTP->{'param'}->{$_} ) if $HTTP->{'param'}->{$_}; + foreach ($config->allvariables) { + $config->variable($_, $HTTP->{'param'}->{$_}) if $HTTP->{'param'}->{$_}; } $release = $config->variable('v'); - $pathname = fixpaths( $HTTP->{'path_info'} || $HTTP->{'param'}->{'file'} ); + $pathname = fixpaths($HTTP->{'path_info'} || $HTTP->{'param'}->{'file'}); printhttp; } @@ -533,10 +532,10 @@ } sub expandtemplate { - my ( $templ, %expfunc ) = @_; - my ( $expfun, $exppar ); + my ($templ, %expfunc) = @_; + my ($expfun, $exppar); - while ( $templ =~ s/(\{[^\{\}]*)\{([^\{\}]*)\}/$1\01$2\02/s ) { } + while ($templ =~ s/(\{[^\{\}]*)\{([^\{\}]*)\}/$1\01$2\02/s) { } $templ =~ s/(\$(\w+)(\{([^\}]*)\}|))/{ if (defined($expfun = $expfunc{$2})) { @@ -564,13 +563,13 @@ # templates than it used to be. State information is passed via # function arguments, as God intended. sub bannerexpand { - my ( $templ, $who ) = @_; + my ($templ, $who) = @_; - if ( $who eq 'source' || $who eq 'sourcedir' || $who eq 'diff' ) { + if ($who eq 'source' || $who eq 'sourcedir' || $who eq 'diff') { my $fpath = ''; - my $furl = fileref( $config->sourcerootname . '/', "banner", '/' ); + my $furl = fileref($config->sourcerootname . '/', "banner", '/'); - foreach ( $pathname =~ m|([^/]+/?)|g ) { + foreach ($pathname =~ m|([^/]+/?)|g) { $fpath .= $_; # jwz: put a space after each / in the banner so that it's @@ -579,7 +578,7 @@ # so we have to use a real space. It's somewhat ugly to # have these spaces be visible, but not as ugly as getting # a horizontal scrollbar... - $furl .= ' ' . fileref( $_, "banner", "/$fpath" ); + $furl .= ' ' . fileref($_, "banner", "/$fpath"); } $furl =~ s|/</a>|</a>/|gi; @@ -594,19 +593,19 @@ } sub titleexpand { - my ( $templ, $who ) = @_; + my ($templ, $who) = @_; - if ( $who eq 'source' || $who eq 'diff' || $who eq 'sourcedir' ) { + if ($who eq 'source' || $who eq 'diff' || $who eq 'sourcedir') { return $config->sourcerootname . $pathname; - } elsif ( $who eq 'ident' ) { + } elsif ($who eq 'ident') { my $i = $HTTP->{'param'}->{'i'}; - return $config->sourcerootname . ' identfier search' . ( $i ? ": $i" : '' ); - } elsif ( $who eq 'search' ) { + return $config->sourcerootname . ' identfier search' . ($i ? ": $i" : ''); + } elsif ($who eq 'search') { my $s = $HTTP->{'param'}->{'string'}; - return $config->sourcerootname . ' freetext search' . ( $s ? ": $s" : '' ); - } elsif ( $who eq 'find' ) { + return $config->sourcerootname . ' freetext search' . ($s ? ": $s" : ''); + } elsif ($who eq 'find') { my $s = $HTTP->{'param'}->{'string'}; - return $config->sourcerootname . ' file search' . ( $s ? ": $s" : '' ); + return $config->sourcerootname . ' file search' . ($s ? ": $s" : ''); } } @@ -618,7 +617,7 @@ } sub baseurl { - ( my $url = $config->baseurl ) =~ s|/*$|/|; + (my $url = $config->baseurl) =~ s|/*$|/|; return $url; } @@ -638,51 +637,51 @@ # by filling in all the relevant values in the nested "modelink" # template. sub modeexpand { - my ( $templ, $who ) = @_; + my ($templ, $who) = @_; my $modex = ''; my @mlist = (); my $mode; - if ( $who eq 'source' || $who eq 'sourcedir' ) { - push( @mlist, "<span class='modes-sel'>source navigation</span>" ); + if ($who eq 'source' || $who eq 'sourcedir') { + push(@mlist, "<span class='modes-sel'>source navigation</span>"); } else { - push( @mlist, fileref( "source navigation", "modes", $pathname ) ); + push(@mlist, fileref("source navigation", "modes", $pathname)); } - if ( $who eq 'diff' ) { - push( @mlist, "<span class='modes-sel'>diff markup</span>" ); - } elsif ( $who eq 'source' && $pathname !~ m|/$| ) { - push( @mlist, diffref( "diff markup", "modes", $pathname ) ); + if ($who eq 'diff') { + push(@mlist, "<span class='modes-sel'>diff markup</span>"); + } elsif ($who eq 'source' && $pathname !~ m|/$|) { + push(@mlist, diffref("diff markup", "modes", $pathname)); } - if ( $who eq 'ident' ) { - push( @mlist, "<span class='modes-sel'>identifier search</span>" ); + if ($who eq 'ident') { + push(@mlist, "<span class='modes-sel'>identifier search</span>"); } else { - push( @mlist, idref( "identifier search", "modes", "" ) ); + push(@mlist, idref("identifier search", "modes", "")); } - if ( $who eq 'search' ) { - push( @mlist, "<span class='modes-sel'>freetext search</span>" ); + if ($who eq 'search') { + push(@mlist, "<span class='modes-sel'>freetext search</span>"); } else { - push( @mlist, + push(@mlist, "<a class=\"modes\" " . "href=\"$config->{virtroot}/search" . urlargs - . "\">freetext search</a>" ); + . "\">freetext search</a>"); } - if ( $who eq 'find' ) { - push( @mlist, "<span class='modes-sel'>file search</span>" ); + if ($who eq 'find') { + push(@mlist, "<span class='modes-sel'>file search</span>"); } else { - push( @mlist, + push(@mlist, "<a class='modes' " . "href=\"$config->{virtroot}/find" . urlargs - . "\">file search</a>" ); + . "\">file search</a>"); } foreach $mode (@mlist) { - $modex .= expandtemplate( $templ, ( 'modelink' => sub { return $mode } ) ); + $modex .= expandtemplate($templ, ('modelink' => sub { return $mode })); } return ($modex); @@ -692,54 +691,54 @@ # "variables" template using varname and varlinks, the latter in turn # expands the nested "varlinks" template using varval. sub varlinks { - my ( $templ, $who, $var ) = @_; + my ($templ, $who, $var) = @_; my $vlex = ''; - my ( $val, $oldval ); + my ($val, $oldval); my $vallink; $oldval = $config->variable($var); - foreach $val ( $config->varrange($var) ) { - if ( $val eq $oldval ) { + foreach $val ($config->varrange($var)) { + if ($val eq $oldval) { $vallink = "<span class=\"var-sel\">$val</span>"; } else { - if ( $who eq 'source' || $who eq 'sourcedir' ) { - $vallink = &fileref( $val, "varlink", $config->mappath( $pathname, "$var=$val" ), - 0, "$var=$val" ); + if ($who eq 'source' || $who eq 'sourcedir') { + $vallink = &fileref($val, "varlink", $config->mappath($pathname, "$var=$val"), + 0, "$var=$val"); - } elsif ( $who eq 'diff' ) { - $vallink = &diffref( $val, "varlink", $pathname, "$var=$val" ); - } elsif ( $who eq 'ident' ) { - $vallink = &idref( $val, "varlink", $identifier, "$var=$val" ); - } elsif ( $who eq 'search' ) { + } elsif ($who eq 'diff') { + $vallink = &diffref($val, "varlink", $pathname, "$var=$val"); + } elsif ($who eq 'ident') { + $vallink = &idref($val, "varlink", $identifier, "$var=$val"); + } elsif ($who eq 'search') { $vallink = "<a class=\"varlink\" href=\"$config->{virtroot}/search" - . &urlargs( "$var=$val", "string=" . $HTTP->{'param'}->{'string'} ) + . &urlargs("$var=$val", "string=" . $HTTP->{'param'}->{'string'}) . "\">$val</a>"; - } elsif ( $who eq 'find' ) { + } elsif ($who eq 'find') { $vallink = "<a class=\"varlink\" href=\"$config->{virtroot}/find" - . &urlargs( "$var=$val", "string=" . $HTTP->{'param'}->{'string'} ) + . &urlargs("$var=$val", "string=" . $HTTP->{'param'}->{'string'}) . "\">$val</a>"; } } - $vlex .= expandtemplate( $templ, ( 'varvalue' => sub { return $vallink } ) ); + $vlex .= expandtemplate($templ, ('varvalue' => sub { return $vallink })); } return ($vlex); } sub varexpand { - my ( $templ, $who ) = @_; + my ($templ, $who) = @_; my $varex = ''; my $var; - foreach $var ( $config->allvariables ) { + foreach $var ($config->allvariables) { $varex .= expandtemplate( $templ, ( 'varname' => sub { $config->vardescription($var) }, - 'varlinks' => sub { varlinks( @_, $who, $var ) } + 'varlinks' => sub { varlinks(@_, $who, $var) } ) ); } @@ -748,10 +747,10 @@ sub devinfo { my ($templ) = @_; - my ( @mods, $mod, $path ); - my %mods = ( 'main' => $0, %INC ); + my (@mods, $mod, $path); + my %mods = ('main' => $0, %INC); - while ( ( $mod, $path ) = each %mods ) { + while (($mod, $path) = each %mods) { $mod =~ s/.pm$//; $mod =~ s|/|::|g; $path =~ s|/+|/|g; @@ -759,7 +758,7 @@ no strict 'refs'; next unless ${ $mod . '::CVSID' }; - push( @mods, [ ${ $mod . '::CVSID' }, $path, ( stat($path) )[9] ] ); + push(@mods, [ ${ $mod . '::CVSID' }, $path, (stat($path))[9] ]); } return join( @@ -770,7 +769,7 @@ ( 'moduleid' => sub { $$_[0] }, 'modpath' => sub { $$_[1] }, - 'modtime' => sub { scalar( localtime( $$_[2] ) ) } + 'modtime' => sub { scalar(localtime($$_[2])) } ) ); } @@ -783,16 +782,16 @@ sub atticlink { return " " if !$files->isa("LXR::Files::CVS"); return " " if $ENV{'SCRIPT_NAME'} !~ m|/source$|; - if ( $HTTP->{'param'}->{'showattic'} ) { + if ($HTTP->{'param'}->{'showattic'}) { return ("<a class='modes' href=\"$config->{virtroot}/source" . $HTTP->{'path_info'} . &urlargs("showattic=0") - . "\">Hide attic files</a>" ); + . "\">Hide attic files</a>"); } else { return ("<a class='modes' href=\"$config->{virtroot}/source" . $HTTP->{'path_info'} . &urlargs("showattic=1") - . "\">Show attic files</a>" ); + . "\">Show attic files</a>"); } } @@ -803,20 +802,20 @@ $tmplname = $who . "head"; - unless ( $who ne "sourcedir" || $config->sourcedirhead ) { + unless ($who ne "sourcedir" || $config->sourcedirhead) { $tmplname = "sourcehead"; } - unless ( $config->value($tmplname) ) { + unless ($config->value($tmplname)) { $tmplname = "htmlhead"; } - if ( $config->value($tmplname) ) { - if ( open( TEMPL, $config->value($tmplname) ) ) { + if ($config->value($tmplname)) { + if (open(TEMPL, $config->value($tmplname))) { local ($/) = undef; $template = <TEMPL>; close(TEMPL); } else { - warning( "Template " . $config->value($tmplname) . " does not exist." ); + warning("Template " . $config->value($tmplname) . " does not exist."); } } @@ -825,15 +824,15 @@ expandtemplate( $template, ( - 'title' => sub { titleexpand( @_, $who ) }, - 'banner' => sub { bannerexpand( @_, $who ) }, + 'title' => sub { titleexpand(@_, $who) }, + 'banner' => sub { bannerexpand(@_, $who) }, 'baseurl' => sub { baseurl(@_) }, 'stylesheet' => sub { stylesheet(@_) }, 'dotdoturl' => sub { dotdoturl(@_) }, 'thisurl' => sub { thisurl(@_) }, 'pathname' => sub { pathname(@_) }, - 'modes' => sub { modeexpand( @_, $who ) }, - 'variables' => sub { varexpand( @_, $who ) }, + 'modes' => sub { modeexpand(@_, $who) }, + 'variables' => sub { varexpand(@_, $who) }, 'devinfo' => sub { devinfo(@_) }, 'atticlink' => sub { atticlink(@_) }, ) @@ -848,20 +847,20 @@ $tmplname = $who . "tail"; - unless ( $who ne "sourcedir" || $config->sourcedirhead ) { + unless ($who ne "sourcedir" || $config->sourcedirhead) { $tmplname = "sourcetail"; } - unless ( $config->value($tmplname) ) { + unless ($config->value($tmplname)) { $tmplname = "htmltail"; } - if ( $config->value($tmplname) ) { - if ( open( TEMPL, $config->value($tmplname) ) ) { + if ($config->value($tmplname)) { + if (open(TEMPL, $config->value($tmplname))) { local ($/) = undef; $template = <TEMPL>; close(TEMPL); } else { - warning( "Template " . $config->value($tmplname) . " does not exist." ); + warning("Template " . $config->value($tmplname) . " does not exist."); } } @@ -869,10 +868,10 @@ expandtemplate( $template, ( - 'banner' => sub { bannerexpand( @_, $who ) }, + 'banner' => sub { bannerexpand(@_, $who) }, 'thisurl' => sub { thisurl(@_) }, - 'modes' => sub { modeexpand( @_, $who ) }, - 'variables' => sub { varexpand( @_, $who ) }, + 'modes' => sub { modeexpand(@_, $who) }, + 'variables' => sub { varexpand(@_, $who) }, 'devinfo' => sub { devinfo(@_) } ) ), Index: Config.pm =================================================================== RCS file: /cvsroot/lxr/lxr/lib/LXR/Config.pm,v retrieving revision 1.31 retrieving revision 1.32 diff -u -d -r1.31 -r1.32 --- Config.pm 19 Jul 2004 19:50:20 -0000 1.31 +++ Config.pm 21 Jul 2004 20:44:30 -0000 1.32 @@ -31,7 +31,7 @@ $confname = 'lxr.conf'; sub new { - my ( $class, @parms ) = @_; + my ($class, @parms) = @_; my $self = {}; bless($self); $self->_initialize(@parms); @@ -44,7 +44,7 @@ my $file = shift; my @data; - open( INPUT, $file ) || fatal("Config: cannot open $file\n"); + open(INPUT, $file) || fatal("Config: cannot open $file\n"); $file = <INPUT>; close(INPUT); @@ -54,8 +54,8 @@ } sub _initialize { - my ( $self, $url, $confpath ) = @_; - my ( $dir, $arg ); + my ($self, $url, $confpath) = @_; + my ($dir, $arg); unless ($url) { $url = 'http://' . $ENV{'SERVER_NAME'} . ':' . $ENV{'SERVER_PORT'}; @@ -66,11 +66,11 @@ $url .= '/' unless $url =~ m#/$#; # append / if necessary unless ($confpath) { - ($confpath) = ( $0 =~ /(.*?)[^\/]*$/ ); + ($confpath) = ($0 =~ /(.*?)[^\/]*$/); $confpath .= $confname; } - unless ( open( CONFIG, $confpath ) ) { + unless (open(CONFIG, $confpath)) { die("Couldn't open configuration file \"$confpath\"."); } @@ -80,17 +80,17 @@ my $config_contents = <CONFIG>; $config_contents =~ /(.*)/s; $config_contents = $1; #untaint it - my @config = eval( "\n#line 1 \"configuration file\"\n" . $config_contents ); + my @config = eval("\n#line 1 \"configuration file\"\n" . $config_contents); die($@) if $@; my $config; - if ( scalar(@config) > 0 ) { - %$self = ( %$self, %{ $config[0] } ); + if (scalar(@config) > 0) { + %$self = (%$self, %{ $config[0] }); } CANDIDATE: foreach $config (@config) { - if ( $config->{baseurl} ) { + if ($config->{baseurl}) { my @aliases; - if ( $config->{baseurl_aliases} ) { + if ($config->{baseurl_aliases}) { @aliases = @{ $config->{baseurl_aliases} }; } my $root = $config->{baseurl}; @@ -98,9 +98,9 @@ foreach my $rt (@aliases) { $rt .= '/' unless $rt =~ m#/$#; # append / if necessary my $r = quotemeta($rt); - if ( $url =~ /^$r/ ) { + if ($url =~ /^$r/) { $config->{baseurl} = $rt; - %$self = ( %$self, %$config ); + %$self = (%$self, %$config); last CANDIDATE; } } @@ -113,11 +113,11 @@ sub allvariables { my $self = shift; - return keys( %{ $self->{variables} || {} } ); + return keys(%{ $self->{variables} || {} }); } sub variable { - my ( $self, $var, $val ) = @_; + my ($self, $var, $val) = @_; $self->{variables}{$var}{value} = $val if defined($val); return $self->{variables}{$var}{value} @@ -125,14 +125,14 @@ } sub vardefault { - my ( $self, $var ) = @_; + my ($self, $var) = @_; return $self->{variables}{$var}{default} || $self->{variables}{$var}{range}[0]; } sub vardescription { - my ( $self, $var, $val ) = @_; + my ($self, $var, $val) = @_; $self->{variables}{$var}{name} = $val if defined($val); @@ -140,9 +140,9 @@ } sub varrange { - my ( $self, $var ) = @_; + my ($self, $var) = @_; - if ( ref( $self->{variables}{$var}{range} ) eq "CODE" ) { + if (ref($self->{variables}{$var}{range}) eq "CODE") { return &{ $self->{variables}{$var}{range} }; } @@ -150,21 +150,21 @@ } sub varexpand { - my ( $self, $exp ) = @_; + my ($self, $exp) = @_; $exp =~ s/\$\{?(\w+)\}?/$self->variable($1)/ge; return $exp; } sub value { - my ( $self, $var ) = @_; + my ($self, $var) = @_; - if ( exists( $self->{$var} ) ) { + if (exists($self->{$var})) { my $val = $self->{$var}; - if ( ref($val) eq 'ARRAY' ) { + if (ref($val) eq 'ARRAY') { return map { $self->varexpand($_) } @$val; - } elsif ( ref($val) eq 'CODE' ) { + } elsif (ref($val) eq 'CODE') { return $val; } else { return $self->varexpand($val); @@ -176,11 +176,11 @@ sub AUTOLOAD { my $self = shift; - ( my $var = $AUTOLOAD ) =~ s/.*:://; + (my $var = $AUTOLOAD) =~ s/.*:://; my @val = $self->value($var); - if ( ref( $val[0] ) eq 'CODE' ) { + if (ref($val[0]) eq 'CODE') { return $val[0]->(@_); } else { return wantarray ? @val : $val[0]; @@ -188,23 +188,23 @@ } sub mappath { - my ( $self, $path, @args ) = @_; + my ($self, $path, @args) = @_; my %oldvars; - my ( $m, $n ); + my ($m, $n); foreach $m (@args) { - if ( $m =~ /(.*?)=(.*)/ ) { + if ($m =~ /(.*?)=(.*)/) { $oldvars{$1} = $self->variable($1); - $self->variable( $1, $2 ); + $self->variable($1, $2); } } - while ( ( $m, $n ) = each %{ $self->{maps} || {} } ) { + while (($m, $n) = each %{ $self->{maps} || {} }) { $path =~ s/$m/$self->varexpand($n)/e; } - while ( ( $m, $n ) = each %oldvars ) { - $self->variable( $m, $n ); + while (($m, $n) = each %oldvars) { + $self->variable($m, $n); } return $path; Index: Files.pm =================================================================== RCS file: /cvsroot/lxr/lxr/lib/LXR/Files.pm,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- Files.pm 19 Jul 2004 19:50:20 -0000 1.7 +++ Files.pm 21 Jul 2004 20:44:30 -0000 1.8 @@ -23,10 +23,10 @@ use strict; sub new { - my ( $self, $srcroot ) = @_; + my ($self, $srcroot) = @_; my $files; - if ( $srcroot =~ /^CVS:(.*)/i ) { + if ($srcroot =~ /^CVS:(.*)/i) { require LXR::Files::CVS; $srcroot = $1; $files = new LXR::Files::CVS($srcroot); Index: Index.pm =================================================================== RCS file: /cvsroot/lxr/lxr/lib/LXR/Index.pm,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- Index.pm 19 Jul 2004 19:50:20 -0000 1.10 +++ Index.pm 21 Jul 2004 20:44:30 -0000 1.11 @@ -24,15 +24,15 @@ use strict; sub new { - my ( $self, $dbname, @args ) = @_; + my ($self, $dbname, @args) = @_; my $index; - if ( $dbname =~ /^DBI:/i ) { + if ($dbname =~ /^DBI:/i) { require LXR::Index::DBI; - $index = new LXR::Index::DBI( $dbname, @args ); - } elsif ( $dbname =~ /^DBM:/i ) { + $index = new LXR::Index::DBI($dbname, @args); + } elsif ($dbname =~ /^DBM:/i) { require LXR::Index::DB; - $index = new LXR::Index::DB( $dbname, @args ); + $index = new LXR::Index::DB($dbname, @args); } else { die "Can't find database, $dbname"; } Index: Lang.pm =================================================================== RCS file: /cvsroot/lxr/lxr/lib/LXR/Lang.pm,v retrieving revision 1.31 retrieving revision 1.32 diff -u -d -r1.31 -r1.32 --- Lang.pm 19 Jul 2004 19:50:20 -0000 1.31 +++ Lang.pm 21 Jul 2004 20:44:30 -0000 1.32 @@ -24,11 +24,11 @@ use LXR::Common; sub new { - my ( $self, $pathname, $release, @itag ) = @_; - my ( $lang, $type ); + my ($self, $pathname, $release, @itag) = @_; + my ($lang, $type); - foreach $type ( values %{ $config->filetype } ) { - if ( $pathname =~ /$$type[1]/ ) { + foreach $type (values %{ $config->filetype }) { + if ($pathname =~ /$$type[1]/) { eval "require $$type[2]"; die "Unable to load $$type[2] Lang class, $@" if $@; my $create = "new $$type[2]" . '($pathname, $release, $$type[0])'; @@ -38,10 +38,10 @@ } } - if ( !defined $lang ) { + if (!defined $lang) { # Try to see if it's a script - my $fh = $files->getfilehandle( $pathname, $release ); + my $fh = $files->getfilehandle($pathname, $release); return undef if !defined $fh; $fh->getline =~ /^\#!\s*(\S+)/s; @@ -49,8 +49,8 @@ my %filetype = %{ $config->filetype }; my %inter = %{ $config->interpreters }; - foreach my $patt ( keys %inter ) { - if ( $shebang =~ /\/$patt/ ) { + foreach my $patt (keys %inter) { + if ($shebang =~ /\/$patt/) { eval "require $filetype{$inter{$patt}}[2]"; die "Unable to load $filetype{$inter{$patt}}[2] Lang class, $@" if $@; my $create = "new " @@ -72,7 +72,7 @@ } sub processinclude { - my ( $self, $frag, $dir ) = @_; + my ($self, $frag, $dir) = @_; $$frag =~ s#(\")(.*?)(\")# $1.&LXR::Common::incref($2, "include", $2, $dir).$3 #e; @@ -81,7 +81,7 @@ } sub processcomment { - my ( $self, $frag ) = @_; + my ($self, $frag) = @_; $$frag = "<span class=\"comment\">$$frag</span>"; $$frag =~ s#\n#</span>\n<span class=\"comment\">#g; @@ -90,7 +90,7 @@ sub referencefile { my ($self) = @_; - print( STDERR ref($self), "->referencefile not implemented.\n" ); + print(STDERR ref($self), "->referencefile not implemented.\n"); } 1; Index: SimpleParse.pm =================================================================== RCS file: /cvsroot/lxr/lxr/lib/LXR/SimpleParse.pm,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- SimpleParse.pm 19 Jul 2004 19:50:20 -0000 1.16 +++ SimpleParse.pm 21 Jul 2004 20:44:30 -0000 1.17 @@ -52,13 +52,13 @@ $tabwidth = 8; my $tabhint; - ( $fileh, $tabhint, @blksep ) = @_; + ($fileh, $tabhint, @blksep) = @_; $tabwidth = $tabhint || $tabwidth; - while ( @_ = splice( @blksep, 0, 3 ) ) { - push( @bodyid, $_[0] ); - push( @open, $_[1] ); - push( @term, $_[2] ); + while (@_ = splice(@blksep, 0, 3)) { + push(@bodyid, $_[0]); + push(@open, $_[1]); + push(@term, $_[2]); } foreach (@open) { @@ -79,7 +79,7 @@ $_[0] =~ s/^(\t+)/(' ' x ($t * length($1)))/ge; # Optimize for common case. $_[0] =~ s/([^\t]*)\t/$1.(' ' x ($t - (length($1) % $t)))/ge; - return ( $_[0] ); + return ($_[0]); } sub nextfrag { @@ -93,11 +93,11 @@ # read one more line if we have processed # all of the previously read line - if ( $#frags < 0 ) { + if ($#frags < 0) { $line = $fileh->getline; if ( $. <= 2 - && $line =~ /^.*-[*]-.*?[ \t;]tab-width:[ \t]*([0-9]+).*-[*]-/ ) + && $line =~ /^.*-[*]-.*?[ \t;]tab-width:[ \t]*([0-9]+).*-[*]-/) { # make sure there really is a non-zero tabwidth @@ -107,25 +107,25 @@ # &untabify($line, $tabwidth); # We inline this for performance. # Optimize for common case. - if ( defined($line) ) { + if (defined($line)) { $line =~ s/^(\t+)/' ' x ($tabwidth * length($1))/ge; $line =~ s/([^\t]*)\t/$1.(' ' x ($tabwidth - (length($1) % $tabwidth)))/ge; # split the line into fragments - @frags = split( /($split)/, $line ); + @frags = split(/($split)/, $line); } } last if $#frags < 0; # skip empty fragments - if ( $frags[0] eq '' ) { + if ($frags[0] eq '') { shift(@frags); } # check if we are inside a fragment - if ( defined($frag) ) { - if ( defined($btype) ) { + if (defined($frag)) { + if (defined($btype)) { my $next = shift(@frags); # Add to the fragment @@ -135,7 +135,7 @@ last if $next =~ /^$term[$btype]$/; } else { - if ( $frags[0] =~ /^$open$/ ) { + if ($frags[0] =~ /^$open$/) { # print "encountered open token while btype was $btype\n"; last; @@ -147,7 +147,7 @@ # print "start of new fragment\n"; # Find the blocktype of the current block $frag = shift(@frags); - if ( defined($frag) && ( @_ = $frag =~ /^$open$/ ) ) { + if (defined($frag) && (@_ = $frag =~ /^$open$/)) { # print "hit\n"; # grep in a scalar context returns the number of times @@ -156,7 +156,7 @@ my $i = 1; $btype = grep { $i &&= !defined($_) } @_; - if ( !defined( $term[$btype] ) ) { + if (!defined($term[$btype])) { print "fragment without terminator\n"; last; } @@ -165,7 +165,7 @@ } $btype = $bodyid[$btype] if defined($btype); - return ( $btype, $frag ); + return ($btype, $frag); } 1; Index: Tagger.pm =================================================================== RCS file: /cvsroot/lxr/lxr/lib/LXR/Tagger.pm,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- Tagger.pm 19 Jul 2004 19:50:20 -0000 1.21 +++ Tagger.pm 21 Jul 2004 20:44:30 -0000 1.22 @@ -25,72 +25,72 @@ use LXR::Lang; sub processfile { - my ( $pathname, $release, $config, $files, $index ) = @_; + my ($pathname, $release, $config, $files, $index) = @_; - my $lang = new LXR::Lang( $pathname, $release ); + my $lang = new LXR::Lang($pathname, $release); return unless $lang; - my $revision = $files->filerev( $pathname, $release ); + my $revision = $files->filerev($pathname, $release); return unless $revision; - print( STDERR "--- $pathname $release $revision\n" ); + print(STDERR "--- $pathname $release $revision\n"); if ($index) { - my $fileid = $index->fileid( $pathname, $revision ); + my $fileid = $index->fileid($pathname, $revision); - $index->release( $fileid, $release ); + $index->release($fileid, $release); - if ( $index->toindex($fileid) ) { + if ($index->toindex($fileid)) { $index->empty_cache(); - print( STDERR "--- $pathname $fileid\n" ); + print(STDERR "--- $pathname $fileid\n"); - my $path = $files->tmpfile( $pathname, $release ); + my $path = $files->tmpfile($pathname, $release); - $lang->indexfile( $pathname, $path, $fileid, $index, $config ); + $lang->indexfile($pathname, $path, $fileid, $index, $config); $index->setindexed($fileid); unlink($path); } else { - print( STDERR "$pathname was already indexed\n" ); + print(STDERR "$pathname was already indexed\n"); } } else { - print( STDERR " **** FAILED ****\n" ); + print(STDERR " **** FAILED ****\n"); } $lang = undef; $revision = undef; } sub processrefs { - my ( $pathname, $release, $config, $files, $index ) = @_; + my ($pathname, $release, $config, $files, $index) = @_; - my $lang = new LXR::Lang( $pathname, $release ); + my $lang = new LXR::Lang($pathname, $release); return unless $lang; - my $revision = $files->filerev( $pathname, $release ); + my $revision = $files->filerev($pathname, $release); return unless $revision; - print( STDERR "--- $pathname $release $revision\n" ); + print(STDERR "--- $pathname $release $revision\n"); if ($index) { - my $fileid = $index->fileid( $pathname, $revision ); + my $fileid = $index->fileid($pathname, $revision); - if ( $index->toreference($fileid) ) { + if ($index->toreference($fileid)) { $index->empty_cache(); - print( STDERR "--- $pathname $fileid\n" ); + print(STDERR "--- $pathname $fileid\n"); - my $path = $files->tmpfile( $pathname, $release ); + my $path = $files->tmpfile($pathname, $release); - $lang->referencefile( $pathname, $path, $fileid, $index, $config ); + $lang->referencefile($pathname, $path, $fileid, $index, $config); $index->setreferenced($fileid); unlink($path); } else { print STDERR "$pathname was already referenced\n"; } } else { - print( STDERR " **** FAILED ****\n" ); + print(STDERR " **** FAILED ****\n"); } $lang = undef; |
From: Dave B. <bro...@us...> - 2004-07-21 20:44:41
|
Update of /cvsroot/lxr/lxr/templates In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25090/templates Modified Files: lxr.conf Log Message: perltidy with options: -ce -pt=2 -nolq -nsfs Index: lxr.conf =================================================================== RCS file: /cvsroot/lxr/lxr/templates/lxr.conf,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- lxr.conf 20 Jul 2004 15:31:25 -0000 1.22 +++ lxr.conf 21 Jul 2004 20:44:31 -0000 1.23 @@ -2,221 +2,224 @@ # Configuration file # ( - { - # Global configuration + { - # Path to glimpse executables. - # Define this OR the swish-e variable depending which search engine you want to use. - 'glimpsebin' => '/info/lxr/bin/glimpse', - 'glimpseindex' => '/info/lxr/bin/glimpseindex', + # Global configuration - # Location of SWISH-E binary - 'swishbin' => '/usr/local/bin/swish-e', + # Path to glimpse executables. + # Define this OR the swish-e variable depending which search engine you want to use. + 'glimpsebin' => '/info/lxr/bin/glimpse', + 'glimpseindex' => '/info/lxr/bin/glimpseindex', - # Path to Exuberant Ctags executable - 'ectagsbin' => '/usr/bin/ctags', + # Location of SWISH-E binary + 'swishbin' => '/usr/local/bin/swish-e', - # Place where lxr can write temporary files - 'tmpdir' => '/tmp', + # Path to Exuberant Ctags executable + 'ectagsbin' => '/usr/bin/ctags', - # Location of the Generic.pm config file - 'genericconf' => '/path/to/lib/LXR/Lang/generic.conf', + # Place where lxr can write temporary files + 'tmpdir' => '/tmp', - # Location of the ectags.conf file - 'ectagsconf' => '/path/to/lib/LXR/Lang/ectags.conf', + # Location of the Generic.pm config file + 'genericconf' => '/path/to/lib/LXR/Lang/generic.conf', - }, + # Location of the ectags.conf file + 'ectagsconf' => '/path/to/lib/LXR/Lang/ectags.conf', - { - # Configuration for http://192.168.1.3/lxr. - # baseurl is used to select configuration block. + }, - 'baseurl' => 'http://192.168.1.3/lxr', # Put your URL here - # baseurl_aliases allows other URLs to be used to reach the site - # comment this out if you do not want any aliases - 'baseurl_aliases' => [ 'http://localhost/lxr', 'http://mydomain/lxr'], - 'virtroot' => '/lxr', # The bit after the / above - - 'variables' => { - # Define typed variable "v". This is the list of versions to index. - 'v' => {'name' => 'Version', - # This can come from a file, a function or be explicitly - # ennumerated. - # From a file: - 'range' => [ readfile('src/versions') ], - # Explicitly: - # 'range' => [qw(v1 v2 v3.1 v4 experimental)], - # If files within a tree can have different versions, - # e.g in a CVS tree, 'range' can be specified as a - # function to call for each file: - #'range' => sub { return - # ($files->allreleases($LXR::Common::pathname), - # $files->allrevisions($LXR::Common::pathname)) - # }, # deferred function call. + { - # The default version to display - 'default' => '1.0.6'}, - - # Define typed variable "a". First value is default. - 'a' => {'name' => 'Architecture', - 'range' => [qw(i386 alpha arm m68k mips ppc sparc sparc64)]}, - }, + # Configuration for http://192.168.1.3/lxr. + # baseurl is used to select configuration block. - # These do funky things to paths in the system - you probably don't need them. - 'maps' => { - '/include/asm[^\/]*/' => '/include/asm-$a/', - '/arch/[^\/]+/' => '/arch/$a/', + 'baseurl' => 'http://192.168.1.3/lxr', # Put your URL here + # baseurl_aliases allows other URLs to be used to reach the site + # comment this out if you do not want any aliases + 'baseurl_aliases' => [ 'http://localhost/lxr', 'http://mydomain/lxr' ], + 'virtroot' => '/lxr', # The bit after the / above + + 'variables' => { + + # Define typed variable "v". This is the list of versions to index. + 'v' => { + 'name' => 'Version', + + # This can come from a file, a function or be explicitly + # ennumerated. + # From a file: + 'range' => [ readfile('src/versions') ], + + # Explicitly: + # 'range' => [qw(v1 v2 v3.1 v4 experimental)], + # If files within a tree can have different versions, + # e.g in a CVS tree, 'range' can be specified as a + # function to call for each file: + #'range' => sub { return + # ($files->allreleases($LXR::Common::pathname), + # $files->allrevisions($LXR::Common::pathname)) + # }, # deferred function call. + + # The default version to display + 'default' => '1.0.6' }, - - - # Templates used for headers and footers - 'htmlhead' => 'html-head.html', - 'htmltail' => 'html-tail.html', - 'htmldir' => 'html-dir.html', - 'htmlident' => 'html-ident.html', - 'htmlident_refs' => 'html-ident-refs.html', - 'htmlfind' => 'html-find.html', - 'htmlsearch' => 'html-search-swish.html', - - 'sourcehead' => 'html-head.html', - 'sourcedirhead' => 'html-head.html', - 'stylesheet' => 'lxr.css', - - # sourceroot - where to get the source files from - # For ordinary directories, this specifies a directory which has each version as a - # subdirectory e.g. - # indexed-src/version1/... - # indexed-src/version2/... - # The names of the version directories must match the values for the Version - # variable above. - 'sourceroot' => '/home/malcolm/indexed-src', - # Alternatively, this can specify a CVS repository by setting the value to "cvs:" - # followed by the path to the repository. Note this must be file accessible - remote - # server access does NOT work. - # 'sourceroot' => 'cvs:/hom/karsk/a/CVSROOT/linux', + # Define typed variable "a". First value is default. + 'a' => { + 'name' => 'Architecture', + 'range' => [qw(i386 alpha arm m68k mips ppc sparc sparc64)] + }, + }, - # The name to display for this source tree - 'sourcerootname' => 'Example', + # These do funky things to paths in the system - you probably don't need them. + 'maps' => { + '/include/asm[^\/]*/' => '/include/asm-$a/', + '/arch/[^\/]+/' => '/arch/$a/', + }, + # Templates used for headers and footers + 'htmlhead' => 'html-head.html', + 'htmltail' => 'html-tail.html', + 'htmldir' => 'html-dir.html', + 'htmlident' => 'html-ident.html', + 'htmlident_refs' => 'html-ident-refs.html', + 'htmlfind' => 'html-find.html', + 'htmlsearch' => 'html-search-swish.html', - # The DBI identifier for the database to use - # For mysql, the format is dbi:mysql:dbname=<name> - # for Postgres, it is dbi:Pg:dbname=<name> - # for Oracle, it is dbi:Oracle:host=localhost;sid=DEVMMS;port=1521 - 'dbname' => 'dbi:mysql:dbname=lxr', + 'sourcehead' => 'html-head.html', + 'sourcedirhead' => 'html-head.html', + 'stylesheet' => 'lxr.css', - # If you need to specify the username or password for the database connection, - # uncomment the following two lines - # 'dbpass' => 'foo', - # 'dbuser' => 'lxr', - - # If you need multiple lxr configurations in one database, set different table - # prefixes for them. - # 'dbprefix' => 'lxr_', + # sourceroot - where to get the source files from - # For using glimpse, the directory to store the .glimpse files in is required - 'glimpsedir' => '/path/to/glimpse/databases', + # For ordinary directories, this specifies a directory which has each version as a + # subdirectory e.g. + # indexed-src/version1/... + # indexed-src/version2/... + # The names of the version directories must match the values for the Version + # variable above. + 'sourceroot' => '/home/malcolm/indexed-src', - # Location of swish-e index database files if using swish-e - 'swishdir' => '/a/directory/here/', + # Alternatively, this can specify a CVS repository by setting the value to "cvs:" + # followed by the path to the repository. Note this must be file accessible - remote + # server access does NOT work. + # 'sourceroot' => 'cvs:/hom/karsk/a/CVSROOT/linux', - - # where to look for include files inside the sourcetree. This is used to hyperlink - # to included files. - 'incprefix' => ['/include', '/include/linux'], - - # Which extensions to treat as images when browsing. If a file is an image, - # it is displayed. - 'graphicfile' => '(?i)\.(gif|jpg|jpeg|pjpg|pjpeg|xbm|png)$', #' + # The name to display for this source tree + 'sourcerootname' => 'Example', - # How to map files to languages - # Note that the string for the key and the first entry in the - # array MUST match - 'filetype' => { - # Format is - # Language name, filepatten regexp, module to invoke, - # (optional )tabwidth - # Note that to have another language supported by Generic.pm, - # you must ensure that: - # a) exuberant ctags supports it - # b) generic.conf is updated to specify information about the language - # c) the name of the language given here matches the entry in generic.conf - 'C' => ['C', '\.c$|\.pc$' #' - , 'LXR::Lang::Generic', '8'], - 'C++' => ['C++', '\.C$|((?i)\.c\+\+$|\.cc$|\.cpp$|\.cxx$|\.h$|\.hh$|\.hpp$|\.hxx$|\.h\+\+$)' #' - , 'LXR::Lang::Generic', '8'], + # The DBI identifier for the database to use + # For mysql, the format is dbi:mysql:dbname=<name> + # for Postgres, it is dbi:Pg:dbname=<name> + # for Oracle, it is dbi:Oracle:host=localhost;sid=DEVMMS;port=1521 + 'dbname' => 'dbi:mysql:dbname=lxr', -# Some languages are commented out until the relevant entries in generic.conf are made -# The list here is the set supported by ctags 5.0.1 -# 'Beta' => ['Beta', '(?i)\.bet$' -# , 'LXR::Lang::Generic'], -# 'Cobol' => ['Cobol', '(?i)\.cob$' -# , 'LXR::Lang::Generic'], -# 'Eiffel' => ['Eiffel', '(?i)\.e$' -# , 'LXR::Lang::Generic'], -# 'Fortran' => ['Fortran', '(?i)\.f$|\.for$|\.ftn$|\.f77$|\.f90$|\.f95$' -# , 'LXR::Lang::Generic'], - 'Java' => ['Java', '(?i)\.java$' - , 'LXR::Lang::Java', '4'], -# 'Lisp' => ['Lisp', '(?i)\.cl$|\.clisp$|\.el$|\.l$|\.lisp$|\.lsp$|\.ml$' - # , 'LXR::Lang::Generic'], - # No tabwidth specified here as an example - 'Make' => ['Make', '(?i)\.mak$|(?i)\.mk$|makefile*' - , 'LXR::Lang::Generic'], -# 'Pascal' => ['Pascal', '(?i)\.p$|\.pas$' -# , 'LXR::Lang::Generic'], - 'Perl' => ['Perl', '(?i)\.pl$|\.pm$|\.perl$' - , 'LXR::Lang::Generic', '4'], - 'php' => ['php', '(?i)\.php$|\.php3$|\.phtml$' - , 'LXR::Lang::Generic', '2'], - 'Python' => ['Python', '(?i)\.py$|\.python$' - , 'LXR::Lang::Generic', '4'], -# 'rexx' => ['rexx', '(?i)\.cmd$|\.rexx$|\.rx$' -# , 'LXR::Lang::Generic'], -# 'ruby' => ['ruby', '(?i)\.rb$' -# , 'LXR::Lang::Generic'], -# 'scheme' => ['scheme', '(?i)\.sch$|\.scheme$|\.scm$|\.sm$' -# , 'LXR::Lang::Generic'], - 'shell' => ['shell', '(?i)\.sh$|\.bsh$|\.bash$|\.ksh$|\.zsh$' - , 'LXR::Lang::Generic'], -# 's-Lang' => ['s-Lang', '(?i)\.sl$' -# , 'LXR::Lang::Generic'], - 'SQL' => ['SQL', '(?i)\.sql$|\.pks$|\.pkb$' - , 'LXR::Lang::Generic'], - 'VB' => ['VB', '(?i)\.bas$|\.cls$|\.ctl$|\.frm$|\.vbs$' - , 'LXR::Lang::Generic'], - 'tcl' => ['tcl', '(?i)\.tcl$|\.wish$' - , 'LXR::Lang::Generic'], - }, + # If you need to specify the username or password for the database connection, + # uncomment the following two lines + # 'dbpass' => 'foo', + # 'dbuser' => 'lxr', - # Maps interpreter names to languages. The format is: - # regexp => langname - # regexp is matched against the part after #! on the first line of a file - # langname must match one of the keys in filetype above. - # - # This mapping is only used if the filename doesn't match a pattern above, so - # a shell script called shell.c will be recognised as a C file, not a shell file. - - 'interpreters' => { - 'perl' => 'Perl', - 'bash' => 'shell', - 'csh' => 'shell', - 'python' => 'Python', - 'ksh' => 'shell', - 'zsh' => 'shell', - 'sh' => 'shell', - 'ksh' => 'shell', - }, - - # a link of the form (prefix)($filepath)(postfix) is generated when viewing a file - # example for cvsweb: - #'cvswebprefix' => 'http://cvs.myhost.com/cgi-bin/cvsweb.cgi', - #'cvswebpostfix' => '?cvsroot=rootname', - # example for viewcvs: - #'cvswebprefix' => 'http://cvs.myhost.com/cgi-bin/viewcvs.cgi/myroot', - #'cvswebpostfix' => '', + # If you need multiple lxr configurations in one database, set different table + # prefixes for them. + # 'dbprefix' => 'lxr_', - # choose to ignore certain directories - 'ignoredirs' => ['CVSROOT'], # 'CVS' dir is always ignored -}) + # For using glimpse, the directory to store the .glimpse files in is required + 'glimpsedir' => '/path/to/glimpse/databases', + + # Location of swish-e index database files if using swish-e + 'swishdir' => '/a/directory/here/', + + # where to look for include files inside the sourcetree. This is used to hyperlink + # to included files. + 'incprefix' => [ '/include', '/include/linux' ], + + # Which extensions to treat as images when browsing. If a file is an image, + # it is displayed. + 'graphicfile' => '(?i)\.(gif|jpg|jpeg|pjpg|pjpeg|xbm|png)$', #' + + # How to map files to languages + # Note that the string for the key and the first entry in the + # array MUST match + 'filetype' => { + + # Format is + # Language name, filepatten regexp, module to invoke, + # (optional )tabwidth + # Note that to have another language supported by Generic.pm, + # you must ensure that: + # a) exuberant ctags supports it + # b) generic.conf is updated to specify information about the language + # c) the name of the language given here matches the entry in generic.conf + 'C' => [ + 'C', '\.c$|\.pc$' #' + , 'LXR::Lang::Generic', '8' + ], + 'C++' => [ + 'C++', + '\.C$|((?i)\.c\+\+$|\.cc$|\.cpp$|\.cxx$|\.h$|\.hh$|\.hpp$|\.hxx$|\.h\+\+$)' #' + , 'LXR::Lang::Generic', '8' + ], + + # Some languages are commented out until the relevant entries in generic.conf are made + # The list here is the set supported by ctags 5.0.1 + # 'Beta' => [ 'Beta', '(?i)\.bet$', 'LXR::Lang::Generic' ], + # 'Cobol' => [ 'Cobol', '(?i)\.cob$', 'LXR::Lang::Generic' ], + # 'Eiffel' => [ 'Eiffel', '(?i)\.e$', 'LXR::Lang::Generic' ], + # 'Fortran' => + # [ 'Fortran', '(?i)\.f$|\.for$|\.ftn$|\.f77$|\.f90$|\.f95$', 'LXR::Lang::Generic' ], + 'Java' => [ 'Java', '(?i)\.java$', 'LXR::Lang::Java', '4' ], + + # 'Lisp' => [ + # 'Lisp', '(?i)\.cl$|\.clisp$|\.el$|\.l$|\.lisp$|\.lsp$|\.ml$', 'LXR::Lang::Generic' + # ], + + # No tabwidth specified here as an example + 'Make' => [ 'Make', '(?i)\.mak$|(?i)\.mk$|makefile*', 'LXR::Lang::Generic' ], + + # 'Pascal' => [ 'Pascal', '(?i)\.p$|\.pas$', 'LXR::Lang::Generic' ], + 'Perl' => [ 'Perl', '(?i)\.pl$|\.pm$|\.perl$', 'LXR::Lang::Generic', '4' ], + 'php' => [ 'php', '(?i)\.php$|\.php3$|\.phtml$', 'LXR::Lang::Generic', '2' ], + 'Python' => [ 'Python', '(?i)\.py$|\.python$', 'LXR::Lang::Generic', '4' ], + + # 'rexx' => [ 'rexx', '(?i)\.cmd$|\.rexx$|\.rx$', 'LXR::Lang::Generic' ], + # 'ruby' => [ 'ruby', '(?i)\.rb$', 'LXR::Lang::Generic' ], + # 'scheme' => [ 'scheme', '(?i)\.sch$|\.scheme$|\.scm$|\.sm$', 'LXR::Lang::Generic' ], + 'shell' => [ 'shell', '(?i)\.sh$|\.bsh$|\.bash$|\.ksh$|\.zsh$', 'LXR::Lang::Generic' ], + + # 's-Lang' => [ 's-Lang', '(?i)\.sl$', 'LXR::Lang::Generic' ], + 'SQL' => [ 'SQL', '(?i)\.sql$|\.pks$|\.pkb$', 'LXR::Lang::Generic' ], + 'VB' => [ 'VB', '(?i)\.bas$|\.cls$|\.ctl$|\.frm$|\.vbs$', 'LXR::Lang::Generic' ], + 'tcl' => [ 'tcl', '(?i)\.tcl$|\.wish$', 'LXR::Lang::Generic' ], + }, + + # Maps interpreter names to languages. The format is: + # regexp => langname + # regexp is matched against the part after #! on the first line of a file + # langname must match one of the keys in filetype above. + # + # This mapping is only used if the filename doesn't match a pattern above, so + # a shell script called shell.c will be recognised as a C file, not a shell file. + + 'interpreters' => { + 'perl' => 'Perl', + 'bash' => 'shell', + 'csh' => 'shell', + 'python' => 'Python', + 'ksh' => 'shell', + 'zsh' => 'shell', + 'sh' => 'shell', + 'ksh' => 'shell', + }, + + # a link of the form (prefix)($filepath)(postfix) is generated when viewing a file + # example for cvsweb: + #'cvswebprefix' => 'http://cvs.myhost.com/cgi-bin/cvsweb.cgi', + #'cvswebpostfix' => '?cvsroot=rootname', + # example for viewcvs: + #'cvswebprefix' => 'http://cvs.myhost.com/cgi-bin/viewcvs.cgi/myroot', + #'cvswebpostfix' => '', + + # choose to ignore certain directories + 'ignoredirs' => ['CVSROOT'], # 'CVS' dir is always ignored + } + ) |
From: Dave B. <bro...@us...> - 2004-07-21 20:44:41
|
Update of /cvsroot/lxr/lxr In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25090 Modified Files: Local.pm diff find genxref ident search source Log Message: perltidy with options: -ce -pt=2 -nolq -nsfs Index: Local.pm =================================================================== RCS file: /cvsroot/lxr/lxr/Local.pm,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- Local.pm 19 Jul 2004 19:50:20 -0000 1.19 +++ Local.pm 21 Jul 2004 20:44:30 -0000 1.20 @@ -83,18 +83,18 @@ #ignore files that aren't source code if ( !( - ( $filename =~ /\.c$/ ) | ( $filename =~ /\.h$/ ) | ( $filename =~ /\.cc$/ ) | - ( $filename =~ /\.cp$/ ) | ( $filename =~ /\.cpp$/ ) | ( $filename =~ /\.java$/ ) + ($filename =~ /\.c$/) | ($filename =~ /\.h$/) | ($filename =~ /\.cc$/) | + ($filename =~ /\.cp$/) | ($filename =~ /\.cpp$/) | ($filename =~ /\.java$/) ) ) { return ("\ \;"); } - if ( $fh = $files->getfilehandle( $dir . $filename, $release ) ) { + if ($fh = $files->getfilehandle($dir . $filename, $release)) { while (<$fh>) { $desc = $desc . $_; - if ( $linecount++ > 60 ) { + if ($linecount++ > 60) { last; } } @@ -102,12 +102,12 @@ } # sanity check: if there's no description then stop - if ( !( $desc =~ /\w/ ) ) { + if (!($desc =~ /\w/)) { return ("\ \;"); } # if a java file, only consider class-level javadoc comments - if ( $filename =~ /\.java$/ ) { + if ($filename =~ /\.java$/) { # last /** ... */ before 'public class' or 'public interface' @@ -119,7 +119,7 @@ # last comment start before declaration pos $desc = 0; $commentStart = -1; - while ( $desc =~ m#/\*\*#g ) { + while ($desc =~ m#/\*\*#g) { last if $declPos < pos $desc; $commentStart = pos $desc; } @@ -129,7 +129,7 @@ pos $desc = $commentStart; $desc =~ m#\*/#g; $commentEnd = pos $desc; - $desc = substr( $desc, $commentStart + 3, $commentEnd - $commentStart - 5 ); + $desc = substr($desc, $commentStart + 3, $commentEnd - $commentStart - 5); return "\ \;" if !$desc; @@ -145,8 +145,8 @@ $desc =~ s#<[/\w]+(\s*\w+=[\w]*\s*)*>##g; # no quotes on attributes # strip off some CVS keyword lines - foreach $keyword ( 'Workfile', 'Revision', 'Modtime', 'Author', 'Id', 'Date', 'Source', - 'RCSfile' ) + foreach $keyword ('Workfile', 'Revision', 'Modtime', 'Author', 'Id', 'Date', 'Source', + 'RCSfile') { $desc =~ s/^\s*\$$keyword[\$:].*$//mg; } @@ -160,13 +160,13 @@ # descriptions before we go to the trouble of looking for # one in the first comment. The whitespace between the # delimeter and the description may include a newline. - if ( ( $desc =~ s/(?:.*?$filename\s*?- ?-*\s*)([^\n]*)(?:.*)/$1/sgi ) - || ( $desc =~ s/(?:.*?$filename\s*?:\s*)([^\n]*)(?:.*)/$1/sgi ) - || ( $desc =~ s/(?:.*?Description:\s*)([^\n]*)(?:.*)/$1/sgi ) ) + if ( ($desc =~ s/(?:.*?$filename\s*?- ?-*\s*)([^\n]*)(?:.*)/$1/sgi) + || ($desc =~ s/(?:.*?$filename\s*?:\s*)([^\n]*)(?:.*)/$1/sgi) + || ($desc =~ s/(?:.*?Description:\s*)([^\n]*)(?:.*)/$1/sgi)) { # if the description is non-empty then clean it up and return it - if ( $desc =~ /\w/ ) { + if ($desc =~ /\w/) { #strip trailing asterisks and "*/" $desc =~ s#\*/?\s*$##; @@ -180,13 +180,13 @@ $desc =~ s#[^\w]*##ms; #htmlify the comments making links to symbols and files - $desc = markupstring( $desc, $Path->{'virt'} ); + $desc = markupstring($desc, $Path->{'virt'}); return ($desc); } } # if java and the <filename><seperator> check above didn't work, just dump the whole javadoc - if ( $filename =~ /\.java$/ ) { + if ($filename =~ /\.java$/) { return $desc; } @@ -216,7 +216,7 @@ $desc =~ s#\n\s*/\*+[\s\*]+\*/\n#\n#sg; # Don't bother to continue if there aren't any comments here - if ( !( $desc =~ m#/\*# ) ) { + if (!($desc =~ m#/\*#)) { return (" "); } @@ -253,18 +253,18 @@ # If the description is too long then just use the first sentence # this will fail if no period was used. - if ( length($desc) > 200 ) { + if (length($desc) > 200) { $desc =~ s#([^\.]+\.)\s.*#$1#s; } # If the description is still too long then assume it will look # like gobbeldygook and give up - if ( length($desc) > 200 ) { + if (length($desc) > 200) { return (" "); } # htmlify the comments, making links to symbols and files - $desc = markupstring( $desc, $Path->{'virt'} ); + $desc = markupstring($desc, $Path->{'virt'}); if ($desc) { return ($desc); @@ -280,13 +280,13 @@ # In Mozilla, if the directory has a README file look in it for lines # like the ones used in source code: "directoryname --- A short description" sub descexpand { - my ( $templ, $node, $dir, $release ) = @_; - if ( $files->isdir( $dir . $node, $release ) ) { - return LXR::Common::expandtemplate( $templ, - ( 'desctext' => sub { return dirdesc( $dir . $node, $release ); } ) ); + my ($templ, $node, $dir, $release) = @_; + if ($files->isdir($dir . $node, $release)) { + return LXR::Common::expandtemplate($templ, + ('desctext' => sub { return dirdesc($dir . $node, $release); })); } else { - return LXR::Common::expandtemplate( $templ, - ( 'desctext' => sub { return fdescexpand( $node, $dir, $release ); } ) ); + return LXR::Common::expandtemplate($templ, + ('desctext' => sub { return fdescexpand($node, $dir, $release); })); } } @@ -299,21 +299,21 @@ # possible make this work for randomly formatted files rather than # inventing strict rules which create gobbeldygook when they're broken. sub dirdesc { - my ( $path, $release ) = @_; - if ( $files->isfile( $path . "README.txt", $release ) ) { - descreadme( $path . "README.txt", $release ); - } elsif ( $files->isfile( $path . "README", $release ) ) { - descreadme( $path . "README", $release ); - } elsif ( $files->isfile( $path . "README.html", $release ) ) { - descreadmehtml( $path . "README.html", $release ); + my ($path, $release) = @_; + if ($files->isfile($path . "README.txt", $release)) { + descreadme($path . "README.txt", $release); + } elsif ($files->isfile($path . "README", $release)) { + descreadme($path . "README", $release); + } elsif ($files->isfile($path . "README.html", $release)) { + descreadmehtml($path . "README.html", $release); } } sub descreadmehtml { - my ( $file, $release ) = @_; + my ($file, $release) = @_; my $string = ""; - return if !( $desc = $files->getfilehandle( $file, $release ) ); + return if !($desc = $files->getfilehandle($file, $release)); # undef $/; $string = <$desc>; @@ -322,31 +322,31 @@ close($desc); # if the README is 0 length then give up - if ( !$string ) { + if (!$string) { return; } # check if there's a short desc nested inside the long desc. If not, do # a non-greedy search for a long desc. assume there are no other stray # spans within the description. - if ( $string =~ -/<span class=["']?lxrlongdesc['"]?>(.*?<span class=["']?lxrshortdesc['"]?>.*?<\/span>.*?)<\/span>/is + if ($string =~ + /<span class=["']?lxrlongdesc['"]?>(.*?<span class=["']?lxrshortdesc['"]?>.*?<\/span>.*?)<\/span>/is ) { $long = $1; - if ( !( $long =~ /<span.*?\<span/is ) ) { - return ( $long . "<p>\nSEE ALSO: <a href=\"README.html\">README</a></p>\n" ); + if (!($long =~ /<span.*?\<span/is)) { + return ($long . "<p>\nSEE ALSO: <a href=\"README.html\">README</a></p>\n"); } - } elsif ( $string =~ /<span class=["']?lxrlongdesc['"]?>(.*?)<\/span>/is ) { + } elsif ($string =~ /<span class=["']?lxrlongdesc['"]?>(.*?)<\/span>/is) { $long = $1; - if ( !( $long =~ /\<span/is ) ) { - return ( $long . "<p>\nSEE ALSO: <a href=\"README.html\">README</a></p>\n" ); + if (!($long =~ /\<span/is)) { + return ($long . "<p>\nSEE ALSO: <a href=\"README.html\">README</a></p>\n"); } } } sub descreadme { - my ( $file, $release ) = @_; + my ($file, $release) = @_; my $string = ""; @@ -359,7 +359,7 @@ my $minlines = 5; # Too small. Go back and add another paragraph. my $chopto = 10; # Truncate long READMEs to this length - return if !( $desc = $files->getfilehandle( $file, $release ) ); + return if !($desc = $files->getfilehandle($file, $release)); # undef $/; $string = <$desc>; @@ -368,7 +368,7 @@ close($desc); # if the README is 0 length then give up - if ( !$string ) { + if (!$string) { return; } @@ -396,8 +396,8 @@ # If the file is small there's not much use splitting it up. # Just print it all - if ( $count <= $maxlines ) { - $string = markupstring( $string, $Path->{'virt'} ); + if ($count <= $maxlines) { + $string = markupstring($string, $Path->{'virt'}); $string = convertwhitespace($string); return ($string); } else { @@ -407,7 +407,7 @@ # one paragraph. $n = 6; $temp = $string; - while ( ( $count > $chopto ) && ( $n-- > 1 ) ) { + while (($count > $chopto) && ($n-- > 1)) { $string =~ s/^((?:(?:[\S\t ]*?\n)+?[\t ]*\n){$n}?)(.*)/$1/s; $_ = $string; $string =~ s/\s*\n$//gs; @@ -417,7 +417,7 @@ # if we have too few lines then back up and grab another paragraph $_ = $string; $count = tr/\n//; - if ( $count < $minlines ) { + if ($count < $minlines) { $n = $n + 1; $temp =~ s/^((?:(?:[\S\t ]*?\n)+?[\t ]*\n){$n}?)(.*)/$1/s; $string = $temp; @@ -425,7 +425,7 @@ # if we have more than $maxlines then truncate to $chopto # and add an elipsis. - if ( $count > $maxlines ) { + if ($count > $maxlines) { $string =~ s/^((?:[\S \t]*\n){$chopto}?)(.*)/$1/s; chomp($string); $string = $string . "\n..."; @@ -434,13 +434,13 @@ # since not all of the README is displayed here, # add a link to it. chomp($string); - if ( $string =~ /SEE ALSO/ ) { + if ($string =~ /SEE ALSO/) { $string = $string . ", README"; } else { $string = $string . "\n\nSEE ALSO: README"; } - $string = markupstring( $string, $Path->{'virt'} ); + $string = markupstring($string, $Path->{'virt'}); $string = convertwhitespace($string); # strip blank lines at beginning and end of file again Index: diff =================================================================== RCS file: /cvsroot/lxr/lxr/diff,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- diff 19 Jul 2004 19:50:20 -0000 1.12 +++ diff 21 Jul 2004 20:44:30 -0000 1.13 @@ -32,17 +32,17 @@ use Local; sub htmlsub { - my ( $s, $l ) = @_; - my @s = split( /(<[^>]*>|&[\#\w\d]+;?)/, $s ); + my ($s, $l) = @_; + my @s = split(/(<[^>]*>|&[\#\w\d]+;?)/, $s); $s = ''; while (@s) { - my $f = substr( shift(@s), 0, $l ); + my $f = substr(shift(@s), 0, $l); $l -= length($f); $s .= $f; $f = shift(@s); - if ( $f =~ /^&/ ) { - if ( $l > 0 ) { + if ($f =~ /^&/) { + if ($l > 0) { $s .= $f; $l--; } @@ -55,12 +55,12 @@ } sub printdiff { - my ( $diffvar, $diffval ) = @_; + my ($diffvar, $diffval) = @_; unless ($diffvar) { my @vars; - foreach ( $config->allvariables ) { - push( @vars, $config->vardescription($_) ); + foreach ($config->allvariables) { + push(@vars, $config->vardescription($_)); } $vars[ $#vars - 1 ] .= " or " . pop(@vars) if $#vars > 0; @@ -69,34 +69,33 @@ "<p align=\"center\">\n", "Please indicate the version of the file you wish to\n", "compare to by clicking on the appropriate\n", - join( ", ", @vars ), - " button.\n", - "</p>\n" + join(", ", @vars), + " button.\n", "</p>\n" ); return; } - if ( $pathname =~ m|/$| ) { + if ($pathname =~ m|/$|) { print("<h3 align=\"center\">Diff not yet supported for directories.</h3>\n"); return; } my $origval = $config->variable($diffvar); my $origname = $pathname; - my $origtemp = $files->tmpfile( $origname, $release ); + my $origtemp = $files->tmpfile($origname, $release); - $config->variable( $diffvar, $diffval ); + $config->variable($diffvar, $diffval); my $diffname = $config->mappath($pathname); - my $difftemp = $files->tmpfile( $diffname, $config->variable('v') ); + my $difftemp = $files->tmpfile($diffname, $config->variable('v')); - $config->variable( $diffvar, $origval ); + $config->variable($diffvar, $origval); - unless ( defined($origtemp) ) { + unless (defined($origtemp)) { unlink($difftemp); print("*** $origname does not exist ***\n"); return; } - unless ( defined($difftemp) ) { + unless (defined($difftemp)) { unlink($origtemp); print("*** $diffname does not exist ***\n"); return; @@ -104,24 +103,24 @@ fflush; $ENV{'PATH'} = '/bin:/usr/local/bin:/usr/bin:/usr/sbin'; - unless ( open( DIFF, "-|" ) ) { - open( STDERR, ">&STDOUT" ); - exec( 'diff', '-U0', $origtemp, $difftemp ); + unless (open(DIFF, "-|")) { + open(STDERR, ">&STDOUT"); + exec('diff', '-U0', $origtemp, $difftemp); print "*** Diff subprocess died unexpextedly: $!\n"; exit; } - my ( $os, $ol, $ns, $nl, $ms, $ml, $bo, $ofs, $dir, %orig, %new, %chg ); + my ($os, $ol, $ns, $nl, $ms, $ml, $bo, $ofs, $dir, %orig, %new, %chg); while (<DIFF>) { - if ( ( $os, $ol, $ns, $nl ) = /@@ -(\d+)(?:,(\d+)|) \+(\d+)(?:,(\d+)|) @@/ ) { + if (($os, $ol, $ns, $nl) = /@@ -(\d+)(?:,(\d+)|) \+(\d+)(?:,(\d+)|) @@/) { $os++ if $ol eq '0'; $ns++ if $nl eq '0'; $ol = 1 unless defined($ol); $nl = 1 unless defined($nl); $bo = $os + $ofs; - if ( $ol < $nl ) { + if ($ol < $nl) { $ofs += $nl - $ol; $dir = '>>'; @@ -134,10 +133,10 @@ $ml = $nl; $new{ $ns + $nl } = $ms; } - foreach ( 0 .. $ml - 1 ) { + foreach (0 .. $ml - 1) { $chg{ $bo + $_ } = '!!'; } - foreach ( 0 .. $ms - 1 ) { + foreach (0 .. $ms - 1) { $chg{ $bo + $ml + $_ } = $dir; } @@ -164,20 +163,20 @@ my $origh = new FileHandle($origtemp); my $orig = ''; - markupfile( $origh, sub { $orig .= shift }, 1 ); + markupfile($origh, sub { $orig .= shift }, 1); my $len = $. + $ofs; $origh->close; - $config->variable( $diffvar, $diffval ); + $config->variable($diffvar, $diffval); $pathname = $diffname; my $diffh = new FileHandle($difftemp); my $new = ''; - markupfile( $diffh, sub { $new .= shift } ); + markupfile($diffh, sub { $new .= shift }); $diffh->close; - $config->variable( $diffvar, $origval ); + $config->variable($diffvar, $origval); $pathname = $origname; my $i; @@ -186,16 +185,16 @@ $i = 1; $new =~ s/^/"\n" x ($new{$i++})/mge; - my @orig = split( /\n/, $orig ); - my @new = split( /\n/, $new ); + my @orig = split(/\n/, $orig); + my @new = split(/\n/, $new); print("<pre class=\"file\">\n"); - foreach $i ( 0 .. $len ) { - my $o = htmlsub( $orig[$i], 50 ); + foreach $i (0 .. $len) { + my $o = htmlsub($orig[$i], 50); my $n = $new[$i]; my $diffmark = - $chg{ $i + 1 } ? ( "<span class=\"diff-mark\">" . $chg{ $i + 1 } . "</span>" ) : " "; + $chg{ $i + 1 } ? ("<span class=\"diff-mark\">" . $chg{ $i + 1 } . "</span>") : " "; #print("$o <span class=\"diff-mark\">", # ($chg{$i+1} || " "), "</span> $n\n"); @@ -203,13 +202,13 @@ } print("</pre>"); - unlink( $origtemp, $difftemp ); + unlink($origtemp, $difftemp); } httpinit; makeheader('diff'); -printdiff( $$HTTP{'param'}{'diffvar'}, $$HTTP{'param'}{'diffval'} ); +printdiff($$HTTP{'param'}{'diffvar'}, $$HTTP{'param'}{'diffval'}); makefooter('diff'); httpclean; Index: find =================================================================== RCS file: /cvsroot/lxr/lxr/find,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- find 19 Jul 2004 20:03:31 -0000 1.22 +++ find 21 Jul 2004 20:44:30 -0000 1.23 @@ -35,8 +35,8 @@ my $templ = shift; my $ret = ''; - foreach ( $config->allvariables ) { - if ( $config->variable($_) ne $config->vardefault($_) ) { + foreach ($config->allvariables) { + if ($config->variable($_) ne $config->vardefault($_)) { $ret .= expandtemplate( $templ, ( @@ -55,35 +55,34 @@ my $ret = ''; foreach (@results) { - $ret .= - expandtemplate( $templ, ( fileref => sub { fileref( "$_", "find-file", "/$_" ) } ) ); + $ret .= expandtemplate($templ, (fileref => sub { fileref("$_", "find-file", "/$_") })); } return $ret; } sub dofind { - my ( $searchtext, $FILELISTING, $advanced, $casesensitive ) = @_; + my ($searchtext, $FILELISTING, $advanced, $casesensitive) = @_; my @ret; - if ( $searchtext ne "" ) { + if ($searchtext ne "") { my $sourceroot = $config->sourceroot . '/' . $release . '/'; - while ( my $file = <$FILELISTING> ) { + while (my $file = <$FILELISTING>) { chomp $file; $file =~ s/^$sourceroot//; if ($advanced) { if ($casesensitive) { - if ( $file =~ /$searchtext/ ) { + if ($file =~ /$searchtext/) { push @ret, $file; } - } elsif ( $file =~ /$searchtext/i ) { + } elsif ($file =~ /$searchtext/i) { push @ret, $file; } } else { if ($casesensitive) { - if ( index( $file, $searchtext ) != -1 ) { + if (index($file, $searchtext) != -1) { push @ret, $file; } - } elsif ( index( lc($file), lc($searchtext) ) != -1 ) { + } elsif (index(lc($file), lc($searchtext)) != -1) { push @ret, $file; } } @@ -95,9 +94,9 @@ sub find { my $templ; - if ( $config->htmlfind ) { - unless ( open( TEMPL, $config->htmlfind ) ) { - warning( "Template " . $config->htmlfind . " does not exist." ); + if ($config->htmlfind) { + unless (open(TEMPL, $config->htmlfind)) { + warning("Template " . $config->htmlfind . " does not exist."); } else { local ($/) = undef; $templ = <TEMPL>; @@ -112,32 +111,32 @@ my $casesensitive = $HTTP->{'param'}->{'casesensitive'}; my $FILELISTING; - if ( $config->swishdir and $config->swishbin ) { - unless ( $FILELISTING = new IO::File( $config->swishdir . "/$release.filenames" ) ) { + if ($config->swishdir and $config->swishbin) { + unless ($FILELISTING = new IO::File($config->swishdir . "/$release.filenames")) { &warning( -"Version '$release' has not been indexed and is unavailable for searching<br>Could not open " + "Version '$release' has not been indexed and is unavailable for searching<br>Could not open " . $config->swishdir - . "/$release.filenames." ); + . "/$release.filenames."); return; } - } elsif ( $config->glimpsedir and $config->glimpsebin ) { - unless ( $FILELISTING = - new IO::File( $config->glimpsedir . "/" . $release . "/.glimpse_filenames" ) ) + } elsif ($config->glimpsedir and $config->glimpsebin) { + unless ($FILELISTING = + new IO::File($config->glimpsedir . "/" . $release . "/.glimpse_filenames")) { &warning( -"Version '$release' has not been indexed and is unavailable for searching<br>Could not open " + "Version '$release' has not been indexed and is unavailable for searching<br>Could not open " . $config->glimpsedir - . "/$release/.glimpse_filenames." ); + . "/$release/.glimpse_filenames."); return; } } else { warning( -"Freetext search engine required for file search, and no freetext search engine is configured" + "Freetext search engine required for file search, and no freetext search engine is configured" ); return; } - my @results = dofind( $searchtext, $FILELISTING, $advanced, $casesensitive ); + my @results = dofind($searchtext, $FILELISTING, $advanced, $casesensitive); close($FILELISTING); print expandtemplate( @@ -148,7 +147,7 @@ searchtext => sub { return $searchtext }, searchtext_escaped => sub { $_ = $searchtext; s/\"/"/g; return $_; }, casesensitivechecked => sub { return $casesensitive ? "checked" : "" }, - results => sub { printresults( @_, @results ) }, + results => sub { printresults(@_, @results) }, resultcount => sub { return scalar @results }, ) ); Index: genxref =================================================================== RCS file: /cvsroot/lxr/lxr/genxref,v retrieving revision 1.35 retrieving revision 1.36 diff -u -d -r1.35 -r1.36 --- genxref 19 Jul 2004 20:03:31 -0000 1.35 +++ genxref 21 Jul 2004 20:44:30 -0000 1.36 @@ -29,9 +29,9 @@ use LXR::Common; my %option; -GetOptions( \%option, "help!", "url=s", "version=s", "allurls!", "allversions!", "reindexall!" ); +GetOptions(\%option, "help!", "url=s", "version=s", "allurls!", "allversions!", "reindexall!"); -if ( $option{'help'} ) { +if ($option{'help'}) { # this may not be the best way to implement this, but at least it's something print <<END_HELP; @@ -63,14 +63,14 @@ die("URL must be specified. Try \"genxref --help\".\n") unless $option{'url'}; -$config = new LXR::Config( $option{'url'} ); +$config = new LXR::Config($option{'url'}); die("No matching configuration") unless $config->sourceroot; -$files = new LXR::Files( $config->sourceroot ); +$files = new LXR::Files($config->sourceroot); die "Can't create file access object " . $config->sourceroot if !defined($files); -$index = new LXR::Index( $config->dbname, O_RDWR | O_CREAT ); +$index = new LXR::Index($config->dbname, O_RDWR | O_CREAT); die "Can't create Index " . $config->dbname if !defined($index); our $filetype = new File::MMagic(); @@ -78,10 +78,10 @@ my @versions; -if ( $option{'allversions'} || !$option{'version'} ) { +if ($option{'allversions'} || !$option{'version'}) { @versions = $config->varrange('v'); die -"Option --allversions cannot be used because no versions found automatically. Use --version=VERSION or fix lxr.conf.\n" + "Option --allversions cannot be used because no versions found automatically. Use --version=VERSION or fix lxr.conf.\n" if scalar @versions <= 0; } else { @versions = $option{'version'}; @@ -90,49 +90,49 @@ foreach my $version (@versions) { $index->purge($version) if $option{'reindexall'}; gensearch($version); - genindex( '/', $version ); - genrefs( '/', $version ); + genindex('/', $version); + genrefs('/', $version); } sub genindex { - my ( $pathname, $release ) = @_; + my ($pathname, $release) = @_; - print( STDERR "*** $pathname $release \n" ); + print(STDERR "*** $pathname $release \n"); - if ( $pathname =~ m|/$| ) { - map { genindex( $pathname . $_, $release ) } $files->getdir( $pathname, $release ); + if ($pathname =~ m|/$|) { + map { genindex($pathname . $_, $release) } $files->getdir($pathname, $release); } else { - &LXR::Tagger::processfile( $pathname, $release, $config, $files, $index ) + &LXR::Tagger::processfile($pathname, $release, $config, $files, $index) unless exists $binaryfiles{$pathname}; } } sub genrefs { - my ( $pathname, $release ) = @_; + my ($pathname, $release) = @_; - print( STDERR "### $pathname $release \n" ); + print(STDERR "### $pathname $release \n"); - if ( $pathname =~ m|/$| ) { - map { genrefs( $pathname . $_, $release ) } $files->getdir( $pathname, $release ); + if ($pathname =~ m|/$|) { + map { genrefs($pathname . $_, $release) } $files->getdir($pathname, $release); } else { - &LXR::Tagger::processrefs( $pathname, $release, $config, $files, $index ) + &LXR::Tagger::processrefs($pathname, $release, $config, $files, $index) unless exists $binaryfiles{$pathname}; } } sub feedswish { - my ( $pathname, $release, $swish, $filelist ) = @_; + my ($pathname, $release, $swish, $filelist) = @_; - print( STDERR "&&& $pathname $release \n" ); + print(STDERR "&&& $pathname $release \n"); - if ( $pathname =~ m|/$| ) { - map { feedswish( $pathname . $_, $release, $swish, $filelist ) } - $files->getdir( $pathname, $release ); + if ($pathname =~ m|/$|) { + map { feedswish($pathname . $_, $release, $swish, $filelist) } + $files->getdir($pathname, $release); } else { print $filelist "$pathname\n"; - my $contents = $files->getfile( $pathname, $release ); - if ( $filetype->checktype_contents($contents) =~ m%(text|message)/% - and length($contents) > 0 ) + my $contents = $files->getfile($pathname, $release); + if ($filetype->checktype_contents($contents) =~ m%(text|message)/% + and length($contents) > 0) { $swish->print( "Path-Name: $pathname\n", @@ -150,7 +150,7 @@ my ($release) = @_; my $string; - if ( $config->glimpsedir and $config->glimpseindex ) { + if ($config->glimpsedir and $config->glimpseindex) { # Make sure the directory that the glimpse results go into # already exists as glimpse won't work if the directory does @@ -161,14 +161,14 @@ mkdir $string; system("chmod 755 $string"); my $glimpse = new IO::Handle; - my $pid = open( $glimpse, "|-" ); - if ( $pid == 0 ) { - exec( $config->glimpseindex, "-n", "-o", "-H", + my $pid = open($glimpse, "|-"); + if ($pid == 0) { + exec($config->glimpseindex, "-n", "-o", "-H", $config->glimpsedir . "/$release", $config->sourceroot . "/" . $release ); - print( STDERR "Couldn't exec " . $config->glimpseindex . ": $!\n" ); - kill( 9, $$ ); + print(STDERR "Couldn't exec " . $config->glimpseindex . ": $!\n"); + kill(9, $$); } $glimpse->close(); @@ -177,7 +177,7 @@ system("chmod 644 $string"); } - if ( $config->swishdir and $config->swishbin ) { + if ($config->swishdir and $config->swishbin) { my $swish = new IO::Handle; die $config->swishdir . " does not exist" unless -d $config->swishdir; my $filelist = new IO::File $config->swishdir . "/$release.filenames", "w" @@ -185,16 +185,16 @@ # execute swish, as a pipe we can write to - open( $swish, + open($swish, "| " . $config->swishbin . " -S prog -i stdin -v 1 -c swish-e.conf -f " . $config->swishdir . "/" . $release - . ".index" ) + . ".index") or die "Couldn't exec " . $config->swishbin . ": $!\n"; - feedswish( "/", $release, $swish, $filelist ); + feedswish("/", $release, $swish, $filelist); $swish->close(); $filelist->close(); Index: ident =================================================================== RCS file: /cvsroot/lxr/lxr/ident,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- ident 19 Jul 2004 19:50:20 -0000 1.19 +++ ident 21 Jul 2004 20:44:30 -0000 1.20 @@ -36,8 +36,8 @@ sub varinputs { my $ret = ''; - foreach ( $config->allvariables ) { - if ( $config->variable($_) ne $config->vardefault($_) ) { + foreach ($config->allvariables) { + if ($config->variable($_) ne $config->vardefault($_)) { $ret .= "<input type=\"hidden\" name=\"$_\" value=\"" . $config->variable($_) . "\">\n"; } } @@ -48,17 +48,17 @@ my $templ = shift; my $ret = ''; - my @refs = $index->getindex( $identifier, $release ); + my @refs = $index->getindex($identifier, $release); my $file_hits = 0; my $last_file; my $def; foreach my $def (@refs) { - my ( $file, $line, $type, $rel ) = @$def; + my ($file, $line, $type, $rel) = @$def; $file_hits++ if $file ne $last_file; $last_file = $file; - $rel &&= "(member of " . idref( $rel, "search-member", $rel ) . ")"; + $rel &&= "(member of " . idref($rel, "search-member", $rel) . ")"; $ret .= expandtemplate( $templ, ( @@ -67,7 +67,7 @@ type => sub { $type }, rel => sub { $rel }, fileref => sub { - fileref( "$file, line $line", "search-decl", $file, $line ); + fileref("$file, line $line", "search-decl", $file, $line); } ) ); @@ -85,11 +85,11 @@ my $templ = shift; my $ret = ''; - my @uses = $index->getreference( $identifier, $release ); + my @uses = $index->getreference($identifier, $release); my $file_hits = 0; my $last_file; - foreach my $ref ( sort { $$a[0] cmp $$b[0] } @uses ) { - my ( $file, $line ) = @$ref; + foreach my $ref (sort { $$a[0] cmp $$b[0] } @uses) { + my ($file, $line) = @$ref; $file_hits++ if $file ne $last_file; $last_file = $file; $ret .= expandtemplate( @@ -98,7 +98,7 @@ file => sub { $file }, line => sub { $line }, fileref => sub { - fileref( "$file, line $line", "search-ref", $file, $line ); + fileref("$file, line $line", "search-ref", $file, $line); } ) ); @@ -109,12 +109,12 @@ sub printident { my $dir = shift; - my ( $templ, $templ_refs ); + my ($templ, $templ_refs); #$templ = "<ul>\n\$files{\n<li>\$iconlink \$namelink\n}</ul>\n"; - if ( $config->htmlident ) { - unless ( open( TEMPL, $config->htmlident ) ) { - warning( "Template " . $config->htmlident . " does not exist." ); + if ($config->htmlident) { + unless (open(TEMPL, $config->htmlident)) { + warning("Template " . $config->htmlident . " does not exist."); } else { local ($/) = undef; $templ = <TEMPL>; @@ -124,9 +124,9 @@ die "Ident template not configured"; } - if ( $config->htmlident_refs ) { - unless ( open( TEMPL, $config->htmlident_refs ) ) { - warning( "Template " . $config->htmlident_refs . " does not exist." ); + if ($config->htmlident_refs) { + unless (open(TEMPL, $config->htmlident_refs)) { + warning("Template " . $config->htmlident_refs . " does not exist."); } else { local ($/) = undef; $templ_refs = <TEMPL>; @@ -152,7 +152,7 @@ ) ); print $declare_hits; - print( expandtemplate( $templ_refs, ( uses => sub { usesexpand(@_) }, ) ) ); + print(expandtemplate($templ_refs, (uses => sub { usesexpand(@_) },))); print $reference_hits; } Index: search =================================================================== RCS file: /cvsroot/lxr/lxr/search,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- search 19 Jul 2004 20:03:31 -0000 1.23 +++ search 21 Jul 2004 20:44:30 -0000 1.24 @@ -37,8 +37,8 @@ my $templ = shift; my $ret = ''; - foreach ( $config->allvariables ) { - if ( $config->variable($_) ne $config->vardefault($_) ) { + foreach ($config->allvariables) { + if ($config->variable($_) ne $config->vardefault($_)) { $ret .= expandtemplate( $templ, ( @@ -55,11 +55,11 @@ my ($searchtext) = @_; $ENV{'PATH'} = '/bin:/usr/local/bin:/usr/bin:/usr/sbin'; - unless ( open( GLIMPSE, "-|" ) ) { - open( STDERR, ">&STDOUT" ); + unless (open(GLIMPSE, "-|")) { + open(STDERR, ">&STDOUT"); $! = ''; - exec( $config->glimpsebin, "-i", "-H" . $config->glimpsedir . "/" . $release, - '-y', '-n', $searchtext ); + exec($config->glimpsebin, "-i", "-H" . $config->glimpsedir . "/" . $release, + '-y', '-n', $searchtext); print("Glimpse subprocess died unexpextedly: $!\n"); exit; } @@ -68,8 +68,8 @@ my @glimpselines = (); while (<GLIMPSE>) { $numlines++; - push( @glimpselines, $_ ); - if ( $numlines > $maxhits ) { + push(@glimpselines, $_); + if ($numlines > $maxhits) { last; } } @@ -82,15 +82,15 @@ # inaccessible files. It seems this is not the case. # We will have to work around it for the time being. - if ( $retval == 0 ) { + if ($retval == 0) { my @ret; my $sourceroot = $config->sourceroot . '/' . $release . '/'; my $i = 0; foreach my $glimpseline (@glimpselines) { - last if ( $i > $maxhits ); + last if ($i > $maxhits); $glimpseline =~ s/$sourceroot//; - my ( $file, $line, $text ) = $glimpseline =~ /(.*?):\s*(\d+)\s*:(.*)/; + my ($file, $line, $text) = $glimpseline =~ /(.*?):\s*(\d+)\s*:(.*)/; $text =~ s/&/&/g; $text =~ s/</</g; $text =~ s/>/>/g; @@ -100,9 +100,9 @@ $i++; } return @ret; - } elsif ( $retval == 1 ) { + } elsif ($retval == 1) { my $glimpsebin = $config->glimpsebin; - my $glimpseresponse = join( "<br>", @glimpselines ); + my $glimpseresponse = join("<br>", @glimpselines); my $glimpseresponse =~ s/$glimpsebin/Reason/; my $glimpseresponse =~ s/glimpse: error in searching index//; print("<b>Search failed</b><br>\n$glimpseresponse"); @@ -116,20 +116,20 @@ sub swishsearch { my ($searchtext) = @_; - if ( !-e $config->swishdir . "/" . $release . ".index" ) { + if (!-e $config->swishdir . "/" . $release . ".index") { print -"<p align='center'><i>Version '$release' has not been indexed and is unavailable for searching.</i></p>"; + "<p align='center'><i>Version '$release' has not been indexed and is unavailable for searching.</i></p>"; return; } $ENV{'PATH'} = '/bin:/usr/local/bin:/usr/bin:/usr/sbin'; - unless ( open( SWISH, "-|" ) ) { - open( STDERR, ">&STDOUT" ); - exec( $config->swishbin, "-f", $config->swishdir . "/" . $release . ".index", - "-m", $maxhits, "-w", "'" . $searchtext . "'" ); + unless (open(SWISH, "-|")) { + open(STDERR, ">&STDOUT"); + exec($config->swishbin, "-f", $config->swishdir . "/" . $release . ".index", + "-m", $maxhits, "-w", "'" . $searchtext . "'"); - print( STDERR "Couldn't exec " . $config->swishbin . ": $!\n" ); - kill( 9, $$ ); + print(STDERR "Couldn't exec " . $config->swishbin . ": $!\n"); + kill(9, $$); } my @result = grep { not /^[\#\.]/ } <SWISH>; @@ -137,18 +137,17 @@ my $retval = $? >> 8; my @ret; - if ( $retval == 0 ) { + if ($retval == 0) { foreach my $hit (@result) { - if ( $hit =~ /^err:/ ) { - print $hit if $hit !~ /no results/; - next; - } - my ( $score, $file ) = $hit =~ /^(\d+) \/(.+) "(.+)" \d+/; + next if $hit =~ /^err:/; # skip; only 'no results' errors happen with return value 0 + my ($score, $file) = $hit =~ /^(\d+) \/(.+) "(.+)" \d+/; push @ret, [ $file, $score ]; } return @ret; } else { print("<b>Search failed</b><br>\n@result"); + print "<br><i>Tip: you may need to quote words that end with *</i>" + if join('', @result) =~ /Wildcard not allowed within a word/; return; } } @@ -163,7 +162,7 @@ # glimpse and swish-e provide different data for each result my (@params) = @$_; - if ( $config->glimpsebin ) { + if ($config->glimpsebin) { my $file = $params[0]; my $line = $params[1]; my $text = $params[2]; @@ -171,7 +170,7 @@ $templ, ( text => sub { return $text }, - fileref => sub { fileref( "$file, line $line", "find-file", "/$file", $line ) }, + fileref => sub { fileref("$file, line $line", "find-file", "/$file", $line) }, ) ); } else { @@ -181,7 +180,7 @@ $templ, ( score => sub { return $score }, - fileref => sub { fileref( "$file", "find-file", "/$file" ) }, + fileref => sub { fileref("$file", "find-file", "/$file") }, ) ); } @@ -192,9 +191,9 @@ sub search { my $templ; - if ( $config->htmlsearch ) { - unless ( open( TEMPL, $config->htmlsearch ) ) { - warning( "Template " . $config->htmlsearch . " does not exist." ); + if ($config->htmlsearch) { + unless (open(TEMPL, $config->htmlsearch)) { + warning("Template " . $config->htmlsearch . " does not exist."); } else { local ($/) = undef; $templ = <TEMPL>; @@ -207,10 +206,10 @@ my $searchtext = $HTTP->{'param'}->{'string'}; my @results; - if ( $searchtext ne "" ) { - if ( $config->glimpsebin ) { + if ($searchtext ne "") { + if ($config->glimpsebin) { @results = glimpsesearch($searchtext); - } elsif ( $config->swishbin and $config->swishdir ) { + } elsif ($config->swishbin and $config->swishdir) { @results = swishsearch($searchtext); } else { warning("No freetext search engine configured."); @@ -229,7 +228,7 @@ : ""; }, - results => sub { printresults( @_, @results ) }, + results => sub { printresults(@_, @results) }, resultcount => sub { return scalar @results }, ) ); Index: source =================================================================== RCS file: /cvsroot/lxr/lxr/source,v retrieving revision 1.42 retrieving revision 1.43 diff -u -d -r1.42 -r1.43 --- source 19 Jul 2004 19:50:20 -0000 1.42 +++ source 21 Jul 2004 20:44:30 -0000 1.43 @@ -33,68 +33,68 @@ use Local; sub diricon { - my ( $templ, $node, $dir ) = @_; + my ($templ, $node, $dir) = @_; my $img; - if ( $node eq '../' ) { + if ($node eq '../') { $img = "/icons/back.gif"; } else { $img = "/icons/folder.gif"; } - return fileref( "<img align=\"bottom\" border=\"0\" src=\"$img\" alt=\"folder\">", "", - $dir . $node ); + return fileref("<img align=\"bottom\" border=\"0\" src=\"$img\" alt=\"folder\">", "", + $dir . $node); } sub dirname { - my ( $templ, $node, $dir ) = @_; + my ($templ, $node, $dir) = @_; - if ( $node eq '../' ) { - return fileref( "Parent directory", "dirfolder", $dir . $node ); + if ($node eq '../') { + return fileref("Parent directory", "dirfolder", $dir . $node); } else { - return fileref( $node, "dirfolder", $dir . $node ); + return fileref($node, "dirfolder", $dir . $node); } } sub fileicon { - my ( $templ, $node, $dir ) = @_; + my ($templ, $node, $dir) = @_; my $img; - if ( $node =~ /^.*\.[ch]$/ ) { + if ($node =~ /^.*\.[ch]$/) { $img = "/icons/c.gif"; - } elsif ( $node =~ /^.*\.(cpp|cc|java)$/ ) { + } elsif ($node =~ /^.*\.(cpp|cc|java)$/) { # TODO: Find a nice icon for c++ files (KDE?) $img = "/icons/c.gif"; - } elsif ( $node =~ /^.*\.(txt)$/ ) { + } elsif ($node =~ /^.*\.(txt)$/) { $img = "/icons/text.gif"; - } elsif ( $node =~ /^.*\.(jar|war|ear|zip|tar|gz|tgz|cab)$/ ) { + } elsif ($node =~ /^.*\.(jar|war|ear|zip|tar|gz|tgz|cab)$/) { $img = "/icons/compressed.gif"; - } elsif ( $node =~ /^.*\.(jpg|jpeg|gif|bmp|png)$/ ) { + } elsif ($node =~ /^.*\.(jpg|jpeg|gif|bmp|png)$/) { $img = "/icons/image2.gif"; } else { $img = "/icons/generic.gif"; } - return fileref( "<img align=\"bottom\" border=\"0\" src=\"$img\" alt=\"\">", "", $dir . $node ); + return fileref("<img align=\"bottom\" border=\"0\" src=\"$img\" alt=\"\">", "", $dir . $node); } sub filename { - my ( $templ, $node, $dir ) = @_; - return fileref( $node, "dirfile", $dir . $node ); + my ($templ, $node, $dir) = @_; + return fileref($node, "dirfile", $dir . $node); } sub filesize { - my ( $templ, $node, $dir ) = @_; + my ($templ, $node, $dir) = @_; - my $s = $files->getfilesize( $dir . $node, $release ); + my $s = $files->getfilesize($dir . $node, $release); my $str; - if ( $s < 1 << 10 ) { + if ($s < 1 << 10) { $str = "$s"; } else { # if ($s < 1<<20) { - $str = ( $s >> 10 ) . "k"; + $str = ($s >> 10) . "k"; # } else { # $str = ($s>>20) . "M"; @@ -111,72 +111,72 @@ } sub modtime { - my ( $templ, $node, $dir ) = @_; + my ($templ, $node, $dir) = @_; my $current_time = time; - my $file_time = $files->getfiletime( $dir . $node, $release ); + my $file_time = $files->getfiletime($dir . $node, $release); return '-' unless defined($file_time); my @t = gmtime($file_time); - my ( $sec, $min, $hour, $mday, $mon, $year ) = @t; + my ($sec, $min, $hour, $mday, $mon, $year) = @t; return - sprintf( "%04d-%02d-%02d %02d:%02d:%02d", $year + 1900, $mon + 1, $mday, $hour, $min, $sec ); + sprintf("%04d-%02d-%02d %02d:%02d:%02d", $year + 1900, $mon + 1, $mday, $hour, $min, $sec); } sub bgcolor { - my ( $templ, $line ) = @_; - return ( ( ( $line - 1 ) / 3 ) % 2 ) ? "#FFFFFF" : "#EEEEEE"; + my ($templ, $line) = @_; + return ((($line - 1) / 3) % 2) ? "#FFFFFF" : "#EEEEEE"; } sub rowclass { - my ( $templ, $line ) = @_; - return ( ( ( $line - 1 ) / 3 ) % 2 ) ? "dirrow2" : "dirrow1"; + my ($templ, $line) = @_; + return ((($line - 1) / 3) % 2) ? "dirrow2" : "dirrow1"; } sub direxpand { - my ( $templ, $dir ) = @_; + my ($templ, $dir) = @_; my $direx = ''; my $line = 1; my %index; my @nodes; my $node; - @nodes = $files->getdir( $dir, $release ); + @nodes = $files->getdir($dir, $release); unless (@nodes) { print( "<p align=\"center\">\n<i>The directory " - . $files->toreal( $dir, $release ) - . " does not exist.</i>\n" ); + . $files->toreal($dir, $release) + . " does not exist.</i>\n"); print( -"\<p align=\"center\">\n<i>This directory might exist in other versions, try 'Show attic files' or select a different Version.</i>\n" + "\<p align=\"center\">\n<i>This directory might exist in other versions, try 'Show attic files' or select a different Version.</i>\n" ) if $files->isa("LXR::Files::CVS") and !$HTTP->{'param'}->{'showattic'}; #FIXME what does this do? - if ( $files->toreal( $dir, $release ) =~ m#(.+[^/])[/]*$# ) { - if ( -e $1 ) { - warning( "Unable to open " . $files->toreal( $dir, $release ) ); + if ($files->toreal($dir, $release) =~ m#(.+[^/])[/]*$#) { + if (-e $1) { + warning("Unable to open " . $files->toreal($dir, $release)); } } return; } - unshift( @nodes, '../' ) unless $dir eq '/'; + unshift(@nodes, '../') unless $dir eq '/'; #CSS checked _PH_ foreach $node (@nodes) { - if ( $node =~ /\/$/ ) { + if ($node =~ /\/$/) { $direx .= expandtemplate( $templ, ( - 'iconlink' => sub { diricon( @_, $node, $dir ) }, - 'namelink' => sub { dirname( @_, $node, $dir ) }, + 'iconlink' => sub { diricon(@_, $node, $dir) }, + 'namelink' => sub { dirname(@_, $node, $dir) }, 'filesize' => sub { '-' }, - 'modtime' => sub { modtime( @_, $node, $dir ) }, - 'bgcolor' => sub { bgcolor( @_, $line++ ) }, - 'css' => sub { rowclass( @_, $line++ ) }, - 'description' => sub { descexpand( @_, $node, $dir, $release ) } + 'modtime' => sub { modtime(@_, $node, $dir) }, + 'bgcolor' => sub { bgcolor(@_, $line++) }, + 'css' => sub { rowclass(@_, $line++) }, + 'description' => sub { descexpand(@_, $node, $dir, $release) } ) ); } else { @@ -184,17 +184,19 @@ $direx .= expandtemplate( $templ, ( - 'iconlink' => sub { fileicon( @_, $node, $dir ) }, - 'namelink' => sub { filename( @_, $node, $dir ) }, - 'filesize' => sub { filesize( @_, $node, $dir ) }, - 'modtime' => sub { modtime( @_, $node, $dir ) }, - 'bgcolor' => sub { bgcolor( @_, $line++ ) }, - 'css' => sub { rowclass( @_, $line++ ) }, + 'iconlink' => sub { fileicon(@_, $node, $dir) }, + 'namelink' => sub { filename(@_, $node, $dir) }, + 'filesize' => sub { filesize(@_, $node, $dir) }, + 'modtime' => sub { modtime(@_, $node, $dir) }, + 'bgcolor' => sub { bgcolor(@_, $line++) }, + 'css' => sub { rowclass(@_, $line++) }, 'description' => sub { - ( $files->toreal( $dir . $node, $release ) =~ m|/Attic/| + ( + $files->toreal($dir . $node, $release) =~ m|/Attic/| ? "<i>In Attic</i> " - : "" ) - . descexpand( @_, $node, $dir, $release ); + : "" + ) + . descexpand(@_, $node, $dir, $release); } ) ); @@ -209,9 +211,9 @@ my $templ; $templ = "<ul>\n\$files{\n<li>\$iconlink \$namelink\n}</ul>\n"; - if ( $config->htmldir ) { - unless ( open( TEMPL, $config->htmldir ) ) { - warning( "Template " . $config->htmldir . " does not exist." ); + if ($config->htmldir) { + unless (open(TEMPL, $config->htmldir)) { + warning("Template " . $config->htmldir . " does not exist."); } else { local ($/) = undef; $templ = <TEMPL>; @@ -220,23 +222,23 @@ } # print the description of the current directory - print dirdesc( $dir, $release ); + print dirdesc($dir, $release); # print the listing itself - print( expandtemplate( $templ, ( 'files' => sub { direxpand( @_, $dir ) } ) ) ); + print(expandtemplate($templ, ('files' => sub { direxpand(@_, $dir) }))); } sub printfile { my $raw = shift; - if ( $pathname =~ m|/$| ) { + if ($pathname =~ m|/$|) { printdir($pathname); } else { - my $fileh = $files->getfilehandle( $pathname, $release ); + my $fileh = $files->getfilehandle($pathname, $release); if ($fileh) { if ($raw) { - print( $fileh->getlines ); + print($fileh->getlines ); } # elsif ($node =~ /README$/) { @@ -245,7 +247,7 @@ # "</pre>"); # } else { - if ( $config->cvswebprefix ) { + if ($config->cvswebprefix) { my $revtarget = ""; $revtarget = "#rev$release" if lc($release) ne "head"; print "<a href='" @@ -255,19 +257,19 @@ . $revtarget . "'>View CVS Log</a>"; } - my @ann = $files->getannotations( $pathname, $release ); + my @ann = $files->getannotations($pathname, $release); if (@ann) { - my ( $a, $b ); + my ($a, $b); foreach $a (@ann) { - if ( $a eq $b ) { + if ($a eq $b) { $a = ' ' x 16; next; } $b = $a; - $a .= ' ' x ( 6 - length($a) ) . $files->getauthor( $pathname, $a ); - $a .= ' ' x ( 16 - length($a) ); + $a .= ' ' x (6 - length($a)) . $files->getauthor($pathname, $a); + $a .= ' ' x (16 - length($a)); } } @@ -278,19 +280,19 @@ print $l; }; &$outfun("<pre class=\"file\">\n"); - markupfile( $fileh, $outfun ); + markupfile($fileh, $outfun); &$outfun("</pre>\n"); } } else { print("\<p align=\"center\">\n<i>The file $pathname does not exist.</i>\n"); print( -"\<p align=\"center\">\n<i>This file might exist in other versions, try 'Show attic files' or select a different Version.</i>\n" + "\<p align=\"center\">\n<i>This file might exist in other versions, try 'Show attic files' or select a different Version.</i>\n" ) if $files->isa("LXR::Files::CVS") and !$HTTP->{'param'}->{'showattic'}; - if ( -f $files->toreal( $pathname, $release ) ) { - warning( "Unable to open " . $files->toreal( $pathname, $release ) ); + if (-f $files->toreal($pathname, $release)) { + warning("Unable to open " . $files->toreal($pathname, $release)); } } } @@ -298,7 +300,7 @@ httpinit; -if ( $config->filter && $pathname !~ $config->filter ) { +if ($config->filter && $pathname !~ $config->filter) { makeheader('source'); print("\<p align=\"center\">\n<i>The file $pathname does not exist.</i>\n"); makefooter('source'); @@ -306,10 +308,10 @@ } # If the file is html then simply pump it out. -if ( $pathname =~ /\.(html)$/ || $HTTP->{'param'}->{'raw'} ) { +if ($pathname =~ /\.(html)$/ || $HTTP->{'param'}->{'raw'}) { printfile(1); } else { - my $type = ( $pathname !~ m|/$| ? 'source' : 'sourcedir' ); + my $type = ($pathname !~ m|/$| ? 'source' : 'sourcedir'); makeheader($type); printfile(0); |
From: Dave B. <bro...@us...> - 2004-07-21 14:08:46
|
Update of /cvsroot/lxr/lxr/lib/LXR/Files In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29832/lib/LXR/Files Modified Files: CVS.pm Log Message: sort CVS revisions intelligently Index: CVS.pm =================================================================== RCS file: /cvsroot/lxr/lxr/lib/LXR/Files/CVS.pm,v retrieving revision 1.29 retrieving revision 1.30 diff -u -d -r1.29 -r1.30 --- CVS.pm 20 Jul 2004 20:40:21 -0000 1.29 +++ CVS.pm 21 Jul 2004 14:08:38 -0000 1.30 @@ -374,12 +374,25 @@ } } +# sort by CVS version +# split rev numbers into arrays +# compare each array element, returning as soon as we find a difference +sub byrevision { + my @one = split /\./, $a; + my @two = split /\./, $b; + for (my $i = 0; $i <= $#one; $i++) { + my $ret = $one[$i] <=> $two[$i]; + return $ret if $ret; + } + return $#one <=> $#two; # if still no difference after we ran through all elements of @one, compare the length of the array +} + sub allrevisions { my ( $self, $filename ) = @_; $self->parsecvs($filename); - return sort( keys( %{ $cvs{'branch'} } ) ); + return sort byrevision keys( %{ $cvs{'branch'} } ); } sub parsecvs { |
From: Dave B. <bro...@us...> - 2004-07-20 20:40:31
|
Update of /cvsroot/lxr/lxr/lib/LXR/Files In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25163/lib/LXR/Files Modified Files: CVS.pm Log Message: remember gnu_diff setting Index: CVS.pm =================================================================== RCS file: /cvsroot/lxr/lxr/lib/LXR/Files/CVS.pm,v retrieving revision 1.28 retrieving revision 1.29 diff -u -d -r1.28 -r1.29 --- CVS.pm 20 Jul 2004 18:17:39 -0000 1.28 +++ CVS.pm 20 Jul 2004 20:40:21 -0000 1.29 @@ -34,12 +34,14 @@ $self->{'rootpath'} = $rootpath; $self->{'rootpath'} =~ s@/*$@/@; - # the rcsdiff command (used in getdiff) uses parameters only supported by GNU diff - $ENV{'PATH'} = '/bin:/usr/local/bin:/usr/bin:/usr/sbin'; - if ( `diff --version` =~ /GNU/ ) { - $gnu_diff = 1; - } else { - $gnu_diff = 0; + unless (defined $gnu_diff) { + # the rcsdiff command (used in getdiff) uses parameters only supported by GNU diff + $ENV{'PATH'} = '/bin:/usr/local/bin:/usr/bin:/usr/sbin'; + if ( `diff --version` =~ /GNU/ ) { + $gnu_diff = 1; + } else { + $gnu_diff = 0; + } } return $self; |
From: Dave B. <bro...@us...> - 2004-07-20 18:58:33
|
Update of /cvsroot/lxr/lxr/lib/LXR/Lang In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3384/lib/LXR/Lang Modified Files: Generic.pm Log Message: exact matching against reserved words, not substring Index: Generic.pm =================================================================== RCS file: /cvsroot/lxr/lxr/lib/LXR/Lang/Generic.pm,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- Generic.pm 19 Jul 2004 19:50:21 -0000 1.15 +++ Generic.pm 20 Jul 2004 18:58:24 -0000 1.16 @@ -157,7 +157,7 @@ # Replace identifier by link unless it's a reserved word { $1. - ((!grep(/$2/, $self->langinfo('reserved')) && + ((!grep(/^$2$/, $self->langinfo('reserved')) && $index->issymbol($2, $$self{'release'})) ? join($2, @{$$self{'itag'}}) : $2); @@ -203,7 +203,7 @@ $string = $_; # print "considering $string\n"; - if ( !grep( /$string/, $self->langinfo('reserved') ) + if ( !grep( /^$string$/, $self->langinfo('reserved') ) && $index->issymbol($string) ) { |
From: Dave B. <bro...@us...> - 2004-07-20 18:17:49
|
Update of /cvsroot/lxr/lxr/lib/LXR/Files In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25773/lib/LXR/Files Modified Files: CVS.pm Log Message: that was weird. proper commit this time. Index: CVS.pm =================================================================== RCS file: /cvsroot/lxr/lxr/lib/LXR/Files/CVS.pm,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- CVS.pm 20 Jul 2004 18:02:00 -0000 1.27 +++ CVS.pm 20 Jul 2004 18:17:39 -0000 1.28 @@ -133,7 +133,9 @@ } } + if (@anno) { map { $anno[$_] = $lrev if $_ ne ''; } @head; + } # print(STDERR "** Anno: ".scalar(@anno).join("\n", '', @anno, '')); return @anno; |
From: Dave B. <bro...@us...> - 2004-07-20 18:02:15
|
Update of /cvsroot/lxr/lxr/lib/LXR/Files In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22105/lib/LXR/Files Modified Files: CVS.pm Log Message: improved handling when there are no annotations Index: CVS.pm =================================================================== RCS file: /cvsroot/lxr/lxr/lib/LXR/Files/CVS.pm,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- CVS.pm 20 Jul 2004 17:30:54 -0000 1.26 +++ CVS.pm 20 Jul 2004 18:02:00 -0000 1.27 @@ -114,7 +114,6 @@ $hrev = $cvs{'branch'}{$hrev}{'next'} || last; my @diff = $self->getdiff( $filename, $lrev, $hrev ); - return () unless scalar @diff; my $off = 0; while (@diff) { @@ -133,8 +132,8 @@ } } } - - map { $anno[$_] = $lrev if $_ ne ''; } @head; + + map { $anno[$_] = $lrev if $_ ne ''; } @head; # print(STDERR "** Anno: ".scalar(@anno).join("\n", '', @anno, '')); return @anno; |
From: Dave B. <bro...@us...> - 2004-07-20 17:31:09
|
Update of /cvsroot/lxr/lxr/lib/LXR/Files In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15115/lib/LXR/Files Modified Files: CVS.pm Log Message: non-GNU 'diff' doesn't work for getting annotations; handle this nicely by checking and then showing none Index: CVS.pm =================================================================== RCS file: /cvsroot/lxr/lxr/lib/LXR/Files/CVS.pm,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- CVS.pm 19 Jul 2004 19:50:20 -0000 1.25 +++ CVS.pm 20 Jul 2004 17:30:54 -0000 1.26 @@ -25,7 +25,7 @@ use Time::Local; use LXR::Common; -use vars qw(%cvs $cache_filename); +use vars qw(%cvs $cache_filename $gnu_diff); sub new { my ( $self, $rootpath ) = @_; @@ -34,6 +34,14 @@ $self->{'rootpath'} = $rootpath; $self->{'rootpath'} =~ s@/*$@/@; + # the rcsdiff command (used in getdiff) uses parameters only supported by GNU diff + $ENV{'PATH'} = '/bin:/usr/local/bin:/usr/bin:/usr/sbin'; + if ( `diff --version` =~ /GNU/ ) { + $gnu_diff = 1; + } else { + $gnu_diff = 0; + } + return $self; } @@ -89,7 +97,7 @@ $self->parsecvs($filename); my $rev = $self->filerev( $filename, $release ); - return undef unless defined($rev); + return () unless defined($rev); my $hrev = $cvs{'header'}{'head'}; my $lrev; @@ -106,6 +114,7 @@ $hrev = $cvs{'branch'}{$hrev}{'next'} || last; my @diff = $self->getdiff( $filename, $lrev, $hrev ); + return () unless scalar @diff; my $off = 0; while (@diff) { @@ -166,14 +175,16 @@ sub getdiff { my ( $self, $filename, $release1, $release2 ) = @_; my ($fileh); + + return () if $gnu_diff == 0; $self->parsecvs($filename); my $rev1 = $self->filerev( $filename, $release1 ); - return undef unless defined($rev1); + return () unless defined($rev1); my $rev2 = $self->filerev( $filename, $release2 ); - return undef unless defined($rev2); + return () unless defined($rev2); $rev1 =~ /([\d\.]*)/; $rev1 = $1; # untaint |
From: Dave B. <bro...@us...> - 2004-07-20 15:34:46
|
Update of /cvsroot/lxr/lxr In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22772 Modified Files: INSTALL Log Message: note about CVS not working w/ glimpse. consistent blank lines between sections Index: INSTALL =================================================================== RCS file: /cvsroot/lxr/lxr/INSTALL,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- INSTALL 20 Jul 2004 15:31:24 -0000 1.17 +++ INSTALL 20 Jul 2004 15:34:37 -0000 1.18 @@ -122,8 +122,10 @@ You may also want to configure the 'graphicfile', 'filetype' and 'incprefix' variables, but the defaults should be reasonable for most setups. -Getting lxr to work with CVS +Getting LXR to work with CVS ---------------------------- +Currently LXR cannot index CVS files with glimpse. You must use swish-e. + If you want lxr to work on files that are located in a CVS repository, edit lxr.conf and set the range variable so that it uses a subroutine instead of the default setting that reads the src/cvsversions file. @@ -149,7 +151,6 @@ Using Swish-e with LXR ---------------------- - Create a directory for the swish index files to go in, and put the path of this directory in the 'swishdir' variable. @@ -160,7 +161,6 @@ Generate index. --------------- - It is now time to generate the index. This is done using the program "genxref". genxref takes two arguments --url= and --version= where is the url where the lxr cgi scripts are found. @@ -211,7 +211,6 @@ Getting help if it doesn't work: -------------------------------- - If you can't get LXR to work then you can try asking on the mailing list or the support forums. Do check the archives of both first though - your question may already have been answered. @@ -219,11 +218,8 @@ By web: http://sourceforge.net/forum/forum.php?forum_id=86145 By email: Send a mail to lxr...@li... - - Troubleshooting: --------------- - ** Fatal: Can't find database This message comes from the DB backend. The likely cause is that the |
From: Dave B. <bro...@us...> - 2004-07-20 15:31:37
|
Update of /cvsroot/lxr/lxr In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22189 Modified Files: INSTALL initdb-mysql initdb-oracle.sql initdb-postgres Removed Files: initdb Log Message: prefix tables with lxr_ (configurable). existing users should set dbprefix to '' since their tables have no prefix fix ordering of delete statements fix some oracle syntax Index: INSTALL =================================================================== RCS file: /cvsroot/lxr/lxr/INSTALL,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- INSTALL 19 Jul 2004 20:03:31 -0000 1.16 +++ INSTALL 20 Jul 2004 15:31:24 -0000 1.17 @@ -31,7 +31,10 @@ You will need to create a database for lxr, and possibly create a user as well. If you are unsure how to do this, or don't have admin rights to the database, consult the documentation or your sysadmin -respectively. The steps below assume you know what you're doing. +respectively. If you want a custom prefix for the table names, you must +manually edit the initdb script by replaceing every 'lxr_' with your prefix. +Don't forget to set the 'dbprefix' in lxr.conf. +The steps below assume you know what you're doing. For Postgresql: Create a user for lxr and give the user permission to create databases: Index: initdb-mysql =================================================================== RCS file: /cvsroot/lxr/lxr/initdb-mysql,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- initdb-mysql 2 May 2003 22:58:34 -0000 1.9 +++ initdb-mysql 20 Jul 2004 15:31:24 -0000 1.10 @@ -6,7 +6,7 @@ use lxr; /* symnum filenum */ -create table files ( +create table lxr_files ( filename char(255) binary not null, revision char(255) binary not null, fileid int not null auto_increment, @@ -15,7 +15,7 @@ ); -create table symbols ( +create table lxr_symbols ( symname char(255) binary not null, symid int not null auto_increment, primary key (symid), @@ -23,34 +23,34 @@ ); -create table indexes ( - symid int not null references symbols, - fileid int not null references files, +create table lxr_indexes ( + symid int not null references lxr_symbols, + fileid int not null references lxr_files, line int not null, - langid tinyint not null references declarations, - type smallint not null references declarations, - relsym int references symbols + langid tinyint not null references lxr_declarations, + type smallint not null references lxr_declarations, + relsym int references lxr_symbols ); -create table releases - (fileid int not null references files, +create table lxr_releases + (fileid int not null references lxr_files, release char(255) binary not null, primary key (fileid,release) ); -create table useage - (fileid int not null references files, +create table lxr_useage + (fileid int not null references lxr_files, line int not null, - symid int not null references symbols + symid int not null references lxr_symbols ); -create table status - (fileid int not null references files, +create table lxr_status + (fileid int not null references lxr_files, status tinyint not null, primary key (fileid) ); -create table declarations +create table lxr_declarations (declid smallint not null auto_increment, langid tinyint not null, declaration char(255) not null, @@ -58,9 +58,9 @@ ); -create index indexindex on indexes (symid) ; -create unique index symbolindex on symbols (symname) ; -create index useageindex on useage (symid) ; -create index filelookup on files (filename); +create index lxr_indexindex on lxr_indexes (symid) ; +create unique index lxr_symbolindex on lxr_symbols (symname) ; +create index lxr_useageindex on lxr_useage (symid) ; +create index lxr_filelookup on lxr_files (filename); grant all on lxr.* to lxr@localhost; Index: initdb-oracle.sql =================================================================== RCS file: /cvsroot/lxr/lxr/initdb-oracle.sql,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- initdb-oracle.sql 15 Jul 2004 20:40:13 -0000 1.2 +++ initdb-oracle.sql 20 Jul 2004 15:31:24 -0000 1.3 @@ -1,78 +1,78 @@ -drop sequence filenum; -drop sequence symnum; -drop table indexes; -drop table usage; -drop table symbols; -drop table releases; -drop table status; -drop table files; +drop sequence lxr_filenum; +drop sequence lxr_symnum; +drop table lxr_indexes; +drop table lxr_usage; +drop table lxr_symbols; +drop table lxr_releases; +drop table lxr_status; +drop table lxr_files; commit; -create sequence filenum; -create sequence symnum; +create sequence lxr_filenum; +create sequence lxr_symnum; commit; -create table files ( +create table lxr_files ( filename varchar2(250), revision varchar2(250), fileid number, - constraint pk_files primary key (fileid) + constraint lxr_pk_files primary key (fileid) ); -alter table files add unique (filename, revision); -create index i_files on files(filename); +alter table lxr_files add unique (filename, revision); +create index lxr_i_files on lxr_files(filename); commit; -create table symbols ( +create table lxr_symbols ( symname varchar2(250), symid number, - constraint pk_symbols primary key (symid) + constraint lxr_pk_symbols primary key (symid) ); -alter table symbols add unique(symname); +alter table lxr_symbols add unique(symname); commit; -create table indexes ( +create table lxr_indexes ( symid number, fileid number, line number, type varchar2(250), relsym number, - constraint fk_indexes_fileid foreign key (fileid) references files(fileid), - constraint fk_indexes_symid foreign key (symid) references symbols(symid), - constraint fk_indexes_relsym foreign key (relsym) references symbols(symid) + constraint lxr_fk_indexes_fileid foreign key (fileid) references lxr_files(fileid), + constraint lxr_fk_indexes_symid foreign key (symid) references lxr_symbols(symid), + constraint lxr_fk_indexes_relsym foreign key (relsym) references lxr_symbols(symid) ); -create index i_indexes on indexes(symid); +create index lxr_i_indexes on lxr_indexes(symid); commit; -create table releases ( +create table lxr_releases ( fileid number, release varchar2(250), - constraint pk_releases primary key (fileid,release), - constraint fk_releases_fileid foreign key (fileid) references files(fileid) + constraint lxr_pk_releases primary key (fileid,release), + constraint lxr_fk_releases_fileid foreign key (fileid) references lxr_files(fileid) ); commit; -create table status ( +create table lxr_status ( fileid number, status number, - constraint pk_status primary key (fileid), - constraint fk_status_fileid foreign key (fileid) references files(fileid) + constraint lxr_pk_status primary key (fileid), + constraint lxr_fk_status_fileid foreign key (fileid) references lxr_files(fileid) ); commit; -create table usage ( +create table lxr_usage ( fileid number, line number, symid number, - constraint fk_usage_fileid foreign key (fileid) references files(fileid), - constraint fk_usage_symid foreign key (symid) references symbols(symid) + constraint lxr_fk_usage_fileid foreign key (fileid) references lxr_files(fileid), + constraint lxr_fk_usage_symid foreign key (symid) references lxr_symbols(symid) ); -create index i_usage on usage(symid); +create index lxr_i_usage on lxr_usage(symid); commit; \ No newline at end of file Index: initdb-postgres =================================================================== RCS file: /cvsroot/lxr/lxr/initdb-postgres,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- initdb-postgres 28 Nov 2001 12:59:02 -0000 1.5 +++ initdb-postgres 20 Jul 2004 15:31:24 -0000 1.6 @@ -1,19 +1,19 @@ -drop sequence filenum; -drop sequence symnum; -drop sequence declnum; -drop table files; -drop table symbols; -drop table indexes; -drop table releases; -drop table usage; -drop table status; -drop table declarations; +drop sequence lxr_filenum; +drop sequence lxr_symnum; +drop sequence lxr_declnum; +drop table lxr_files; +drop table lxr_symbols; +drop table lxr_indexes; +drop table lxr_releases; +drop table lxr_usage; +drop table lxr_status; +drop table lxr_declarations; -create sequence filenum cache 50; -create sequence symnum cache 50; -create sequence declnum cache 10; +create sequence lxr_filenum cache 50; +create sequence lxr_symnum cache 50; +create sequence lxr_declnum cache 10; -create table files ( +create table lxr_files ( filename varchar, revision varchar, fileid int, @@ -22,7 +22,7 @@ ); -create table symbols ( +create table lxr_symbols ( symname varchar, symid int, primary key (symid), @@ -30,50 +30,50 @@ ); -create table declarations ( +create table lxr_declarations ( declid smallint not null, langid smallint not null, declaration char(255) not null, primary key (declid, langid) ); -create table indexes ( - symid int references symbols, - fileid int references files, +create table lxr_indexes ( + symid int references lxr_symbols, + fileid int references lxr_files, line int, langid smallint not null, type smallint not null, - relsym int references symbols, - foreign key (langid, type) references declarations (langid, declid) + relsym int references lxr_symbols, + foreign key (langid, type) references lxr_declarations (langid, declid) ); -create table releases - (fileid int references files, +create table lxr_releases + (fileid int references lxr_files, release varchar, primary key (fileid,release) ); -create table usage - (fileid int references files, +create table lxr_usage + (fileid int references lxr_files, line int, - symid int references symbols + symid int references lxr_symbols ); -create table status - (fileid int references files, +create table lxr_status + (fileid int references lxr_files, status smallint, primary key (fileid) ); -create index indexindex on indexes using btree (symid); -create index symbolindex on symbols using btree (symname); -create index usageindex on usage using btree (symid); -create index filelookup on files using btree (filename); +create index lxr_indexindex on lxr_indexes using btree (symid); +create index lxr_symbolindex on lxr_symbols using btree (symname); +create index lxr_usageindex on lxr_usage using btree (symid); +create index lxr_filelookup on lxr_files using btree (filename); -grant select on files to public; -grant select on symbols to public; -grant select on indexes to public; -grant select on releases to public; -grant select on usage to public; -grant select on status to public; -grant select on declarations to public; \ No newline at end of file +grant select on lxr_files to public; +grant select on lxr_symbols to public; +grant select on lxr_indexes to public; +grant select on lxr_releases to public; +grant select on lxr_usage to public; +grant select on lxr_status to public; +grant select on lxr_declarations to public; \ No newline at end of file --- initdb DELETED --- |
From: Dave B. <bro...@us...> - 2004-07-20 15:31:35
|
Update of /cvsroot/lxr/lxr/lib/LXR/Index In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22189/lib/LXR/Index Modified Files: Mysql.pm Oracle.pm Postgres.pm Log Message: prefix tables with lxr_ (configurable). existing users should set dbprefix to '' since their tables have no prefix fix ordering of delete statements fix some oracle syntax Index: Mysql.pm =================================================================== RCS file: /cvsroot/lxr/lxr/lib/LXR/Index/Mysql.pm,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- Mysql.pm 19 Jul 2004 19:50:21 -0000 1.16 +++ Mysql.pm 20 Jul 2004 15:31:25 -0000 1.17 @@ -24,7 +24,7 @@ use DBI; use LXR::Common; -use vars qw(%files %symcache @ISA); +use vars qw(%files %symcache @ISA $prefix); @ISA = ("LXR::Index"); @@ -40,84 +40,97 @@ || fatal "Can't open connection to database\n"; } + if ( $config->{'dbprefix'} ) { + $prefix = $config->{'dbprefix'}; + } else { + $prefix = "lxr_"; + } + %files = (); %symcache = (); $self->{files_select} = - $self->{dbh}->prepare("select fileid from files where filename = ? and revision = ?"); + $self->{dbh} + ->prepare("select fileid from ${prefix}files where filename = ? and revision = ?"); $self->{files_insert} = - $self->{dbh}->prepare("insert into files (filename, revision, fileid) values (?, ?, NULL)"); + $self->{dbh} + ->prepare("insert into ${prefix}files (filename, revision, fileid) values (?, ?, NULL)"); - $self->{symbols_byname} = $self->{dbh}->prepare("select symid from symbols where symname = ?"); - $self->{symbols_byid} = $self->{dbh}->prepare("select symname from symbols where symid = ?"); + $self->{symbols_byname} = + $self->{dbh}->prepare("select symid from ${prefix}symbols where symname = ?"); + $self->{symbols_byid} = + $self->{dbh}->prepare("select symname from ${prefix}symbols where symid = ?"); $self->{symbols_insert} = - $self->{dbh}->prepare("insert into symbols (symname, symid) values ( ?, NULL)"); - $self->{symbols_remove} = $self->{dbh}->prepare("delete from symbols where symname = ?"); + $self->{dbh}->prepare("insert into ${prefix}symbols (symname, symid) values ( ?, NULL)"); + $self->{symbols_remove} = + $self->{dbh}->prepare("delete from ${prefix}symbols where symname = ?"); $self->{indexes_select} = $self->{dbh}->prepare( "select f.filename, i.line, d.declaration, i.relsym " - . "from symbols s, indexes i, files f, releases r, declarations d " + . "from ${prefix}symbols s, ${prefix}indexes i, ${prefix}files f, ${prefix}releases r, ${prefix}declarations d " . "where s.symid = i.symid and i.fileid = f.fileid " . "and f.fileid = r.fileid " . "and i.langid = d.langid and i.type = d.declid " . "and s.symname = ? and r.release = ?" ); $self->{indexes_insert} = $self->{dbh}->prepare( - "insert into indexes (symid, fileid, line, langid, type, relsym) values (?, ?, ?, ?, ?, ?)" +"insert into ${prefix}indexes (symid, fileid, line, langid, type, relsym) values (?, ?, ?, ?, ?, ?)" ); $self->{releases_select} = - $self->{dbh}->prepare("select * from releases where fileid = ? and release = ?"); + $self->{dbh}->prepare("select * from ${prefix}releases where fileid = ? and release = ?"); $self->{releases_insert} = - $self->{dbh}->prepare("insert into releases (fileid, release) values (?, ?)"); + $self->{dbh}->prepare("insert into ${prefix}releases (fileid, release) values (?, ?)"); - $self->{status_get} = $self->{dbh}->prepare("select status from status where fileid = ?"); + $self->{status_get} = + $self->{dbh}->prepare("select status from ${prefix}status where fileid = ?"); $self->{status_insert} = $self->{dbh}->prepare # ("insert into status select ?, 0 except select fileid, 0 from status"); - ("insert into status (fileid, status) values (?, ?)"); + ("insert into ${prefix}status (fileid, status) values (?, ?)"); $self->{status_update} = - $self->{dbh}->prepare("update status set status = ? where fileid = ? and status <= ?"); + $self->{dbh} + ->prepare("update ${prefix}status set status = ? where fileid = ? and status <= ?"); $self->{usage_insert} = - $self->{dbh}->prepare("insert into useage (fileid, line, symid) values (?, ?, ?)"); + $self->{dbh}->prepare("insert into ${prefix}useage (fileid, line, symid) values (?, ?, ?)"); $self->{usage_select} = $self->{dbh}->prepare( "select f.filename, u.line " - . "from symbols s, files f, releases r, useage u " + . "from ${prefix}symbols s, ${prefix}files f, ${prefix}releases r, ${prefix}useage u " . "where s.symid = u.symid " . "and f.fileid = u.fileid " . "and u.fileid = r.fileid " . "and s.symname = ? and r.release = ? " . "order by f.filename" ); $self->{decl_select} = - $self->{dbh} - ->prepare( "select declid from declarations where langid = ? and " . "declaration = ?" ); + $self->{dbh}->prepare( + "select declid from ${prefix}declarations where langid = ? and " . "declaration = ?" ); $self->{decl_insert} = - $self->{dbh} - ->prepare("insert into declarations (declid, langid, declaration) values (NULL, ?, ?)"); + $self->{dbh}->prepare( + "insert into ${prefix}declarations (declid, langid, declaration) values (NULL, ?, ?)"); $self->{delete_indexes} = - $self->{dbh}->prepare( "delete from indexes " - . "using indexes i, releases r " + $self->{dbh}->prepare( "delete from ${prefix}indexes " + . "using ${prefix}indexes i, ${prefix}releases r " . "where i.fileid = r.fileid " . "and r.release = ?" ); $self->{delete_useage} = - $self->{dbh}->prepare( "delete from useage " - . "using useage u, releases r " + $self->{dbh}->prepare( "delete from ${prefix}useage " + . "using ${prefix}useage u, ${prefix}releases r " . "where u.fileid = r.fileid " . "and r.release = ?" ); $self->{delete_status} = - $self->{dbh}->prepare( "delete from status " - . "using status s, releases r " + $self->{dbh}->prepare( "delete from ${prefix}status " + . "using ${prefix}status s, ${prefix}releases r " . "where s.fileid = r.fileid " . "and r.release = ?" ); $self->{delete_releases} = - $self->{dbh}->prepare( "delete from releases " . "where release = ?" ); + $self->{dbh}->prepare( "delete from ${prefix}releases " . "where release = ?" ); $self->{delete_files} = - $self->{dbh}->prepare( "delete from files " - . "using files f, releases r " + $self->{dbh}->prepare( "delete from ${prefix}files " + . "using ${prefix}files f, ${prefix}releases r " . "where f.fileid = r.fileid " . "and r.release = ?" ); @@ -321,8 +334,8 @@ $self->{delete_indexes}->execute($version); $self->{delete_useage}->execute($version); $self->{delete_status}->execute($version); - $self->{delete_releases}->execute($version); $self->{delete_files}->execute($version); + $self->{delete_releases}->execute($version); } sub DESTROY { Index: Oracle.pm =================================================================== RCS file: /cvsroot/lxr/lxr/lib/LXR/Index/Oracle.pm,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- Oracle.pm 19 Jul 2004 19:50:21 -0000 1.5 +++ Oracle.pm 20 Jul 2004 15:31:25 -0000 1.6 @@ -24,7 +24,7 @@ use DBI; use LXR::Common; -use vars qw(%files %symcache @ISA); +use vars qw(%files %symcache @ISA $prefix); @ISA = ("LXR::Index"); @@ -38,47 +38,60 @@ { RaiseError => 1, AutoCommit => 1 } ) || fatal "Can't open connection to database\n"; + if ( $config->{'dbprefix'} ) { + $prefix = $config->{'dbprefix'}; + } else { + $prefix = "lxr_"; + } + %files = (); %symcache = (); $self->{files_select} = - $self->{dbh}->prepare("select fileid from files where filename = ? and revision = ?"); + $self->{dbh} + ->prepare("select fileid from ${prefix}files where filename = ? and revision = ?"); $self->{files_insert} = - $self->{dbh}->prepare("insert into files values (?, ?, filenum.nextval)"); + $self->{dbh}->prepare("insert into ${prefix}files values (?, ?, filenum.nextval)"); - $self->{symbols_byname} = $self->{dbh}->prepare("select symid from symbols where symname = ?"); - $self->{symbols_byid} = $self->{dbh}->prepare("select symname from symbols where symid = ?"); + $self->{symbols_byname} = + $self->{dbh}->prepare("select symid from ${prefix}symbols where symname = ?"); + $self->{symbols_byid} = + $self->{dbh}->prepare("select symname from ${prefix}symbols where symid = ?"); $self->{symbols_insert} = - $self->{dbh}->prepare("insert into symbols values ( ?, symnum.nextval)"); - $self->{symbols_remove} = $self->{dbh}->prepare("delete from symbols where symname = ?"); + $self->{dbh}->prepare("insert into ${prefix}symbols values ( ?, symnum.nextval)"); + $self->{symbols_remove} = + $self->{dbh}->prepare("delete from ${prefix}symbols where symname = ?"); $self->{indexes_select} = $self->{dbh}->prepare( "select f.filename, i.line, i.type, i.relsym " - . "from symbols s, indexes i, files f, releases r " + . "from ${prefix}symbols s, ${prefix}indexes i, ${prefix}files f, ${prefix}releases r " . "where s.symid = i.symid and i.fileid = f.fileid " . "and f.fileid = r.fileid " . "and s.symname = ? and r.release = ? " ); - $self->{indexes_insert} = $self->{dbh}->prepare("insert into indexes values (?, ?, ?, ?, ?)"); + $self->{indexes_insert} = + $self->{dbh}->prepare("insert into ${prefix}indexes values (?, ?, ?, ?, ?)"); $self->{releases_select} = - $self->{dbh}->prepare("select * from releases where fileid = ? and release = ?"); + $self->{dbh}->prepare("select * from ${prefix}releases where fileid = ? and release = ?"); - $self->{releases_insert} = $self->{dbh}->prepare("insert into releases values (?, ?)"); + $self->{releases_insert} = $self->{dbh}->prepare("insert into ${prefix}releases values (?, ?)"); - $self->{status_get} = $self->{dbh}->prepare("select status from status where fileid = ?"); + $self->{status_get} = + $self->{dbh}->prepare("select status from ${prefix}status where fileid = ?"); $self->{status_insert} = $self->{dbh}->prepare # ("insert into status select ?, 0 except select fileid, 0 from status"); - ("insert into status values (?, ?)"); + ("insert into ${prefix}status values (?, ?)"); $self->{status_update} = - $self->{dbh}->prepare("update status set status = ? where fileid = ? and status <= ?"); + $self->{dbh} + ->prepare("update ${prefix}status set status = ? where fileid = ? and status <= ?"); - $self->{usage_insert} = $self->{dbh}->prepare("insert into usage values (?, ?, ?)"); + $self->{usage_insert} = $self->{dbh}->prepare("insert into ${prefix}usage values (?, ?, ?)"); $self->{usage_select} = $self->{dbh}->prepare( "select f.filename, u.line " - . "from symbols s, files f, releases r, usage u " + . "from ${prefix}symbols s, ${prefix}files f, ${prefix}releases r, ${prefix}usage u " . "where s.symid = u.symid " . "and f.fileid = u.fileid " . "and u.fileid = r.fileid and " @@ -86,23 +99,23 @@ . "order by f.filename" ); $self->{delete_indexes} = - $self->{dbh}->prepare( "delete from indexes " + $self->{dbh}->prepare( "delete from ${prefix}indexes " . "where fileid in " - . " (select fileid from releases where release = ?)" ); + . " (select fileid from ${prefix}releases where release = ?)" ); $self->{delete_usage} = - $self->{dbh}->prepare( "delete from usage " + $self->{dbh}->prepare( "delete from ${prefix}usage " . "where fileid in " - . " (select fileid from releases where release = ?)" ); + . " (select fileid from ${prefix}releases where release = ?)" ); $self->{delete_status} = - $self->{dbh}->prepare( "delete from status " + $self->{dbh}->prepare( "delete from ${prefix}status " . "where fileid in " - . " (select fileid from releases where release = ?)" ); + . " (select fileid from ${prefix}releases where release = ?)" ); $self->{delete_releases} = - $self->{dbh}->prepare( "delete from releases " . "where release = ?" ); + $self->{dbh}->prepare( "delete from ${prefix}releases " . "where release = ?" ); $self->{delete_files} = - $self->{dbh}->prepare( "delete from files " + $self->{dbh}->prepare( "delete from ${prefix}files " . "where fileid in " - . " (select fileid from releases where release = ?)" ); + . " (select fileid from ${prefix}releases where release = ?)" ); return $self; } @@ -283,10 +296,10 @@ # we don't delete symbols, because they might be used by other versions # so we can end up with unused symbols, but that doesn't cause any problems $self->{delete_indexes}->execute($version); - $self->{$delete_usage}->execute($version); - $self->{$delete_status}->execute($version); - $self->{$delete_releases}->execute($version); - $self->{$delete_files}->execute($version); + $self->{delete_usage}->execute($version); + $self->{delete_status}->execute($version); + $self->{delete_files}->execute($version); + $self->{delete_releases}->execute($version); } sub DESTROY { Index: Postgres.pm =================================================================== RCS file: /cvsroot/lxr/lxr/lib/LXR/Index/Postgres.pm,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- Postgres.pm 19 Jul 2004 19:50:21 -0000 1.15 +++ Postgres.pm 20 Jul 2004 15:31:25 -0000 1.16 @@ -31,7 +31,7 @@ $releases_select $releases_insert $status_insert $status_update $usage_insert $usage_select $decl_select $declid_nextnum $decl_insert $delete_indexes $delete_usage - $delete_status $delete_releases $delete_files); + $delete_status $delete_releases $delete_files $prefix); sub new { my ( $self, $dbname ) = @_; @@ -44,47 +44,56 @@ # $dbh->trace(1); + if ( $config->{'dbprefix'} ) { + $prefix = $config->{'dbprefix'}; + } else { + $prefix = "lxr_"; + } + $commitlimit = 100; $transactions = 0; %files = (); %symcache = (); - $files_select = $dbh->prepare("select fileid from files where filename = ? and revision = ?"); + $files_select = + $dbh->prepare("select fileid from ${prefix}files where filename = ? and revision = ?"); $filenum_nextval = $dbh->prepare("select nextval('filenum')"); - $files_insert = $dbh->prepare("insert into files values (?, ?, ?)"); + $files_insert = $dbh->prepare("insert into ${prefix}files values (?, ?, ?)"); - $symbols_byname = $dbh->prepare("select symid from symbols where symname = ?"); - $symbols_byid = $dbh->prepare("select symname from symbols where symid = ?"); + $symbols_byname = $dbh->prepare("select symid from ${prefix}symbols where symname = ?"); + $symbols_byid = $dbh->prepare("select symname from ${prefix}symbols where symid = ?"); $symnum_nextval = $dbh->prepare("select nextval('symnum')"); - $symbols_insert = $dbh->prepare("insert into symbols values (?, ?)"); - $symbols_remove = $dbh->prepare("delete from symbols where symname = ?"); + $symbols_insert = $dbh->prepare("insert into ${prefix}symbols values (?, ?)"); + $symbols_remove = $dbh->prepare("delete from ${prefix}symbols where symname = ?"); $indexes_select = $dbh->prepare( "select f.filename, i.line, d.declaration, i.relsym " - . "from symbols s, indexes i, files f, releases r, declarations d " + . "from ${prefix}symbols s, ${prefix}indexes i, ${prefix}files f, ${prefix}releases r, ${prefix}declarations d " . "where s.symid = i.symid and i.fileid = f.fileid " . "and f.fileid = r.fileid " . "and i.langid = d.langid and i.type = d.declid " . "and s.symname = ? and r.release = ?" ); $indexes_insert = - $dbh->prepare( "insert into indexes (symid, fileid, line, langid, type, relsym) " + $dbh->prepare( "insert into ${prefix}indexes (symid, fileid, line, langid, type, relsym) " . "values (?, ?, ?, ?, ?, ?)" ); - $releases_select = $dbh->prepare("select * from releases where fileid = ? and release = ?"); - $releases_insert = $dbh->prepare("insert into releases values (?, ?)"); + $releases_select = + $dbh->prepare("select * from ${prefix}releases where fileid = ? and release = ?"); + $releases_insert = $dbh->prepare("insert into ${prefix}releases values (?, ?)"); $status_insert = $dbh->prepare # ("insert into status select ?, 0 except select fileid, 0 from status"); - ( "insert into status select ?, 0 where not exists " - . "(select * from status where fileid = ?)" ); + ( "insert into ${prefix}status select ?, 0 where not exists " + . "(select * from ${prefix}status where fileid = ?)" ); - $status_update = $dbh->prepare("update status set status = ? where fileid = ? and status <= ?"); + $status_update = + $dbh->prepare("update ${prefix}status set status = ? where fileid = ? and status <= ?"); - $usage_insert = $dbh->prepare("insert into usage values (?, ?, ?)"); + $usage_insert = $dbh->prepare("insert into ${prefix}usage values (?, ?, ?)"); $usage_select = $dbh->prepare( "select f.filename, u.line " - . "from symbols s, files f, releases r, usage u " + . "from ${prefix}symbols s, ${prefix}files f, ${prefix}releases r, ${prefix}usage u " . "where s.symid = u.symid " . "and f.fileid = u.fileid " . "and f.fileid = r.fileid and " @@ -93,27 +102,29 @@ $declid_nextnum = $dbh->prepare("select nextval('declnum')"); $decl_select = - $dbh->prepare( "select declid from declarations where langid = ? and " . "declaration = ?" ); + $dbh->prepare( + "select declid from ${prefix}declarations where langid = ? and " . "declaration = ?" ); $decl_insert = - $dbh->prepare("insert into declarations (declid, langid, declaration) values (?, ?, ?)"); + $dbh->prepare( + "insert into ${prefix}declarations (declid, langid, declaration) values (?, ?, ?)"); $delete_indexes = - $dbh->prepare( "delete from indexes " + $dbh->prepare( "delete from ${prefix}indexes " . "where fileid in " - . " (select fileid from releases where release = ?)" ); + . " (select fileid from ${prefix}releases where release = ?)" ); $delete_usage = - $dbh->prepare( "delete from usage " + $dbh->prepare( "delete from ${prefix}usage " . "where fileid in " - . " (select fileid from releases where release = ?)" ); + . " (select fileid from ${prefix}releases where release = ?)" ); $delete_status = - $dbh->prepare( "delete from status " + $dbh->prepare( "delete from ${prefix}status " . "where fileid in " - . " (select fileid from releases where release = ?)" ); - $delete_releases = $dbh->prepare( "delete from releases " . "where release = ?" ); + . " (select fileid from ${prefix}releases where release = ?)" ); + $delete_releases = $dbh->prepare( "delete from ${prefix}releases " . "where release = ?" ); $delete_files = - $dbh->prepare( "delete from files " + $dbh->prepare( "delete from ${prefix}files " . "where fileid in " - . " (select fileid from releases where release = ?)" ); + . " (select fileid from ${prefix}releases where release = ?)" ); return $self; } @@ -304,8 +315,8 @@ $delete_indexes->execute($version); $delete_usage->execute($version); $delete_status->execute($version); - $delete_releases->execute($version); $delete_files->execute($version); + $delete_releases->execute($version); commit_if_limit(); } |
From: Dave B. <bro...@us...> - 2004-07-20 15:31:34
|
Update of /cvsroot/lxr/lxr/templates In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22189/templates Modified Files: lxr.conf Log Message: prefix tables with lxr_ (configurable). existing users should set dbprefix to '' since their tables have no prefix fix ordering of delete statements fix some oracle syntax Index: lxr.conf =================================================================== RCS file: /cvsroot/lxr/lxr/templates/lxr.conf,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- lxr.conf 19 Jul 2004 20:19:13 -0000 1.21 +++ lxr.conf 20 Jul 2004 15:31:25 -0000 1.22 @@ -110,6 +110,10 @@ # uncomment the following two lines # 'dbpass' => 'foo', # 'dbuser' => 'lxr', + + # If you need multiple lxr configurations in one database, set different table + # prefixes for them. + # 'dbprefix' => 'lxr_', # For using glimpse, the directory to store the .glimpse files in is required 'glimpsedir' => '/path/to/glimpse/databases', |
From: Dave B. <bro...@us...> - 2004-07-20 15:28:55
|
Update of /cvsroot/lxr/lxr/lib/LXR/Lang In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21757/lib/LXR/Lang Modified Files: ectags.conf generic.conf Log Message: index synonyms Index: ectags.conf =================================================================== RCS file: /cvsroot/lxr/lxr/lib/LXR/Lang/ectags.conf,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- ectags.conf 15 Jul 2004 20:25:26 -0000 1.4 +++ ectags.conf 20 Jul 2004 15:28:46 -0000 1.5 @@ -21,6 +21,7 @@ --regex-SQL2=/^[ \t]*CURSOR[ \t]+([a-zA-Z_][a-zA-Z0-9_]*)/\1/C,cursor/i --regex-SQL2=/^[ \t]*CREATE[ \t]+([a-zA-Z0-9 \t]*)?INDEX[ \t]+([a-zA-Z_][a-zA-Z0-9_]*)/\2/i,index/i --regex-SQL2=/^[ \t]*CREATE[ \t]+SEQUENCE[ \t]+([a-zA-Z_][a-zA-Z0-9_]*)/\1/s,sequence/i +--regex-SQL2=/^[ \t]*CREATE[ \t]+SYNONYM[ \t]+([a-zA-Z_][a-zA-Z0-9_]*)/\1/S,synonym/i --regex-SQL2=/^[ \t]*CREATE[ \t+](OR[ \t]+REPLACE[ \t]+)?TRIGGER[ \t]+([a-zA-Z_][a-zA-Z0-9_]*)/\2/T,trigger/i --regex-SQL2=/^[ \t]*CREATE[ \t+](OR[ \t]+REPLACE[ \t]+)?PACKAGE[ \t]+(BODY[ \t]+)?([a-zA-Z_][a-zA-Z0-9_]*)/\3/p,package/i Index: generic.conf =================================================================== RCS file: /cvsroot/lxr/lxr/lib/LXR/Lang/generic.conf,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- generic.conf 19 Jul 2004 18:05:11 -0000 1.14 +++ generic.conf 20 Jul 2004 15:28:46 -0000 1.15 @@ -248,6 +248,7 @@ # some oracle reserved words 'SYSDATE', 'SEQUENCE', +'SYNONYM', # sql 89, 92, and 99 reserved words 'ABSOLUTE', 'ACTION', @@ -606,6 +607,7 @@ 'p' => 'package', 'i' => 'index', 's' => 'sequence', + 'S' => 'synonym', 'v' => 'view', }, 'langid' => '11', |
From: Dave B. <bro...@us...> - 2004-07-19 20:19:21
|
Update of /cvsroot/lxr/lxr/templates In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12869/templates Modified Files: lxr.conf Log Message: remove glimpsedir from global section Index: lxr.conf =================================================================== RCS file: /cvsroot/lxr/lxr/templates/lxr.conf,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- lxr.conf 19 Jul 2004 20:03:31 -0000 1.20 +++ lxr.conf 19 Jul 2004 20:19:13 -0000 1.21 @@ -6,13 +6,10 @@ # Global configuration # Path to glimpse executables. - # Define this OR the swish-e variables depending which search engine you want to use. + # Define this OR the swish-e variable depending which search engine you want to use. 'glimpsebin' => '/info/lxr/bin/glimpse', 'glimpseindex' => '/info/lxr/bin/glimpseindex', - # Where to store the glimpse index files - 'glimpsedir' => 'somewhere', - # Location of SWISH-E binary 'swishbin' => '/usr/local/bin/swish-e', |
From: Dave B. <bro...@us...> - 2004-07-19 20:03:40
|
Update of /cvsroot/lxr/lxr In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9944 Modified Files: INSTALL find genxref search Log Message: consolidate swishindex & swishsearch variables into swishbin Index: INSTALL =================================================================== RCS file: /cvsroot/lxr/lxr/INSTALL,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- INSTALL 19 Jul 2004 18:16:35 -0000 1.15 +++ INSTALL 19 Jul 2004 20:03:31 -0000 1.16 @@ -86,8 +86,7 @@ If you have swish-e installed, you should set - 'swishindex' => '/path/to/your/swishe-e/executable' - 'swishsearch' => '/path/to/your/swishe-e/executable' + 'swishbin' => '/path/to/your/swishe-e/executable' Comment out the variables for the indexer you are not using. Set 'htmlsearch' to either 'html-search-swish.html' or @@ -193,7 +192,7 @@ Alias /lxr /usr/local/lxr <Directory /usr/local/lxr> - AllowOverride All + AllowOverride All </Directory> The distribution contains a .htaccess file set up to ensure that lxr Index: find =================================================================== RCS file: /cvsroot/lxr/lxr/find,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- find 19 Jul 2004 19:50:20 -0000 1.21 +++ find 19 Jul 2004 20:03:31 -0000 1.22 @@ -112,7 +112,7 @@ my $casesensitive = $HTTP->{'param'}->{'casesensitive'}; my $FILELISTING; - if ( $config->swishdir and $config->swishindex ) { + if ( $config->swishdir and $config->swishbin ) { unless ( $FILELISTING = new IO::File( $config->swishdir . "/$release.filenames" ) ) { &warning( "Version '$release' has not been indexed and is unavailable for searching<br>Could not open " Index: genxref =================================================================== RCS file: /cvsroot/lxr/lxr/genxref,v retrieving revision 1.34 retrieving revision 1.35 diff -u -d -r1.34 -r1.35 --- genxref 19 Jul 2004 19:50:20 -0000 1.34 +++ genxref 19 Jul 2004 20:03:31 -0000 1.35 @@ -177,7 +177,7 @@ system("chmod 644 $string"); } - if ( $config->swishdir and $config->swishindex ) { + if ( $config->swishdir and $config->swishbin ) { my $swish = new IO::Handle; die $config->swishdir . " does not exist" unless -d $config->swishdir; my $filelist = new IO::File $config->swishdir . "/$release.filenames", "w" @@ -187,12 +187,12 @@ open( $swish, "| " - . $config->swishindex + . $config->swishbin . " -S prog -i stdin -v 1 -c swish-e.conf -f " . $config->swishdir . "/" . $release . ".index" ) - or die "Couldn't exec " . $config->swishindex . ": $!\n"; + or die "Couldn't exec " . $config->swishbin . ": $!\n"; feedswish( "/", $release, $swish, $filelist ); Index: search =================================================================== RCS file: /cvsroot/lxr/lxr/search,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- search 19 Jul 2004 19:50:20 -0000 1.22 +++ search 19 Jul 2004 20:03:31 -0000 1.23 @@ -125,10 +125,10 @@ $ENV{'PATH'} = '/bin:/usr/local/bin:/usr/bin:/usr/sbin'; unless ( open( SWISH, "-|" ) ) { open( STDERR, ">&STDOUT" ); - exec( $config->swishsearch, "-f", $config->swishdir . "/" . $release . ".index", + exec( $config->swishbin, "-f", $config->swishdir . "/" . $release . ".index", "-m", $maxhits, "-w", "'" . $searchtext . "'" ); - print( STDERR "Couldn't exec " . $config->swishsearch . ": $!\n" ); + print( STDERR "Couldn't exec " . $config->swishbin . ": $!\n" ); kill( 9, $$ ); } @@ -210,7 +210,7 @@ if ( $searchtext ne "" ) { if ( $config->glimpsebin ) { @results = glimpsesearch($searchtext); - } elsif ( $config->swishsearch and $config->swishdir ) { + } elsif ( $config->swishbin and $config->swishdir ) { @results = swishsearch($searchtext); } else { warning("No freetext search engine configured."); |
From: Dave B. <bro...@us...> - 2004-07-19 20:03:40
|
Update of /cvsroot/lxr/lxr/templates In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9944/templates Modified Files: lxr.conf Log Message: consolidate swishindex & swishsearch variables into swishbin Index: lxr.conf =================================================================== RCS file: /cvsroot/lxr/lxr/templates/lxr.conf,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- lxr.conf 19 Jul 2004 17:56:44 -0000 1.19 +++ lxr.conf 19 Jul 2004 20:03:31 -0000 1.20 @@ -13,14 +13,8 @@ # Where to store the glimpse index files 'glimpsedir' => 'somewhere', - # Location of SWISH-E indexer binary - 'swishindex' => '/usr/local/bin/swish-e', - - # Location of SWISH-E search binary - 'swishsearch' => '/usr/local/bin/swish-e', - - # Where to store the swish index files - 'swishdir' => 'somewhere', + # Location of SWISH-E binary + 'swishbin' => '/usr/local/bin/swish-e', # Path to Exuberant Ctags executable 'ectagsbin' => '/usr/bin/ctags', |
From: Dave B. <bro...@us...> - 2004-07-19 19:50:37
|
Update of /cvsroot/lxr/lxr/lib/LXR In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7323/lib/LXR Modified Files: Common.pm Config.pm Files.pm Index.pm Lang.pm SimpleParse.pm Tagger.pm Log Message: formatting (with eclipse EPIC plugin which uses PerlTidy. options used: line width 100, cuddle else, use tabs, tab-width 4) Index: Common.pm =================================================================== RCS file: /cvsroot/lxr/lxr/lib/LXR/Common.pm,v retrieving revision 1.47 retrieving revision 1.48 diff -u -d -r1.47 -r1.48 --- Common.pm 15 Jul 2004 14:41:04 -0000 1.47 +++ Common.pm 19 Jul 2004 19:50:20 -0000 1.48 @@ -13,7 +13,7 @@ # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -26,22 +26,21 @@ require Exporter; [...1174 lines suppressed...] - 'variables' => sub { varexpand(@_, $who) }, - 'devinfo' => sub { devinfo(@_) })), - "</html>\n"); + print( + expandtemplate( + $template, + ( + 'banner' => sub { bannerexpand( @_, $who ) }, + 'thisurl' => sub { thisurl(@_) }, + 'modes' => sub { modeexpand( @_, $who ) }, + 'variables' => sub { varexpand( @_, $who ) }, + 'devinfo' => sub { devinfo(@_) } + ) + ), + "</html>\n" + ); } - 1; Index: Config.pm =================================================================== RCS file: /cvsroot/lxr/lxr/lib/LXR/Config.pm,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- Config.pm 15 Jul 2004 20:20:12 -0000 1.30 +++ Config.pm 19 Jul 2004 19:50:20 -0000 1.31 @@ -11,7 +11,7 @@ # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -31,198 +31,183 @@ $confname = 'lxr.conf'; sub new { - my ($class, @parms) = @_; - my $self = {}; - bless($self); - $self->_initialize(@parms); - return($self); + my ( $class, @parms ) = @_; + my $self = {}; + bless($self); + $self->_initialize(@parms); + return ($self); die("Foo!\n"); } sub readfile { - local($/) = undef; # Just in case; probably redundant. - my $file = shift; - my @data; + local ($/) = undef; # Just in case; probably redundant. + my $file = shift; + my @data; - open(INPUT, $file) || fatal("Config: cannot open $file\n"); - $file = <INPUT>; - close(INPUT); + open( INPUT, $file ) || fatal("Config: cannot open $file\n"); + $file = <INPUT>; + close(INPUT); - @data = $file =~ /([^\s]+)/gs; + @data = $file =~ /([^\s]+)/gs; - return wantarray ? @data : $data[0]; + return wantarray ? @data : $data[0]; } - sub _initialize { - my ($self, $url, $confpath) = @_; - my ($dir, $arg); + my ( $self, $url, $confpath ) = @_; + my ( $dir, $arg ); - unless ($url) { - $url = 'http://'.$ENV{'SERVER_NAME'}.':'.$ENV{'SERVER_PORT'}; + unless ($url) { + $url = 'http://' . $ENV{'SERVER_NAME'} . ':' . $ENV{'SERVER_PORT'}; $url =~ s/:80$//; - } - - $url =~ s|^http://([^/]*):443/|https://$1/|; - $url .= '/' unless $url =~ m#/$#; # append / if necessary + } - unless ($confpath) { - ($confpath) = ($0 =~ /(.*?)[^\/]*$/); + $url =~ s|^http://([^/]*):443/|https://$1/|; + $url .= '/' unless $url =~ m#/$#; # append / if necessary + + unless ($confpath) { + ($confpath) = ( $0 =~ /(.*?)[^\/]*$/ ); $confpath .= $confname; - } - - unless (open(CONFIG, $confpath)) { + } + + unless ( open( CONFIG, $confpath ) ) { die("Couldn't open configuration file \"$confpath\"."); - } + } $$self{'confpath'} = $confpath; - - local($/) = undef; - my $config_contents = <CONFIG>; - $config_contents =~ /(.*)/s ; $config_contents = $1; #untaint it - my @config = eval("\n#line 1 \"configuration file\"\n". - $config_contents); - die($@) if $@; - my $config; - if (scalar(@config) > 0) { - %$self = (%$self, %{$config[0]}); + local ($/) = undef; + my $config_contents = <CONFIG>; + $config_contents =~ /(.*)/s; + $config_contents = $1; #untaint it + my @config = eval( "\n#line 1 \"configuration file\"\n" . $config_contents ); + die($@) if $@; + + my $config; + if ( scalar(@config) > 0 ) { + %$self = ( %$self, %{ $config[0] } ); } - CANDIDATE: foreach $config (@config) { - if ($config->{baseurl}) { + CANDIDATE: foreach $config (@config) { + if ( $config->{baseurl} ) { my @aliases; - if ($config->{baseurl_aliases}) { - @aliases = @{$config->{baseurl_aliases}}; + if ( $config->{baseurl_aliases} ) { + @aliases = @{ $config->{baseurl_aliases} }; } my $root = $config->{baseurl}; push @aliases, $root; foreach my $rt (@aliases) { - $rt .= '/' unless $rt =~ m#/$#; # append / if necessary + $rt .= '/' unless $rt =~ m#/$#; # append / if necessary my $r = quotemeta($rt); - if ($url =~ /^$r/) { + if ( $url =~ /^$r/ ) { $config->{baseurl} = $rt; - %$self = (%$self, %$config); + %$self = ( %$self, %$config ); last CANDIDATE; } } } - } + } die "Can't find config for $url\n" if !defined $$self{baseurl}; } - sub allvariables { - my $self = shift; + my $self = shift; - return keys(%{$self->{variables} || {}}); + return keys( %{ $self->{variables} || {} } ); } - sub variable { - my ($self, $var, $val) = @_; + my ( $self, $var, $val ) = @_; - $self->{variables}{$var}{value} = $val if defined($val); - return $self->{variables}{$var}{value} || - $self->vardefault($var); + $self->{variables}{$var}{value} = $val if defined($val); + return $self->{variables}{$var}{value} + || $self->vardefault($var); } - sub vardefault { - my ($self, $var) = @_; + my ( $self, $var ) = @_; - return $self->{variables}{$var}{default} || - $self->{variables}{$var}{range}[0]; + return $self->{variables}{$var}{default} + || $self->{variables}{$var}{range}[0]; } - sub vardescription { - my ($self, $var, $val) = @_; + my ( $self, $var, $val ) = @_; - $self->{variables}{$var}{name} = $val if defined($val); + $self->{variables}{$var}{name} = $val if defined($val); - return $self->{variables}{$var}{name}; + return $self->{variables}{$var}{name}; } - sub varrange { - my ($self, $var) = @_; + my ( $self, $var ) = @_; - if (ref($self->{variables}{$var}{range}) eq "CODE") { - return &{$self->{variables}{$var}{range}}; + if ( ref( $self->{variables}{$var}{range} ) eq "CODE" ) { + return &{ $self->{variables}{$var}{range} }; } - return @{$self->{variables}{$var}{range} || []}; + return @{ $self->{variables}{$var}{range} || [] }; } - sub varexpand { - my ($self, $exp) = @_; - $exp =~ s/\$\{?(\w+)\}?/$self->variable($1)/ge; + my ( $self, $exp ) = @_; + $exp =~ s/\$\{?(\w+)\}?/$self->variable($1)/ge; - return $exp; + return $exp; } - sub value { - my ($self, $var) = @_; + my ( $self, $var ) = @_; - if (exists($self->{$var})) { + if ( exists( $self->{$var} ) ) { my $val = $self->{$var}; - - if (ref($val) eq 'ARRAY') { + + if ( ref($val) eq 'ARRAY' ) { return map { $self->varexpand($_) } @$val; - } - elsif (ref($val) eq 'CODE') { + } elsif ( ref($val) eq 'CODE' ) { return $val; - } - else { + } else { return $self->varexpand($val); } - } - else { + } else { return undef; - } + } } - sub AUTOLOAD { - my $self = shift; - (my $var = $AUTOLOAD) =~ s/.*:://; + my $self = shift; + ( my $var = $AUTOLOAD ) =~ s/.*:://; my @val = $self->value($var); - - if (ref($val[0]) eq 'CODE') { + + if ( ref( $val[0] ) eq 'CODE' ) { return $val[0]->(@_); - } - else { + } else { return wantarray ? @val : $val[0]; - } + } } - sub mappath { - my ($self, $path, @args) = @_; - my %oldvars; - my ($m, $n); - - foreach $m (@args) { - if ($m =~ /(.*?)=(.*)/) { + my ( $self, $path, @args ) = @_; + my %oldvars; + my ( $m, $n ); + + foreach $m (@args) { + if ( $m =~ /(.*?)=(.*)/ ) { $oldvars{$1} = $self->variable($1); - $self->variable($1, $2); + $self->variable( $1, $2 ); } - } + } - while (($m, $n) = each %{$self->{maps} || {}}) { + while ( ( $m, $n ) = each %{ $self->{maps} || {} } ) { $path =~ s/$m/$self->varexpand($n)/e; - } + } - while (($m, $n) = each %oldvars) { - $self->variable($m, $n); - } + while ( ( $m, $n ) = each %oldvars ) { + $self->variable( $m, $n ); + } - return $path; + return $path; } - 1; Index: Files.pm =================================================================== RCS file: /cvsroot/lxr/lxr/lib/LXR/Files.pm,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- Files.pm 15 Aug 2001 15:50:27 -0000 1.6 +++ Files.pm 19 Jul 2004 19:50:20 -0000 1.7 @@ -11,7 +11,7 @@ # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -23,20 +23,18 @@ use strict; sub new { - my ($self, $srcroot) = @_; + my ( $self, $srcroot ) = @_; my $files; - if ($srcroot =~ /^CVS:(.*)/i) { + if ( $srcroot =~ /^CVS:(.*)/i ) { require LXR::Files::CVS; $srcroot = $1; - $files = new LXR::Files::CVS($srcroot); - } - else { + $files = new LXR::Files::CVS($srcroot); + } else { require LXR::Files::Plain; $files = new LXR::Files::Plain($srcroot); } return $files; } - 1; Index: Index.pm =================================================================== RCS file: /cvsroot/lxr/lxr/lib/LXR/Index.pm,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- Index.pm 15 Aug 2001 15:50:27 -0000 1.9 +++ Index.pm 19 Jul 2004 19:50:20 -0000 1.10 @@ -11,7 +11,7 @@ # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -24,19 +24,17 @@ use strict; sub new { - my ($self, $dbname, @args) = @_; + my ( $self, $dbname, @args ) = @_; my $index; - if ($dbname =~ /^DBI:/i) { + if ( $dbname =~ /^DBI:/i ) { require LXR::Index::DBI; - $index = new LXR::Index::DBI($dbname, @args); - } - elsif ($dbname =~ /^DBM:/i) { - require LXR::Index::DB; - $index = new LXR::Index::DB($dbname, @args); - } - else { - die "Can't find database, $dbname"; + $index = new LXR::Index::DBI( $dbname, @args ); + } elsif ( $dbname =~ /^DBM:/i ) { + require LXR::Index::DB; + $index = new LXR::Index::DB( $dbname, @args ); + } else { + die "Can't find database, $dbname"; } return $index; } Index: Lang.pm =================================================================== RCS file: /cvsroot/lxr/lxr/lib/LXR/Lang.pm,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- Lang.pm 1 Jul 2004 20:41:25 -0000 1.30 +++ Lang.pm 19 Jul 2004 19:50:20 -0000 1.31 @@ -11,7 +11,7 @@ # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -24,36 +24,38 @@ use LXR::Common; sub new { - my ($self, $pathname, $release, @itag) = @_; - my ($lang, $type); + my ( $self, $pathname, $release, @itag ) = @_; + my ( $lang, $type ); - foreach $type (values %{$config->filetype}) { - if ($pathname =~ /$$type[1]/) { + foreach $type ( values %{ $config->filetype } ) { + if ( $pathname =~ /$$type[1]/ ) { eval "require $$type[2]"; die "Unable to load $$type[2] Lang class, $@" if $@; - my $create = "new $$type[2]".'($pathname, $release, $$type[0])'; + my $create = "new $$type[2]" . '($pathname, $release, $$type[0])'; $lang = eval($create); die "Unable to create $$type[2] Lang object, $@" unless defined $lang; last; - } - } - - if (!defined $lang) { - # Try to see if it's a script - my $fh = $files->getfilehandle($pathname, $release); + } + } + + if ( !defined $lang ) { + + # Try to see if it's a script + my $fh = $files->getfilehandle( $pathname, $release ); return undef if !defined $fh; $fh->getline =~ /^\#!\s*(\S+)/s; - my $shebang = $1; - my %filetype = %{$config->filetype}; - my %inter = %{$config->interpreters}; - - foreach my $patt (keys %inter) { - if ($shebang =~ /\/$patt/) { + my $shebang = $1; + my %filetype = %{ $config->filetype }; + my %inter = %{ $config->interpreters }; + + foreach my $patt ( keys %inter ) { + if ( $shebang =~ /\/$patt/ ) { eval "require $filetype{$inter{$patt}}[2]"; die "Unable to load $filetype{$inter{$patt}}[2] Lang class, $@" if $@; - my $create = "new ". - $filetype{$inter{$patt}}[2].'($pathname, $release, $filetype{$inter{$patt}}[0])'; + my $create = "new " + . $filetype{ $inter{$patt} }[2] + . '($pathname, $release, $filetype{$inter{$patt}}[0])'; $lang = eval($create); last if defined $lang; die "Unable to create $filetype{$inter{$patt}}[2] Lang object, $@"; @@ -63,23 +65,23 @@ # No match for this file return undef if !defined $lang; - + $$lang{'itag'} = \@itag if $lang; return $lang; } sub processinclude { - my ($self, $frag, $dir) = @_; + my ( $self, $frag, $dir ) = @_; $$frag =~ s#(\")(.*?)(\")# $1.&LXR::Common::incref($2, "include", $2, $dir).$3 #e; - $$frag =~ s#(\0<)(.*?)(\0>)# + $$frag =~ s#(\0<)(.*?)(\0>)# $1.&LXR::Common::incref($2, "include", $2).$3 #e; - } +} sub processcomment { - my ($self, $frag) = @_; + my ( $self, $frag ) = @_; $$frag = "<span class=\"comment\">$$frag</span>"; $$frag =~ s#\n#</span>\n<span class=\"comment\">#g; @@ -87,9 +89,8 @@ sub referencefile { my ($self) = @_; - - print(STDERR ref($self), "->referencefile not implemented.\n"); -} + print( STDERR ref($self), "->referencefile not implemented.\n" ); +} 1; Index: SimpleParse.pm =================================================================== RCS file: /cvsroot/lxr/lxr/lib/LXR/SimpleParse.pm,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- SimpleParse.pm 22 Mar 2003 01:00:58 -0000 1.15 +++ SimpleParse.pm 19 Jul 2004 19:50:20 -0000 1.16 @@ -11,7 +11,7 @@ # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -27,144 +27,145 @@ use vars qw(@ISA @EXPORT); -@ISA = qw(Exporter); +@ISA = qw(Exporter); @EXPORT = qw(&doparse &untabify &init &nextfrag); -my $fileh; # File handle -my @frags; # Fragments in queue -my @bodyid; # Array of body type ids -my @open; # Fragment opening delimiters -my @term; # Fragment closing delimiters -my $split; # Fragmentation regexp -my $open; # Fragment opening regexp -my $tabwidth; # Tab width +my $fileh; # File handle +my @frags; # Fragments in queue +my @bodyid; # Array of body type ids +my @open; # Fragment opening delimiters +my @term; # Fragment closing delimiters +my $split; # Fragmentation regexp +my $open; # Fragment opening regexp +my $tabwidth; # Tab width sub init { - my @blksep; - - $fileh = ""; - @frags = (); - @bodyid = (); - @open = (); - @term = (); - $split = ""; - $open = ""; + my @blksep; + + $fileh = ""; + @frags = (); + @bodyid = (); + @open = (); + @term = (); + $split = ""; + $open = ""; $tabwidth = 8; my $tabhint; - ($fileh, $tabhint, @blksep) = @_; + ( $fileh, $tabhint, @blksep ) = @_; $tabwidth = $tabhint || $tabwidth; - - while (@_ = splice(@blksep,0,3)) { - push(@bodyid, $_[0]); - push(@open, $_[1]); - push(@term, $_[2]); - } - foreach (@open) { - $open .= "($_)|"; + while ( @_ = splice( @blksep, 0, 3 ) ) { + push( @bodyid, $_[0] ); + push( @open, $_[1] ); + push( @term, $_[2] ); + } + + foreach (@open) { + $open .= "($_)|"; $split .= "$_|"; - } - chop($open); - - foreach (@term) { + } + chop($open); + + foreach (@term) { next if $_ eq ''; $split .= "$_|"; - } - chop($split); + } + chop($split); } - sub untabify { - my $t = $_[1] || 8; + my $t = $_[1] || 8; - $_[0] =~ s/^(\t+)/(' ' x ($t * length($1)))/ge; # Optimize for common case. - $_[0] =~ s/([^\t]*)\t/$1.(' ' x ($t - (length($1) % $t)))/ge; - return($_[0]); + $_[0] =~ s/^(\t+)/(' ' x ($t * length($1)))/ge; # Optimize for common case. + $_[0] =~ s/([^\t]*)\t/$1.(' ' x ($t - (length($1) % $t)))/ge; + return ( $_[0] ); } - sub nextfrag { - my $btype = undef; - my $frag = undef; - my $line = ''; + my $btype = undef; + my $frag = undef; + my $line = ''; -# print "nextfrag called\n"; + # print "nextfrag called\n"; - while (1) { + while (1) { - # read one more line if we have processed + # read one more line if we have processed # all of the previously read line - if ($#frags < 0) { + if ( $#frags < 0 ) { $line = $fileh->getline; - - if ($. <= 2 && - $line =~ /^.*-[*]-.*?[ \t;]tab-width:[ \t]*([0-9]+).*-[*]-/) { + + if ( $. <= 2 + && $line =~ /^.*-[*]-.*?[ \t;]tab-width:[ \t]*([0-9]+).*-[*]-/ ) + { + # make sure there really is a non-zero tabwidth if ($1) { $tabwidth = $1; } } - -# &untabify($line, $tabwidth); # We inline this for performance. - + + # &untabify($line, $tabwidth); # We inline this for performance. + # Optimize for common case. - if(defined($line)) { + if ( defined($line) ) { $line =~ s/^(\t+)/' ' x ($tabwidth * length($1))/ge; $line =~ s/([^\t]*)\t/$1.(' ' x ($tabwidth - (length($1) % $tabwidth)))/ge; - + # split the line into fragments - @frags = split(/($split)/, $line); + @frags = split( /($split)/, $line ); } } last if $#frags < 0; - + # skip empty fragments - if ($frags[0] eq '') { + if ( $frags[0] eq '' ) { shift(@frags); } # check if we are inside a fragment - if (defined($frag)) { - if (defined($btype)) { + if ( defined($frag) ) { + if ( defined($btype) ) { my $next = shift(@frags); - + # Add to the fragment $frag .= $next; + # We are done if this was the terminator last if $next =~ /^$term[$btype]$/; - } - else { - if ($frags[0] =~ /^$open$/) { -# print "encountered open token while btype was $btype\n"; + } else { + if ( $frags[0] =~ /^$open$/ ) { + + # print "encountered open token while btype was $btype\n"; last; } $frag .= shift(@frags); } - } - else { -# print "start of new fragment\n"; + } else { + + # print "start of new fragment\n"; # Find the blocktype of the current block $frag = shift(@frags); - if (defined($frag) && (@_ = $frag =~ /^$open$/)) { -# print "hit\n"; + if ( defined($frag) && ( @_ = $frag =~ /^$open$/ ) ) { + + # print "hit\n"; # grep in a scalar context returns the number of times # EXPR evaluates to true, which is this case will be # the index of the first defined element in @_. my $i = 1; $btype = grep { $i &&= !defined($_) } @_; - if(!defined($term[$btype])) { + if ( !defined( $term[$btype] ) ) { print "fragment without terminator\n"; last; } } } - } - $btype = $bodyid[$btype] if defined($btype); - - return($btype, $frag); -} + } + $btype = $bodyid[$btype] if defined($btype); + return ( $btype, $frag ); +} 1; Index: Tagger.pm =================================================================== RCS file: /cvsroot/lxr/lxr/lib/LXR/Tagger.pm,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- Tagger.pm 21 Apr 2004 22:52:08 -0000 1.20 +++ Tagger.pm 19 Jul 2004 19:50:20 -0000 1.21 @@ -11,7 +11,7 @@ # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -25,73 +25,76 @@ use LXR::Lang; sub processfile { - my ($pathname, $release, $config, $files, $index) = @_; + my ( $pathname, $release, $config, $files, $index ) = @_; - my $lang = new LXR::Lang($pathname, $release); + my $lang = new LXR::Lang( $pathname, $release ); return unless $lang; - my $revision = $files->filerev($pathname, $release); + my $revision = $files->filerev( $pathname, $release ); return unless $revision; - print(STDERR "--- $pathname $release $revision\n"); - + print( STDERR "--- $pathname $release $revision\n" ); + if ($index) { - my $fileid = $index->fileid($pathname, $revision); - - $index->release($fileid, $release); - - if ($index->toindex($fileid)) { - $index->empty_cache(); - print(STDERR "--- $pathname $fileid\n"); - - my $path = $files->tmpfile($pathname, $release); - - $lang->indexfile($pathname, $path, $fileid, $index, $config); - $index->setindexed($fileid); - unlink($path); - } else { - print(STDERR "$pathname was already indexed\n"); - } - } else { print(STDERR " **** FAILED ****\n"); } - $lang = undef; + my $fileid = $index->fileid( $pathname, $revision ); + + $index->release( $fileid, $release ); + + if ( $index->toindex($fileid) ) { + $index->empty_cache(); + print( STDERR "--- $pathname $fileid\n" ); + + my $path = $files->tmpfile( $pathname, $release ); + + $lang->indexfile( $pathname, $path, $fileid, $index, $config ); + $index->setindexed($fileid); + unlink($path); + } else { + print( STDERR "$pathname was already indexed\n" ); + } + } else { + print( STDERR " **** FAILED ****\n" ); + } + $lang = undef; $revision = undef; } - sub processrefs { - my ($pathname, $release, $config, $files, $index) = @_; + my ( $pathname, $release, $config, $files, $index ) = @_; - my $lang = new LXR::Lang($pathname, $release); + my $lang = new LXR::Lang( $pathname, $release ); return unless $lang; - - my $revision = $files->filerev($pathname, $release); + + my $revision = $files->filerev( $pathname, $release ); return unless $revision; - print(STDERR "--- $pathname $release $revision\n"); - + print( STDERR "--- $pathname $release $revision\n" ); + if ($index) { - my $fileid = $index->fileid($pathname, $revision); - - if ($index->toreference($fileid)) { - $index->empty_cache(); - print(STDERR "--- $pathname $fileid\n"); - - my $path = $files->tmpfile($pathname, $release); - - $lang->referencefile($pathname, $path, $fileid, $index, $config); - $index->setreferenced($fileid); - unlink($path); - } else { - print STDERR "$pathname was already referenced\n"; - } - } else { print( STDERR " **** FAILED ****\n"); } + my $fileid = $index->fileid( $pathname, $revision ); - $lang = undef; + if ( $index->toreference($fileid) ) { + $index->empty_cache(); + print( STDERR "--- $pathname $fileid\n" ); + + my $path = $files->tmpfile( $pathname, $release ); + + $lang->referencefile( $pathname, $path, $fileid, $index, $config ); + $index->setreferenced($fileid); + unlink($path); + } else { + print STDERR "$pathname was already referenced\n"; + } + } else { + print( STDERR " **** FAILED ****\n" ); + } + + $lang = undef; $revision = undef; - } +} 1; |
From: Dave B. <bro...@us...> - 2004-07-19 19:50:36
|
Update of /cvsroot/lxr/lxr/lib/LXR/Index In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7323/lib/LXR/Index Modified Files: DB.pm DBI.pm Mysql.pm Oracle.pm Postgres.pm Log Message: formatting (with eclipse EPIC plugin which uses PerlTidy. options used: line width 100, cuddle else, use tabs, tab-width 4) Index: DB.pm =================================================================== RCS file: /cvsroot/lxr/lxr/lib/LXR/Index/DB.pm,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- DB.pm 15 Aug 2001 15:50:27 -0000 1.11 +++ DB.pm 19 Jul 2004 19:50:21 -0000 1.12 @@ -11,7 +11,7 @@ # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -24,48 +24,46 @@ use DB_File; use NDBM_File; - sub new { - my ($self, $dbpath, $mode) = @_; + my ( $self, $dbpath, $mode ) = @_; my ($foo); - $self = bless({}, $self); + $self = bless( {}, $self ); $$self{'dbpath'} = $dbpath; $$self{'dbpath'} =~ s@/*$@/@; - foreach ('releases', 'files', 'symbols', 'indexes', 'status') { + foreach ( 'releases', 'files', 'symbols', 'indexes', 'status' ) { $foo = {}; - tie (%$foo, 'NDBM_File' , $$self{'dbpath'}.$_, - $mode||O_RDONLY, 0664) || - die "Can't open database ".$$self{'dbpath'}.$_. "\n"; + tie( %$foo, 'NDBM_File', $$self{'dbpath'} . $_, $mode || O_RDONLY, 0664 ) + || die "Can't open database " . $$self{'dbpath'} . $_ . "\n"; $$self{$_} = $foo; } - + return $self; } sub index { - my ($self, $symname, $fileid, $line, $type, $rel) = @_; + my ( $self, $symname, $fileid, $line, $type, $rel ) = @_; my $symid = $self->symid($symname); - $self->{'indexes'}{$symid} .= join("\t", $fileid, $line, $type, $rel)."\0"; -# $$self{'index'}{$self->symid($symname, $release)} = -# join("\t", $filename, $line, $type, ''); + $self->{'indexes'}{$symid} .= join( "\t", $fileid, $line, $type, $rel ) . "\0"; + + # $$self{'index'}{$self->symid($symname, $release)} = + # join("\t", $filename, $line, $type, ''); } # Returns array of (fileid, line, type) sub getindex { - my ($self, $symname, $release) = @_; + my ( $self, $symname, $release ) = @_; - my (@d, $f); - foreach $f (split(/\0/, - $$self{'indexes'}{$self->symid($symname, $release)})) { - my ($fi, $l, $t, $s) = split(/\t/, $f); + my ( @d, $f ); + foreach $f ( split( /\0/, $$self{'indexes'}{ $self->symid( $symname, $release ) } ) ) { + my ( $fi, $l, $t, $s ) = split( /\t/, $f ); - my %r = map { ($_ => 1) } split(/;/, $self->{'releases'}{$fi}); + my %r = map { ( $_ => 1 ) } split( /;/, $self->{'releases'}{$fi} ); next unless $r{$release}; - push(@d, [ $self->filename($fi), $l, $t, $s ]); + push( @d, [ $self->filename($fi), $l, $t, $s ] ); } return @d; } @@ -75,26 +73,28 @@ } sub relate { - my ($self, $symname, $release, $rsymname, $reltype) = @_; - my $symid = $self->symid($symname, $release); + my ( $self, $symname, $release, $rsymname, $reltype ) = @_; + my $symid = $self->symid( $symname, $release ); - $$self{''}{$symid} = join("", $$self{'relation'}{$self->symid($symname, $release)}, join("\t", $self->symid($rsymname, $release), $reltype, '')); + $$self{''}{$symid} = join( "", + $$self{'relation'}{ $self->symid( $symname, $release ) }, + join( "\t", $self->symid( $rsymname, $release ), $reltype, '' ) ); } sub getrelations { - my ($self, $symname, $release) = @_; + my ( $self, $symname, $release ) = @_; } sub fileid { - my ($self , $filename, $release) = @_; - - return $filename.';'.$release; + my ( $self, $filename, $release ) = @_; + + return $filename . ';' . $release; } # Convert from fileid to filename sub filename { - my ($self, $fileid) = @_; - my ($filename) = split(/;/, $fileid); + my ( $self, $fileid ) = @_; + my ($filename) = split( /;/, $fileid ); return $filename; } @@ -102,7 +102,7 @@ # If this file has not been indexed earlier, mark it as being indexed # now and return true. Return false if already indexed. sub toindex { - my ($self, $fileid) = @_; + my ( $self, $fileid ) = @_; return undef if $self->{'status'}{$fileid} >= 1; @@ -112,26 +112,25 @@ # Indicate that this filerevision is part of this release sub release { - my ($self, $fileid, $release) = @_; + my ( $self, $fileid, $release ) = @_; - $self->{'releases'}{$fileid} .= $release.";"; + $self->{'releases'}{$fileid} .= $release . ";"; } sub symid { - my ($self, $symname, $release) = @_; + my ( $self, $symname, $release ) = @_; my ($symid); return $symname; } sub issymbol { - my ($self, $symname, $release) = @_; + my ( $self, $symname, $release ) = @_; - return $$self{'indexes'}{$self->symid($symname, $release)}; + return $$self{'indexes'}{ $self->symid( $symname, $release ) }; } sub empty_cache { } - 1; Index: DBI.pm =================================================================== RCS file: /cvsroot/lxr/lxr/lib/LXR/Index/DBI.pm,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- DBI.pm 26 Feb 2002 16:18:46 -0000 1.19 +++ DBI.pm 19 Jul 2004 19:50:21 -0000 1.20 @@ -11,7 +11,7 @@ # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -23,21 +23,20 @@ use strict; sub new { - my ($self, $dbname) = @_; + my ( $self, $dbname ) = @_; my ($index); - if($dbname =~ /^dbi:mysql:/i) { - require LXR::Index::Mysql; - $index = new LXR::Index::Mysql($dbname); - } elsif($dbname =~ /^dbi:Pg:/i) { - require LXR::Index::Postgres; - $index = new LXR::Index::Postgres($dbname); - } elsif($dbname =~ /^dbi:oracle:/i) { - require LXR::Index::Oracle; - $index = new LXR::Index::Oracle($dbname); + if ( $dbname =~ /^dbi:mysql:/i ) { + require LXR::Index::Mysql; + $index = new LXR::Index::Mysql($dbname); + } elsif ( $dbname =~ /^dbi:Pg:/i ) { + require LXR::Index::Postgres; + $index = new LXR::Index::Postgres($dbname); + } elsif ( $dbname =~ /^dbi:oracle:/i ) { + require LXR::Index::Oracle; + $index = new LXR::Index::Oracle($dbname); } return $index; } - 1; Index: Mysql.pm =================================================================== RCS file: /cvsroot/lxr/lxr/lib/LXR/Index/Mysql.pm,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- Mysql.pm 15 Jul 2004 20:42:41 -0000 1.15 +++ Mysql.pm 19 Jul 2004 19:50:21 -0000 1.16 @@ -11,7 +11,7 @@ # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -29,148 +29,140 @@ @ISA = ("LXR::Index"); sub new { - my ($self, $dbname) = @_; + my ( $self, $dbname ) = @_; - $self = bless({}, $self); - if(defined($config->{dbpass})) { - $self->{dbh} = DBI->connect($dbname, $config->{dbuser}, - $config->{dbpass}) - || fatal "Can't open connection to database\n"; + $self = bless( {}, $self ); + if ( defined( $config->{dbpass} ) ) { + $self->{dbh} = DBI->connect( $dbname, $config->{dbuser}, $config->{dbpass} ) + || fatal "Can't open connection to database\n"; } else { - $self->{dbh} = DBI->connect($dbname, "lxr", $config->{dbpass}) - || fatal "Can't open connection to database\n"; + $self->{dbh} = DBI->connect( $dbname, "lxr", $config->{dbpass} ) + || fatal "Can't open connection to database\n"; } - %files = (); + %files = (); %symcache = (); - $self->{files_select} = $self->{dbh}->prepare - ("select fileid from files where filename = ? and revision = ?"); - $self->{files_insert} = $self->{dbh}->prepare - ("insert into files (filename, revision, fileid) values (?, ?, NULL)"); + $self->{files_select} = + $self->{dbh}->prepare("select fileid from files where filename = ? and revision = ?"); + $self->{files_insert} = + $self->{dbh}->prepare("insert into files (filename, revision, fileid) values (?, ?, NULL)"); - $self->{symbols_byname} = $self->{dbh}->prepare - ("select symid from symbols where symname = ?"); - $self->{symbols_byid} = $self->{dbh}->prepare - ("select symname from symbols where symid = ?"); - $self->{symbols_insert} = $self->{dbh}->prepare - ("insert into symbols (symname, symid) values ( ?, NULL)"); - $self->{symbols_remove} = $self->{dbh}->prepare - ("delete from symbols where symname = ?"); + $self->{symbols_byname} = $self->{dbh}->prepare("select symid from symbols where symname = ?"); + $self->{symbols_byid} = $self->{dbh}->prepare("select symname from symbols where symid = ?"); + $self->{symbols_insert} = + $self->{dbh}->prepare("insert into symbols (symname, symid) values ( ?, NULL)"); + $self->{symbols_remove} = $self->{dbh}->prepare("delete from symbols where symname = ?"); - $self->{indexes_select} = $self->{dbh}->prepare - ("select f.filename, i.line, d.declaration, i.relsym ". - "from symbols s, indexes i, files f, releases r, declarations d ". - "where s.symid = i.symid and i.fileid = f.fileid ". - "and f.fileid = r.fileid ". - "and i.langid = d.langid and i.type = d.declid ". - "and s.symname = ? and r.release = ?"); - $self->{indexes_insert} = $self->{dbh}->prepare - ("insert into indexes (symid, fileid, line, langid, type, relsym) values (?, ?, ?, ?, ?, ?)"); + $self->{indexes_select} = + $self->{dbh}->prepare( "select f.filename, i.line, d.declaration, i.relsym " + . "from symbols s, indexes i, files f, releases r, declarations d " + . "where s.symid = i.symid and i.fileid = f.fileid " + . "and f.fileid = r.fileid " + . "and i.langid = d.langid and i.type = d.declid " + . "and s.symname = ? and r.release = ?" ); + $self->{indexes_insert} = + $self->{dbh}->prepare( + "insert into indexes (symid, fileid, line, langid, type, relsym) values (?, ?, ?, ?, ?, ?)" + ); - $self->{releases_select} = $self->{dbh}->prepare - ("select * from releases where fileid = ? and release = ?"); - $self->{releases_insert} = $self->{dbh}->prepare - ("insert into releases (fileid, release) values (?, ?)"); + $self->{releases_select} = + $self->{dbh}->prepare("select * from releases where fileid = ? and release = ?"); + $self->{releases_insert} = + $self->{dbh}->prepare("insert into releases (fileid, release) values (?, ?)"); - $self->{status_get} = $self->{dbh}->prepare - ("select status from status where fileid = ?"); + $self->{status_get} = $self->{dbh}->prepare("select status from status where fileid = ?"); $self->{status_insert} = $self->{dbh}->prepare -# ("insert into status select ?, 0 except select fileid, 0 from status"); - ("insert into status (fileid, status) values (?, ?)"); - $self->{status_update} = $self->{dbh}->prepare - ("update status set status = ? where fileid = ? and status <= ?"); + # ("insert into status select ?, 0 except select fileid, 0 from status"); + ("insert into status (fileid, status) values (?, ?)"); - $self->{usage_insert} = $self->{dbh}->prepare - ("insert into useage (fileid, line, symid) values (?, ?, ?)"); - $self->{usage_select} = $self->{dbh}->prepare - ("select f.filename, u.line ". - "from symbols s, files f, releases r, useage u ". - "where s.symid = u.symid ". - "and f.fileid = u.fileid ". - "and u.fileid = r.fileid ". - "and s.symname = ? and r.release = ? ". - "order by f.filename"); - $self->{decl_select} = $self->{dbh}->prepare - ("select declid from declarations where langid = ? and ". - "declaration = ?"); - $self->{decl_insert} = $self->{dbh}->prepare - ("insert into declarations (declid, langid, declaration) values (NULL, ?, ?)"); + $self->{status_update} = + $self->{dbh}->prepare("update status set status = ? where fileid = ? and status <= ?"); - $self->{delete_indexes} = $self->{dbh}->prepare - ("delete from indexes ". - "using indexes i, releases r ". - "where i.fileid = r.fileid ". - "and r.release = ?"); - $self->{delete_useage} = $self->{dbh}->prepare - ("delete from useage ". - "using useage u, releases r ". - "where u.fileid = r.fileid ". - "and r.release = ?"); - $self->{delete_status} = $self->{dbh}->prepare - ("delete from status ". - "using status s, releases r ". - "where s.fileid = r.fileid ". - "and r.release = ?"); - $self->{delete_releases} = $self->{dbh}->prepare - ("delete from releases ". - "where release = ?"); - $self->{delete_files} = $self->{dbh}->prepare - ("delete from files ". - "using files f, releases r ". - "where f.fileid = r.fileid ". - "and r.release = ?"); + $self->{usage_insert} = + $self->{dbh}->prepare("insert into useage (fileid, line, symid) values (?, ?, ?)"); + $self->{usage_select} = + $self->{dbh}->prepare( "select f.filename, u.line " + . "from symbols s, files f, releases r, useage u " + . "where s.symid = u.symid " + . "and f.fileid = u.fileid " + . "and u.fileid = r.fileid " + . "and s.symname = ? and r.release = ? " + . "order by f.filename" ); + $self->{decl_select} = + $self->{dbh} + ->prepare( "select declid from declarations where langid = ? and " . "declaration = ?" ); + $self->{decl_insert} = + $self->{dbh} + ->prepare("insert into declarations (declid, langid, declaration) values (NULL, ?, ?)"); + + $self->{delete_indexes} = + $self->{dbh}->prepare( "delete from indexes " + . "using indexes i, releases r " + . "where i.fileid = r.fileid " + . "and r.release = ?" ); + $self->{delete_useage} = + $self->{dbh}->prepare( "delete from useage " + . "using useage u, releases r " + . "where u.fileid = r.fileid " + . "and r.release = ?" ); + $self->{delete_status} = + $self->{dbh}->prepare( "delete from status " + . "using status s, releases r " + . "where s.fileid = r.fileid " + . "and r.release = ?" ); + $self->{delete_releases} = + $self->{dbh}->prepare( "delete from releases " . "where release = ?" ); + $self->{delete_files} = + $self->{dbh}->prepare( "delete from files " + . "using files f, releases r " + . "where f.fileid = r.fileid " + . "and r.release = ?" ); return $self; } sub index { - my ($self, $symname, $fileid, $line, $langid, $type, $relsym) = @_; + my ( $self, $symname, $fileid, $line, $langid, $type, $relsym ) = @_; - $self->{indexes_insert}->execute($self->symid($symname), - $fileid, - $line, - $langid, - $type, - $relsym ? $self->symid($relsym) : undef); + $self->{indexes_insert}->execute( $self->symid($symname), + $fileid, $line, $langid, $type, $relsym ? $self->symid($relsym) : undef ); } sub reference { - my ($self, $symname, $fileid, $line) = @_; + my ( $self, $symname, $fileid, $line ) = @_; - $self->{usage_insert}->execute($fileid, - $line, - $self->symid($symname)); + $self->{usage_insert}->execute( $fileid, $line, $self->symid($symname) ); } sub getindex { - my ($self, $symname, $release) = @_; - my ($rows, @ret); + my ( $self, $symname, $release ) = @_; + my ( $rows, @ret ); - $rows = $self->{indexes_select}->execute("$symname", "$release"); + $rows = $self->{indexes_select}->execute( "$symname", "$release" ); - while ($rows-- > 0) { - push(@ret, [ $self->{indexes_select}->fetchrow_array ]); + while ( $rows-- > 0 ) { + push( @ret, [ $self->{indexes_select}->fetchrow_array ] ); } $self->{indexes_select}->finish(); - map { $$_[3] &&= $self->symname($$_[3]) } @ret; + map { $$_[3] &&= $self->symname( $$_[3] ) } @ret; return @ret; } sub getreference { - my ($self, $symname, $release) = @_; - my ($rows, @ret); + my ( $self, $symname, $release ) = @_; + my ( $rows, @ret ); - $rows = $self->{usage_select}->execute("$symname", "$release"); + $rows = $self->{usage_select}->execute( "$symname", "$release" ); - while ($rows-- > 0) { - push(@ret, [ $self->{usage_select}->fetchrow_array ]); + while ( $rows-- > 0 ) { + push( @ret, [ $self->{usage_select}->fetchrow_array ] ); } $self->{usage_select}->finish(); @@ -179,16 +171,16 @@ } sub fileid { - my ($self, $filename, $revision) = @_; + my ( $self, $filename, $revision ) = @_; my ($fileid); # CAUTION: $revision is not $release! - unless (defined($fileid = $files{"$filename\t$revision"})) { - $self->{files_select}->execute($filename, $revision); + unless ( defined( $fileid = $files{"$filename\t$revision"} ) ) { + $self->{files_select}->execute( $filename, $revision ); ($fileid) = $self->{files_select}->fetchrow_array(); unless ($fileid) { - $self->{files_insert}->execute($filename, $revision); - $self->{files_select}->execute($filename, $revision); + $self->{files_insert}->execute( $filename, $revision ); + $self->{files_select}->execute( $filename, $revision ); ($fileid) = $self->{files_select}->fetchrow_array(); } $files{"$filename\t$revision"} = $fileid; @@ -199,28 +191,29 @@ # Indicate that this filerevision is part of this release sub release { - my ($self, $fileid, $release) = @_; + my ( $self, $fileid, $release ) = @_; - my $rows = $self->{releases_select}->execute($fileid+0, $release); + my $rows = $self->{releases_select}->execute( $fileid + 0, $release ); $self->{releases_select}->finish(); - unless ($rows > 0) { - $self->{releases_insert}->execute($fileid, $release); + unless ( $rows > 0 ) { + $self->{releases_insert}->execute( $fileid, $release ); $self->{releases_insert}->finish(); } } sub symid { - my ($self, $symname) = @_; + my ( $self, $symname ) = @_; my ($symid); $symid = $symcache{$symname}; - unless (defined($symid)) { + unless ( defined($symid) ) { $self->{symbols_byname}->execute($symname); ($symid) = $self->{symbols_byname}->fetchrow_array(); $self->{symbols_byname}->finish(); unless ($symid) { $self->{symbols_insert}->execute($symname); + # Get the id of the new symbol $self->{symbols_byname}->execute($symname); ($symid) = $self->{symbols_byname}->fetchrow_array(); @@ -233,10 +226,10 @@ } sub symname { - my ($self, $symid) = @_; + my ( $self, $symid ) = @_; my ($symname); - $self->{symbols_byid}->execute($symid+0); + $self->{symbols_byid}->execute( $symid + 0 ); ($symname) = $self->{symbols_byid}->fetchrow_array(); $self->{symbols_byid}->finish(); @@ -244,11 +237,11 @@ } sub issymbol { - my ($self, $symname) = @_; + my ( $self, $symname ) = @_; my ($symid); $symid = $symcache{$symname}; - unless (defined($symid)) { + unless ( defined($symid) ) { $self->{symbols_byname}->execute($symname); ($symid) = $self->{symbols_byname}->fetchrow_array(); $self->{symbols_byname}->finish(); @@ -261,27 +254,27 @@ # If this file has not been indexed earlier return true. Return false # if already indexed. sub toindex { - my ($self, $fileid) = @_; + my ( $self, $fileid ) = @_; my ($status); $self->{status_get}->execute($fileid); $status = $self->{status_get}->fetchrow_array(); $self->{status_get}->finish(); - if(!defined($status)) { - $self->{status_insert}->execute($fileid+0, 0); + if ( !defined($status) ) { + $self->{status_insert}->execute( $fileid + 0, 0 ); } - + return $status == 0; } sub setindexed { - my ($self, $fileid) = @_; - $self->{status_update}->execute(1, $fileid, 0); - } + my ( $self, $fileid ) = @_; + $self->{status_update}->execute( 1, $fileid, 0 ); +} sub toreference { - my ($self, $fileid) = @_; + my ( $self, $fileid ) = @_; my ($status); $self->{status_get}->execute($fileid); @@ -292,73 +285,71 @@ } sub setreferenced { - my ($self, $fileid) = @_; - $self->{status_update}->execute(2, $fileid, 1); - } - + my ( $self, $fileid ) = @_; + $self->{status_update}->execute( 2, $fileid, 1 ); +} -# This function should be called before parsing each new file, +# This function should be called before parsing each new file, # if this is not done the too much memory will be used and -# tings will become very slow. +# tings will become very slow. sub empty_cache { %symcache = (); } sub getdecid { - my ($self, $lang, $string) = @_; + my ( $self, $lang, $string ) = @_; - my $rows = $self->{decl_select}->execute($lang, $string); - $self->{decl_select}->finish(); - - unless ($rows > 0) { - $self->{decl_insert}->execute($lang, $string); - } + my $rows = $self->{decl_select}->execute( $lang, $string ); + $self->{decl_select}->finish(); - $self->{decl_select}->execute($lang, $string); - my $id = $self->{decl_select}->fetchrow_array(); - $self->{decl_select}->finish(); + unless ( $rows > 0 ) { + $self->{decl_insert}->execute( $lang, $string ); + } - return $id; + $self->{decl_select}->execute( $lang, $string ); + my $id = $self->{decl_select}->fetchrow_array(); + $self->{decl_select}->finish(); + + return $id; } sub purge { - my ($self, $version) = @_; + my ( $self, $version ) = @_; + # we don't delete symbols, because they might be used by other versions - # so we can end up with unused symbols, but that doesn't cause any problems + # so we can end up with unused symbols, but that doesn't cause any problems $self->{delete_indexes}->execute($version); $self->{delete_useage}->execute($version); $self->{delete_status}->execute($version); $self->{delete_releases}->execute($version); $self->{delete_files}->execute($version); - } - +} sub DESTROY { my ($self) = @_; - $self->{files_select} = undef; - $self->{files_insert} = undef; - $self->{symbols_byname} = undef; - $self->{symbols_byid} = undef; - $self->{symbols_insert} = undef; - $self->{indexes_insert} = undef; + $self->{files_select} = undef; + $self->{files_insert} = undef; + $self->{symbols_byname} = undef; + $self->{symbols_byid} = undef; + $self->{symbols_insert} = undef; + $self->{indexes_insert} = undef; $self->{releases_insert} = undef; - $self->{status_insert} = undef; - $self->{status_update} = undef; - $self->{usage_insert} = undef; - $self->{usage_select} = undef; - $self->{decl_select} = undef; - $self->{decl_insert} = undef; - $self->{delete_indexes} = undef; - $self->{delete_useage} = undef; - $self->{delete_status} = undef; + $self->{status_insert} = undef; + $self->{status_update} = undef; + $self->{usage_insert} = undef; + $self->{usage_select} = undef; + $self->{decl_select} = undef; + $self->{decl_insert} = undef; + $self->{delete_indexes} = undef; + $self->{delete_useage} = undef; + $self->{delete_status} = undef; $self->{delete_releases} = undef; - $self->{delete_files} = undef; - - if($self->{dbh}) { + $self->{delete_files} = undef; + + if ( $self->{dbh} ) { $self->{dbh}->disconnect(); $self->{dbh} = undef; } } - 1; Index: Oracle.pm =================================================================== RCS file: /cvsroot/lxr/lxr/lib/LXR/Index/Oracle.pm,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- Oracle.pm 15 Jul 2004 20:42:41 -0000 1.4 +++ Oracle.pm 19 Jul 2004 19:50:21 -0000 1.5 @@ -11,7 +11,7 @@ # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -29,164 +29,153 @@ @ISA = ("LXR::Index"); sub new { - my ($self, $dbname) = @_; + my ( $self, $dbname ) = @_; - $self = bless({}, $self); - - $self->{dbh} = DBI->connect($dbname, $config->{dbuser}, $config->{dbpass}, { RaiseError => 1, AutoCommit => 1 }) - || fatal "Can't open connection to database\n"; + $self = bless( {}, $self ); - %files = (); + $self->{dbh} = + DBI->connect( $dbname, $config->{dbuser}, $config->{dbpass}, + { RaiseError => 1, AutoCommit => 1 } ) + || fatal "Can't open connection to database\n"; + + %files = (); %symcache = (); - $self->{files_select} = $self->{dbh}->prepare - ("select fileid from files where filename = ? and revision = ?"); - $self->{files_insert} = $self->{dbh}->prepare - ("insert into files values (?, ?, filenum.nextval)"); + $self->{files_select} = + $self->{dbh}->prepare("select fileid from files where filename = ? and revision = ?"); + $self->{files_insert} = + $self->{dbh}->prepare("insert into files values (?, ?, filenum.nextval)"); - $self->{symbols_byname} = $self->{dbh}->prepare - ("select symid from symbols where symname = ?"); - $self->{symbols_byid} = $self->{dbh}->prepare - ("select symname from symbols where symid = ?"); - $self->{symbols_insert} = $self->{dbh}->prepare - ("insert into symbols values ( ?, symnum.nextval)"); - $self->{symbols_remove} = $self->{dbh}->prepare - ("delete from symbols where symname = ?"); + $self->{symbols_byname} = $self->{dbh}->prepare("select symid from symbols where symname = ?"); + $self->{symbols_byid} = $self->{dbh}->prepare("select symname from symbols where symid = ?"); + $self->{symbols_insert} = + $self->{dbh}->prepare("insert into symbols values ( ?, symnum.nextval)"); + $self->{symbols_remove} = $self->{dbh}->prepare("delete from symbols where symname = ?"); - $self->{indexes_select} = $self->{dbh}->prepare - ("select f.filename, i.line, i.type, i.relsym ". - "from symbols s, indexes i, files f, releases r ". - "where s.symid = i.symid and i.fileid = f.fileid ". - "and f.fileid = r.fileid ". - "and s.symname = ? and r.release = ? "); - $self->{indexes_insert} = $self->{dbh}->prepare - ("insert into indexes values (?, ?, ?, ?, ?)"); + $self->{indexes_select} = + $self->{dbh}->prepare( "select f.filename, i.line, i.type, i.relsym " + . "from symbols s, indexes i, files f, releases r " + . "where s.symid = i.symid and i.fileid = f.fileid " + . "and f.fileid = r.fileid " + . "and s.symname = ? and r.release = ? " ); + $self->{indexes_insert} = $self->{dbh}->prepare("insert into indexes values (?, ?, ?, ?, ?)"); - $self->{releases_select} = $self->{dbh}->prepare - ("select * from releases where fileid = ? and release = ?"); - - $self->{releases_insert} = $self->{dbh}->prepare - ("insert into releases values (?, ?)"); + $self->{releases_select} = + $self->{dbh}->prepare("select * from releases where fileid = ? and release = ?"); - $self->{status_get} = $self->{dbh}->prepare - ("select status from status where fileid = ?"); + $self->{releases_insert} = $self->{dbh}->prepare("insert into releases values (?, ?)"); + + $self->{status_get} = $self->{dbh}->prepare("select status from status where fileid = ?"); $self->{status_insert} = $self->{dbh}->prepare -# ("insert into status select ?, 0 except select fileid, 0 from status"); - ("insert into status values (?, ?)"); - $self->{status_update} = $self->{dbh}->prepare - ("update status set status = ? where fileid = ? and status <= ?"); + # ("insert into status select ?, 0 except select fileid, 0 from status"); + ("insert into status values (?, ?)"); - $self->{usage_insert} = $self->{dbh}->prepare - ("insert into usage values (?, ?, ?)"); - $self->{usage_select} = $self->{dbh}->prepare - ("select f.filename, u.line ". - "from symbols s, files f, releases r, usage u ". - "where s.symid = u.symid ". - "and f.fileid = u.fileid ". - "and u.fileid = r.fileid and ". - "s.symname = ? and r.release = ? ". - "order by f.filename"); + $self->{status_update} = + $self->{dbh}->prepare("update status set status = ? where fileid = ? and status <= ?"); - $self->{delete_indexes} = $self->{dbh}->prepare - ("delete from indexes ". - "where fileid in ". - " (select fileid from releases where release = ?)"); - $self->{delete_usage} = $self->{dbh}->prepare - ("delete from usage ". - "where fileid in ". - " (select fileid from releases where release = ?)"); - $self->{delete_status} = $self->{dbh}->prepare - ("delete from status ". - "where fileid in ". - " (select fileid from releases where release = ?)"); - $self->{delete_releases} = $self->{dbh}->prepare - ("delete from releases ". - "where release = ?"); - $self->{delete_files} = $self->{dbh}->prepare - ("delete from files ". - "where fileid in ". - " (select fileid from releases where release = ?)"); + $self->{usage_insert} = $self->{dbh}->prepare("insert into usage values (?, ?, ?)"); + $self->{usage_select} = + $self->{dbh}->prepare( "select f.filename, u.line " + . "from symbols s, files f, releases r, usage u " + . "where s.symid = u.symid " + . "and f.fileid = u.fileid " + . "and u.fileid = r.fileid and " + . "s.symname = ? and r.release = ? " + . "order by f.filename" ); + + $self->{delete_indexes} = + $self->{dbh}->prepare( "delete from indexes " + . "where fileid in " + . " (select fileid from releases where release = ?)" ); + $self->{delete_usage} = + $self->{dbh}->prepare( "delete from usage " + . "where fileid in " + . " (select fileid from releases where release = ?)" ); + $self->{delete_status} = + $self->{dbh}->prepare( "delete from status " + . "where fileid in " + . " (select fileid from releases where release = ?)" ); + $self->{delete_releases} = + $self->{dbh}->prepare( "delete from releases " . "where release = ?" ); + $self->{delete_files} = + $self->{dbh}->prepare( "delete from files " + . "where fileid in " + . " (select fileid from releases where release = ?)" ); - return $self; } sub index { - my ($self, $symname, $fileid, $line, $type, $relsym) = @_; + my ( $self, $symname, $fileid, $line, $type, $relsym ) = @_; - $self->{indexes_insert}->execute($self->symid($symname), - $fileid, - $line, - $type, - $relsym ? $self->symid($relsym) : undef); + $self->{indexes_insert}->execute( $self->symid($symname), + $fileid, $line, $type, $relsym ? $self->symid($relsym) : undef ); } sub reference { - my ($self, $symname, $fileid, $line) = @_; + my ( $self, $symname, $fileid, $line ) = @_; - $self->{usage_insert}->execute($fileid, - $line, - $self->symid($symname)); + $self->{usage_insert}->execute( $fileid, $line, $self->symid($symname) ); } -sub getindex { # Hinzugefügt von Variable @row, While-Schleife - my ($self, $symname, $release) = @_; - my ($rows, @ret, @row); +sub getindex { # Hinzugefügt von Variable @row, While-Schleife + my ( $self, $symname, $release ) = @_; + my ( $rows, @ret, @row ); - $rows = $self->{indexes_select}->execute("$symname", "$release"); - - while (@row = $self->{indexes_select}->fetchrow_array){ - push (@ret,[@row]); + $rows = $self->{indexes_select}->execute( "$symname", "$release" ); + + while ( @row = $self->{indexes_select}->fetchrow_array ) { + push( @ret, [@row] ); } - + #while ($rows-- > 0) { # push(@ret, [ $self->{indexes_select}->fetchrow_array ]); #} $self->{indexes_select}->finish(); - map { $$_[3] &&= $self->symname($$_[3]) } @ret; + map { $$_[3] &&= $self->symname( $$_[3] ) } @ret; return @ret; } sub getreference { - my ($self, $symname, $release) = @_; - my ($rows, @ret, @row); - - $rows = $self->{usage_select}->execute("$symname", "$release"); + my ( $self, $symname, $release ) = @_; + my ( $rows, @ret, @row ); - while (@row = $self->{usage_select}->fetchrow_array){ - push (@ret,[@row]); + $rows = $self->{usage_select}->execute( "$symname", "$release" ); + + while ( @row = $self->{usage_select}->fetchrow_array ) { + push( @ret, [@row] ); } - + #while ($rows-- > 0) { # push(@ret, [ $self->{usage_select}->fetchrow_array ]); #} - $self->{usage_select}->finish(); + $self->{usage_select}->finish(); return @ret; } sub fileid { - my ($self, $filename, $revision) = @_; + my ( $self, $filename, $revision ) = @_; my ($fileid); # CAUTION: $revision is not $release! - unless (defined($fileid = $files{"$filename\t$revision"})) { - $self->{files_select}->execute($filename, $revision); + unless ( defined( $fileid = $files{"$filename\t$revision"} ) ) { + $self->{files_select}->execute( $filename, $revision ); ($fileid) = $self->{files_select}->fetchrow_array(); - unless ($fileid) { - $self->{files_insert}->execute($filename, $revision); - $self->{files_select}->execute($filename, $revision); + unless ($fileid) { + $self->{files_insert}->execute( $filename, $revision ); + $self->{files_select}->execute( $filename, $revision ); ($fileid) = $self->{files_select}->fetchrow_array(); - + } - + $files{"$filename\t$revision"} = $fileid; $self->{files_select}->finish(); } @@ -195,31 +184,32 @@ # Indicate that this filerevision is part of this release sub release { - my ($self, $fileid, $release) = @_; + my ( $self, $fileid, $release ) = @_; my (@row); - my $rows = $self->{releases_select}->execute($fileid+0, $release); - while (@row = $self->{releases_select}->fetchrow_array){ - $rows=1; - } + my $rows = $self->{releases_select}->execute( $fileid + 0, $release ); + while ( @row = $self->{releases_select}->fetchrow_array ) { + $rows = 1; + } $self->{releases_select}->finish(); - unless ($rows > 0) { - $self->{releases_insert}->execute($fileid+0, $release); + unless ( $rows > 0 ) { + $self->{releases_insert}->execute( $fileid + 0, $release ); $self->{releases_insert}->finish(); } } sub symid { - my ($self, $symname) = @_; + my ( $self, $symname ) = @_; my ($symid); $symid = $symcache{$symname}; - unless (defined($symid)) { + unless ( defined($symid) ) { $self->{symbols_byname}->execute($symname); ($symid) = $self->{symbols_byname}->fetchrow_array(); $self->{symbols_byname}->finish(); unless ($symid) { $self->{symbols_insert}->execute($symname); + # Get the id of the new symbol $self->{symbols_byname}->execute($symname); ($symid) = $self->{symbols_byname}->fetchrow_array(); @@ -232,10 +222,10 @@ } sub symname { - my ($self, $symid) = @_; + my ( $self, $symid ) = @_; my ($symname); - $self->{symbols_byid}->execute($symid+0); + $self->{symbols_byid}->execute( $symid + 0 ); ($symname) = $self->{symbols_byid}->fetchrow_array(); $self->{symbols_byid}->finish(); @@ -243,11 +233,11 @@ } sub issymbol { - my ($self, $symname) = @_; + my ( $self, $symname ) = @_; my ($symid); $symid = $symcache{$symname}; - unless (defined($symid)) { + unless ( defined($symid) ) { $self->{symbols_byname}->execute($symname); ($symid) = $self->{symbols_byname}->fetchrow_array(); $self->{symbols_byname}->finish(); @@ -260,68 +250,68 @@ # If this file has not been indexed earlier, mark it as being indexed # now and return true. Return false if already indexed. sub toindex { - my ($self, $fileid) = @_; + my ( $self, $fileid ) = @_; my ($status); $self->{status_get}->execute($fileid); $status = $self->{status_get}->fetchrow_array(); $self->{status_get}->finish(); - if(!defined($status)) { - $self->{status_insert}->execute($fileid+0, 0); + if ( !defined($status) ) { + $self->{status_insert}->execute( $fileid + 0, 0 ); } - return $self->{status_update}->execute(1, $fileid, 0) > 0; + return $self->{status_update}->execute( 1, $fileid, 0 ) > 0; } sub toreference { - my ($self, $fileid) = @_; + my ( $self, $fileid ) = @_; my ($rv); - return $self->{status_update}->execute(2, $fileid, 1) > 0; + return $self->{status_update}->execute( 2, $fileid, 1 ) > 0; } -# This function should be called before parsing each new file, +# This function should be called before parsing each new file, # if this is not done the too much memory will be used and -# tings will become very slow. +# tings will become very slow. sub empty_cache { %symcache = (); } sub purge { - my ($self, $version) = @_; + my ( $self, $version ) = @_; + # we don't delete symbols, because they might be used by other versions - # so we can end up with unused symbols, but that doesn't cause any problems - $self ->{delete_indexes}->execute($version); - $self ->{$delete_usage}->execute($version); - $self ->{$delete_status}->execute($version); - $self ->{$delete_releases}->execute($version); - $self ->{$delete_files}->execute($version); - } + # so we can end up with unused symbols, but that doesn't cause any problems + $self->{delete_indexes}->execute($version); + $self->{$delete_usage}->execute($version); + $self->{$delete_status}->execute($version); + $self->{$delete_releases}->execute($version); + $self->{$delete_files}->execute($version); +} sub DESTROY { my ($self) = @_; - $self->{files_select} = undef; - $self->{files_insert} = undef; - $self->{symbols_byname} = undef; - $self->{symbols_byid} = undef; - $self->{symbols_insert} = undef; - $self->{indexes_insert} = undef; + $self->{files_select} = undef; + $self->{files_insert} = undef; + $self->{symbols_byname} = undef; + $self->{symbols_byid} = undef; + $self->{symbols_insert} = undef; + $self->{indexes_insert} = undef; $self->{releases_insert} = undef; - $self->{status_insert} = undef; - $self->{status_update} = undef; - $self->{usage_insert} = undef; - $self->{usage_select} = undef; - $self->{delete_indexes} = undef; - $self->{delete_useage} = undef; - $self->{delete_status} = undef; + $self->{status_insert} = undef; + $self->{status_update} = undef; + $self->{usage_insert} = undef; + $self->{usage_select} = undef; + $self->{delete_indexes} = undef; + $self->{delete_useage} = undef; + $self->{delete_status} = undef; $self->{delete_releases} = undef; - $self->{delete_files} = undef; + $self->{delete_files} = undef; - if($self->{dbh}) { + if ( $self->{dbh} ) { $self->{dbh}->disconnect(); $self->{dbh} = undef; } } - 1; Index: Postgres.pm =================================================================== RCS file: /cvsroot/lxr/lxr/lib/LXR/Index/Postgres.pm,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- Postgres.pm 19 Jul 2004 13:55:30 -0000 1.14 +++ Postgres.pm 19 Jul 2004 19:50:21 -0000 1.15 @@ -11,7 +11,7 @@ # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -25,170 +25,149 @@ use LXR::Common; use vars qw($dbh $transactions %files %symcache $commitlimit - $files_select $filenum_nextval $files_insert - $symbols_byname $symbols_byid $symnum_nextval - $symbols_remove $symbols_insert $indexes_select $indexes_insert - $releases_select $releases_insert $status_insert - $status_update $usage_insert $usage_select $decl_select - $declid_nextnum $decl_insert $delete_indexes $delete_usage - $delete_status $delete_releases $delete_files); - + $files_select $filenum_nextval $files_insert + $symbols_byname $symbols_byid $symnum_nextval + $symbols_remove $symbols_insert $indexes_select $indexes_insert + $releases_select $releases_insert $status_insert + $status_update $usage_insert $usage_select $decl_select + $declid_nextnum $decl_insert $delete_indexes $delete_usage + $delete_status $delete_releases $delete_files); sub new { - my ($self, $dbname) = @_; + my ( $self, $dbname ) = @_; - $self = bless({}, $self); - $dbh ||= DBI->connect($dbname, $config->{'dbuser'}, $config->{'dbpass'}); + $self = bless( {}, $self ); + $dbh ||= DBI->connect( $dbname, $config->{'dbuser'}, $config->{'dbpass'} ); die($DBI::errstr) unless $dbh; $$dbh{'AutoCommit'} = 0; -# $dbh->trace(1); - $commitlimit = 100; + # $dbh->trace(1); + + $commitlimit = 100; $transactions = 0; - %files = (); - %symcache = (); + %files = (); + %symcache = (); - $files_select = $dbh->prepare - ("select fileid from files where filename = ? and revision = ?"); - $filenum_nextval = $dbh->prepare - ("select nextval('filenum')"); - $files_insert = $dbh->prepare - ("insert into files values (?, ?, ?)"); + $files_select = $dbh->prepare("select fileid from files where filename = ? and revision = ?"); + $filenum_nextval = $dbh->prepare("select nextval('filenum')"); + $files_insert = $dbh->prepare("insert into files values (?, ?, ?)"); - $symbols_byname = $dbh->prepare - ("select symid from symbols where symname = ?"); - $symbols_byid = $dbh->prepare - ("select symname from symbols where symid = ?"); - $symnum_nextval = $dbh->prepare - ("select nextval('symnum')"); - $symbols_insert = $dbh->prepare - ("insert into symbols values (?, ?)"); - $symbols_remove = $dbh->prepare - ("delete from symbols where symname = ?"); + $symbols_byname = $dbh->prepare("select symid from symbols where symname = ?"); + $symbols_byid = $dbh->prepare("select symname from symbols where symid = ?"); + $symnum_nextval = $dbh->prepare("select nextval('symnum')"); + $symbols_insert = $dbh->prepare("insert into symbols values (?, ?)"); + $symbols_remove = $dbh->prepare("delete from symbols where symname = ?"); - $indexes_select = $dbh->prepare - ("select f.filename, i.line, d.declaration, i.relsym ". - "from symbols s, indexes i, files f, releases r, declarations d ". - "where s.symid = i.symid and i.fileid = f.fileid ". - "and f.fileid = r.fileid ". - "and i.langid = d.langid and i.type = d.declid ". - "and s.symname = ? and r.release = ?"); - $indexes_insert = $dbh->prepare - ("insert into indexes (symid, fileid, line, langid, type, relsym) ". - "values (?, ?, ?, ?, ?, ?)"); + $indexes_select = + $dbh->prepare( "select f.filename, i.line, d.declaration, i.relsym " + . "from symbols s, indexes i, files f, releases r, declarations d " + . "where s.symid = i.symid and i.fileid = f.fileid " + . "and f.fileid = r.fileid " + . "and i.langid = d.langid and i.type = d.declid " + . "and s.symname = ? and r.release = ?" ); + $indexes_insert = + $dbh->prepare( "insert into indexes (symid, fileid, line, langid, type, relsym) " + . "values (?, ?, ?, ?, ?, ?)" ); - $releases_select = $dbh->prepare - ("select * from releases where fileid = ? and release = ?"); - $releases_insert = $dbh->prepare - ("insert into releases values (?, ?)"); + $releases_select = $dbh->prepare("select * from releases where fileid = ? and release = ?"); + $releases_insert = $dbh->prepare("insert into releases values (?, ?)"); $status_insert = $dbh->prepare -# ("insert into status select ?, 0 except select fileid, 0 from status"); - ("insert into status select ?, 0 where not exists ". - "(select * from status where fileid = ?)"); - $status_update = $dbh->prepare - ("update status set status = ? where fileid = ? and status <= ?"); + # ("insert into status select ?, 0 except select fileid, 0 from status"); + ( "insert into status select ?, 0 where not exists " + . "(select * from status where fileid = ?)" ); - $usage_insert = $dbh->prepare - ("insert into usage values (?, ?, ?)"); - $usage_select = $dbh->prepare - ("select f.filename, u.line ". - "from symbols s, files f, releases r, usage u ". - "where s.symid = u.symid ". - "and f.fileid = u.fileid ". - "and f.fileid = r.fileid and ". - "s.symname = ? and r.release = ?"); + $status_update = $dbh->prepare("update status set status = ? where fileid = ? and status <= ?"); - $declid_nextnum = $dbh->prepare - ("select nextval('declnum')"); - - $decl_select = $dbh->prepare - ("select declid from declarations where langid = ? and ". - "declaration = ?"); - $decl_insert = $dbh->prepare - ("insert into declarations (declid, langid, declaration) values (?, ?, ?)"); + $usage_insert = $dbh->prepare("insert into usage values (?, ?, ?)"); + $usage_select = + $dbh->prepare( "select f.filename, u.line " + . "from symbols s, files f, releases r, usage u " + . "where s.symid = u.symid " + . "and f.fileid = u.fileid " + . "and f.fileid = r.fileid and " + . "s.symname = ? and r.release = ?" ); - $delete_indexes = $dbh->prepare - ("delete from indexes ". - "where fileid in ". - " (select fileid from releases where release = ?)"); - $delete_usage = $dbh->prepare - ("delete from usage ". - "where fileid in ". - " (select fileid from releases where release = ?)"); - $delete_status = $dbh->prepare - ("delete from status ". - "where fileid in ". - " (select fileid from releases where release = ?)"); - $delete_releases = $dbh->prepare - ("delete from releases ". - "where release = ?"); - $delete_files = $dbh->prepare - ("delete from files ". - "where fileid in ". - " (select fileid from releases where release = ?)"); + $declid_nextnum = $dbh->prepare("select nextval('declnum')"); + + $decl_select = + $dbh->prepare( "select declid from declarations where langid = ? and " . "declaration = ?" ); + $decl_insert = + $dbh->prepare("insert into declarations (declid, langid, declaration) values (?, ?, ?)"); + + $delete_indexes = + $dbh->prepare( "delete from indexes " + . "where fileid in " + . " (select fileid from releases where release = ?)" ); + $delete_usage = + $dbh->prepare( "delete from usage " + . "where fileid in " + . " (select fileid from releases where release = ?)" ); + $delete_status = + $dbh->prepare( "delete from status " + . "where fileid in " + . " (select fileid from releases where release = ?)" ); + $delete_releases = $dbh->prepare( "delete from releases " . "where release = ?" ); + $delete_files = + $dbh->prepare( "delete from files " + . "where fileid in " + . " (select fileid from releases where release = ?)" ); return $self; } sub empty_cache { - %symcache = (); + %symcache = (); } sub commit_if_limit { - unless (++$transactions % $commitlimit) { + unless ( ++$transactions % $commitlimit ) { $dbh->commit(); } } sub index { - my ($self, $symname, $fileid, $line, $langid, $type, $relsym) = @_; + my ( $self, $symname, $fileid, $line, $langid, $type, $relsym ) = @_; - $indexes_insert->execute($self->symid($symname), - $fileid, - $line, - $langid, - $type, - $relsym ? $self->symid($relsym) : undef); + $indexes_insert->execute( $self->symid($symname), + $fileid, $line, $langid, $type, $relsym ? $self->symid($relsym) : undef ); commit_if_limit(); } sub reference { - my ($self, $symname, $fileid, $line) = @_; + my ( $self, $symname, $fileid, $line ) = @_; - $usage_insert->execute($fileid, - $line, - $self->symid($symname)); + $usage_insert->execute( $fileid, $line, $self->symid($symname) ); commit_if_limit(); } sub getindex { - my ($self, $symname, $release) = @_; - my ($rows, @ret); + my ( $self, $symname, $release ) = @_; + my ( $rows, @ret ); - $rows = $indexes_select->execute("$symname", "$release"); + $rows = $indexes_select->execute( "$symname", "$release" ); - while ($rows-- > 0) { - push(@ret, [ $indexes_select->fetchrow_array ]); + while ( $rows-- > 0 ) { + push( @ret, [ $indexes_select->fetchrow_array ] ); } $indexes_select->finish(); - map { $$_[3] &&= $self->symname($$_[3]) } @ret; + map { $$_[3] &&= $self->symname( $$_[3] ) } @ret; return @ret; } sub getreference { - my ($self, $symname, $release) = @_; - my ($rows, @ret); + my ( $self, $symname, $release ) = @_; + my ( $rows, @ret ); - $rows = $usage_select->execute("$symname", "$release"); + $rows = $usage_select->execute( "$symname", "$release" ); - while ($rows-- > 0) { - push(@ret, [ $usage_select->fetchrow_array ]); + while ( $rows-- > 0 ) { + push( @ret, [ $usage_select->fetchrow_array ] ); } $usage_select->finish(); @@ -197,29 +176,29 @@ } sub relate { - my ($self, $symname, $release, $rsymname, $reltype) = @_; + my ( $self, $symname, $release, $rsymname, $reltype ) = @_; -# $relation{$self->symid($symname, $release)} .= -# join("\t", $self->symid($rsymname, $release), $reltype, ''); + # $relation{$self->symid($symname, $release)} .= + # join("\t", $self->symid($rsymname, $release), $reltype, ''); } sub getrelations { - my ($self, $symname, $release) = @_; + my ( $self, $symname, $release ) = @_; } sub fileid { - my ($self, $filename, $revision) = @_; + my ( $self, $filename, $revision ) = @_; my ($fileid); # CAUTION: $revision is not $release! - unless (defined($fileid = $files{"$filename\t$revision"})) { - $files_select->execute($filename, $revision); + unless ( defined( $fileid = $files{"$filename\t$revision"} ) ) { + $files_select->execute( $filename, $revision ); ($fileid) = $files_select->fetchrow_array(); unless ($fileid) { $filenum_nextval->execute(); ($fileid) = $filenum_nextval->fetchrow_array(); - $files_insert->execute($filename, $revision, $fileid); + $files_insert->execute( $filename, $revision, $fileid ); } $files{"$filename\t$revision"} = $fileid; } @@ -229,32 +208,30 @@ # Indicate that this filerevision is part of this release sub release { - my ($self, $fileid, $release) = @_; - + my ( $self, $fileid, $release ) = @_; - $releases_select->execute($fileid+0, $release); + $releases_select->execute( $fileid + 0, $release ); my $firstrow = $releases_select->fetchrow_array(); - -# $releases_select->finish(); + # $releases_select->finish(); unless ($firstrow) { - $releases_insert->execute($fileid+0, $release); + $releases_insert->execute( $fileid + 0, $release ); } commit_if_limit(); } sub symid { - my ($self, $symname) = @_; + my ( $self, $symname ) = @_; my ($symid); - unless (defined($symid = $symcache{$symname})) { + unless ( defined( $symid = $symcache{$symname} ) ) { $symbols_byname->execute($symname); ($symid) = $symbols_byname->fetchrow_array(); unless ($symid) { $symnum_nextval->execute(); ($symid) = $symnum_nextval->fetchrow_array(); - $symbols_insert->execute($symname, $symid); + $symbols_insert->execute( $symname, $symid ); } $symcache{$symname} = $symid; } @@ -263,66 +240,67 @@ } sub symname { - my ($self, $symid) = @_; + my ( $self, $symid ) = @_; my ($symname); - $symbols_byid->execute($symid+0); + $symbols_byid->execute( $symid + 0 ); ($symname) = $symbols_byid->fetchrow_array(); return $symname; } sub issymbol { - my ($self, $symname) = @_; + my ( $self, $symname ) = @_; - unless (exists($symcache{$symname})) { + unless ( exists( $symcache{$symname} ) ) { $symbols_byname->execute($symname); - ($symcache{$symname}) = $symbols_byname->fetchrow_array(); + ( $symcache{$symname} ) = $symbols_byname->fetchrow_array(); } - + return $symcache{$symname}; } # If this file has not been indexed earlier, mark it as being indexed # now and return true. Return false if already indexed. sub toindex { - my ($self, $fileid) = @_; + my ( $self, $fileid ) = @_; - $status_insert->execute($fileid+0, $fileid+0); + $status_insert->execute( $fileid + 0, $fileid + 0 ); commit_if_limit(); - return $status_update->execute(1, $fileid+0, 0) > 0; + return $status_update->execute( 1, $fileid + 0, 0 ) > 0; } sub toreference { - my ($self, $fileid) = @_; + my ( $self, $fileid ) = @_; - return $status_update->execute(2, $fileid, 1) > 0; + return $status_update->execute( 2, $fileid, 1 ) > 0; } sub getdecid { - my ($self, $lang, $string) = @_; + my ( $self, $lang, $string ) = @_; - my $rows = $decl_select->execute($lang, $string); - $decl_select->finish(); - - unless ($rows > 0) { - $declid_nextnum->execute(); - my ($declid) = $declid_nextnum->fetchrow_array(); - $decl_insert->execute($declid, $lang, $string); - } + my $rows = $decl_select->execute( $lang, $string ); + $decl_select->finish(); - $decl_select->execute($lang, $string); + unless ( $rows > 0 ) { + $declid_nextnum->execute(); + my ($declid) = $declid_nextnum->fetchrow_array(); + $decl_insert->execute( $declid, $lang, $string ); + } + + $decl_select->execute( $lang, $string ); my $id = $decl_select->fetchrow_array(); - $decl_select->finish(); + $decl_select->finish(); commit_if_limit(); - return $id; + return $id; } sub purge { - my ($self, $version) = @_; + my ( $self, $version ) = @_; + # we don't delete symbols, because they might be used by other versions - # so we can end up with unused symbols, but that doesn't cause any problems + # so we can end up with unused symbols, but that doesn't cause any problems $delete_indexes->execute($version); $delete_usage->execute($version); $delete_status->execute($version); @@ -332,45 +310,45 @@ } sub setindexed { - my ($self, $fileid) = @_; - $status_update->execute(1, $fileid, 0); + my ( $self, $fileid ) = @_; + $status_update->execute( 1, $fileid, 0 ); } + sub setreferenced { - my ($self, $fileid) = @_; - $status_update->execute(2, $fileid, 1); + my ( $self, $fileid ) = @_; + $status_update->execute( 2, $fileid, 1 ); } sub END { - $files_select= undef; - $filenum_nextval= undef; - $files_insert = undef; - $symbols_byname= undef; - $symbols_byid= undef; - $symnum_nextval = undef; - $symbols_remove= undef; - $symbols_insert= undef; - $indexes_select= undef; - $indexes_insert = undef; - $releases_select= undef; - $releases_insert= undef; - $status_insert = undef; - $status_update= undef; - $usage_insert= undef; - $usage_select= undef; - $decl_select = undef; - $declid_nextnum= undef; - $decl_insert = undef; - $delete_indexes = undef; - $delete_usage = undef; - $delete_status = undef; + $files_select = undef; + $filenum_nextval = undef; + $files_insert = undef; + $symbols_byname = undef; + $symbols_byid = undef; + $symnum_nextval = undef; + $symbols_remove = undef; + $symbols_insert = undef; + $indexes_select = undef; + $indexes_insert = undef; + $releases_select = undef; + $releases_insert = undef; + $status_insert = undef; + $status_update = undef; + $usage_insert = undef; + $usage_select = undef; + $decl_select = undef; + $declid_nextnum = undef; + $decl_insert = undef; + $delete_indexes = undef; + $delete_usage = undef; + $delete_status = undef; $delete_releases = undef; - $delete_files = undef; - + $delete_files = undef; + $dbh->commit(); $dbh->disconnect(); $dbh = undef; } - 1; |
From: Dave B. <bro...@us...> - 2004-07-19 19:50:36
|
Update of /cvsroot/lxr/lxr/lib/LXR/Lang In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7323/lib/LXR/Lang Modified Files: Generic.pm Java.pm Perl.pm Python.pm Log Message: formatting (with eclipse EPIC plugin which uses PerlTidy. options used: line width 100, cuddle else, use tabs, tab-width 4) Index: Generic.pm =================================================================== RCS file: /cvsroot/lxr/lxr/lib/LXR/Lang/Generic.pm,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- Generic.pm 19 Jul 2004 17:33:17 -0000 1.14 +++ Generic.pm 19 Jul 2004 19:50:21 -0000 1.15 @@ -3,7 +3,7 @@ # $Id$ # # Implements generic support for any language that ectags can parse. -# This may not be ideal support, but it should at least work until +# This may not be ideal support, but it should at least work until # someone writes better support. # # This program is free software; you can redistribute it and/or modify @@ -15,7 +15,7 @@ # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -35,102 +35,100 @@ @LXR::Lang::Generic::ISA = ('LXR::Lang'); sub new { - my ($proto, $pathname, $release, $lang) = @_; - my $class = ref($proto) || $proto; - my $self = {}; - bless ($self, $class); - $$self{'release'} = $release; - $$self{'language'} = $lang; + my ( $proto, $pathname, $release, $lang ) = @_; + my $class = ref($proto) || $proto; + my $self = {}; + bless( $self, $class ); + $$self{'release'} = $release; + $$self{'language'} = $lang; - read_config() unless defined $generic_config; - %$self = (%$self, %$generic_config); + read_config() unless defined $generic_config; + %$self = ( %$self, %$generic_config ); - # Set langid - $$self{'langid'} = $self->langinfo('langid'); - die "No langid for language $lang" if !defined $self->langid; + # Set langid + $$self{'langid'} = $self->langinfo('langid'); + die "No langid for language $lang" if !defined $self->langid; - return $self; + return $self; } # This is only executed once, saving the overhead of processing the # config file each time. Because it is only done once, we also use # this to check the version of ctags. sub read_config { - open (CONF, $config->genericconf) || die "Can't open ".$config->genericconf.", $!"; - - local($/) = undef; - + open( CONF, $config->genericconf ) || die "Can't open " . $config->genericconf . ", $!"; + + local ($/) = undef; + my $config_contents = <CONF>; - $config_contents =~ /(.*)/s ; $config_contents = $1; #untaint it - $generic_config = eval ("\n#line 1 \"generic.conf\"\n". - $config_contents); - die ($@) if $@; + $config_contents =~ /(.*)/s; + $config_contents = $1; #untaint it + $generic_config = eval( "\n#line 1 \"generic.conf\"\n" . $config_contents ); + die($@) if $@; close CONF; # Setup the ctags to declid mapping my $langmap = $generic_config->{'langmap'}; - foreach my $lang (keys %$langmap) { + foreach my $lang ( keys %$langmap ) { my $typemap = $langmap->{$lang}{'typemap'}; - foreach my $type (keys %$typemap) { - $typemap->{$type} = - $index->getdecid($langmap->{$lang}{'langid'}, - $typemap->{$type}); + foreach my $type ( keys %$typemap ) { + $typemap->{$type} = $index->getdecid( $langmap->{$lang}{'langid'}, $typemap->{$type} ); } } - + my $ctags = $config->ectagsbin; - + $ENV{'PATH'} = '/bin:/usr/local/bin:/usr/bin:/usr/sbin'; my $version = `$ctags --version`; - $version=~ /Exuberant ctags +(\d+)/i; - if($1 < 5 ) { - die "Exuberant ctags version 5 or above required, found $version\n"; + $version =~ /Exuberant ctags +(\d+)/i; + if ( $1 < 5 ) { + die "Exuberant ctags version 5 or above required, found $version\n"; } } sub indexfile { - my ($self, $name, $path, $fileid, $index, $config) = @_; + my ( $self, $name, $path, $fileid, $index, $config ) = @_; + + my $typemap = $self->langinfo('typemap'); + + my $langforce = ${ $self->eclangnamemapping }{ $self->language }; + if ( !defined $langforce ) { + $langforce = $self->language; + } + + if ( $config->ectagsbin ) { + open( CTAGS, + join( " ", + $config->ectagsbin, $self->ectagsopts, "--excmd=number", + "--language-force=$langforce", "-f", "-", $path, "|" ) + ) + or die "Can't run ectags, $!"; + + while (<CTAGS>) { + chomp; + + my ( $sym, $file, $line, $type, $ext ) = split( /\t/, $_ ); + $line =~ s/;\"$//; + $ext =~ /language:(\w+)/; + $type = $typemap->{$type}; + if ( !defined $type ) { + print "Warning: Unknown type ", ( split( /\t/, $_ ) )[3], "\n"; + next; + } + + # TODO: can we make it more generic in parsing the extension fields? + if ( defined($ext) && $ext =~ /^(struct|union|class|enum):(.*)/ ) { + $ext = $2; + $ext =~ s/::<anonymous>//g; + } else { + $ext = undef; + } + + $index->index( $sym, $fileid, $line, $self->langid, $type, $ext ); + } + close(CTAGS); - my $typemap = $self->langinfo('typemap'); - - my $langforce = $ {$self->eclangnamemapping}{$self->language}; - if (!defined $langforce) { - $langforce = $self->language; - } - - if ($config->ectagsbin) { - open(CTAGS, join(" ", $config->ectagsbin, - $self->ectagsopts, - "--excmd=number", - "--language-force=$langforce", - "-f", "-", - $path, "|")) or die "Can't run ectags, $!"; - - while (<CTAGS>) { - chomp; - - my ($sym, $file, $line, $type,$ext) = split(/\t/, $_); - $line =~ s/;\"$//; - $ext =~ /language:(\w+)/; - $type = $typemap->{$type}; - if(!defined $type) { - print "Warning: Unknown type ", (split(/\t/,$_))[3], "\n"; - next; - } - - # TODO: can we make it more generic in parsing the extension fields? - if (defined($ext) && $ext =~ /^(struct|union|class|enum):(.*)/) { - $ext = $2; - $ext =~ s/::<anonymous>//g; - } else { - $ext = undef; - } - - $index->index($sym, $fileid, $line, $self->langid, $type, $ext); } - close(CTAGS); - - } } # This method returns the regexps used by SimpleParse to break the @@ -138,9 +136,9 @@ # Since this depends on the language, it's configured via generic.conf sub parsespec { - my ($self) = @_; - my @spec = $self->langinfo('spec'); - return @spec; + my ($self) = @_; + my @spec = $self->langinfo('spec'); + return @spec; } # Process a chunk of code @@ -153,9 +151,9 @@ # TODO : Make the handling of identifier recognition language dependant sub processcode { - my ($self, $code) = @_; - my ($start, $id); - $$code =~ s {(^|[^\w\#])([\w~][\w]*)\b} + my ( $self, $code ) = @_; + my ( $start, $id ); + $$code =~ s {(^|[^\w\#])([\w~][\w]*)\b} # Replace identifier by link unless it's a reserved word { $1. @@ -171,127 +169,129 @@ # sub referencefile { - my ($self, $name, $path, $fileid, $index, $config) = @_; + my ( $self, $name, $path, $fileid, $index, $config ) = @_; - require LXR::SimpleParse; - # Use dummy tabwidth here since it doesn't matter for referencing - &LXR::SimpleParse::init(new FileHandle($path), 1, $self->parsespec); + require LXR::SimpleParse; - my $linenum = 1; - my ($btype, $frag) = &LXR::SimpleParse::nextfrag; - my @lines; - my $ls; + # Use dummy tabwidth here since it doesn't matter for referencing + &LXR::SimpleParse::init( new FileHandle($path), 1, $self->parsespec ); - while (defined($frag)) { - @lines = ($frag =~ /(.*?\n)/g, $frag =~ /([^\n]*)$/); + my $linenum = 1; + my ( $btype, $frag ) = &LXR::SimpleParse::nextfrag; + my @lines; + my $ls; - if (defined($btype)) { - if ($btype eq 'comment' or $btype eq 'string' or $btype eq 'include') { - $linenum += @lines - 1; - } else { - print "BTYPE was: $btype\n"; - } - } else { - my $l; - my $string; - foreach $l (@lines) { - foreach ($l =~ /(?:^|[^a-zA-Z_\#]) # Non-symbol chars. + while ( defined($frag) ) { + @lines = ( $frag =~ /(.*?\n)/g, $frag =~ /([^\n]*)$/ ); + + if ( defined($btype) ) { + if ( $btype eq 'comment' or $btype eq 'string' or $btype eq 'include' ) { + $linenum += @lines - 1; + } else { + print "BTYPE was: $btype\n"; + } + } else { + my $l; + my $string; + foreach $l (@lines) { + foreach ( + $l =~ /(?:^|[^a-zA-Z_\#]) # Non-symbol chars. (\~?_*[a-zA-Z][a-zA-Z0-9_]*) # The symbol. - \b/ogx) { - $string = $_; -# print "considering $string\n"; - if (!grep(/$string/, $self->langinfo('reserved')) && - $index->issymbol($string)) { -# print "adding $string to references\n"; - $index->reference($string, $fileid, $linenum); - } + \b/ogx + ) + { + $string = $_; - } - - $linenum++; - } - $linenum--; - } - ($btype, $frag) = &LXR::SimpleParse::nextfrag; - } - print("+++ $linenum\n"); -} + # print "considering $string\n"; + if ( !grep( /$string/, $self->langinfo('reserved') ) + && $index->issymbol($string) ) + { + # print "adding $string to references\n"; + $index->reference( $string, $fileid, $linenum ); + } + } + $linenum++; + } + $linenum--; + } + ( $btype, $frag ) = &LXR::SimpleParse::nextfrag; + } + print("+++ $linenum\n"); +} # Autoload magic to allow access using $generic->variable syntax # blatently ripped from Config.pm - I still don't fully understand how # this works. sub variable { - my ($self, $var, $val) = @_; + my ( $self, $var, $val ) = @_; - $self->{variables}{$var}{value} = $val if defined($val); - return $self->{variables}{$var}{value} || - $self->vardefault($var); + $self->{variables}{$var}{value} = $val if defined($val); + return $self->{variables}{$var}{value} + || $self->vardefault($var); } sub varexpand { - my ($self, $exp) = @_; - $exp =~ s/\$\{?(\w+)\}?/$self->variable($1)/ge; + my ( $self, $exp ) = @_; + $exp =~ s/\$\{?(\w+)\}?/$self->variable($1)/ge; - return $exp; + return $exp; } - sub value { - my ($self, $var) = @_; + my ( $self, $var ) = @_; - if (exists($self->{$var})) { - my $val = $self->{$var}; - - if (ref($val) eq 'ARRAY') { - return map { $self->varexpand($_) } @$val; - } elsif (ref($val) eq 'CODE') { - return $val; + if ( exists( $self->{$var} ) ) { + my $val = $self->{$var}; + + if ( ref($val) eq 'ARRAY' ) { + return map { $self->varexpand($_) } @$val; + } elsif ( ref($val) eq 'CODE' ) { + return $val; + } else { + return $self->varexpand($val); + } } else { - return $self->varexpand($val); + return undef; } - } else { - return undef; - } } - sub AUTOLOAD { - my $self = shift; - (my $var = $AUTOLOAD) =~ s/.*:://; + my $self = shift; + ( my $var = $AUTOLOAD ) =~ s/.*:://; - my @val = $self->value($var); - - if (ref($val[0]) eq 'CODE') { - return $val[0]->(@_); - } else { - return wantarray ? @val : $val[0]; - } + my @val = $self->value($var); + + if ( ref( $val[0] ) eq 'CODE' ) { + return $val[0]->(@_); + } else { + return wantarray ? @val : $val[0]; + } } sub langinfo { - my ($self, $item) = @_; - - my $val; - my $map = $self->langmap; - die if !defined $map; - if (exists $$map{$self->language}) { - $val = $$map{$self->language}; - } else { - return undef; - } + my ( $self, $item ) = @_; - if (defined $val && defined $$val{$item}) { - if (ref($$val{$item}) eq 'ARRAY') { - return wantarray ? @{$$val{$item}} : $$val{$item}; - } - return $$val{$item}; - } else { - return undef; - } + my $val; + my $map = $self->langmap; + die if !defined $map; + if ( exists $$map{ $self->language } ) { + $val = $$map{ $self->language }; + } else { + return undef; + } + + if ( defined $val && defined $$val{$item} ) { + if ( ref( $$val{$item} ) eq 'ARRAY' ) { + return wantarray ? @{ $$val{$item} } : $$val{$item}; + } + return $$val{$item}; + } else { + return undef; + } } 1; Index: Java.pm =================================================================== RCS file: /cvsroot/lxr/lxr/lib/LXR/Lang/Java.pm,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- Java.pm 14 Nov 2001 15:27:36 -0000 1.4 +++ Java.pm 19 Jul 2004 19:50:21 -0000 1.5 @@ -21,7 +21,6 @@ package LXR::Lang::Java; - my $CVSID = '$Id$ '; use strict; @@ -32,11 +31,12 @@ @LXR::Lang::Java::ISA = ('LXR::Lang::Generic'); # Only override the include handling. For java, this is really package -# handling, as there is no include mechanism, so deals with "package" +# handling, as there is no include mechanism, so deals with "package" # and "import" keywords sub processinclude { - my ($self, $frag, $dir) = @_; + my ( $self, $frag, $dir ) = @_; + # Deal with package declaration of the form # "package java.lang.util" $$frag =~ s#(package\s+)([\w.]+)# @@ -44,6 +44,7 @@ ($index->issymbol($2, $$self{'release'}) ? join($2, @{$$self{'itag'}}) : $2) #e; + # Deal with import declaration of the form # "import java.awt.*" by providing link to the package $$frag =~ s#(import\s+)([\w.]+)(\.\*)# @@ -51,21 +52,18 @@ ($index->issymbol($2, $$self{'release'}) ? join($2, @{$$self{'itag'}}) : $2) . $3 #e; - - # Deal with import declaration of the form - # "import java.awt.classname" by providing links to the + + # Deal with import declaration of the form + # "import java.awt.classname" by providing links to the # package and the class - $$frag =~ s#(import\s+)([\w.]+)\.(\w+)(\W)# + $$frag =~ s#(import\s+)([\w.]+)\.(\w+)(\W)# $1. ($index->issymbol($2, $$self{'release'}) ? join($2, @{$$self{'itag'}}) : $2) . "." . ($index->issymbol($3, $$self{'release'}) ? join($3, @{$$self{'itag'}}) : $3) . $4#e; - - } - +} 1; - Index: Perl.pm =================================================================== RCS file: /cvsroot/lxr/lxr/lib/LXR/Lang/Perl.pm,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- Perl.pm 18 Mar 2002 14:55:43 -0000 1.5 +++ Perl.pm 19 Jul 2004 19:50:21 -0000 1.6 @@ -11,7 +11,7 @@ # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -34,24 +34,24 @@ @ISA = ('LXR::Lang'); my @spec = ( - 'atom' => ('\$\W?', ''), - 'atom' => ('\\\\.', ''), - 'include' => ('\buse\s+', ';'), - 'include' => ('\brequire\s+', ';'), - 'string' => ('"', '"'), - 'comment' => ('#', "\$"), - 'comment' => ("^=\\w+", "^=cut"), - 'string' => ("'", "'")); - + 'atom' => ( '\$\W?', '' ), + 'atom' => ( '\\\\.', '' ), + 'include' => ( '\buse\s+', ';' ), + 'include' => ( '\brequire\s+', ';' ), + 'string' => ( '"', '"' ), + 'comment' => ( '#', "\$" ), + 'comment' => ( "^=\\w+", "^=cut" ), + 'string' => ( "'", "'" ) +); sub new { - my ($self, $pathname, $release) = @_; + my ( $self, $pathname, $release ) = @_; - $self = bless({}, $self); + $self = bless( {}, $self ); $$self{'release'} = $release; - return $self; + return $self; } sub parsespec { @@ -59,15 +59,15 @@ } sub processcode { - my ($self, $code, @itag) = @_; + my ( $self, $code, @itag ) = @_; my $sym; -# $$code =~ s#([\@\$\%\&\*])([a-z0-9_]+)|\b([a-z0-9_]+)(\s*\()# -# $sym = $2 || $3; -# $1.($index->issymbol($sym, $$self{'release'}) -# ? join($sym, @{$$self{'itag'}}) -# : $sym).$4#geis; - + # $$code =~ s#([\@\$\%\&\*])([a-z0-9_]+)|\b([a-z0-9_]+)(\s*\()# + # $sym = $2 || $3; + # $1.($index->issymbol($sym, $$self{'release'}) + # ? join($sym, @{$$self{'itag'}}) + # : $sym).$4#geis; + $$code =~ s#\b([a-z][a-z0-9_:]*)\b# ($index->issymbol($1, $$self{'release'}) ? join($1, @{$$self{'itag'}}) @@ -75,77 +75,71 @@ } sub modref { - my $mod = shift; + my $mod = shift; my $file = $mod; $file =~ s,::,/,g; $file .= ".pm"; - return &LXR::Common::incref($mod, "include", $file); + return &LXR::Common::incref( $mod, "include", $file ); } sub processinclude { - my ($self, $frag, $dir) = @_; - + my ( $self, $frag, $dir ) = @_; + $$frag =~ s/(use\s+|require\s+)([\w:]+)/$1.modref($2)/e; } sub processcomment { - my ($self, $comm) = @_; + my ( $self, $comm ) = @_; + + if ( $$comm =~ /^=/s ) { - if ($$comm =~ /^=/s) { # Pod text - $$comm = join('', map { - if (/^=head(\d)\s*(.*)/s) { - "<span class=\"pod\"><font size=\"+".(4-$1)."\">$2<\/font></span>"; - } - elsif (/^=item\s*(.*)/s) { - "<span class=\"podhead\">* $1 ". - ("-" x (67 - length($1)))."<\/span>"; - } - elsif (/^=(pod|cut)/s) { - "<span class=\"podhead\">". - ("-" x 70)."<\/span>"; - } - elsif (/^=.*/s) { - ""; - } - else { - if (/^\s/s) { # Verbatim paragraph - s|^(.*)$|<span class="pod"><code>$1</code></span>|gm; - } - else { # Normal paragraph - s|^(.*)$|<span class="pod">$1</span>|gm; - s/C\0\<(.*?)\0\>/<code>$1<\/code>/g; + $$comm = join( + '', + map { + if (/^=head(\d)\s*(.*)/s) + { + "<span class=\"pod\"><font size=\"+" . ( 4 - $1 ) . "\">$2<\/font></span>"; + } elsif (/^=item\s*(.*)/s) { + "<span class=\"podhead\">* $1 " . ( "-" x ( 67 - length($1) ) ) . "<\/span>"; + } elsif (/^=(pod|cut)/s) { + "<span class=\"podhead\">" . ( "-" x 70 ) . "<\/span>"; + } elsif (/^=.*/s) { + ""; + } else { + if (/^\s/s) { # Verbatim paragraph + s|^(.*)$|<span class="pod"><code>$1</code></span>|gm; + } else { # Normal paragraph + s|^(.*)$|<span class="pod">$1</span>|gm; + s/C\0\<(.*?)\0\>/<code>$1<\/code>/g; + } + $_; } - $_; - } - } split(/((?:\n[ \t]*)*\n)/, $$comm)); - } - else { + } split( /((?:\n[ \t]*)*\n)/, $$comm ) + ); + } else { $$comm =~ s|^(.*)$|<span class='comment'>$1</span>|gm; } } - sub indexfile { - my ($self, $name, $path, $fileid, $index, $config) = @_; + my ( $self, $name, $path, $fileid, $index, $config ) = @_; + + open( PLTAG, $path ); - open(PLTAG, $path); - while (<PLTAG>) { if (/^sub\s+(\w+)/) { - print(STDERR "Sub: $1\n"); - $index->index($1, $fileid, $., 'f'); - } - elsif (/^package\s+([\w:]+)/) { - print(STDERR "Class: $1\n"); - $index->index($1, $fileid, $., 'c'); - } - elsif (/^=item\s+[\@\$\%\&\*]?(\w+)/) { - print(STDERR "Doc: $1\n"); - $index->index($1, $fileid, $., 'i'); + print( STDERR "Sub: $1\n" ); + $index->index( $1, $fileid, $., 'f' ); + } elsif (/^package\s+([\w:]+)/) { + print( STDERR "Class: $1\n" ); + $index->index( $1, $fileid, $., 'c' ); + } elsif (/^=item\s+[\@\$\%\&\*]?(\w+)/) { + print( STDERR "Doc: $1\n" ); + $index->index( $1, $fileid, $., 'i' ); } } close(PLTAG); Index: Python.pm =================================================================== RCS file: /cvsroot/lxr/lxr/lib/LXR/Lang/Python.pm,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Python.pm 15 Aug 2001 15:50:27 -0000 1.2 +++ Python.pm 19 Jul 2004 19:50:21 -0000 1.3 @@ -11,7 +11,7 @@ # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -27,23 +27,25 @@ use vars qw(@ISA); @ISA = ('LXR::Lang'); -my @spec = ('comment' => ('#', "\$"), - 'string' => ('"', '"'), - 'string' => ("'", "'"), - 'atom' => ('\\\\.', '')); +my @spec = ( + 'comment' => ( '#', "\$" ), + 'string' => ( '"', '"' ), + 'string' => ( "'", "'" ), + 'atom' => ( '\\\\.', '' ) +); sub new { - my ($self, $pathname, $release) = @_; + my ( $self, $pathname, $release ) = @_; - $self = bless({}, $self); + $self = bless( {}, $self ); $$self{'release'} = $release; - if ($pathname =~ /(\w+)\.py$/ || $pathname =~ /(\w+)$/) { + if ( $pathname =~ /(\w+)\.py$/ || $pathname =~ /(\w+)$/ ) { $$self{'modulename'} = $1; } - return $self; + return $self; } sub parsespec { @@ -51,8 +53,8 @@ } sub processcode { - my ($self, $code, @itag) = @_; - + my ( $self, $code, @itag ) = @_; + $$code =~ s/([a-zA-Z_][a-zA-Z0-9_\.]*)/ ($index->issymbol( $$self{'modulename'}.".".$1, $$self{'release'} ) ? join('', @@ -64,36 +66,38 @@ : $1)/ge; } +sub indexfile { + my ( $self, $name, $path, $fileid, $index, $config ) = @_; -sub indexfile { - my ($self, $name, $path, $fileid, $index, $config) = @_; - - my (@ptag_lines, @single_ptag, $module_name); + my ( @ptag_lines, @single_ptag, $module_name ); - if ($name =~ m|/(\w+)\.py$|) { + if ( $name =~ m|/(\w+)\.py$| ) { $module_name = $1; } - - open(PYTAG, $path); - + + open( PYTAG, $path ); + while (<PYTAG>) { chomp; - + # Function definitions if ( $_ =~ /^\s*def\s+([^\(]+)/ ) { - $index->index($module_name."\.$1", $fileid, $., "f"); + $index->index( $module_name . "\.$1", $fileid, $., "f" ); } - # Class definitions + + # Class definitions elsif ( $_ =~ /^\s*class\s+([^\(:]+)/ ) { - $index->index($module_name."\.$1", $fileid, $., "c"); + $index->index( $module_name . "\.$1", $fileid, $., "c" ); } + # Targets that are identifiers if occurring in an assignment.. elsif ( $_ =~ /^(\w+) *=.*/ ) { - $index->index($module_name."\.$1", $fileid, $., "v"); + $index->index( $module_name . "\.$1", $fileid, $., "v" ); } + # ..for loop header. elsif ( $_ =~ /^for\s+(\w+)\s+in.*/ ) { - $index->index($module_name."\.$1", $fileid, $., "v"); + $index->index( $module_name . "\.$1", $fileid, $., "v" ); } } close(PYTAG); |
From: Dave B. <bro...@us...> - 2004-07-19 19:50:36
|
Update of /cvsroot/lxr/lxr/lib/LXR/Files In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7323/lib/LXR/Files Modified Files: CVS.pm Plain.pm Log Message: formatting (with eclipse EPIC plugin which uses PerlTidy. options used: line width 100, cuddle else, use tabs, tab-width 4) Index: CVS.pm =================================================================== RCS file: /cvsroot/lxr/lxr/lib/LXR/Files/CVS.pm,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- CVS.pm 15 Jul 2004 14:41:04 -0000 1.24 +++ CVS.pm 19 Jul 2004 19:50:20 -0000 1.25 @@ -11,7 +11,7 @@ # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -28,9 +28,9 @@ use vars qw(%cvs $cache_filename); sub new { - my ($self, $rootpath) = @_; + my ( $self, $rootpath ) = @_; - $self = bless({}, $self); + $self = bless( {}, $self ); $self->{'rootpath'} = $rootpath; $self->{'rootpath'} =~ s@/*$@/@; @@ -38,32 +38,30 @@ } sub filerev { - my ($self, $filename, $release) = @_; + my ( $self, $filename, $release ) = @_; - if ($release =~ /rev_([\d\.]+)/) { + if ( $release =~ /rev_([\d\.]+)/ ) { return $1; - } - elsif ($release =~ /^([\d\.]+)$/) { + } elsif ( $release =~ /^([\d\.]+)$/ ) { return $1; - } - else { + } else { $self->parsecvs($filename); return $cvs{'header'}{'symbols'}{$release}; } -} +} sub getfiletime { - my ($self, $filename, $release) = @_; + my ( $self, $filename, $release ) = @_; - return undef if $self->isdir($filename, $release); + return undef if $self->isdir( $filename, $release ); $self->parsecvs($filename); - my $rev = $self->filerev($filename, $release); + my $rev = $self->filerev( $filename, $release ); return undef unless defined($rev); - my @t = reverse(split(/\./, $cvs{'branch'}{$rev}{'date'})); + my @t = reverse( split( /\./, $cvs{'branch'}{$rev}{'date'} ) ); return undef unless @t; @@ -72,75 +70,69 @@ } sub getfilesize { - my ($self, $filename, $release) = @_; + my ( $self, $filename, $release ) = @_; - return length($self->getfile($filename, $release)); + return length( $self->getfile( $filename, $release ) ); } sub getfile { - my ($self, $filename, $release) = @_; + my ( $self, $filename, $release ) = @_; - my $fileh = $self->getfilehandle($filename, $release); + my $fileh = $self->getfilehandle( $filename, $release ); return undef unless $fileh; - return join('', $fileh->getlines); + return join( '', $fileh->getlines ); } sub getannotations { - my ($self, $filename, $release) = @_; + my ( $self, $filename, $release ) = @_; $self->parsecvs($filename); - my $rev = $self->filerev($filename, $release); + my $rev = $self->filerev( $filename, $release ); return undef unless defined($rev); my $hrev = $cvs{'header'}{'head'}; my $lrev; my @anno; - my $headfh = $self->getfilehandle($filename, $release); - my @head = $headfh->getlines; + my $headfh = $self->getfilehandle( $filename, $release ); + my @head = $headfh->getlines; while (1) { - if ($rev eq $hrev) { - @head = 0..$#head; + if ( $rev eq $hrev ) { + @head = 0 .. $#head; } - + $lrev = $hrev; $hrev = $cvs{'branch'}{$hrev}{'next'} || last; - - my @diff = $self->getdiff($filename, $lrev, $hrev); - my $off = 0; - + + my @diff = $self->getdiff( $filename, $lrev, $hrev ); + my $off = 0; + while (@diff) { my $dir = shift(@diff); - - if ($dir =~ /^a(\d+)\s+(\d+)/) { - splice(@diff, 0, $2); - splice(@head, $1-$off, 0, ('') x $2); + + if ( $dir =~ /^a(\d+)\s+(\d+)/ ) { + splice( @diff, 0, $2 ); + splice( @head, $1 - $off, 0, ('') x $2 ); $off -= $2; - } - elsif ($dir =~ /^d(\d+)\s+(\d+)/) { - map { - $anno[$_] = $lrev if $_ ne ''; - } splice(@head, $1-$off-1, $2); - + } elsif ( $dir =~ /^d(\d+)\s+(\d+)/ ) { + map { $anno[$_] = $lrev if $_ ne ''; } splice( @head, $1 - $off - 1, $2 ); + $off += $2; - } - else { + } else { warn("Oops! Out of sync!"); } } } - map { - $anno[$_] = $lrev if $_ ne ''; - } @head; + map { $anno[$_] = $lrev if $_ ne ''; } @head; -# print(STDERR "** Anno: ".scalar(@anno).join("\n", '', @anno, '')); + # print(STDERR "** Anno: ".scalar(@anno).join("\n", '', @anno, '')); return @anno; } sub getauthor { - my ($self, $filename, $revision) = @_; + my ( $self, $filename, $revision ) = @_; $self->parsecvs($filename); @@ -148,215 +140,218 @@ } sub getfilehandle { - my ($self, $filename, $release) = @_; + my ( $self, $filename, $release ) = @_; my ($fileh); $self->parsecvs($filename); - my $rev = $self->filerev($filename, $release); + my $rev = $self->filerev( $filename, $release ); return undef unless defined($rev); - return undef unless defined($self->toreal($filename, $release)); + return undef unless defined( $self->toreal( $filename, $release ) ); - $rev =~ /([\d\.]*)/; $rev = $1; # untaint - my $clean_filename = $self->cleanstring($self->toreal($filename, $release)); - $clean_filename =~ /(.*)/; $clean_filename = $1; # technically untaint here (cleanstring did the real untainting) - - $ENV{'PATH'} = '/bin:/usr/local/bin:/usr/bin:/usr/sbin'; - open($fileh, "-|", "co -q -p$rev $clean_filename"); + $rev =~ /([\d\.]*)/; + $rev = $1; # untaint + my $clean_filename = $self->cleanstring( $self->toreal( $filename, $release ) ); + $clean_filename =~ /(.*)/; + $clean_filename = $1; # technically untaint here (cleanstring did the real untainting) - die("Error executing \"co\"; rcs not installed?") unless $fileh; - return $fileh; + $ENV{'PATH'} = '/bin:/usr/local/bin:/usr/bin:/usr/sbin'; + open( $fileh, "-|", "co -q -p$rev $clean_filename" ); + + die("Error executing \"co\"; rcs not installed?") unless $fileh; + return $fileh; } sub getdiff { - my ($self, $filename, $release1, $release2) = @_; + my ( $self, $filename, $release1, $release2 ) = @_; my ($fileh); $self->parsecvs($filename); - my $rev1 = $self->filerev($filename, $release1); + my $rev1 = $self->filerev( $filename, $release1 ); return undef unless defined($rev1); - my $rev2 = $self->filerev($filename, $release2); + my $rev2 = $self->filerev( $filename, $release2 ); return undef unless defined($rev2); - $rev1 =~ /([\d\.]*)/; $rev1 = $1; # untaint - $rev2 =~ /([\d\.]*)/; $rev2 = $1; # untaint - my $clean_filename = $self->cleanstring($self->toreal($filename, $release1)); - $clean_filename =~ /(.*)/; $clean_filename = $1; # technically untaint here (cleanstring did the real untainting) - + $rev1 =~ /([\d\.]*)/; + $rev1 = $1; # untaint + $rev2 =~ /([\d\.]*)/; + $rev2 = $1; # untaint + my $clean_filename = $self->cleanstring( $self->toreal( $filename, $release1 ) ); + $clean_filename =~ /(.*)/; + $clean_filename = $1; # technically untaint here (cleanstring did the real untainting) + $ENV{'PATH'} = '/bin:/usr/local/bin:/usr/bin:/usr/sbin'; - open($fileh, "-|", "rcsdiff -q -a -n -r$rev1 -r$rev2 $clean_filename"); + open( $fileh, "-|", "rcsdiff -q -a -n -r$rev1 -r$rev2 $clean_filename" ); die("Error executing \"rcsdiff\"; rcs not installed?") unless $fileh; return $fileh->getlines; } sub tmpfile { - my ($self, $filename, $release) = @_; - my ($tmp, $buf); + my ( $self, $filename, $release ) = @_; + my ( $tmp, $buf ); - $buf = $self->getfile($filename, $release); + $buf = $self->getfile( $filename, $release ); return undef unless defined($buf); - - $tmp = $config->tmpdir.'/lxrtmp.'.time.'.'.$$.'.'.&LXR::Common::tmpcounter; - open(TMP, "> $tmp") || return undef; - print(TMP $buf); + + $tmp = $config->tmpdir . '/lxrtmp.' . time . '.' . $$ . '.' . &LXR::Common::tmpcounter; + open( TMP, "> $tmp" ) || return undef; + print( TMP $buf ); close(TMP); - + return $tmp; } sub dirempty { - my ($self, $pathname, $release) = @_; - my ($node, @dirs, @files); + my ( $self, $pathname, $release ) = @_; + my ( $node, @dirs, @files ); my $DIRH = new IO::Handle; - my $real = $self->toreal($pathname, $release); + my $real = $self->toreal( $pathname, $release ); - opendir($DIRH, $real) || return 1; - while (defined($node = readdir($DIRH))) { + opendir( $DIRH, $real ) || return 1; + while ( defined( $node = readdir($DIRH) ) ) { next if $node =~ /^\.|~$|\.orig$/; next if $node eq 'CVS'; - if (-d $real.$node) { - push(@dirs, $node.'/'); - } - elsif ($node =~ /(.*),v$/) { - push(@files, $1); + if ( -d $real . $node ) { + push( @dirs, $node . '/' ); + } elsif ( $node =~ /(.*),v$/ ) { + push( @files, $1 ); } } closedir($DIRH); foreach $node (@files) { - return 0 if $self->filerev($pathname.$node, $release); + return 0 if $self->filerev( $pathname . $node, $release ); } foreach $node (@dirs) { - return 0 unless $self->dirempty($pathname.$node, $release); + return 0 unless $self->dirempty( $pathname . $node, $release ); } return 1; } sub getdir { - my ($self, $pathname, $release) = @_; - my ($node, @dirs, @files); + my ( $self, $pathname, $release ) = @_; + my ( $node, @dirs, @files ); my $DIRH = new IO::Handle; - my $real = $self->toreal($pathname, $release); + my $real = $self->toreal( $pathname, $release ); - opendir($DIRH, $real) || return (); - FILE: while (defined($node = readdir($DIRH))) { + opendir( $DIRH, $real ) || return (); + FILE: while ( defined( $node = readdir($DIRH) ) ) { next if $node =~ /^\.|~$|\.orig$/; next if $node eq 'CVS'; - if (-d $real.$node) { - foreach my $ignoredir ($config->ignoredirs) { + if ( -d $real . $node ) { + foreach my $ignoredir ( $config->ignoredirs ) { next FILE if $node eq $ignoredir; } - if ($node eq 'Attic') { - push(@files, $self->getdir($pathname.$node.'/', $release)); - } - else { - push(@dirs, $node.'/') - unless defined($release) - && $self->dirempty($pathname.$node.'/', $release); + if ( $node eq 'Attic' ) { + push( @files, $self->getdir( $pathname . $node . '/', $release ) ); + } else { + push( @dirs, $node . '/' ) + unless defined($release) + && $self->dirempty( $pathname . $node . '/', $release ); } - } - elsif ($node =~ /(.*),v$/) { - if (!$$LXR::Common::HTTP{'param'}{'showattic'}) { - # you can't just check for 'Attic' because for certain versions the file is alive even if in Attic - $self->parsecvs($pathname.substr($node,0, length($node)-2)); # substr is to remove the ',v' + } elsif ( $node =~ /(.*),v$/ ) { + if ( !$$LXR::Common::HTTP{'param'}{'showattic'} ) { + + # you can't just check for 'Attic' because for certain versions the file is alive even if in Attic + $self->parsecvs( $pathname . substr( $node, 0, length($node) - 2 ) ) + ; # substr is to remove the ',v' my $rev = $cvs{'header'}{'symbols'}{$release}; - if ($cvs{'branch'}{$rev}{'state'} eq "dead") { + if ( $cvs{'branch'}{$rev}{'state'} eq "dead" ) { next; } } - push(@files, $1) - if ! defined($release) - || $self->getfiletime($pathname.$1, $release); + push( @files, $1 ) + if !defined($release) + || $self->getfiletime( $pathname . $1, $release ); } } closedir($DIRH); - return (sort(@dirs), sort(@files)); + return ( sort(@dirs), sort(@files) ); } sub toreal { - my ($self, $pathname, $release) = @_; - my $real = $self->{'rootpath'}.$pathname; + my ( $self, $pathname, $release ) = @_; + my $real = $self->{'rootpath'} . $pathname; - # nearly all (if not all) method calls eventually call toreal(), so this is a good place to block file access - foreach my $ignoredir ($config->ignoredirs) { +# nearly all (if not all) method calls eventually call toreal(), so this is a good place to block file access + foreach my $ignoredir ( $config->ignoredirs ) { return undef if $real =~ m|/$ignoredir/|; } return $real if -d $real; - - if (!$$LXR::Common::HTTP{'param'}{'showattic'}) { - # you can't just check for 'Attic' because for certain versions the file is alive even if in Attic + + if ( !$$LXR::Common::HTTP{'param'}{'showattic'} ) { + + # you can't just check for 'Attic' because for certain versions the file is alive even if in Attic $self->parsecvs($pathname); my $rev = $cvs{'header'}{'symbols'}{$release}; - if ($cvs{'branch'}{$rev}{'state'} eq "dead") { + if ( $cvs{'branch'}{$rev}{'state'} eq "dead" ) { return undef; } } - return $real.',v' if -f $real.',v'; - + return $real . ',v' if -f $real . ',v'; + $real =~ s|(/[^/]+/?)$|/Attic$1|; - return $real if -d $real; - return $real.',v' if -f $real.',v'; + return $real if -d $real; + return $real . ',v' if -f $real . ',v'; return undef; } - sub cleanstring { - my ($self, $in) = @_; + my ( $self, $in ) = @_; - my $out = ''; + my $out = ''; - for (split('',$in)) { - s/[|&!`;\$%<>[:cntrl:]]// || # drop these in particular - /[\w\/,.-_+=]/ || # keep these intact - s/([ '"\x20-\x7E])/\\$1/ || # escape these out - s/.//; # drop everything else + for ( split( '', $in ) ) { + s/[|&!`;\$%<>[:cntrl:]]// || # drop these in particular + /[\w\/,.-_+=]/ || # keep these intact + s/([ '"\x20-\x7E])/\\$1/ || # escape these out + s/.//; # drop everything else - $out .= $_; - } + $out .= $_; + } - return $out; + return $out; } - sub isdir { - my ($self, $pathname, $release) = @_; + my ( $self, $pathname, $release ) = @_; - return -d $self->toreal($pathname, $release); + return -d $self->toreal( $pathname, $release ); } sub isfile { - my ($self, $pathname, $release) = @_; + my ( $self, $pathname, $release ) = @_; - return -f $self->toreal($pathname, $release); + return -f $self->toreal( $pathname, $release ); } sub getindex { - my ($self, $pathname, $release) = @_; + my ( $self, $pathname, $release ) = @_; - my $index = $self->getfile($pathname, $release); + my $index = $self->getfile( $pathname, $release ); return $index =~ /\n(\S*)\s*\n\t-\s*([^\n]*)/gs; } sub allreleases { - my ($self, $filename) = @_; + my ( $self, $filename ) = @_; $self->parsecvs($filename); # no header symbols for a directory, so we use the default and the current release - if (defined %{$cvs{'header'}{'symbols'}}) { - return sort keys %{$cvs{'header'}{'symbols'}}; + if ( defined %{ $cvs{'header'}{'symbols'} } ) { + return sort keys %{ $cvs{'header'}{'symbols'} }; } else { my @releases; push @releases, $$LXR::Common::HTTP{'param'}{'v'} if $$LXR::Common::HTTP{'param'}{'v'}; @@ -366,18 +361,19 @@ } sub allrevisions { - my ($self, $filename) = @_; + my ( $self, $filename ) = @_; $self->parsecvs($filename); - - return sort(keys(%{$cvs{'branch'}})); + + return sort( keys( %{ $cvs{'branch'} } ) ); } sub parsecvs { + # Actually, these days it just parses the header. # RCS tools are much better at parsing RCS files. # -pok - my ($self, $filename) = @_; + my ( $self, $filename ) = @_; return if $cache_filename eq $filename; $cache_filename = $filename; @@ -385,46 +381,52 @@ undef %cvs; my $file = ''; - open (CVS, $self->toreal($filename, undef)); - close CVS and return if -d CVS; # we can't parse a directory + open( CVS, $self->toreal( $filename, undef ) ); + close CVS and return if -d CVS; # we can't parse a directory while (<CVS>) { if (/^text\s*$/) { + # stop reading when we hit the text. last; } $file .= $_; } - close (CVS); + close(CVS); my @cvs = $file =~ /((?:(?:[^\n@]+|@[^@]*@)\n?)+)/gs; - $cvs{'header'} = { map { s/@@/@/gs; - /^@/s && substr($_, 1, -1) || $_ } - shift(@cvs) =~ /(\w+)\s*((?:[^;@]+|@[^@]*@)*);/gs }; + $cvs{'header'} = { + map { + s/@@/@/gs; + /^@/s && substr( $_, 1, -1 ) || $_ + } shift(@cvs) =~ /(\w+)\s*((?:[^;@]+|@[^@]*@)*);/gs + }; - $cvs{'header'}{'symbols'} - = { $cvs{'header'}{'symbols'} =~ /(\S+?):(\S+)/g }; - - my ($orel, $nrel, $rev); - while (($orel, $rev) = each %{$cvs{'header'}{'symbols'}}) { + $cvs{'header'}{'symbols'} = { $cvs{'header'}{'symbols'} =~ /(\S+?):(\S+)/g }; + + my ( $orel, $nrel, $rev ); + while ( ( $orel, $rev ) = each %{ $cvs{'header'}{'symbols'} } ) { $nrel = $config->cvsversion($orel); next unless defined($nrel); - if ($nrel ne $orel) { - delete($cvs{'header'}{'symbols'}{$orel}); + if ( $nrel ne $orel ) { + delete( $cvs{'header'}{'symbols'}{$orel} ); $cvs{'header'}{'symbols'}{$nrel} = $rev if $nrel; } } $cvs{'header'}{'symbols'}{'head'} = $cvs{'header'}{'head'}; - while (@cvs && $cvs[0] !~ /\s*desc/s) { - my ($r, $v) = shift(@cvs) =~ /\s*(\S+)\s*(.*)/s; - $cvs{'branch'}{$r} = { map { s/@@/@/gs; - /^@/s && substr($_, 1, -1) || $_ } - $v =~ /(\w+)\s*((?:[^;@]+|@[^@]*@)*);/gs }; + while ( @cvs && $cvs[0] !~ /\s*desc/s ) { + my ( $r, $v ) = shift(@cvs) =~ /\s*(\S+)\s*(.*)/s; + $cvs{'branch'}{$r} = { + map { + s/@@/@/gs; + /^@/s && substr( $_, 1, -1 ) || $_ + } $v =~ /(\w+)\s*((?:[^;@]+|@[^@]*@)*);/gs + }; } - delete $cvs{'branch'}{''}; # somehow an empty branch name gets in; delete it + delete $cvs{'branch'}{''}; # somehow an empty branch name gets in; delete it $cvs{'desc'} = shift(@cvs) =~ /\s*desc\s+((?:[^\n@]+|@[^@]*@)*)\n/s; $cvs{'desc'} =~ s/^@|@($|@)/$1/gs; Index: Plain.pm =================================================================== RCS file: /cvsroot/lxr/lxr/lib/LXR/Files/Plain.pm,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- Plain.pm 15 Jul 2004 15:08:04 -0000 1.22 +++ Plain.pm 19 Jul 2004 19:50:21 -0000 1.23 @@ -11,7 +11,7 @@ # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -25,9 +25,9 @@ use LXR::Common; sub new { - my ($self, $rootpath) = @_; + my ( $self, $rootpath ) = @_; - $self = bless({}, $self); + $self = bless( {}, $self ); $self->{'rootpath'} = $rootpath; $self->{'rootpath'} =~ s@/*$@/@; @@ -35,56 +35,57 @@ } sub filerev { - my ($self, $filename, $release) = @_; + my ( $self, $filename, $release ) = @_; -# return $release; - return join("-", $self->getfiletime($filename, $release), - $self->getfilesize($filename, $release)); -} + # return $release; + return join( "-", + $self->getfiletime( $filename, $release ), + $self->getfilesize( $filename, $release ) ); +} sub getfiletime { - my ($self, $filename, $release) = @_; + my ( $self, $filename, $release ) = @_; - return (stat($self->toreal($filename, $release)))[9]; + return ( stat( $self->toreal( $filename, $release ) ) )[9]; } sub getfilesize { - my ($self, $filename, $release) = @_; + my ( $self, $filename, $release ) = @_; - return -s $self->toreal($filename, $release); + return -s $self->toreal( $filename, $release ); } sub getfile { - my ($self, $filename, $release) = @_; + my ( $self, $filename, $release ) = @_; my ($buffer); local ($/) = undef; - open(FILE, "<", $self->toreal($filename, $release)) || return undef; + open( FILE, "<", $self->toreal( $filename, $release ) ) || return undef; $buffer = <FILE>; close(FILE); return $buffer; } sub getfilehandle { - my ($self, $filename, $release) = @_; + my ( $self, $filename, $release ) = @_; my ($fileh); - $fileh = new FileHandle($self->toreal($filename, $release)); + $fileh = new FileHandle( $self->toreal( $filename, $release ) ); return $fileh; } sub tmpfile { - my ($self, $filename, $release) = @_; - my ($tmp, $tries); + my ( $self, $filename, $release ) = @_; + my ( $tmp, $tries ); local ($/) = undef; - $tmp = $config->tmpdir.'/lxrtmp.'.time.'.'.$$.'.'.&LXR::Common::tmpcounter; - open(TMP, "> $tmp") || return undef; - open(FILE, "<", $self->toreal($filename, $release)) || return undef; - print(TMP <FILE>); + $tmp = $config->tmpdir . '/lxrtmp.' . time . '.' . $$ . '.' . &LXR::Common::tmpcounter; + open( TMP, "> $tmp" ) || return undef; + open( FILE, "<", $self->toreal( $filename, $release ) ) || return undef; + print( TMP <FILE> ); close(FILE); close(TMP); - + return $tmp; } @@ -97,23 +98,22 @@ } sub getdir { - my ($self, $pathname, $release) = @_; - my ($dir, $node, @dirs, @files); + my ( $self, $pathname, $release ) = @_; + my ( $dir, $node, @dirs, @files ); - $dir = $self->toreal($pathname, $release); - opendir(DIR, $dir) || return (); - FILE: while (defined($node = readdir(DIR))) { + $dir = $self->toreal( $pathname, $release ); + opendir( DIR, $dir ) || return (); + FILE: while ( defined( $node = readdir(DIR) ) ) { next if $node =~ /^\.|~$|\.orig$/; next if $node eq 'CVS'; - if (-d $dir.$node) { - foreach my $ignoredir ($config->ignoredirs) { + if ( -d $dir . $node ) { + foreach my $ignoredir ( $config->ignoredirs ) { next FILE if $node eq $ignoredir; } - push(@dirs, $node.'/'); - } - else { - push(@files, $node); + push( @dirs, $node . '/' ); + } else { + push( @files, $node ); } } closedir(DIR); @@ -127,37 +127,37 @@ # other possible File classes.) sub toreal { - my ($self, $pathname, $release) = @_; - - # nearly all (if not all) method calls eventually call toreal(), so this is a good place to block file access - foreach my $ignoredir ($config->ignoredirs) { + my ( $self, $pathname, $release ) = @_; + +# nearly all (if not all) method calls eventually call toreal(), so this is a good place to block file access + foreach my $ignoredir ( $config->ignoredirs ) { return undef if $pathname =~ m|/$ignoredir/|; } - return ($self->{'rootpath'}.$release.$pathname); + return ( $self->{'rootpath'} . $release . $pathname ); } sub isdir { - my ($self, $pathname, $release) = @_; + my ( $self, $pathname, $release ) = @_; - return -d $self->toreal($pathname, $release); + return -d $self->toreal( $pathname, $release ); } sub isfile { - my ($self, $pathname, $release) = @_; + my ( $self, $pathname, $release ) = @_; - return -f $self->toreal($pathname, $release); + return -f $self->toreal( $pathname, $release ); } sub getindex { - my ($self, $pathname, $release) = @_; - my ($index, %index); - my $indexname = $self->toreal($pathname, $release)."00-INDEX"; + my ( $self, $pathname, $release ) = @_; + my ( $index, %index ); + my $indexname = $self->toreal( $pathname, $release ) . "00-INDEX"; - if (-f $indexname) { - open(INDEX, "<", $indexname) || - warning("Existing $indexname could not be opened."); - local($/) = undef; + if ( -f $indexname ) { + open( INDEX, "<", $indexname ) + || warning("Existing $indexname could not be opened."); + local ($/) = undef; $index = <INDEX>; %index = $index =~ /\n(\S*)\s*\n\t-\s*([^\n]*)/gs; @@ -166,14 +166,13 @@ } sub allreleases { - my ($self, $filename) = @_; + my ( $self, $filename ) = @_; - opendir(SRCDIR, $self->{'rootpath'}); + opendir( SRCDIR, $self->{'rootpath'} ); my @dirs = readdir(SRCDIR); closedir(SRCDIR); - return grep { /^[^\.]/ && -r $self->toreal($filename, $_) } @dirs; + return grep { /^[^\.]/ && -r $self->toreal( $filename, $_ ) } @dirs; } - 1; |
From: Dave B. <bro...@us...> - 2004-07-19 19:50:34
|
Update of /cvsroot/lxr/lxr In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7323 Modified Files: Local.pm diff find genxref ident search source Log Message: formatting (with eclipse EPIC plugin which uses PerlTidy. options used: line width 100, cuddle else, use tabs, tab-width 4) Index: Local.pm =================================================================== RCS file: /cvsroot/lxr/lxr/Local.pm,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- Local.pm 14 Jul 2004 14:42:28 -0000 1.18 +++ Local.pm 19 Jul 2004 19:50:20 -0000 1.19 @@ -15,7 +15,7 @@ # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -31,7 +31,7 @@ $CVSID = '$Id$ '; require Exporter; -@ISA = qw(Exporter); +@ISA = qw(Exporter); @EXPORT = qw(&fdescexpand &descexpand &dirdesc &convertwhitespace); use LXR::Common qw(:html); @@ -40,28 +40,28 @@ # If no description, return the string "\ \;" to keep the # table looking pretty. # -# In mozilla search the beginning of a source file for a short -# description. Not all files have them and the ones that do use +# In mozilla search the beginning of a source file for a short +# description. Not all files have them and the ones that do use # many different formats. Try to find as many of these without # printing gobbeldygook or something silly like a file name or a date. # -# Read in the beginning of the file into a string. I chose 60 because the -# Berkeley copyright notice is around 40 lines long so we need a bit more +# Read in the beginning of the file into a string. I chose 60 because the +# Berkeley copyright notice is around 40 lines long so we need a bit more # than this. # # Its common for file descriptions to be delimited by the file name or # the word "Description" which preceeds the description. Search the entire # string for these. Sometimes they're put in odd places such as inside # the copyright notice or after the code begins. The file name should be -# followed by a colon or some pattern of dashes. +# followed by a colon or some pattern of dashes. # # If no such description is found then use the contents of the "first" # comment as the description. First, strip off the copyright notice plus # anything before it. Remove rcs comments. Search for the first bit of # code (usually #include) and remove it plus anything after it. In what's # left, find the contents of the first comment, and get the first paragraph. -# If that's too long, use only the first sentence up to a period. If that's -# still too long then we probably have a list or something that will look +# If that's too long, use only the first sentence up to a period. If that's +# still too long then we probably have a list or something that will look # strange if we print it out so give up and return null. # # Yes, this is a lot of trouble to go through but its easier than getting @@ -72,397 +72,400 @@ # Yea, though I walk through the valley of the shadow of pattern # matching, I shall fear no regex. sub fdescexpand { - my $filename = shift; - my $dir = shift; - my $release = shift; - my $linecount=0; - my $copy= ""; - local $desc= ""; - my $maxlines = 40; #only look at the beginning of the file + my $filename = shift; + my $dir = shift; + my $release = shift; + my $linecount = 0; + my $copy = ""; + local $desc = ""; + my $maxlines = 40; #only look at the beginning of the file - #ignore files that aren't source code - if (!( - ($filename =~ /\.c$/) | - ($filename =~ /\.h$/) | - ($filename =~ /\.cc$/) | - ($filename =~ /\.cp$/) | - ($filename =~ /\.cpp$/) | - ($filename =~ /\.java$/) - )){ - return("\ \;"); - } + #ignore files that aren't source code + if ( + !( + ( $filename =~ /\.c$/ ) | ( $filename =~ /\.h$/ ) | ( $filename =~ /\.cc$/ ) | + ( $filename =~ /\.cp$/ ) | ( $filename =~ /\.cpp$/ ) | ( $filename =~ /\.java$/ ) + ) + ) + { + return ("\ \;"); + } + if ( $fh = $files->getfilehandle( $dir . $filename, $release ) ) { + while (<$fh>) { + $desc = $desc . $_; + if ( $linecount++ > 60 ) { + last; + } + } + close($file); + } - if ($fh = $files->getfilehandle($dir.$filename, $release)) { - while(<$fh>){ - $desc = $desc . $_ ; - if($linecount++ > 60) { - last; - } + # sanity check: if there's no description then stop + if ( !( $desc =~ /\w/ ) ) { + return ("\ \;"); } - close($file); - } - # sanity check: if there's no description then stop - if (!($desc =~ /\w/)){ - return("\ \;"); - } + # if a java file, only consider class-level javadoc comments + if ( $filename =~ /\.java$/ ) { + # last /** ... */ before 'public class' or 'public interface' + + # find declaration + $desc =~ m/public\s((abstract|static|final|strictfp)\s)*(class|interface)/g; + $declPos = pos $desc; + return "\ \;" if !$declPos; + + # last comment start before declaration + pos $desc = 0; + $commentStart = -1; + while ( $desc =~ m#/\*\*#g ) { + last if $declPos < pos $desc; + $commentStart = pos $desc; + } + return "\ \;" if $commentStart == -1; + + # find comment end, and extract + pos $desc = $commentStart; + $desc =~ m#\*/#g; + $commentEnd = pos $desc; + $desc = substr( $desc, $commentStart + 3, $commentEnd - $commentStart - 5 ); + + return "\ \;" if !$desc; + + # strip off any leading * s + $desc =~ s/^\s*\*\s?//mg; + + # Strip off @parameter lines + $desc =~ s/^\s*@\w+.*$//mg; + + # strip html tags (probably a way to do this all in one, but it's beyond my skill) + $desc =~ s#<[/\w]+(\s*\w+="[\w\s]*"\s*)*>##g; # double quoted attributes + $desc =~ s#<[/\w]+(\s*\w+='[\w\s]*'\s*)*>##g; # single quoted attributes + $desc =~ s#<[/\w]+(\s*\w+=[\w]*\s*)*>##g; # no quotes on attributes + + # strip off some CVS keyword lines + foreach $keyword ( 'Workfile', 'Revision', 'Modtime', 'Author', 'Id', 'Date', 'Source', + 'RCSfile' ) + { + $desc =~ s/^\s*\$$keyword[\$:].*$//mg; + } - # if a java file, only consider class-level javadoc comments - if ($filename =~ /\.java$/) { - # last /** ... */ before 'public class' or 'public interface' - - # find declaration - $desc =~ m/public\s((abstract|static|final|strictfp)\s)*(class|interface)/g; - $declPos = pos $desc; - return "\ \;" if ! $declPos; - - # last comment start before declaration - pos $desc = 0; - $commentStart = -1; - while ($desc =~ m#/\*\*#g) { - last if $declPos < pos $desc; - $commentStart = pos $desc; } - return "\ \;" if $commentStart == -1; - # find comment end, and extract - pos $desc = $commentStart; - $desc =~ m#\*/#g; - $commentEnd = pos $desc; - $desc = substr($desc,$commentStart+3, $commentEnd-$commentStart - 5); - - return "\ \;" if ! $desc; - - # strip off any leading * s - $desc =~ s/^\s*\*\s?//mg; - - # Strip off @parameter lines - $desc =~ s/^\s*@\w+.*$//mg; - - # strip html tags (probably a way to do this all in one, but it's beyond my skill) - $desc =~ s#<[/\w]+(\s*\w+="[\w\s]*"\s*)*>##g; # double quoted attributes - $desc =~ s#<[/\w]+(\s*\w+='[\w\s]*'\s*)*>##g; # single quoted attributes - $desc =~ s#<[/\w]+(\s*\w+=[\w]*\s*)*>##g; # no quotes on attributes - - # strip off some CVS keyword lines - foreach $keyword ('Workfile', 'Revision', 'Modtime', 'Author', 'Id', 'Date', 'Source', 'RCSfile') + # save a copy for later + $copy = $desc; + + # Look for well behaved <filename><seperator> formatted + # descriptions before we go to the trouble of looking for + # one in the first comment. The whitespace between the + # delimeter and the description may include a newline. + if ( ( $desc =~ s/(?:.*?$filename\s*?- ?-*\s*)([^\n]*)(?:.*)/$1/sgi ) + || ( $desc =~ s/(?:.*?$filename\s*?:\s*)([^\n]*)(?:.*)/$1/sgi ) + || ( $desc =~ s/(?:.*?Description:\s*)([^\n]*)(?:.*)/$1/sgi ) ) { - $desc =~ s/^\s*\$$keyword[\$:].*$//mg; - } - - } - # save a copy for later - $copy = $desc; + # if the description is non-empty then clean it up and return it + if ( $desc =~ /\w/ ) { - # Look for well behaved <filename><seperator> formatted - # descriptions before we go to the trouble of looking for - # one in the first comment. The whitespace between the - # delimeter and the description may include a newline. - if (($desc =~ s/(?:.*?$filename\s*?- ?-*\s*)([^\n]*)(?:.*)/$1/sgi) || - ($desc =~ s/(?:.*?$filename\s*?:\s*)([^\n]*)(?:.*)/$1/sgi) || - ($desc =~ s/(?:.*?Description:\s*)([^\n]*)(?:.*)/$1/sgi) - ){ - # if the description is non-empty then clean it up and return it - if ($desc =~ /\w/) { - #strip trailing asterisks and "*/" - $desc =~ s#\*/?\s*$##; - $desc =~ s#^[^\S]*\**[^\S]*#\n#gs; + #strip trailing asterisks and "*/" + $desc =~ s#\*/?\s*$##; + $desc =~ s#^[^\S]*\**[^\S]*#\n#gs; - # Strip beginning and trailing whitespace - $desc =~ s/^\s+//; - $desc =~ s/\s+$//; + # Strip beginning and trailing whitespace + $desc =~ s/^\s+//; + $desc =~ s/\s+$//; - # Strip junk from the beginning - $desc =~ s#[^\w]*##ms; + # Strip junk from the beginning + $desc =~ s#[^\w]*##ms; - #htmlify the comments making links to symbols and files - $desc = markupstring($desc, $Path->{'virt'}); - return($desc); - } - } - - # if java and the <filename><seperator> check above didn't work, just dump the whole javadoc - if ($filename =~ /\.java$/) { - return $desc; - } + #htmlify the comments making links to symbols and files + $desc = markupstring( $desc, $Path->{'virt'} ); + return ($desc); + } + } - # we didn't find any well behaved descriptions above so start over - # and look for one in the first comment - $desc = $copy; + # if java and the <filename><seperator> check above didn't work, just dump the whole javadoc + if ( $filename =~ /\.java$/ ) { + return $desc; + } - # Strip off code from the end, starting at the first cpp directive - $desc =~ s/\n#.*//s; + # we didn't find any well behaved descriptions above so start over + # and look for one in the first comment + $desc = $copy; - # Strip off code from the end, starting at typedef - $desc =~ s/\ntypedef.*//s; + # Strip off code from the end, starting at the first cpp directive + $desc =~ s/\n#.*//s; - # Strip off license - $desc =~ s#(?:/\*.*license.*?\*/)(.*)#$1#is; + # Strip off code from the end, starting at typedef + $desc =~ s/\ntypedef.*//s; - # Strip off copyright notice - $desc =~ s#(?:/\*.*copyright.*?\*/)(.*)#$1#is; + # Strip off license + $desc =~ s#(?:/\*.*license.*?\*/)(.*)#$1#is; - # Strip off emacs line - $desc =~ s#(/\*.*tab-width.*?\*/)(.*)#$2#isg; + # Strip off copyright notice + $desc =~ s#(?:/\*.*copyright.*?\*/)(.*)#$1#is; - # excise rcs crud - $desc =~ s#Id: $filename.*?Exp \$##g; + # Strip off emacs line + $desc =~ s#(/\*.*tab-width.*?\*/)(.*)#$2#isg; - # Yuck, nuke these silly comments in js/jsj /* ** */ - $desc =~ s#\n\s*/\*+[\s\*]+\*/\n#\n#sg; - - # Don't bother to continue if there aren't any comments here - if(!($desc =~ m#/\*#)) { - return(" "); - } + # excise rcs crud + $desc =~ s#Id: $filename.*?Exp \$##g; - # Remove lines generated by jmc - $desc =~ s#\n.*?Source date:.*\n#\n#; - $desc =~ s#\n.*?Generated by jmc.*\n#\n#; + # Yuck, nuke these silly comments in js/jsj /* ** */ + $desc =~ s#\n\s*/\*+[\s\*]+\*/\n#\n#sg; - # Extract the first comment - $desc =~ s#(?:.*?/\*+)(.*?)(?:(?:\*+/.*)|(?:$))#$1#s; + # Don't bother to continue if there aren't any comments here + if ( !( $desc =~ m#/\*# ) ) { + return (" "); + } - # Strip silly borders - $desc =~ s#\n\s*[\*\=\-\s]+#\n#sg; + # Remove lines generated by jmc + $desc =~ s#\n.*?Source date:.*\n#\n#; + $desc =~ s#\n.*?Generated by jmc.*\n#\n#; - # Strip beginning and trailing whitespace - $desc =~ s/^\s+//; - $desc =~ s/\s+$//; + # Extract the first comment + $desc =~ s#(?:.*?/\*+)(.*?)(?:(?:\*+/.*)|(?:$))#$1#s; - # Strip out file name - $desc =~ s#$filename##i; + # Strip silly borders + $desc =~ s#\n\s*[\*\=\-\s]+#\n#sg; - # Strip By line - $desc =~ s#By [^\n]*##; + # Strip beginning and trailing whitespace + $desc =~ s/^\s+//; + $desc =~ s/\s+$//; - # Strip out dates - $desc =~ s#\d{1,2}/\d{1,2}/\d\d\d\d##; - $desc =~ s#\d{1,2}/\d{1,2}/\d\d##; - $desc =~ s#\d{1,2} \w\w\w \d\d\d\d##; + # Strip out file name + $desc =~ s#$filename##i; - # Strip junk from the beginning - $desc =~ s#[^\w]*##; + # Strip By line + $desc =~ s#By [^\n]*##; - # Extract the first paragraph - $desc =~ s#(\n\s*?\n.*)##s; + # Strip out dates + $desc =~ s#\d{1,2}/\d{1,2}/\d\d\d\d##; + $desc =~ s#\d{1,2}/\d{1,2}/\d\d##; + $desc =~ s#\d{1,2} \w\w\w \d\d\d\d##; - # If the description is too long then just use the first sentence - # this will fail if no period was used. - if (length($desc) > 200 ) { - $desc =~ s#([^\.]+\.)\s.*#$1#s; - } + # Strip junk from the beginning + $desc =~ s#[^\w]*##; - # If the description is still too long then assume it will look - # like gobbeldygook and give up - if (length($desc) > 200 ) { - return(" "); - } + # Extract the first paragraph + $desc =~ s#(\n\s*?\n.*)##s; - # htmlify the comments, making links to symbols and files - $desc = markupstring($desc, $Path->{'virt'}); + # If the description is too long then just use the first sentence + # this will fail if no period was used. + if ( length($desc) > 200 ) { + $desc =~ s#([^\.]+\.)\s.*#$1#s; + } - if ($desc) { - return($desc); - } - else { - return("\ \;"); - } -} + # If the description is still too long then assume it will look + # like gobbeldygook and give up + if ( length($desc) > 200 ) { + return (" "); + } + # htmlify the comments, making links to symbols and files + $desc = markupstring( $desc, $Path->{'virt'} ); + if ($desc) { + return ($desc); + } else { + return ("\ \;"); + } +} # dme: create a short description for a subdirectory in a directory listing # If no description, return the string "\ \;" to keep the # table looking pretty. # -# In Mozilla, if the directory has a README file look in it for lines +# In Mozilla, if the directory has a README file look in it for lines # like the ones used in source code: "directoryname --- A short description" sub descexpand { - my ($templ, $node, $dir, $release) = @_; - if ($files->isdir($dir . $node, $release)) { - return LXR::Common::expandtemplate($templ, - ('desctext' => - sub { return dirdesc($dir.$node, $release); })); - } else { - return LXR::Common::expandtemplate($templ, - ('desctext' => - sub { return fdescexpand($node, $dir, $release); })); - } + my ( $templ, $node, $dir, $release ) = @_; + if ( $files->isdir( $dir . $node, $release ) ) { + return LXR::Common::expandtemplate( $templ, + ( 'desctext' => sub { return dirdesc( $dir . $node, $release ); } ) ); + } else { + return LXR::Common::expandtemplate( $templ, + ( 'desctext' => sub { return fdescexpand( $node, $dir, $release ); } ) ); + } } -# dme: Print a descriptive blurb in directory listings between +# dme: Print a descriptive blurb in directory listings between # the document heading and the table containing the actual listing. # # For Mozilla, we extract this information from the README file if # it exists. If the file is short then just print the whole thing. -# For longer files print the first paragraph or so. As much as -# possible make this work for randomly formatted files rather than +# For longer files print the first paragraph or so. As much as +# possible make this work for randomly formatted files rather than # inventing strict rules which create gobbeldygook when they're broken. sub dirdesc { - my ($path, $release) = @_; - if ($files->isfile($path."README.txt", $release)) { - descreadme($path."README.txt", $release); - } elsif ($files->isfile($path."README", $release)) { - descreadme($path."README", $release); - } elsif ($files->isfile($path."README.html", $release)) { - descreadmehtml($path."README.html", $release); - } + my ( $path, $release ) = @_; + if ( $files->isfile( $path . "README.txt", $release ) ) { + descreadme( $path . "README.txt", $release ); + } elsif ( $files->isfile( $path . "README", $release ) ) { + descreadme( $path . "README", $release ); + } elsif ( $files->isfile( $path . "README.html", $release ) ) { + descreadmehtml( $path . "README.html", $release ); + } } - sub descreadmehtml { - my ($file, $release) = @_; + my ( $file, $release ) = @_; - my $string = ""; - return if !($desc = $files->getfilehandle($file, $release)); -# undef $/; - $string = <$desc>; -# $/ = "\n"; - close($desc); + my $string = ""; + return if !( $desc = $files->getfilehandle( $file, $release ) ); - # if the README is 0 length then give up - if (!$string) { - return; - } + # undef $/; + $string = <$desc>; - # check if there's a short desc nested inside the long desc. If not, do - # a non-greedy search for a long desc. assume there are no other stray - # spans within the description. - if ($string =~ /<span class=["']?lxrlongdesc['"]?>(.*?<span class=["']?lxrshortdesc['"]?>.*?<\/span>.*?)<\/span>/is) { - $long = $1; - if (!($long =~ /<span.*?\<span/is)) { - return($long . "<p>\nSEE ALSO: <a href=\"README.html\">README</a></p>\n"); - } - } elsif ($string =~ /<span class=["']?lxrlongdesc['"]?>(.*?)<\/span>/is) { - $long = $1; - if (!($long =~ /\<span/is)) { - return($long . "<p>\nSEE ALSO: <a href=\"README.html\">README</a></p>\n"); - } - } + # $/ = "\n"; + close($desc); + + # if the README is 0 length then give up + if ( !$string ) { + return; + } + + # check if there's a short desc nested inside the long desc. If not, do + # a non-greedy search for a long desc. assume there are no other stray + # spans within the description. + if ( $string =~ +/<span class=["']?lxrlongdesc['"]?>(.*?<span class=["']?lxrshortdesc['"]?>.*?<\/span>.*?)<\/span>/is + ) + { + $long = $1; + if ( !( $long =~ /<span.*?\<span/is ) ) { + return ( $long . "<p>\nSEE ALSO: <a href=\"README.html\">README</a></p>\n" ); + } + } elsif ( $string =~ /<span class=["']?lxrlongdesc['"]?>(.*?)<\/span>/is ) { + $long = $1; + if ( !( $long =~ /\<span/is ) ) { + return ( $long . "<p>\nSEE ALSO: <a href=\"README.html\">README</a></p>\n" ); + } + } } sub descreadme { - my ($file, $release) = @_; + my ( $file, $release ) = @_; - my $string = ""; -# $string =~ s#(</?([^>^\s]+[^>]*)>.*$)#($2~/B|A|IMG|FONT|BR|EM|I|TT/i)?$1:""#sg; - my $n; - my $count; - my $temp; + my $string = ""; - my $maxlines = 20; # If file is less than this then just print it all - my $minlines = 5; # Too small. Go back and add another paragraph. - my $chopto = 10; # Truncate long READMEs to this length + # $string =~ s#(</?([^>^\s]+[^>]*)>.*$)#($2~/B|A|IMG|FONT|BR|EM|I|TT/i)?$1:""#sg; + my $n; + my $count; + my $temp; - return if !($desc = $files->getfilehandle($file, $release)); + my $maxlines = 20; # If file is less than this then just print it all + my $minlines = 5; # Too small. Go back and add another paragraph. + my $chopto = 10; # Truncate long READMEs to this length -# undef $/; - $string = <$desc>; -# $/ = "\n"; - close($desc); + return if !( $desc = $files->getfilehandle( $file, $release ) ); - # if the README is 0 length then give up - if (!$string){ - return; - } - # strip the emacs tab line - $string =~ s/.*tab-width:[ \t]*([0-9]+).*\n//; + # undef $/; + $string = <$desc>; - # strip the npl - $string =~ s/.*The contents of this .* All Rights.*Reserved\.//s; + # $/ = "\n"; + close($desc); - # strip the short description from the beginning - $path =~ s#/(.+)/#$1#; - $string =~ s/.*$path\/*\s+--- .*//; + # if the README is 0 length then give up + if ( !$string ) { + return; + } - # strip away junk - $string =~ s/#+\s*\n/\n/; - $string =~ s/---+\s*\n/\n/g; - $string =~ s/===+\s*\n/\n/g; + # strip the emacs tab line + $string =~ s/.*tab-width:[ \t]*([0-9]+).*\n//; - # strip blank lines at beginning and end of file. - $string =~ s/^\s*\n//gs; - $string =~ s/\s*\n$//gs; - chomp($string); - $_ = $string; - $count = tr/\n//; + # strip the npl + $string =~ s/.*The contents of this .* All Rights.*Reserved\.//s; - # If the file is small there's not much use splitting it up. - # Just print it all - if ($count <= $maxlines) { - $string = markupstring($string, $Path->{'virt'}); - $string = convertwhitespace($string); - return($string); - } else { - # grab the first n paragraphs, with n decreasing until the - # string is 10 lines or shorter or until we're down to - # one paragraph. - $n = 6; - $temp = $string; - while ( ($count > $chopto) && ($n-- > 1) ) { - $string =~ s/^((?:(?:[\S\t ]*?\n)+?[\t ]*\n){$n}?)(.*)/$1/s; - $_ = $string; - $string =~ s/\s*\n$//gs; - $count = tr/\n//; - } + # strip the short description from the beginning + $path =~ s#/(.+)/#$1#; + $string =~ s/.*$path\/*\s+--- .*//; - # if we have too few lines then back up and grab another paragraph - $_ = $string; + # strip away junk + $string =~ s/#+\s*\n/\n/; + $string =~ s/---+\s*\n/\n/g; + $string =~ s/===+\s*\n/\n/g; + + # strip blank lines at beginning and end of file. + $string =~ s/^\s*\n//gs; + $string =~ s/\s*\n$//gs; + chomp($string); + $_ = $string; $count = tr/\n//; - if ($count < $minlines) { - $n = $n+1; - $temp =~ s/^((?:(?:[\S\t ]*?\n)+?[\t ]*\n){$n}?)(.*)/$1/s; - $string = $temp; - } - # if we have more than $maxlines then truncate to $chopto - # and add an elipsis. - if ($count > $maxlines) { - $string =~ s/^((?:[\S \t]*\n){$chopto}?)(.*)/$1/s; - chomp($string); - $string = $string . "\n..."; - } - - # since not all of the README is displayed here, - # add a link to it. - chomp($string); - if ($string =~ /SEE ALSO/) { - $string = $string . ", README"; - } else { - $string = $string . "\n\nSEE ALSO: README"; - } + # If the file is small there's not much use splitting it up. + # Just print it all + if ( $count <= $maxlines ) { + $string = markupstring( $string, $Path->{'virt'} ); + $string = convertwhitespace($string); + return ($string); + } else { - $string = markupstring($string, $Path->{'virt'}); - $string = convertwhitespace($string); + # grab the first n paragraphs, with n decreasing until the + # string is 10 lines or shorter or until we're down to + # one paragraph. + $n = 6; + $temp = $string; + while ( ( $count > $chopto ) && ( $n-- > 1 ) ) { + $string =~ s/^((?:(?:[\S\t ]*?\n)+?[\t ]*\n){$n}?)(.*)/$1/s; + $_ = $string; + $string =~ s/\s*\n$//gs; + $count = tr/\n//; + } - # strip blank lines at beginning and end of file again - $string =~ s/^\s*\n//gs; - $string =~ s/\s*\n$//gs; - chomp($string); + # if we have too few lines then back up and grab another paragraph + $_ = $string; + $count = tr/\n//; + if ( $count < $minlines ) { + $n = $n + 1; + $temp =~ s/^((?:(?:[\S\t ]*?\n)+?[\t ]*\n){$n}?)(.*)/$1/s; + $string = $temp; + } - return($string); - } + # if we have more than $maxlines then truncate to $chopto + # and add an elipsis. + if ( $count > $maxlines ) { + $string =~ s/^((?:[\S \t]*\n){$chopto}?)(.*)/$1/s; + chomp($string); + $string = $string . "\n..."; + } + + # since not all of the README is displayed here, + # add a link to it. + chomp($string); + if ( $string =~ /SEE ALSO/ ) { + $string = $string . ", README"; + } else { + $string = $string . "\n\nSEE ALSO: README"; + } + + $string = markupstring( $string, $Path->{'virt'} ); + $string = convertwhitespace($string); + + # strip blank lines at beginning and end of file again + $string =~ s/^\s*\n//gs; + $string =~ s/\s*\n$//gs; + chomp($string); + + return ($string); + } } # dme: substitute carraige returns and spaces in original text # for html equivalent so we don't need to use <pre> and can # use variable width fonts but preserve the formatting sub convertwhitespace { - my ($string) = @_; + my ($string) = @_; - # handle ascii bulleted lists - $string =~ s/<p>\n\s+o\s/<p>\n\ \;\ \;o /sg; - $string =~ s/\n\s+o\s/ \;\n<br>\ \;\ \;o /sg; + # handle ascii bulleted lists + $string =~ s/<p>\n\s+o\s/<p>\n\ \;\ \;o /sg; + $string =~ s/\n\s+o\s/ \;\n<br>\ \;\ \;o /sg; - #find paragraph breaks and replace with <p> - $string =~ s/\n\s*\n/<p>\n/sg; + #find paragraph breaks and replace with <p> + $string =~ s/\n\s*\n/<p>\n/sg; - return($string); + return ($string); } - 1; Index: diff =================================================================== RCS file: /cvsroot/lxr/lxr/diff,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- diff 15 Jul 2004 15:29:35 -0000 1.11 +++ diff 19 Jul 2004 19:50:20 -0000 1.12 @@ -16,7 +16,7 @@ # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -32,180 +32,185 @@ use Local; sub htmlsub { - my ($s, $l) = @_; - my @s = split(/(<[^>]*>|&[\#\w\d]+;?)/, $s); - $s = ''; - - while (@s) { - my $f = substr(shift(@s), 0, $l); - $l -= length($f); - $s .= $f; - $f = shift(@s); - if ($f =~ /^&/) { - if ($l > 0) { + my ( $s, $l ) = @_; + my @s = split( /(<[^>]*>|&[\#\w\d]+;?)/, $s ); + $s = ''; + + while (@s) { + my $f = substr( shift(@s), 0, $l ); + $l -= length($f); $s .= $f; - $l--; - } - } else { - $s .= $f; + $f = shift(@s); + if ( $f =~ /^&/ ) { + if ( $l > 0 ) { + $s .= $f; + $l--; + } + } else { + $s .= $f; + } } - } - $s .= ' ' x $l; - return $s; + $s .= ' ' x $l; + return $s; } - sub printdiff { - my ($diffvar, $diffval) = @_; + my ( $diffvar, $diffval ) = @_; - unless ($diffvar) { - my @vars; - foreach ($config->allvariables) { - push(@vars, $config->vardescription($_)); + unless ($diffvar) { + my @vars; + foreach ( $config->allvariables ) { + push( @vars, $config->vardescription($_) ); + } + + $vars[ $#vars - 1 ] .= " or " . pop(@vars) if $#vars > 0; + + print( + "<p align=\"center\">\n", + "Please indicate the version of the file you wish to\n", + "compare to by clicking on the appropriate\n", + join( ", ", @vars ), + " button.\n", + "</p>\n" + ); + return; } - - $vars[$#vars-1] .= " or ".pop(@vars) if $#vars > 0; - - print("<p align=\"center\">\n", - "Please indicate the version of the file you wish to\n", - "compare to by clicking on the appropriate\n", - join(", ",@vars)," button.\n", - "</p>\n"); - return; - } - if ($pathname =~ m|/$|) { - print("<h3 align=\"center\">Diff not yet supported for directories.</h3>\n"); - return; - } + if ( $pathname =~ m|/$| ) { + print("<h3 align=\"center\">Diff not yet supported for directories.</h3>\n"); + return; + } - my $origval = $config->variable($diffvar); - my $origname = $pathname; - my $origtemp = $files->tmpfile($origname, $release); + my $origval = $config->variable($diffvar); + my $origname = $pathname; + my $origtemp = $files->tmpfile( $origname, $release ); - $config->variable($diffvar,$diffval); - my $diffname = $config->mappath($pathname); - my $difftemp = $files->tmpfile($diffname, $config->variable('v')); + $config->variable( $diffvar, $diffval ); + my $diffname = $config->mappath($pathname); + my $difftemp = $files->tmpfile( $diffname, $config->variable('v') ); - $config->variable($diffvar,$origval); + $config->variable( $diffvar, $origval ); - unless (defined($origtemp)) { - unlink($difftemp); - print("*** $origname does not exist ***\n"); - return; - } - unless (defined($difftemp)) { - unlink($origtemp); - print("*** $diffname does not exist ***\n"); - return; - } + unless ( defined($origtemp) ) { + unlink($difftemp); + print("*** $origname does not exist ***\n"); + return; + } + unless ( defined($difftemp) ) { + unlink($origtemp); + print("*** $diffname does not exist ***\n"); + return; + } - fflush; - $ENV{'PATH'} = '/bin:/usr/local/bin:/usr/bin:/usr/sbin'; - unless (open(DIFF, "-|")){ - open(STDERR, ">&STDOUT"); - exec('diff', '-U0', $origtemp, $difftemp); - print "*** Diff subprocess died unexpextedly: $!\n"; - exit; - } - - my ($os, $ol, $ns, $nl, $ms, $ml, $bo, $ofs, $dir, %orig, %new, %chg); + fflush; + $ENV{'PATH'} = '/bin:/usr/local/bin:/usr/bin:/usr/sbin'; + unless ( open( DIFF, "-|" ) ) { + open( STDERR, ">&STDOUT" ); + exec( 'diff', '-U0', $origtemp, $difftemp ); + print "*** Diff subprocess died unexpextedly: $!\n"; + exit; + } - while (<DIFF>) { - if (($os, $ol, $ns, $nl) = - /@@ -(\d+)(?:,(\d+)|) \+(\d+)(?:,(\d+)|) @@/) { - $os++ if $ol eq '0'; - $ns++ if $nl eq '0'; - $ol = 1 unless defined($ol); - $nl = 1 unless defined($nl); + my ( $os, $ol, $ns, $nl, $ms, $ml, $bo, $ofs, $dir, %orig, %new, %chg ); - $bo = $os + $ofs; - if ($ol < $nl) { - $ofs += $nl - $ol; + while (<DIFF>) { + if ( ( $os, $ol, $ns, $nl ) = /@@ -(\d+)(?:,(\d+)|) \+(\d+)(?:,(\d+)|) @@/ ) { + $os++ if $ol eq '0'; + $ns++ if $nl eq '0'; + $ol = 1 unless defined($ol); + $nl = 1 unless defined($nl); - $dir = '>>'; - $ms = $nl - $ol; - $ml = $ol; - $orig{$os+$ol} = $ms; - } else { - $dir = '<<'; - $ms = $ol - $nl; - $ml = $nl; - $new{$ns+$nl} = $ms; - } - foreach (0..$ml - 1) { - $chg{$bo + $_} = '!!'; - } - foreach (0..$ms - 1) { - $chg{$bo + $ml + $_} = $dir; - } + $bo = $os + $ofs; + if ( $ol < $nl ) { + $ofs += $nl - $ol; + $dir = '>>'; + $ms = $nl - $ol; + $ml = $ol; + $orig{ $os + $ol } = $ms; + } else { + $dir = '<<'; + $ms = $ol - $nl; + $ml = $nl; + $new{ $ns + $nl } = $ms; + } + foreach ( 0 .. $ml - 1 ) { + $chg{ $bo + $_ } = '!!'; + } + foreach ( 0 .. $ms - 1 ) { + $chg{ $bo + $ml + $_ } = $dir; + } + + } } - } - close(DIFF); + close(DIFF); + print( + "<h1>Diff markup</h1>\n", + "<h3>Differences between ", - print("<h1>Diff markup</h1>\n", - "<h3>Differences between ", + fileref( + "$origname (" . $config->vardescription($diffvar) . " $origval)", + "diff-fref", $origname, undef, "$diffvar=$origval" + ), + " and ", - fileref("$origname (".$config->vardescription($diffvar). - " $origval)", "diff-fref", - $origname, undef, "$diffvar=$origval"), - " and ", + fileref( + "$diffname (" . $config->vardescription($diffvar) . " $diffval)", + "diff-fref", $diffname, undef, "$diffvar=$diffval" + ), + "</h3><hr>\n" + ); - fileref("$diffname (".$config->vardescription($diffvar). - " $diffval)", "diff-fref", - $diffname, undef, "$diffvar=$diffval"), - "</h3><hr>\n"); + my $origh = new FileHandle($origtemp); + my $orig = ''; + markupfile( $origh, sub { $orig .= shift }, 1 ); + my $len = $. + $ofs; + $origh->close; - my $origh = new FileHandle($origtemp); - my $orig = ''; - markupfile($origh, sub { $orig .= shift }, 1); - my $len = $.+$ofs; - $origh->close; - - $config->variable($diffvar, $diffval); - $pathname = $diffname; + $config->variable( $diffvar, $diffval ); + $pathname = $diffname; - my $diffh = new FileHandle($difftemp); - my $new = ''; - - markupfile($diffh, sub { $new .= shift }); - $diffh->close; + my $diffh = new FileHandle($difftemp); + my $new = ''; - $config->variable($diffvar, $origval); - $pathname = $origname; + markupfile( $diffh, sub { $new .= shift } ); + $diffh->close; - my $i; - $i = 1; $orig =~ s/^/"\n" x ($orig{$i++})/mge; - $i = 1; $new =~ s/^/"\n" x ($new{$i++})/mge; + $config->variable( $diffvar, $origval ); + $pathname = $origname; - my @orig = split(/\n/, $orig); - my @new = split(/\n/, $new); + my $i; + $i = 1; + $orig =~ s/^/"\n" x ($orig{$i++})/mge; + $i = 1; + $new =~ s/^/"\n" x ($new{$i++})/mge; - print("<pre class=\"file\">\n"); - foreach $i (0..$len) { - my $o = htmlsub($orig[$i], 50); - my $n = $new[$i]; + my @orig = split( /\n/, $orig ); + my @new = split( /\n/, $new ); - my $diffmark = $chg{$i+1} ? - ("<span class=\"diff-mark\">" . $chg{$i+1} . "</span>") : " "; - #print("$o <span class=\"diff-mark\">", - # ($chg{$i+1} || " "), "</span> $n\n"); - print "$o $diffmark $n\n"; - } - print("</pre>"); + print("<pre class=\"file\">\n"); + foreach $i ( 0 .. $len ) { + my $o = htmlsub( $orig[$i], 50 ); + my $n = $new[$i]; - unlink($origtemp, $difftemp); -} + my $diffmark = + $chg{ $i + 1 } ? ( "<span class=\"diff-mark\">" . $chg{ $i + 1 } . "</span>" ) : " "; + #print("$o <span class=\"diff-mark\">", + # ($chg{$i+1} || " "), "</span> $n\n"); + print "$o $diffmark $n\n"; + } + print("</pre>"); + + unlink( $origtemp, $difftemp ); +} httpinit; makeheader('diff'); -printdiff($$HTTP{'param'}{'diffvar'}, $$HTTP{'param'}{'diffval'}); +printdiff( $$HTTP{'param'}{'diffvar'}, $$HTTP{'param'}{'diffval'} ); makefooter('diff'); httpclean; - Index: find =================================================================== RCS file: /cvsroot/lxr/lxr/find,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- find 19 Jul 2004 17:56:43 -0000 1.20 +++ find 19 Jul 2004 19:50:20 -0000 1.21 @@ -16,7 +16,7 @@ # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -31,112 +31,127 @@ use LXR::Common qw(:html); use LXR::Config; - sub varinputs { - my $templ = shift; - my $ret = ''; + my $templ = shift; + my $ret = ''; - foreach ($config->allvariables) { - if ($config->variable($_) ne $config->vardefault($_)) { - $ret .= expandtemplate($templ, - ( - variable => sub { $_ }, - value => sub { $config->variable($_) }, - )); + foreach ( $config->allvariables ) { + if ( $config->variable($_) ne $config->vardefault($_) ) { + $ret .= expandtemplate( + $templ, + ( + variable => sub { $_ }, + value => sub { $config->variable($_) }, + ) + ); + } } - } - return $ret; + return $ret; } sub printresults { - my $templ = shift; - my @results = @_; - my $ret = ''; - - foreach (@results) { - $ret .= expandtemplate($templ, ( fileref => sub { fileref("$_", "find-file", "/$_") } )); - } - return $ret; + my $templ = shift; + my @results = @_; + my $ret = ''; + + foreach (@results) { + $ret .= + expandtemplate( $templ, ( fileref => sub { fileref( "$_", "find-file", "/$_" ) } ) ); + } + return $ret; } sub dofind { - my ($searchtext, $FILELISTING, $advanced, $casesensitive) = @_; - my @ret; - - if ($searchtext ne "") { - my $sourceroot = $config->sourceroot . '/' . $release . '/'; - while(my $file = <$FILELISTING>) { - chomp $file; - $file =~ s/^$sourceroot//; - if ($advanced) { - if ($casesensitive) { - if ($file =~ /$searchtext/) { - push @ret, $file; - } - } elsif ($file =~ /$searchtext/i) { - push @ret, $file; - } - } else { - if ($casesensitive) { - if (index($file,$searchtext) != -1) { - push @ret, $file; - } - } elsif (index(lc($file),lc($searchtext)) != -1) { - push @ret, $file; + my ( $searchtext, $FILELISTING, $advanced, $casesensitive ) = @_; + my @ret; + + if ( $searchtext ne "" ) { + my $sourceroot = $config->sourceroot . '/' . $release . '/'; + while ( my $file = <$FILELISTING> ) { + chomp $file; + $file =~ s/^$sourceroot//; + if ($advanced) { + if ($casesensitive) { + if ( $file =~ /$searchtext/ ) { + push @ret, $file; + } + } elsif ( $file =~ /$searchtext/i ) { + push @ret, $file; + } + } else { + if ($casesensitive) { + if ( index( $file, $searchtext ) != -1 ) { + push @ret, $file; + } + } elsif ( index( lc($file), lc($searchtext) ) != -1 ) { + push @ret, $file; + } + } } - } } - } - return @ret; + return @ret; } sub find { - my $templ; - - if ($config->htmlfind) { - unless (open(TEMPL, $config->htmlfind)) { - warning("Template ".$config->htmlfind." does not exist."); + my $templ; + + if ( $config->htmlfind ) { + unless ( open( TEMPL, $config->htmlfind ) ) { + warning( "Template " . $config->htmlfind . " does not exist." ); + } else { + local ($/) = undef; + $templ = <TEMPL>; + close(TEMPL); + } } else { - local($/) = undef; - $templ = <TEMPL>; - close(TEMPL); + die "'htmlfind' template not configured"; } - } else { - die "'htmlfind' template not configured"; - } - my $searchtext = $HTTP->{'param'}->{'string'}; - my $advanced = $HTTP->{'param'}->{'advanced'}; - my $casesensitive = $HTTP->{'param'}->{'casesensitive'}; + my $searchtext = $HTTP->{'param'}->{'string'}; + my $advanced = $HTTP->{'param'}->{'advanced'}; + my $casesensitive = $HTTP->{'param'}->{'casesensitive'}; - my $FILELISTING; - if ($config->swishdir and $config->swishindex) { - unless ($FILELISTING = new IO::File($config->swishdir."/$release.filenames")) { - &warning("Version '$release' has not been indexed and is unavailable for searching<br>Could not open ".$config->swishdir."/$release.filenames."); - return; - } - } elsif ($config->glimpsedir and $config->glimpsebin) { - unless ($FILELISTING = new IO::File($config->glimpsedir."/".$release."/.glimpse_filenames")) { - &warning("Version '$release' has not been indexed and is unavailable for searching<br>Could not open ".$config->glimpsedir."/$release/.glimpse_filenames."); - return; - } - } else { - warning("Freetext search engine required for file search, and no freetext search engine is configured"); - return; - } + my $FILELISTING; + if ( $config->swishdir and $config->swishindex ) { + unless ( $FILELISTING = new IO::File( $config->swishdir . "/$release.filenames" ) ) { + &warning( +"Version '$release' has not been indexed and is unavailable for searching<br>Could not open " + . $config->swishdir + . "/$release.filenames." ); + return; + } + } elsif ( $config->glimpsedir and $config->glimpsebin ) { + unless ( $FILELISTING = + new IO::File( $config->glimpsedir . "/" . $release . "/.glimpse_filenames" ) ) + { + &warning( +"Version '$release' has not been indexed and is unavailable for searching<br>Could not open " + . $config->glimpsedir + . "/$release/.glimpse_filenames." ); + return; + } + } else { + warning( +"Freetext search engine required for file search, and no freetext search engine is configured" + ); + return; + } - my @results = dofind($searchtext, $FILELISTING, $advanced, $casesensitive); - close($FILELISTING); + my @results = dofind( $searchtext, $FILELISTING, $advanced, $casesensitive ); + close($FILELISTING); - print expandtemplate($templ, - (variables => sub { varinputs(@_) }, - advancedchecked => sub { return $advanced ? "checked" : "" }, - searchtext => sub { return $searchtext }, - searchtext_escaped => sub { $_ = $searchtext; s/\"/"/g; return $_;}, - casesensitivechecked => sub { return $casesensitive ? "checked" : "" }, - results => sub { printresults(@_, @results) }, - resultcount => sub { return scalar @results }, - )); + print expandtemplate( + $templ, + ( + variables => sub { varinputs(@_) }, + advancedchecked => sub { return $advanced ? "checked" : "" }, + searchtext => sub { return $searchtext }, + searchtext_escaped => sub { $_ = $searchtext; s/\"/"/g; return $_; }, + casesensitivechecked => sub { return $casesensitive ? "checked" : "" }, + results => sub { printresults( @_, @results ) }, + resultcount => sub { return scalar @results }, + ) + ); } httpinit; Index: genxref =================================================================== RCS file: /cvsroot/lxr/lxr/genxref,v retrieving revision 1.33 retrieving revision 1.34 diff -u -d -r1.33 -r1.34 --- genxref 19 Jul 2004 17:56:43 -0000 1.33 +++ genxref 19 Jul 2004 19:50:20 -0000 1.34 @@ -10,7 +10,7 @@ # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -28,13 +28,13 @@ use LXR::Tagger; use LXR::Common; - my %option; -GetOptions(\%option, "help!", "url=s", "version=s", "allurls!", "allversions!", "reindexall!"); +GetOptions( \%option, "help!", "url=s", "version=s", "allurls!", "allversions!", "reindexall!" ); -if ($option{'help'}) { - # this may not be the best way to implement this, but at least it's something - print <<END_HELP; +if ( $option{'help'} ) { + + # this may not be the best way to implement this, but at least it's something + print <<END_HELP; Usage: genxref [option ...] The genxref program automatically generates LXR database cross-reference @@ -53,137 +53,150 @@ --reindexall Purges existing index data Report bugs at http://sourceforge.net/projects/lxr/. END_HELP - exit 0; + exit 0; } # TODO: implement --allurls die("Option --allurls not implemented. Use --url instead.\n") - if $option{'allurls'}; + if $option{'allurls'}; -die("URL must be specified. Try \"genxref --help\".\n") - unless $option{'url'}; +die("URL must be specified. Try \"genxref --help\".\n") + unless $option{'url'}; -$config = new LXR::Config($option{'url'}); +$config = new LXR::Config( $option{'url'} ); die("No matching configuration") unless $config->sourceroot; -$files = new LXR::Files($config->sourceroot); -die "Can't create file access object ".$config->sourceroot if !defined($files); -$index = new LXR::Index($config->dbname, O_RDWR|O_CREAT); -die "Can't create Index ".$config->dbname if !defined($index); +$files = new LXR::Files( $config->sourceroot ); +die "Can't create file access object " . $config->sourceroot + if !defined($files); +$index = new LXR::Index( $config->dbname, O_RDWR | O_CREAT ); +die "Can't create Index " . $config->dbname if !defined($index); our $filetype = new File::MMagic(); our %binaryfiles; my @versions; -if ($option{'allversions'} || !$option{'version'}) { - @versions = $config->varrange('v'); - die "Option --allversions cannot be used because no versions found automatically. Use --version=VERSION or fix lxr.conf.\n" if scalar @versions <= 0; +if ( $option{'allversions'} || !$option{'version'} ) { + @versions = $config->varrange('v'); + die +"Option --allversions cannot be used because no versions found automatically. Use --version=VERSION or fix lxr.conf.\n" + if scalar @versions <= 0; } else { - @versions = $option{'version'}; + @versions = $option{'version'}; } foreach my $version (@versions) { - $index->purge($version) if $option{'reindexall'}; - gensearch($version); - genindex('/', $version); - genrefs('/', $version); + $index->purge($version) if $option{'reindexall'}; + gensearch($version); + genindex( '/', $version ); + genrefs( '/', $version ); } - sub genindex { - my ($pathname, $release) = @_; - - print(STDERR "*** $pathname $release \n"); - - if ($pathname =~ m|/$|) { - map { - genindex($pathname.$_, $release) - } $files->getdir($pathname, $release); - } else { - &LXR::Tagger::processfile($pathname, $release, $config, $files, $index) unless exists $binaryfiles{$pathname}; - } + my ( $pathname, $release ) = @_; + + print( STDERR "*** $pathname $release \n" ); + + if ( $pathname =~ m|/$| ) { + map { genindex( $pathname . $_, $release ) } $files->getdir( $pathname, $release ); + } else { + &LXR::Tagger::processfile( $pathname, $release, $config, $files, $index ) + unless exists $binaryfiles{$pathname}; + } } sub genrefs { - my ($pathname, $release) = @_; - - print(STDERR "### $pathname $release \n"); - - if ($pathname =~ m|/$|) { - map { - genrefs($pathname.$_, $release) - } $files->getdir($pathname, $release); - } else { - &LXR::Tagger::processrefs($pathname, $release, $config, $files, $index) unless exists $binaryfiles{$pathname}; - } + my ( $pathname, $release ) = @_; + + print( STDERR "### $pathname $release \n" ); + + if ( $pathname =~ m|/$| ) { + map { genrefs( $pathname . $_, $release ) } $files->getdir( $pathname, $release ); + } else { + &LXR::Tagger::processrefs( $pathname, $release, $config, $files, $index ) + unless exists $binaryfiles{$pathname}; + } } sub feedswish { - my ($pathname, $release, $swish, $filelist) = @_; + my ( $pathname, $release, $swish, $filelist ) = @_; - print(STDERR "&&& $pathname $release \n"); - - if ($pathname =~ m|/$|) { - map { - feedswish($pathname.$_, $release, $swish, $filelist) - } $files->getdir($pathname, $release); - } else { - print $filelist "$pathname\n"; - my $contents = $files->getfile($pathname, $release); - if ($filetype->checktype_contents($contents) =~ m%(text|message)/% and length($contents) > 0) { - $swish->print("Path-Name: $pathname\n", - "Content-Length: ".length($contents)."\n", - "Document-Type: TXT\n", - "\n", - $contents); + print( STDERR "&&& $pathname $release \n" ); + + if ( $pathname =~ m|/$| ) { + map { feedswish( $pathname . $_, $release, $swish, $filelist ) } + $files->getdir( $pathname, $release ); } else { - $binaryfiles{$pathname} = 1; - } - } + print $filelist "$pathname\n"; + my $contents = $files->getfile( $pathname, $release ); + if ( $filetype->checktype_contents($contents) =~ m%(text|message)/% + and length($contents) > 0 ) + { + $swish->print( + "Path-Name: $pathname\n", + "Content-Length: " . length($contents) . "\n", + "Document-Type: TXT\n", + "\n", $contents + ); + } else { + $binaryfiles{$pathname} = 1; + } + } } sub gensearch { my ($release) = @_; my $string; - if ($config->glimpsedir and $config->glimpseindex) { + if ( $config->glimpsedir and $config->glimpseindex ) { + # Make sure the directory that the glimpse results go into # already exists as glimpse won't work if the directory does # not exist - die $config->glimpsedir . " does not exist" unless -d $config->glimpsedir; - $string = $config->glimpsedir."/".$release; + die $config->glimpsedir . " does not exist" + unless -d $config->glimpsedir; + $string = $config->glimpsedir . "/" . $release; mkdir $string; system("chmod 755 $string"); my $glimpse = new IO::Handle; - my $pid = open($glimpse, "|-"); - if ($pid == 0) { - exec($config->glimpseindex, - "-n", "-o", "-H", $config->glimpsedir."/$release", - $config->sourceroot."/".$release); - print(STDERR "Couldn't exec ".$config->glimpseindex.": $!\n"); - kill(9, $$); + my $pid = open( $glimpse, "|-" ); + if ( $pid == 0 ) { + exec( $config->glimpseindex, "-n", "-o", "-H", + $config->glimpsedir . "/$release", + $config->sourceroot . "/" . $release + ); + print( STDERR "Couldn't exec " . $config->glimpseindex . ": $!\n" ); + kill( 9, $$ ); } $glimpse->close(); + # Need to chmod the glimpse files so everybody can read them. - $string = $config->glimpsedir."/".$release."/.glimpse\*"; + $string = $config->glimpsedir . "/" . $release . "/.glimpse\*"; system("chmod 644 $string"); } - if ($config->swishdir and $config->swishindex) { - my $swish = new IO::Handle; - die $config->swishdir . " does not exist" unless -d $config->swishdir; - my $filelist = new IO::File $config->swishdir."/$release.filenames", "w" or die "can't open $release.filenames for writing"; - - # execute swish, as a pipe we can write to - - open($swish, "| " . $config->swishindex . " -S prog -i stdin -v 1 -c swish-e.conf -f " . $config->swishdir."/".$release.".index") - or die "Couldn't exec ".$config->swishindex.": $!\n"; - - feedswish("/", $release, $swish, $filelist); - - $swish->close(); - $filelist->close(); + if ( $config->swishdir and $config->swishindex ) { + my $swish = new IO::Handle; + die $config->swishdir . " does not exist" unless -d $config->swishdir; + my $filelist = new IO::File $config->swishdir . "/$release.filenames", "w" + or die "can't open $release.filenames for writing"; + + # execute swish, as a pipe we can write to + + open( $swish, + "| " + . $config->swishindex + . " -S prog -i stdin -v 1 -c swish-e.conf -f " + . $config->swishdir . "/" + . $release + . ".index" ) + or die "Couldn't exec " . $config->swishindex . ": $!\n"; + + feedswish( "/", $release, $swish, $filelist ); + + $swish->close(); + $filelist->close(); } } Index: ident =================================================================== RCS file: /cvsroot/lxr/lxr/ident,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- ident 15 Jul 2004 15:29:35 -0000 1.18 +++ ident 19 Jul 2004 19:50:20 -0000 1.19 @@ -16,7 +16,7 @@ # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -35,125 +35,126 @@ my $declare_hits; sub varinputs { - my $ret = ''; - foreach ($config->allvariables) { - if ($config->variable($_) ne $config->vardefault($_)) { - $ret .= "<input type=\"hidden\" name=\"$_\" value=\"" . - $config->variable($_) . "\">\n"; + my $ret = ''; + foreach ( $config->allvariables ) { + if ( $config->variable($_) ne $config->vardefault($_) ) { + $ret .= "<input type=\"hidden\" name=\"$_\" value=\"" . $config->variable($_) . "\">\n"; + } } - } - return $ret; + return $ret; } sub refexpand { - my $templ = shift; - my $ret = ''; + my $templ = shift; + my $ret = ''; - my @refs = $index->getindex($identifier, $release); + my @refs = $index->getindex( $identifier, $release ); - my $file_hits = 0; - my $last_file; - my $def; - foreach my $def (@refs) { - my ($file, $line, $type, $rel) = @$def; - $file_hits++ if $file ne $last_file; - $last_file = $file; - - $rel &&= "(member of ".idref($rel, "search-member", $rel).")"; - $ret .= expandtemplate($templ, - (file => sub { $file }, - line => sub { $line }, - type => sub { $type }, - rel => sub { $rel }, - fileref => sub { - fileref("$file, line $line", - "search-decl", - $file, $line); + my $file_hits = 0; + my $last_file; + my $def; + foreach my $def (@refs) { + my ( $file, $line, $type, $rel ) = @$def; + $file_hits++ if $file ne $last_file; + $last_file = $file; + + $rel &&= "(member of " . idref( $rel, "search-member", $rel ) . ")"; + $ret .= expandtemplate( + $templ, + ( + file => sub { $file }, + line => sub { $line }, + type => sub { $type }, + rel => sub { $rel }, + fileref => sub { + fileref( "$file, line $line", "search-decl", $file, $line ); } - )); - -# print("<span class=\"search-li1\"> $type_names{$type} in ". -# fileref("$file, line $line", "search-decl", -# $file, $line). -# " $rel</span>\n"); - } - $declare_hits = "<br>" . scalar @refs . " declarations in $file_hits files."; - return $ret; + ) + ); + + # print("<span class=\"search-li1\"> $type_names{$type} in ". + # fileref("$file, line $line", "search-decl", + # $file, $line). + # " $rel</span>\n"); + } + $declare_hits = "<br>" . scalar @refs . " declarations in $file_hits files."; + return $ret; } sub usesexpand { - my $templ = shift; - my $ret = ''; + my $templ = shift; + my $ret = ''; - my @uses = $index->getreference($identifier, $release); - my $file_hits = 0; - my $last_file; - foreach my $ref (sort { $$a[0] cmp $$b[0] } @uses) { - my ($file, $line) = @$ref; - $file_hits++ if $file ne $last_file; - $last_file = $file; - $ret .= expandtemplate($templ, - ( - file => sub { $file }, - line => sub { $line }, + my @uses = $index->getreference( $identifier, $release ); + my $file_hits = 0; + my $last_file; + foreach my $ref ( sort { $$a[0] cmp $$b[0] } @uses ) { + my ( $file, $line ) = @$ref; + $file_hits++ if $file ne $last_file; + $last_file = $file; + $ret .= expandtemplate( + $templ, + ( + file => sub { $file }, + line => sub { $line }, fileref => sub { - fileref("$file, line $line", "search-ref", - $file, $line); + fileref( "$file, line $line", "search-ref", $file, $line ); } - )); - } - $reference_hits = "<br>" . scalar @uses . " references in $file_hits files."; - return $ret; + ) + ); + } + $reference_hits = "<br>" . scalar @uses . " references in $file_hits files."; + return $ret; } sub printident { - my $dir = shift; - my ($templ, $templ_refs); - - #$templ = "<ul>\n\$files{\n<li>\$iconlink \$namelink\n}</ul>\n"; - if ($config->htmlident) { - unless (open(TEMPL, $config->htmlident)) { - warning("Template ".$config->htmlident." does not exist."); + my $dir = shift; + my ( $templ, $templ_refs ); + + #$templ = "<ul>\n\$files{\n<li>\$iconlink \$namelink\n}</ul>\n"; + if ( $config->htmlident ) { + unless ( open( TEMPL, $config->htmlident ) ) { + warning( "Template " . $config->htmlident . " does not exist." ); } else { - local($/) = undef; + local ($/) = undef; $templ = <TEMPL>; close(TEMPL); } - } else { + } else { die "Ident template not configured"; } - - - if ($config->htmlident_refs) { - unless (open(TEMPL, $config->htmlident_refs)) { - warning("Template ".$config->htmlident_refs." does not exist."); + + if ( $config->htmlident_refs ) { + unless ( open( TEMPL, $config->htmlident_refs ) ) { + warning( "Template " . $config->htmlident_refs . " does not exist." ); } else { - local($/) = undef; + local ($/) = undef; $templ_refs = <TEMPL>; close(TEMPL); } - } else { + } else { die "Ident refs template not configured"; } - - - # print the description of the current directory - #dirdesc($dir); - - # print the listing itself - print(expandtemplate($templ, - (variables => \&varinputs, - identifier => sub { return $identifier }, - identifier_escaped => sub { $_ = $identifier; s/\"/"/g; return $_;}, - refs => sub { refexpand(@_) }, - ))); - print $declare_hits; - print(expandtemplate($templ_refs, - (uses => sub { usesexpand(@_) }, - ))); - print $reference_hits; -} + # print the description of the current directory + #dirdesc($dir); + + # print the listing itself + print( + expandtemplate( + $templ, + ( + variables => \&varinputs, + identifier => sub { return $identifier }, + identifier_escaped => sub { $_ = $identifier; s/\"/"/g; return $_; }, + refs => sub { refexpand(@_) }, + ) + ) + ); + print $declare_hits; + print( expandtemplate( $templ_refs, ( uses => sub { usesexpand(@_) }, ) ) ); + print $reference_hits; +} httpinit; Index: search =================================================================== RCS file: /cvsroot/lxr/lxr/search,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- search 19 Jul 2004 18:05:56 -0000 1.21 +++ search 19 Jul 2004 19:50:20 -0000 1.22 @@ -16,7 +16,7 @@ # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -34,197 +34,205 @@ my $maxhits = 1000; sub varinputs { - my $templ = shift; - my $ret = ''; + my $templ = shift; + my $ret = ''; - foreach ($config->allvariables) { - if ($config->variable($_) ne $config->vardefault($_)) { - $ret .= expandtemplate($templ, - ( - variable => sub { $_ }, - value => sub { $config->variable($_) }, - )); + foreach ( $config->allvariables ) { + if ( $config->variable($_) ne $config->vardefault($_) ) { + $ret .= expandtemplate( + $templ, + ( + variable => sub { $_ }, + value => sub { $config->variable($_) }, + ) + ); + } } - } - return $ret; + return $ret; } - sub glimpsesearch { - my ($searchtext) = @_; + my ($searchtext) = @_; - $ENV{'PATH'} = '/bin:/usr/local/bin:/usr/bin:/usr/sbin'; - unless (open(GLIMPSE, "-|")) { - open(STDERR, ">&STDOUT"); - $!=''; - exec($config->glimpsebin,"-i","-H".$config->glimpsedir."/".$release,'-y','-n',$searchtext); - print("Glimpse subprocess died unexpextedly: $!\n"); - exit; - } + $ENV{'PATH'} = '/bin:/usr/local/bin:/usr/bin:/usr/sbin'; + unless ( open( GLIMPSE, "-|" ) ) { + open( STDERR, ">&STDOUT" ); + $! = ''; + exec( $config->glimpsebin, "-i", "-H" . $config->glimpsedir . "/" . $release, + '-y', '-n', $searchtext ); + print("Glimpse subprocess died unexpextedly: $!\n"); + exit; + } - my $numlines = 0; - my @glimpselines = (); - while (<GLIMPSE>) { - $numlines++; - push(@glimpselines,$_); - if ($numlines > $maxhits) { - last; + my $numlines = 0; + my @glimpselines = (); + while (<GLIMPSE>) { + $numlines++; + push( @glimpselines, $_ ); + if ( $numlines > $maxhits ) { + last; + } } - } - close(GLIMPSE); + close(GLIMPSE); - my $retval = $? >> 8; + my $retval = $? >> 8; - # The manpage for glimpse says that it returns 2 on syntax errors or - # inaccessible files. It seems this is not the case. - # We will have to work around it for the time being. - - if ($retval == 0) { - my @ret; - my $sourceroot = $config->sourceroot . '/' . $release . '/'; - my $i = 0; - foreach my $glimpseline (@glimpselines) { - last if ($i > $maxhits); - - $glimpseline =~ s/$sourceroot//; - my ($file, $line, $text) = - $glimpseline =~ /(.*?):\s*(\d+)\s*:(.*)/; - $text =~ s/&/&/g; - $text =~ s/</</g; - $text =~ s/>/>/g; - - push @ret, [ $file, $line, $text ]; - } - continue { - $i++; + # The manpage for glimpse says that it returns 2 on syntax errors or + # inaccessible files. It seems this is not the case. + # We will have to work around it for the time being. + + if ( $retval == 0 ) { + my @ret; + my $sourceroot = $config->sourceroot . '/' . $release . '/'; + my $i = 0; + foreach my $glimpseline (@glimpselines) { + last if ( $i > $maxhits ); + + $glimpseline =~ s/$sourceroot//; + my ( $file, $line, $text ) = $glimpseline =~ /(.*?):\s*(\... [truncated message content] |
From: Dave B. <bro...@us...> - 2004-07-19 18:16:44
|
Update of /cvsroot/lxr/lxr In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17194 Modified Files: INSTALL Added Files: .htaccess_cgi Log Message: apache configuration for cgi --- NEW FILE: .htaccess_cgi --- Options Indexes ExecCGI FollowSymlinks order deny,allow <Files lxr.conf> deny from all </Files> <Files lib> deny from all </Files> <Files ~ (find|search|source|ident|diff|cgi-bin)$> SetHandler cgi-script ForceType text/html </Files> Index: INSTALL =================================================================== RCS file: /cvsroot/lxr/lxr/INSTALL,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- INSTALL 19 Jul 2004 17:56:43 -0000 1.14 +++ INSTALL 19 Jul 2004 18:16:35 -0000 1.15 @@ -199,6 +199,10 @@ The distribution contains a .htaccess file set up to ensure that lxr will work. Edit it if you have special local policies. +If you are using Apache without mod_perl (running scripts as CGI), +instead of 'Alias' in httpd.conf use 'ScriptAlias'. Also, delete +.htaccess and rename .htaccess_cgi to .htaccess. + That's it - lxr should now work. Fire up your webbrowser and go to http://yoursite/lxr/source and you should see the listing for the top of your source tree. |