From 13c0ff556759662b67c20fc12b9d31f041024da2 Mon Sep 17 00:00:00 2001 From: Nemo Inis Date: Fri, 21 Dec 2018 21:16:48 +0900 Subject: w3mman support for section number during keyword search Origin: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=916968#5 --- scripts/w3mman/w3mman.1.in | 2 ++ scripts/w3mman/w3mman.in | 13 +++++++------ scripts/w3mman/w3mman2html.cgi.in | 20 +++++++++++++------- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/scripts/w3mman/w3mman.1.in b/scripts/w3mman/w3mman.1.in index 8c433a7..b85b0a0 100644 --- a/scripts/w3mman/w3mman.1.in +++ b/scripts/w3mman/w3mman.1.in @@ -30,6 +30,8 @@ w3mman \- an interface to the on-line reference manuals via w3m(1) .B w3mman [ .BI \-M " path" +] [ +.I section ] .BI \-k " keyword" .br diff --git a/scripts/w3mman/w3mman.in b/scripts/w3mman/w3mman.in index 6a27e70..2a33438 100644 --- a/scripts/w3mman/w3mman.in +++ b/scripts/w3mman/w3mman.in @@ -6,8 +6,8 @@ $SCRIPT = 'file:///$LIB/w3mman2html.cgi'; sub usage { ($_ = $0) =~ s@.*/@@; - print STDERR "$_ [-M ] [[
] ]\n"; - print STDERR "$_ [-M ] [-k ]\n"; + print STDERR "$_ [-M ] [
] ]\n"; + print STDERR "$_ [-M ] [
] [-k ]\n"; print STDERR "$_ [-l ]\n"; exit 1; } @@ -20,7 +20,8 @@ while (@ARGV) { $ENV{'MANPATH'} = shift @ARGV; } elsif (/^-k$/) { @ARGV || &usage(); - $query = "?keyword=" . &form_encode(shift @ARGV); + if ( $query eq "" ) { $query = "?quit=ok"; } + $query .= "&keyword=" . &form_encode(shift @ARGV); } elsif (/^-l$/) { @ARGV || &usage(); $query = "?quit=ok&local=" . &form_encode(shift @ARGV); @@ -28,11 +29,11 @@ while (@ARGV) { } elsif (/^-/) { &usage(); } elsif (/^\d/ || $_ eq 'n') { - @ARGV || &usage(); - $query = "?quit=ok&man=" . &form_encode(shift @ARGV); + if ( $query eq "" ) { $query = "?quit=ok"; } $query .= "§ion=" . &form_encode($_); } else { - $query = "?quit=ok&man=" . &form_encode($_); + if ( $query eq "" ) { $query = "?quit=ok"; } + $query .= "&man=" . &form_encode($_); } } diff --git a/scripts/w3mman/w3mman2html.cgi.in b/scripts/w3mman/w3mman2html.cgi.in index 2cd00f9..d660681 100644 --- a/scripts/w3mman/w3mman2html.cgi.in +++ b/scripts/w3mman/w3mman2html.cgi.in @@ -23,17 +23,23 @@ if ((! $query{"man"}) && (! $query{"local"})) { if ($query{"keyword"}) { $keyword = $query{"keyword"}; $k = &html_quote($keyword); + if ($query{"section"}) { + $section = $query{"section"}; + $sectionopt = "-s $section "; + } else { + $sectionopt = ""; + } print < -man -k $k +man $sectionopt-k $k -

man -k $k

+

man $sectionopt-k $k

    EOF $keyword =~ s:([^-\w\200-\377.,])::g; - open(F, "$MAN -k $keyword 2> /dev/null |"); + open(F, "$MAN $sectionopt -k $keyword 2> /dev/null |"); while() { chop; $_ = &html_quote($_); @@ -58,10 +64,10 @@ Content-Type: text/html
    -
    Manual: -
    Section: -
    Keyword: -
    +
    Manual: +
    Section: +
    Keyword: +
    -- cgit v1.2.3