From bc7f9c90263523dc9c19c63c520cbc8f46c3cbdb Mon Sep 17 00:00:00 2001 From: Dai Sato Date: Wed, 5 Apr 2006 14:18:53 +0000 Subject: apply multiple patches on w3m-dev(-en) ML since Jun 2005 to Jan 2006. --- scripts/w3mman/w3mman.1.in | 11 +++++++-- scripts/w3mman/w3mman.in | 5 +++++ scripts/w3mman/w3mman2html.cgi.in | 47 ++++++++++++++++++++++++++------------- 3 files changed, 46 insertions(+), 17 deletions(-) (limited to 'scripts/w3mman') diff --git a/scripts/w3mman/w3mman.1.in b/scripts/w3mman/w3mman.1.in index eb30237..1c0361d 100644 --- a/scripts/w3mman/w3mman.1.in +++ b/scripts/w3mman/w3mman.1.in @@ -1,4 +1,4 @@ -.TH W3MMAN 1 "Mar 14, 2002" +.TH W3MMAN 1 "Nov 5, 2005" .\" Please adjust this date whenever revising the manpage. .\" .\" Some roff macros, for reference: @@ -19,6 +19,9 @@ w3mman \- an interface to the on-line reference manuals by w3m(1) .br .B w3mman .RI "[-M " path "] -k " keyword +.br +.B w3mman +.RI -l " file .SH DESCRIPTION .B w3mman is the system's manual pager by @@ -31,9 +34,13 @@ Specify .I path as MANPATH. .TP -.B \-k " keyword" +.BI \-k " keyword" Specify .I keyword. +.TP +.BI \-l " file" +Specify a +.I file. .SH ENVIRONMENT .TP .B W3MMAN_W3M diff --git a/scripts/w3mman/w3mman.in b/scripts/w3mman/w3mman.in index 6c6f65d..6a27e70 100644 --- a/scripts/w3mman/w3mman.in +++ b/scripts/w3mman/w3mman.in @@ -8,6 +8,7 @@ sub usage { ($_ = $0) =~ s@.*/@@; print STDERR "$_ [-M ] [[
] ]\n"; print STDERR "$_ [-M ] [-k ]\n"; + print STDERR "$_ [-l ]\n"; exit 1; } @@ -20,6 +21,10 @@ while (@ARGV) { } elsif (/^-k$/) { @ARGV || &usage(); $query = "?keyword=" . &form_encode(shift @ARGV); + } elsif (/^-l$/) { + @ARGV || &usage(); + $query = "?quit=ok&local=" . &form_encode(shift @ARGV); + $query .= "&pwd=" . &form_encode($ENV{'PWD'}); } elsif (/^-/) { &usage(); } elsif (/^\d/ || $_ eq 'n') { diff --git a/scripts/w3mman/w3mman2html.cgi.in b/scripts/w3mman/w3mman2html.cgi.in index f41d487..3cb105d 100644 --- a/scripts/w3mman/w3mman2html.cgi.in +++ b/scripts/w3mman/w3mman2html.cgi.in @@ -19,7 +19,7 @@ if ($QUERY =~ /\=/) { $query{"man"} = &form_decode($QUERY); } -if (! $query{"man"}) { +if ((! $query{"man"}) && (! $query{"local"})) { if ($query{"keyword"}) { $keyword = $query{"keyword"}; $k = &html_quote($keyword); @@ -71,21 +71,29 @@ EOF exit; } -$man = $query{"man"}; -if ($man =~ s/\((\w+)\)$//) { - $section = $1; - $man_section = "$man($1)"; -} elsif ($query{"section"}) { - $section = $query{"section"}; - $man_section = "$man($section)"; +if ($query{"local"}) { + $file = $query{"local"}; + if (! ($file =~ /^\//)) { + $file = $query{"pwd"} . '/' . $file; + } + open(F, "$MAN -l $file 2> /dev/null |"); } else { - $section = ""; - $man_section = "$man"; -} + $man = $query{"man"}; + if ($man =~ s/\((\w+)\)$//) { + $section = $1; + $man_section = "$man($1)"; + } elsif ($query{"section"}) { + $section = $query{"section"}; + $man_section = "$man($section)"; + } else { + $section = ""; + $man_section = "$man"; + } -$section =~ s:([^-\w\200-\377.,])::g; -$man =~ s:([^-\w\200-\377.,])::g; -open(F, "$MAN $section $man 2> /dev/null |"); + $section =~ s:([^-\w\200-\377.,])::g; + $man =~ s:([^-\w\200-\377.,])::g; + open(F, "$MAN $section $man 2> /dev/null |"); +} $ok = 0; undef $header; $blank = -1; @@ -176,6 +184,11 @@ if ($prev) { close(F); if (! $ok) { if ($query{'quit'}) { + if ($query{'local'}) { + print STDERR "File $file not found.\n"; + } else { + print STDERR "No manual entry for $man_section.\n"; + } print STDERR "No manual entry for $man_section.\n"; print <
 EOF
-  print "No manual entry for $man_section.\n";
+  if ($query{'local'}) {
+    print "File $file not found.\n";
+  } else {
+    print "No manual entry for $man_section.\n";
+  }
 }
 print <
-- 
cgit v1.2.3