[Lxr-commits] CVS: lxr/lib/LXR/Lang Generic.pm,1.16,1.17 Java.pm,1.5,1.6 Perl.pm,1.6,1.7 Python.pm,1
Brought to you by:
ajlittoz
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', + }, + } } |