[Lxr-commits] CVS: lxr find,1.13,1.14
Brought to you by:
ajlittoz
From: Dave B. <bro...@us...> - 2004-07-07 20:31:54
|
Update of /cvsroot/lxr/lxr In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22905 Modified Files: find Log Message: option for basic and regexp search; option for case-sensitivity Index: find =================================================================== RCS file: /cvsroot/lxr/lxr/find,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- find 28 Jun 2004 18:35:54 -0000 1.13 +++ find 7 Jul 2004 20:31:45 -0000 1.14 @@ -27,28 +27,12 @@ use lib do { $0 =~ m{(.*)/} ? "$1/lib" : "lib" }; + use LXR::Common qw(:html); use LXR::Config; sub find { -print q~ -<p align=\"center\"> -Search for files (by name) using <a href="http://www.perldoc.com/perl5.8.4/pod/perlrequick.html">perl regular expressions</a>. -</p> -<H3>Quick tip:</H3> -<P> -The database that is searched has the form of the output of the -"find" command. -</p><p>That is, each line is the absolute patch of a file -If you want to search for a specific file(s), you use -<ul> -<li> /el\.po to search for all occurences of file "el.po". -<li> \.desktop$ to search for all files ending with ".desktop". -</ul> -</p> -~; - print ("<form method=\"get\" action=\"find\">\n"); foreach ($config->allvariables) { @@ -61,6 +45,8 @@ print("<b>Find file: </b><input type=\"text\" name=\"string\" ", "value=\"",$searchtext,"\" size=\"50\">\n", "<input type=\"submit\" value=\"search\">\n", + "<br><input type=\"checkbox\" name=\"advanced\"", $advanced ? " checked" : "", " value=\"1\"/> Advanced (allow <a href=\"http://www.perldoc.com/perl5.8.4/pod/perlrequick.html\" target=\"_blank\">regex</a>)\n", + " <input type=\"checkbox\" name=\"casesensitive\"", $casesensitive ? " checked" : "", " value=\"1\"/> Case-sensitive\n", "</form>\n"); @@ -79,12 +65,29 @@ } print("<hr>\n"); $sourceroot = $config->sourceroot; - my $hits = 0; + my $hits = 0; while($file = <FILELLISTING>) { $file =~ s/^$sourceroot//; - if($file =~ /$searchtext/) { - print(&fileref("$file", "find-file", "/$file"),"<br>\n"); - $hits++; + if ($advanced) { + if ($casesensitive) { + if ($file =~ /$searchtext/) { + print(&fileref("$file", "find-file", "/$file"),"<br>\n"); + $hits++; + } + } elsif ($file =~ /$searchtext/i) { + print(&fileref("$file", "find-file", "/$file"),"<br>\n"); + $hits++; + } + } else { + if ($casesensitive) { + if (index($file,$searchtext) != -1) { + print(&fileref("$file", "find-file", "/$file"),"<br>\n"); + $hits++; + } + } elsif (index(lc($file),lc($searchtext)) != -1) { + print(&fileref("$file", "find-file", "/$file"),"<br>\n"); + $hits++; + } } } print "<br>$hits files found."; @@ -94,6 +97,8 @@ httpinit; $searchtext = $HTTP->{'param'}->{'string'}; +$advanced = $HTTP->{'param'}->{'advanced'}; +$casesensitive = $HTTP->{'param'}->{'casesensitive'}; &makeheader('find'); &find; |