Ingo Schwarze [Fri, 13 Mar 2020 15:32:28 +0000 (15:32 +0000)]
Split tagging into a validation part including prioritization
in tag.{h,c} and {mdoc,man}_validate.c
and into a formatting part including command line argument checking
in term_tag.{h,c}, html.c, and {mdoc|man}_{term|html}.c.
Immediate functional benefits include:
* Improved prioritization of automatic tags for .Em and .Sy.
* Avoiding bogus automatic tags when .Em, .Fn, or .Sy are explicitly tagged.
* Explicit tagging of .Er and .Fl now works in HTML output.
* Automatic tagging of .IP and .TP now works in HTML output.
But mainly, this patch provides clean earth to build further improvements on.
Technical changes:
* Main program: Write a tag file for ASCII and UTF-8 output only.
* All formatters: There is no more need to delay writing the tags.
* mdoc(7)+man(7) formatters: No more need for elaborate syntax tree inspection.
* HTML formatter: If available, use the "string" attribute as the tag.
* HTML formatter: New function to write permalinks, to reduce code duplication.
Style cleanup in the vicinity while here:
* mdoc(7) terminal formatter: To set up bold font for children,
defer to termp_bold_pre() rather than calling term_fontpush() manually.
* mdoc(7) terminal formatter: Garbage collect some duplicate functions.
* mdoc(7) HTML formatter: Unify <code> handling, delete redundant functions.
* Where possible, use switch statements rather than if cascades.
* Get rid of some more Yoda notation.
The necessity for such changes was first discussed with kn@, but i didn't
bother him with a request to review the resulting -673/+782 line patch.
Ingo Schwarze [Thu, 27 Feb 2020 21:43:44 +0000 (21:43 +0000)]
Fully support explicit tagging of .Sh and .Ss.
This fixes the offset of two lines in terminal output
and this improves HTML output by putting the id= attribute
and <a> element into the respective <h1> or <h2> element rather
than writing an additional <mark> element.
To that end, introduce node flags NODE_ID (to make the node a link
target, for example by writing an HTML id= attribute or by calling
tag_put()) and NODE_HREF (to make the node a link source, used only
in HTML output, used only to write an <a class="permalink"> element).
In particular:
* In the validator, generalize the concept of the "next node"
such that it also works before .Sh and .Ss.
* If the first argument of .Tg is empty, don't forget to complain
if there are additional arguments, which will be ignored.
* In the terminal formatter, support writing of explicit tags
for all kinds of nodes, not just for .Tg.
* In deroff(), allow nodes to have an explicit string representation
even when they aren't text nodes. Use this for explicitly tagged
section headers. Suprisingly, this is sufficient to make HTML
output work, without explicit code changes in the HTML formatter.
* In syntax tree output, display NODE_ID and NODE_HREF.
Ingo Schwarze [Thu, 27 Feb 2020 01:43:52 +0000 (01:43 +0000)]
Introduce the concept of nodes that are semantically transparent:
they are skipped when looking for previous or following high-level
macros. Examples include roff(7) .ft, .ll, and .ta, mdoc(7) .Sm
and .Tg, and man(7) .DT and .PD. Use this concept for a variety
of improved decisions in various validators and formatters.
While here,
* remove a few const qualifiers on struct arguments that caused trouble;
* get rid of some more Yoda notation in the vicinity;
* and apply some other stylistic improvements in the vicinity.
I found this class of issues while considering .Tg patches from kn@.
Ingo Schwarze [Thu, 27 Feb 2020 00:36:20 +0000 (00:36 +0000)]
Fix this test after the recent Unicode update in OpenBSD base.
The test uses U+07FF NKO TAMAN SIGN because it is the highest
code point having a two-byte UTF-8 representation.
This character is a new single-width punctuation character in
Unicode 11, such that mandoc now does correct horizontal spacing.
We already used the code point for the test before it was assigned,
which resulted in weird spacing because wcwidth(3) returns -1 for
unassigned code points.
Ingo Schwarze [Mon, 24 Feb 2020 21:16:31 +0000 (21:16 +0000)]
Marc Espie reported that "man p*ipc" displayed the perlipc(1) manual.
The reason was that as a last resort when failing to find a page
name in mandoc.db(5) or at a few well well-defined fully qualified
file names, man(1) uses glob(3) to look for candidate files in
relevant directories, because some operating systems have weird
file name extensions, for example pcap.3pcap and BF_set_key.3ssl
on Linux. But during that globbing, the metacharacters "*?[" need
to be escaped in the name, section, and path supplied by the user,
or you would get weird false positives and misleading warning
messages and would be unable to use the fallback for path or file
names that actually contain an opening bracket.
Feedback and OK espie@.
Ingo Schwarze [Tue, 18 Feb 2020 17:31:28 +0000 (17:31 +0000)]
Mention that .AT, .P, .SB, and .UC are extensions; it really matters
because we only retain the language for backward compatibility in
the first place. Part of the research done by <G dot Branden dot
Robinson at gmail dot com>, see the list <groff at gnu dot org> for
details.
No change to the following conventions: Consider portable whatever
made it into GNU troff no later than 4.4BSD. For portable extensions,
mention their origin at the end of the description. For non-portable
extensions, for example from man-ext, usually warn earlier, near
the beginning of the description.
Ingo Schwarze [Wed, 12 Feb 2020 21:15:53 +0000 (21:15 +0000)]
In roff, a space character at the beginning of an input line requires
starting a new output line, and merely starting a new line of HTML
code isn't sufficient to achieve that. Solve this in the same way
as mdoc_html.c already does it, by printing a <br/> element.
Fixing a bug reported by Jason A. Donenfeld <Jason at zx2c4 dot com>
in the wg-quick(8) manual page on manpages.debian.org.
Ingo Schwarze [Mon, 10 Feb 2020 14:42:10 +0000 (14:42 +0000)]
Finally delete support for the "_whatdb" configuration directive,
which has a misleading syntax. It was declared obsolete and
superseded by the "manpath" directive five years ago.
Ingo Schwarze [Mon, 10 Feb 2020 14:13:24 +0000 (14:13 +0000)]
Reduce the diff to OpenBSD by making FILES a list,
even though it has only one entry in the portable version.
Do not add /etc/examples/man.conf for the portable version, though.
Ingo Schwarze [Mon, 10 Feb 2020 14:04:11 +0000 (14:04 +0000)]
The man(1) command was already available in AT&T Version 2 UNIX.
Jonathan Gray found it in the "Combined Table of Contents" in Doug
McIlroy's "A Research UNIX Reader", which contains a table of which
edition manuals appeared in, and in both the "Table of Contents"
(page vi) and the body (page 89) of the printed UNIX Programmer's
Manual (June 12, 1972) from bitsavers.
Ingo Schwarze [Mon, 10 Feb 2020 13:49:15 +0000 (13:49 +0000)]
For compatibility with the man(1) implementations of the man-1.6
and man-db packages, print the manpath if the -w option is given
without a following name argument.
This quirk has been in man-1.6 since at least man-1.5e (1998)
and in man-db since 2012.
Using this feature in portable software is a dubious idea because the
internal organization of manual page directories varies in about a
dozen respects among operating systems, so even if you get the answer,
there is no portable way to use it for looking up anything inside.
However, Matej Cepl <mcepl at suse dot cz> made me aware that some
software, for example the manual viewing functionality in the newest
editors/neovim code, unwisely relies on this feature anyway.
No objections were raised when this patch was shown on tech@.
Ingo Schwarze [Thu, 6 Feb 2020 19:41:40 +0000 (19:41 +0000)]
Make sure that -l always causes -w to be ignored, as documented
in the man(1) manual page. This bugfix is needed to prevent
the command "man -lw" from dereferencing a NULL pointer.
Ingo Schwarze [Wed, 5 Feb 2020 15:12:11 +0000 (15:12 +0000)]
No longer try to ask make(1) what the default compiler is, just use "cc".
That line was a bad idea in the first place, it tried to be too clever,
and it failed in different ways on different platforms. Even when it
succeeded, what make(1) considered the default wasn't always useful.
Having a simple and robust default and asking users to override it
when needed is better.
Ingo Schwarze [Sun, 26 Jan 2020 21:25:41 +0000 (21:25 +0000)]
Repair more of the issues that i found in filescan() while investigating
the report from <Andreas dot Kahari at abc dot se> on ports@:
For a symlink, use the first of the following names that is available:
1. In -t mode, the symlink itself (unchanged).
2. When the (unresolved) symlink already resides inside the manpath,
just strip the manpath and use the rest (unchanged).
3. When prefix(es) of the unresolved symlink point to the manpath,
strip the longest such prefix and use the rest (new); this fixes
situations where the manpath or one of its parent directories is a
symlink and at the same time contains symlinks to manual pages.
4. Fall back to the fully resolved symlink, with the manpath stripped
(new); this may for example happen when the command line passes
symlinks from outside the manpath that point to manual pages inside
the manpath, or if manual page trees contain symlinks to symlinks and
not all of them are given on the command line.
The fallback (4) isn't perfect. You can construct symlink spaghetti
in such a way that this algorithm will not enter all manual page
names into the database that a human would be able to deduce. But
i do not expect such spaghetti to actually occur in practice (not
even in ports), and a full fix would require re-implementing
realpath(3) in terms of step-by-step readlink(2) calls, repeating
the complicated algorithm (3) after each step.
While here, also stop using PATH_MAX as the size of a static buffer
in filescan(); on some systems, it can be unreasonably large.
Instead, allocate path strings dynamically.
Ingo Schwarze [Sun, 26 Jan 2020 11:16:47 +0000 (11:16 +0000)]
Fix incorrect file type tests.
This bug caused sockets and character special devices to be accepted
as manual pages if they appeared inside manpaths, and
it caused incorrect file names to be entered into the database when
the manpath or one of its parent directories was a symbolic link.
This fixes the issues reported by <Andreas dot Kahari at abc dot se>
on ports@, but additional issues remain when symbolic links are
contained in a manpath that involves another symbolic link.
Ingo Schwarze [Sat, 25 Jan 2020 22:59:22 +0000 (22:59 +0000)]
Minor cleanup, no functional change:
Do not abuse strstr(3) to check whether one long string starts with
another long string. Instead, use strncmp(3) with the proper length.
In set_basedir(), also reset *basedir in the error brances for extra safety.
While here, invert some more Yoda conditions in the neighbourhood.
Ingo Schwarze [Mon, 20 Jan 2020 10:37:15 +0000 (10:37 +0000)]
Make the code more readable by introducing
symbolic constants for tagging priorities.
This review also made me find a minor bug: do not upgrade
TAG_FALLBACK to TAG_WEAK when there is trailing whitespace.
Ingo Schwarze [Sun, 19 Jan 2020 18:02:00 +0000 (18:02 +0000)]
Introduce a new mdoc(7) macro .Tg ("tag") to explicitly mark a place
as defining a term. Please only use it when automatic tagging does
not work. Manual page authors will not be required to add the new
macro; using it remains optional. HTML output is still rudimentary
in this version and will be polished later.
Thanks to kn@ for reminding me that i have been considering since
BSDCan 2014 whether something like this might be useful. Given
that possibilities of making automatic tagging better are running
out and there are still several situations where automatic tagging
cannot do the job, i think the time is now ripe.
Feedback and no objection from millert@; OK espie@ inoguchi@ kn@.
Ingo Schwarze [Sun, 19 Jan 2020 16:44:50 +0000 (16:44 +0000)]
Align to the new, sane behaviour of the groff_mdoc(7) .Dd macro:
without an argument, use the empty string, and always concatenate
all arguments, no matter their number.
This allows reducing the number of arguments of mandoc_normdate()
and some other simplifications, at the same time polishing some
error messages by adding the name of the macro in question.
Ingo Schwarze [Sat, 11 Jan 2020 20:48:18 +0000 (20:48 +0000)]
When autogenerating one layout cell from a data cell just beyond the
last layout cell that was explicitly specified, properly initialize
the spacing attribute to indicate that the default is to be used.
Failing to do so and leaving the spacing at zero in this case caused
misformatting when another row further down the table had even more
explicitly specified cells.
Bug found while trying to write regression tests for tbl_term.c rev. 1.73.
Ingo Schwarze [Sat, 11 Jan 2020 16:26:08 +0000 (16:26 +0000)]
Fix a logic error:
When both the first and the third column are spans, do not use
the number of columns of the span starting in column two
for the span starting in column zero.
With afl, Jan Schreiber <jes at posteo dot de> found cases where
this caused NULL pointer accesses because too many layout cells
were consumed.
While here, make the code more similar at the three places
that iterate over data cells.
Ingo Schwarze [Fri, 10 Jan 2020 12:54:43 +0000 (12:54 +0000)]
Switch off the useless and annoying "autocomplete" feature;
issue reported by Tim Baumgard <at bmgrd dot com>.
landry@ and florian@ agree with the general direction.
Ingo Schwarze [Fri, 10 Jan 2020 11:55:04 +0000 (11:55 +0000)]
Document the "delim" syntax and its usage.
Closing a gap reported by bentley@, who also sent a patch,
but i'm explaining it somewhat differently.
While here, remove duplicate information from the text.
OK bentley@
Ingo Schwarze [Wed, 8 Jan 2020 11:01:37 +0000 (11:01 +0000)]
Improve the test case by changing the eqn(7) delimiters such that it
actually tests which parts of text lines are processed with eqn(7)
and which are not.
Ingo Schwarze [Wed, 8 Jan 2020 10:37:53 +0000 (10:37 +0000)]
Simplify maintainer targets in OpenBSD: EQN and TBL variables
no longer exist and NROFF/NOPTS were replaced with GROFF/GOPTS.
This doesn't change how things work in the protable version
of the test suite.
Ingo Schwarze [Tue, 7 Jan 2020 11:16:33 +0000 (11:16 +0000)]
Improve the description of -m/-M/MANPATH/man.conf in multiple respects
after kn@ reported that the descriptions were incomplete and somewhat
inaccurate.
OK jmc@ kn@
Ingo Schwarze [Tue, 31 Dec 2019 22:58:41 +0000 (22:58 +0000)]
When all cells in a tbl(1) column are empty, set the column width
to 1n rather than to 0n, in the same way as groff does.
This fixes misformatting reported by bentley@ in xkeyboard-config(7).
Ingo Schwarze [Thu, 26 Dec 2019 19:51:51 +0000 (19:51 +0000)]
Do not fail an assertion when a high level macro occurs in the body
of a conditional inside a .ce request block. Instead, abort the .ce
block just like when there is no conditional in between.
Bug found by espie@ working on the textproc/fstrcmp port.
Ingo Schwarze [Wed, 11 Dec 2019 18:44:05 +0000 (18:44 +0000)]
In HTML, display straight quotes, not curly quotes, for Qq/Qo/Qc macros.
This is the intended behavior and already the case in terminal output.
Incorrect output noticed by Eldred Habert.
Patch from bentley@.
Ingo Schwarze [Sun, 10 Nov 2019 22:35:25 +0000 (22:35 +0000)]
Add a Content-Security-Policy HTTP header that allows only CSS.
This ensures that in a modern browser that understands the header,
mandoc rendering bugs cannot possibly be interpreted as JavaScript.
Patch from bentley@.
Ingo Schwarze [Sat, 9 Nov 2019 14:39:49 +0000 (14:39 +0000)]
In the past, generating comment nodes stopped at the .TH or .Dd
macro, which is usually close to the beginning of the file, right
after the Copyright header comments. But espie@ found horrible
input files in the textproc/fstrcmp port that generate lots of parse
nodes before even getting to the header macro. In some formatters,
comment nodes after some kinds of real content triggered assertions.
So make sure generation of comment nodes stops once real content is
encountered.
Ingo Schwarze [Tue, 1 Oct 2019 17:54:14 +0000 (17:54 +0000)]
For invalid queries and for valid queries returning no result,
return the appropriate 40x status code rather than 200.
Improvement suggested and diff tested
by John Gardner <gardnerjohng at gmail dot com>.
Fix line breaking in no-fill mode (.Bd -unfilled/<pre>),
which apparently didn't work since the .Pp/<p> reorg.
The new logic is more similar to what the terminal formatter does:
1. Before a node that starts a new mdoc(7) input line,
start a new HTML output line.
2. An empty input line or a .Pp causes an empty output line.
3. Nothing needs to be done at the end of a node.
Severe misformatting was reported in table(5) by
Edgar Pettijohn <edgar at pettijohn dash web dot com> on misc@.
Improve validation of function names:
1. Relax checking to accept function types of the form
"ret_type (fname)(args)" (suggested by Yuri Pankov <yuripv dot net>).
2. Tighten checking to require the closing parenthesis.
Do not clear HTML_NOSPACE in print_indent().
I don't think there ever was a reason for doing so.
Besides, there is a discrepacy with respect to the point in the
document affected. That flag controls whitespace at the current
formatting point. But when HTML_BUFFER is in effect, the line break
and indentation is typically inserted one word further to the left.
Anything happening at that point to the left can't reasonably
influence spacing at the different point further to the right.
Among other effects, this change avoids some spurious line breaks
in HTML code at points where they weren't supposed to happen, line
breaks that in some cases caused undesirable, visible whitespace
when the resulting HTML was rendered.
Wrap text and phrasing elements in paragraphs unless already
contained in flow containers; never put them directly into sections.
This helps to format paragraphs with the CSS class selector .Pp.
Suggested by bentley@ and also by Colin Watson <cjwatson at debian>
via Michael Stapelberg <stapelberg at debian>,
see https://github.com/Debian/debiman/issues/116
Format .Nd with more logically with <span> rather than <div>; after all,
it is supposed to be a one-line description. For the case where .Nd
generates flow content (which is very bad style but syntactically
valid), rely on the new feature of html_close_paragraph() to close
out the <span> prematurely, effectively moving the flow content out
of the .Nd for HTML presentation. For the final closing, also rely
on the new html_close_paragraph() functionality, this time triggered
by the subsequent block, which will typically be .Sh SYNOPSIS.
Make html_close_paragraph() more versatile, more robust, less
dependent on individual HTML elements, and simpler: don't just close
<p>, <pre>, and <a>, but any element that establishes phrasing
context. This doesn't change output for any OpenBSD manual page,
but it will allow using this function more safely and at more places
in the future.
Ingo Schwarze [Thu, 29 Aug 2019 17:57:29 +0000 (17:57 +0000)]
In the HTML formatter, assert(3) that no HTML nesting violation occurs.
Tested on the complete manual page trees of Version 7 AT&T UNIX,
4.4BSD-Lite2, POSIX-2013, OpenBSD 2.2 to 6.5 and -current,
FreeBSD 10.0 to 12.0, NetBSD 6.1.5 to 8.1, DragonFly 3.8.2 to 5.6.1,
and Linux 4.05 to 5.02.
Simplification, no functional change:
Delete the "argc" argument from fs_search() which is now always 1,
and move error reporting to the main() program where it is more
logically placed and easier to see.
In man(1) mode, do the search for each name independently, and
show the results in the order of the command line arguments.
Implemented by separating the code for man(1) and apropos(1)
in the main() program.
Surprisingly, the number of lines of code remains unchanged.
Issue reported by deraadt@, additional input from millert@.
Cleanup, no functional change:
For clarity, stop storing the same information (in this case, -O
settings) in two structs. Give the local struct in main.c a more
descriptive name (output state).
Structural cleanup, no functional change:
Mixing parser and formatter state in the same struct was a bad idea,
so pull the parser state and configuration out of it.
This makes sure output options are not passed into parser functions
and parser options are not passed into output functions.
While here, add comments to the important local variables in main().
Structural cleanup, no functional change:
Move process group management out of main() into its own function
because it has its own, self-contained logic and its own local variables.
Slowly start implementing tagging support for man(7) pages, even
though it is obvious that this can never become as good as for
mdoc(7) pages. As a first step, tag alphabetic arguments of .IP
macros, which are often used for lists of options and keywords.
Try "man -O tag=g as" to get the point.
Thanks to Leah Neukirchen for recently reminding me that exploring
how much can be done in this respect may be worthwhile: it is likely
to slightly improve usability while adding only small amounts of
relatively straightforward code.
If no tags were generated at all, unlink(2) the empty tags file as
soon as the condition can be detected and do not pass it to less(1).
This may happen for man(7) pages, for preformatted pages, and for
very simple pages like true(1). The main benefit is that :t inside
less(1) yields the clearer diagnostic message "No tags file" rather
than the mildly confusing "No such tag in tags file": the latter
might encourage further, futile attempts to jump to other tags.
Improvement suggested by Leah Neukirchen <leah at vuxu dot org>
from The Void.
If messages are shown and output is printed without a pager, display
a heads-up on stderr at the end because otherwise, users may easily
miss the messages: because messages typically occur while parsing,
they typically preceed the output. This is most useful with flag
combinations like "-c -W all" but may also help in some unusual
error scenarios.
Inconvenient ordering of output originally pointed out by espie@
for the example situation that /tmp/ is not writeable.
When parsing a tab character that is not preceded by a space character
on an .It -column line, args() sets the MDOC_PHRASEQL flag to Quote
the Last word of the Phrase. Even if it turns out this quoting is not
needed because the word is already quoted for other reasons, clear the
flag at the end of parsing the phrase, such that the flag does not leak
to the next phrase.
This patch fixes the bug that the trailing Macro on a line of the form
.It "word<tab>word" Ta word Macro<eol>
was incorrectly considered quoted and hence not parsed.
Bug found by Havard Eidnes (he@) with the NetBSD gettytab(5) manual page:
https://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=54361
Reported via Thomas Klausner (wiz@).
Some time ago, i simplified mandoc_msg() such that it can be used
everywhere and not only in the parsers.
For more uniform messages, use it at more places instead of err(3),
in particular in the main program.
While here, integrate a few trivial functions called at exactly one
place into the main option parser, and let a few more functions use
the normal convention of returning 0 for success and -1 for error.
The non-standard .EX/.EE macro pair was invented for Version 9 AT&T UNIX
and only got adopted by GNU two decades later.
Thanks to Doug McIlroy <doug at cs dot dartmouth dot edu>
for pointing out the error.
delete trailing whitespace and space-tab sequences; no code change;
patch from Michal Nowak <mnowak at startmail dot com>
who found these with git pbchk in the illumos tree
Ingo Schwarze [Thu, 27 Jun 2019 15:07:30 +0000 (15:07 +0000)]
Fix mandoc_normdate() and the way it is used.
In the past, it could return NULL but the calling code wasn't prepared
to handle that. Make sure it always returns an allocated string.
While here, simplify the code by handling the "quick" attribute
inside mandoc_normdate() rather than at multiple callsites.
Triggered by deraadt@ pointing out
that snprintf(3) error handling was incomplete in time2a().
Ingo Schwarze [Thu, 27 Jun 2019 12:20:18 +0000 (12:20 +0000)]
Improve "man -h" output.
1. For pages lacking a SYNOPSIS, show the NAME section rather than nothing.
2. Do not print a stray blank before the beginning of a SYNOPSIS.
Both issues reported by, and patch OK'ed by, tb@.
Ingo Schwarze [Tue, 11 Jun 2019 16:04:36 +0000 (16:04 +0000)]
Do not access a NULL pointer if a table contains a horizontal line
next to a table line having fewer columns than the table as a whole.
Bug found by Stephen Gregoratto <dev at sgregoratto dot me>
with aerc-config(5).
Ingo Schwarze [Mon, 3 Jun 2019 20:23:41 +0000 (20:23 +0000)]
Explicitly state that the cases in the inner switch in term_fill()
are exhaustive. While there is no bug, being explicit has no downside
is is potentially safer for the future.
Michal Nowak <mnowak at startmail dot com> reported that gcc 4.4.4
and 7.4.0 on illumos throw -Wuninitialized false positives.
Ingo Schwarze [Mon, 3 Jun 2019 19:58:02 +0000 (19:58 +0000)]
Initialize the local variable "lastln" in mparse_buf_r().
While there is no bug, it logically makes sense given the meaning
of the variable that lastln is NULL as long as firstln is NULL.
Michal Nowak <mnowak at startmail dot com> reported that gcc 4.4.4
and 7.4.0 on illumos throw -Wuninitialized false positives.
Ingo Schwarze [Mon, 3 Jun 2019 19:50:33 +0000 (19:50 +0000)]
Initialize the local variable "act" in print_mdoc_node().
While there is no bug, it helps clarity, and it is also safer in this
particular code because in case a bug gets introduced later, accessing
a NULL pointer is less dangerous than accessing an uninitialized pointer.
Michal Nowak <mnowak at startmail dot com> reported that gcc 4.4.4
and 7.4.0 on illumos throw -Wuninitialized false positives.
Ingo Schwarze [Tue, 21 May 2019 08:04:21 +0000 (08:04 +0000)]
Do not print the style message "missing date" when the date is given
as "$Mdocdate$" without an actual date. That is the canonical way to
write a new manual page and not bad style at all.
Misleading message reported by kn@ on tech@.
Ingo Schwarze [Fri, 3 May 2019 18:17:12 +0000 (18:17 +0000)]
Enter dangling .so links into the database, to avoid harassing
users of man(1) about running makewhatis(8), which won't help.
Seeing the content of the broken .so request might even help
users to figure out how to access the manual page they want.
Fixing the last issue reported by Lorenzo Beretta <loreb at github>
as part of https://github.com/void-linux/void-packages/issues/9868 .
Ingo Schwarze [Fri, 3 May 2019 17:31:15 +0000 (17:31 +0000)]
In fs_lookup(), use stat(2) rather than access(2) to check file existence.
Some mildly broken real-world packages on some operating systems
contain dangling symlinks in manual page directories: pestering the
user to run makewhatis(8) makes no sense because that won't help.
On the other hand, missing read permissions deserve ugly error messages
and are unlikely to occur in practice anyway.
Fixing an issue reported by Lorenzo Beretta <loreb at github>
as part of https://github.com/void-linux/void-packages/issues/9868 .
Ingo Schwarze [Fri, 3 May 2019 16:14:41 +0000 (16:14 +0000)]
In man(1) mode with a specific section requested,
try harder to find the best match.
Use this order of preference:
1. The section in both the directory name and the file name matches exactly.
2. The section in the file name matches exactly.
3. The section in the directory name matches exactly.
4. Neither of them matches exactly.
The latter can happen when mansearch() finds substring matches
or when the second .Dt argument mismatches the dir and file names.
Lorenzo Beretta <loreb at github> reported that this caused real
problems on Void Linux, like "man 3 readline" showing readline(3m).
See https://github.com/void-linux/void-packages/issues/9868 for details.