git: 546cb8d83c - main - man.cgi: make apropos support filtering by section PR: 272906 Reported by: Pat Maddox <[email protected]>

Wolfram Schneider <[email protected]>
Newsgroups gmane.os.freebsd.devel.cvs.doc
Message-ID <[email protected]>
The branch main has been updated by wosch:

URL: https://cgit.FreeBSD.org/doc/commit/?id=546cb8d83cbb382a828a69c0ff56a57745a0ccf7

commit 546cb8d83cbb382a828a69c0ff56a57745a0ccf7
Author:     Wolfram Schneider <[email protected]>
AuthorDate: 2024-03-25 08:28:13 +0000
Commit:     Wolfram Schneider <[email protected]>
CommitDate: 2024-03-25 08:28:13 +0000

    man.cgi: make apropos support filtering by section
    PR:             272906
    Reported by:    Pat Maddox <[email protected]>
---
 website/content/en/cgi/man.cgi | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/website/content/en/cgi/man.cgi b/website/content/en/cgi/man.cgi
index 3ca0d100af..5b82116121 100755
--- a/website/content/en/cgi/man.cgi
+++ b/website/content/en/cgi/man.cgi
@@ -1302,7 +1302,7 @@ sub do_man {
     }
     else { $section = ''; }
 
-    $apropos ? &apropos($query) : &man( $name, $section, $arch );
+    $apropos ? &apropos($query, $section) : &man( $name, $section, $arch );
 }
 
 # --------------------- support routines ------------------------
@@ -1378,7 +1378,7 @@ sub http_header {
 sub env { defined( $main'ENV{ $_[0] } ) ? $main'ENV{ $_[0] } : undef; }
 
 sub apropos {
-    local ($query) = @_;
+    local ($query, $sektion) = @_;
     local ( $_,     $title,   $head, *APROPOS );
     local ( $names, $section, $msg,  $key );
     local ($prefix);
@@ -1397,6 +1397,8 @@ sub apropos {
     &http_header("text/html");
     print &html_header("Apropos $title");
     print "<br/>\n<h1>$www{'head'}</h1>\n\n";
+
+    $section = $sektion;
     &formquery;
 
     local ($mpath) = $manPath{$manpath};
@@ -1421,6 +1423,8 @@ sub apropos {
     print qq{<dl>\n};
     while (<APROPOS>) {
         next if !/$q/oi;
+        next if $sektion && !/\($sektion\)/oi;
+
         $acounter++;
 
         # matches whatis.db lines: name[, name ...] (sect) - msg
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.