[Lxr-commits] CVS: lxr find,1.9,1.10 genxref,1.27,1.28
Brought to you by:
ajlittoz
|
From: Dave B. <bro...@us...> - 2004-06-28 13:17:26
|
Update of /cvsroot/lxr/lxr In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6517 Modified Files: find genxref Log Message: support filename searchs for swish-e; ignore binary files (swish-e only) for full-text indexing; simpler forking/piping to feed swish-e indexer (works in Solaris now) Index: find =================================================================== RCS file: /cvsroot/lxr/lxr/find,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- find 5 Jun 2003 16:55:05 -0000 1.9 +++ find 28 Jun 2004 13:17:17 -0000 1.10 @@ -53,10 +53,18 @@ if ($searchtext ne "") { - unless (open(FILELLISTING,$config->glimpsedir."/".$release."/.glimpse_filenames")) { - &warning("Could not open ".$config->glimpsedir."/$release/.glimpse_filenames."); - return; - } + if ($config->swishdir and $config->swishindex) { + unless (open(FILELLISTING,$config->swishdir."/$release.filenames")) { + &warning("Could not open ".$config->swishdir."/$release.filenames."); + return; + } + } + if ($config->glimpsedir and $config->glimpseindex) { + unless (open(FILELLISTING,$config->glimpsedir."/".$release."/.glimpse_filenames")) { + &warning("Could not open ".$config->glimpsedir."/$release/.glimpse_filenames."); + return; + } + } print("<hr>\n"); $sourceroot = $config->sourceroot; while($file = <FILELLISTING>) { Index: genxref =================================================================== RCS file: /cvsroot/lxr/lxr/genxref,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- genxref 29 Jul 2002 01:17:32 -0000 1.27 +++ genxref 28 Jun 2004 13:17:17 -0000 1.28 @@ -20,6 +20,7 @@ use Fcntl; use Getopt::Long; use IO::Handle; +use File::MMagic; use LXR::Files; use LXR::Index; @@ -70,6 +71,8 @@ $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(); + my @versions; if ($option{'allversions'} || !$option{'version'}) { @@ -116,22 +119,25 @@ } sub feedswish { - my ($pathname, $release, $swish) = @_; + my ($pathname, $release, $swish, $filelist) = @_; print(STDERR "&&& $pathname $release \n"); if ($pathname =~ m|/$|) { map { - feedswish($pathname.$_, $release, $swish) + feedswish($pathname.$_, $release, $swish, $filelist) } $files->getdir($pathname, $release); } else { - my $contents = $files->getfile($pathname, $release); - $swish->print("Path-Name: $pathname\n", - "Content-Length: ".length($contents)."\n", - "Document-Type: TXT\n", - "\n", - $contents) - if length($contents) > 0; + print $filelist "$pathname\n"; + my $contents = $files->getfile($pathname, $release); + if ($filetype->checktype_contents($contents) =~ m%(text|message)/%) { + $swish->print("Path-Name: $pathname\n", + "Content-Length: ".length($contents)."\n", + "Document-Type: TXT\n", + "\n", + $contents) + if length($contents) > 0; + } } } @@ -162,16 +168,17 @@ } if ($config->swishdir and $config->swishindex) { - my $swish = new IO::Handle; - my $pid = open($swish, "|-"); - if ($pid == 0) { - exec($config->swishindex, - "-S", "prog", "-i", "/bin/cat", "-v", "1", - "-f", $config->swishdir."/".$release.".index"); - print(STDERR "Couldn't exec ".$config->swishindex.": $!\n"); - kill(9, $$); - } - feedswish("/", $release, $swish); - $swish->close(); + my $swish = new IO::Handle; + 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 -f " . $config->swishdir."/".$release.".index") + or die "Couldn't exec ".$config->swishindex.": $!\n"; + + feedswish("/", $release, $swish, $filelist); + + $swish->close(); + $filelist->close(); } } |