from dawn: cleverly generate stuff for the "Description" column in LXR directory listings.

This commit is contained in:
jwz 1998-06-19 23:06:50 +00:00
parent b9758acdcb
commit 9e7aae58c2

View File

@ -1,5 +1,5 @@
#!/usr/bonsaitools/bin/perl
# $Id: source,v 1.6 1998/06/16 20:23:38 jwz Exp $
# $Id: source,v 1.7 1998/06/19 23:06:50 jwz Exp $
# source -- Present sourcecode as html, complete with references
#
@ -29,24 +29,56 @@ use LXR::Common;
use LXR::Config;
# Search the beginning of a source file for a short description
# to be displayed in directory listings. Not all files have
# them and the ones that do use different formats so there are
# lots of ways to end up with junk. The basic format is: a file
# name possibly followed by a colon or dash(es) with whitespace
# strewn in followed by the description and maybe some stray comment
# characters. Don't be confused by #includes or rcs comments
# at the beginning of the file.
# -dme
sub fdescexpand {
my $linecount=0;
$desc= "";
# if (open(FILE, $Path->{'real'}."/".$filename)) {
# while(<FILE>){
# if(/$filename\s*--*\s*/i){
# ($null, $desc) = split(/ $filename\s*--*\s*/i);
# if ($desc) {last};
# }elsif (/$filename\s*:\s*/i){
# ($null, $desc) = split(/ $filename\s*:\s*/i);
# if ($desc) {last};
# }elsif (/$filename\s*/i){
# ($null, $desc) = split(/ $filename\s*/i);
# if ($desc) {last};
# }
# }
# close(FILE);
# }
#ignore files that aren't source code
if (!(
($filename =~ /\.c$/) |
($filename =~ /\.h$/) |
($filename =~ /\.cc$/) |
($filename =~ /\.cp$/) |
($filename =~ /\.cpp$/) |
($filename =~ /\.java$/)
)){
return("");
}
if (open(FILE, $Path->{'real'}."/".$filename)) {
while(<FILE>){
if($linecount++ > 40) {
last;
}elsif (/\$Id: source,v 1.7 1998/06/19 23:06:50 jwz Exp $filename/){
#ignore cvs headers
}elsif (/^#/){
#ignore cpp directives
}elsif (/$filename\s*- ?-*\s*/i){
($null, $desc) = split(/ $filename\s*- ?-*\s*/i);
if ($desc) {last};
}elsif (/$filename\s*:\s*/i){
($null, $desc) = split(/ $filename\s*:\s*/i);
if ($desc) {last};
}elsif (/$filename\s\s*/i){
($null, $desc) = split(/ $filename\s\s*/i);
if ($desc) {last};
}
}
close(FILE);
}
#strip trailing asterisks and "*/"
$desc =~ s#\*/?\s*$##;
return($desc);
}
@ -323,6 +355,3 @@ if (!($Path->{'file'} =~ /\.(html)$/)) {
&makefooter('sourcedir');
}
}
#$len = length($file);
#print ("length is: ", $len) ;