Ingo Schwarze [Tue, 8 May 2018 17:52:55 +0000 (17:52 +0000)]
Switch the emitted HTML element from <b> to <code> for the fixed
syntax element macros .Nm, .Fl, .Cm, .Ic, .In, .Fd, .Fn, and .Cd.
Adjust both the internal and external style sheets such that
rendering remains unchanged in typical browsers.
Based on feedback from John Gardner <gardnerjohng at gmail dot com>.
Simpler description of output formats, shortening the manual page by 15 lines.
Avoid the double redirection from -Tutf8 via -Tlocale to -Tascii.
Add LC_CTYPE to the ENVIRONMENT section.
While here, also correct a few inaccuracies and tweak some wordings.
Triggered by a question from Laura Morales <lauretas at mail dot com>.
Better mandoc(1) -I and -T options for Heirloom comparisons.
Filter through col(1) -b for Heirloom because it produces double encoding.
Switch on mandoc(1) -Wall in groff comparisons.
Update usage.
replace my vague and idiosyncratic term "selflink"
with the clearer and more usual "permalink";
suggested by John Gardner <gardnerjohng at gmail dot com>
Avoid the misunderstanding that the essential purpose of -l is
similar to the purpose of the -a option in mandoc(1), which is not
the point: the fact that -l implies -a is merely a minor detail.
The point of -l is to make man(1) behave like mandoc(1).
Move the mention of -a to the end to de-emphasize it.
Nate Bargmann reported that this seriously confused him,
and i can see why.
Compatibility with man-db:
In page name mode (= man(1) default mode), also try to interpret
names containing slashes as absolute or relative file names.
Missing feature reported by Nate Bargmann on <groff at gnu dot org>,
and the man-db maintainer Colin Watson <cjwatson at debian dot org>
kindly explained to me how this is supposed to work.
Use TIOCGWINSZ to reduce the default -Owidth during interactive use
on terminals narrower than 79 columns and the default -Oindent on
terminals narrower than 66 columns.
Requested by and feedback from pirofti@;
mpi@ and juanfra@ also like the general direction.
Make sure that mandoc only goes into UTF-8 mode if the user really
selected UTF-8, not some other multibyte locale. This obviously
makes no difference on OpenBSD but improves portability.
Issue reported by <Nakayama at NetBSD> via wiz@.
preserve comments before .Dd and .TH (typically Copyright and license)
in full HTML output, but not with -Ofragment, e.g. in man.cgi(8);
suggested by Thomas Klausner <wiz at NetBSD>
Two new low-level roff(7) features:
* .nr optional third argument (auto-increment step size)
* \n+ and \n- numerical register auto-increment and -decrement
bentley@ reported on Dec 9, 2013 that lang/sbcl(1) uses these.
When accessing an undefined number register, define it to be zero, like
the previous commit for strings and macros, only technically simpler.
Desired behaviour also mentioned by Werner Lemberg in 2011.
This diff adds functionality but is -21 +19 LOC. :-)
Using an undefined string or macro will cause it to be defined as empty.
Observed by Werner Lemberg on Nov 14, 2011
and rotting on my TODO list ever since.
Do not use a non-portable .R man(7) macro. Neither groff nor the
heirloom-doctools support it. Work around the gap by using .BR
with an empty first argument. This was noticed more than once in
the past, but i always forgot to fix it.
Ingo Schwarze [Fri, 16 Mar 2018 20:41:41 +0000 (20:41 +0000)]
Ouch, fix previous: In the edge case of a single-character string
containing nothing but a single hyphen, the pointer got incremented
twice at one point, causing a read overrun found by naddy@.
Ingo Schwarze [Thu, 15 Mar 2018 18:10:31 +0000 (18:10 +0000)]
Soften the language discouraging special character escape sequences.
After i improved their ASCII renderings in groff and mandoc some time
ago, mathematical symbols can now be used in specialised mathematical
manual pages like libm and some X libraries.
Tweaks and OK jmc@.
Ingo Schwarze [Fri, 23 Feb 2018 21:35:19 +0000 (21:35 +0000)]
After opening a file with gzdopen(3), we have to call gzclose(3) or
we leak memory internally used by zlib to keep compression state.
Bug reported by Wolfgang Mueller <vehk at vehk dot de> who also
provided an incomplete patch, part of which i'm using in this commit.
Ingo Schwarze [Fri, 23 Feb 2018 18:25:57 +0000 (18:25 +0000)]
Logically, the following are are type names - just like .Vt,
some of them with an optional variable name following:
- .Ft
- .Fa in the SYNOPSIS
- .Fn second and later arguments in the SYNOPSIS
So add these to the .Vt macro table in the mandoc.db(5) database.
During my LibreSSL work, i'm getting really tired of typing
$ man -k Vt,Ft,Fa=some_type_name
over and over again; now, this becomes just:
$ man -k Vt=some_type_name
Ingo Schwarze [Fri, 23 Feb 2018 16:47:10 +0000 (16:47 +0000)]
Invalidate the tag_files.tfd after fclose(3)ing the stram associated
with it. In main() assert that the tfd was actually invalidated.
This avoids closing an invalid fd.
From tb@; OK deraadt@ on an earlier version.
Ingo Schwarze [Wed, 7 Feb 2018 20:31:39 +0000 (20:31 +0000)]
In man(7) and cat pages, cut off excessive one line descriptions.
An extreme example of how rogue files could mess up apropos(1) output
was reported by bentley@: qwtlicense(3) in the x11/qwt port.
Ingo Schwarze [Wed, 7 Feb 2018 20:04:57 +0000 (20:04 +0000)]
Fix the mandoc_strndup() utility function. All existing callers seem
safe so far, but implementing it with an unchecked memcpy(3) is just
wrong and quite dangerous.
Ingo Schwarze [Tue, 6 Feb 2018 16:29:57 +0000 (16:29 +0000)]
Delete the "no blank before trailing delimiter" check from the
partial explicit macros. Leah Neukirchen <leah at vuxu dot org>
rightfully points out that the check makes no sense for these macros.
Ingo Schwarze [Sat, 13 Jan 2018 05:23:18 +0000 (05:23 +0000)]
Remove the implicit display feature of .Lk because it was inconsistent
across output devices, counter-intuitive, and resulted in ugly
output for many real-world manual pages. Always format even long
links in-line. I already committed a similar change to groff.
OK jmc@, bentley@, and the original author
of the feature, Werner Lemberg <wl@gnu.org>.
Ingo Schwarze [Wed, 29 Nov 2017 20:05:33 +0000 (20:05 +0000)]
Recognize .Bl -column at parse time, and not only at validation time,
even if other arguments precede -column. This is required because
the .It parser needs to know whether or not we are a -column list.
Fixes tree corruption leading to an assertion failure.
Bug reported by bentley@.
Ingo Schwarze [Thu, 2 Nov 2017 14:53:02 +0000 (14:53 +0000)]
Shrink -Tps output by more than 50%
by using PostScript as a programming language.
* Define and use one PostScript procedure to select each font.
* Define and use procedures combining "use" and "show".
* In one of these, reuse the current row if it did not change.
Most ideas and most coding by espie@, tweaked by me.
Ingo Schwarze [Sun, 29 Oct 2017 19:25:31 +0000 (19:25 +0000)]
Print a human-readable media name in the %%DocumentMedia DSC comment
and use the setpagedevice PostScript operator to help printers
automatically select the paper of the best matching PageSize.
Many thanks to Mike Williams <obsd1 at eandem dot co dot uk>
for teaching me about the relevant features of PostScript and DSC
and for suggesting what to put into the first %%DocumentMedia argument.
Ingo Schwarze [Wed, 25 Oct 2017 20:48:48 +0000 (20:48 +0000)]
The page footer line (psmarg) is created in ps_begin(), and the
last call writing to it is always ps_endline(), which ends with
ps_pclose(), which prints "ET" (end text).
Consequently, do not print another instance of "ET" in ps_closepage()
after the footer line and before the "endstream" for the page.
Fixing a PDF syntax error found while investigating the bug report
from Jan Stary that also resulted in the previous commit.
Ingo Schwarze [Wed, 25 Oct 2017 18:52:06 +0000 (18:52 +0000)]
Properly close out the top-level Font object, the end-of-page
Resource objects, and the Catalog object, fixing three PDF syntax
errors that were present in every PDF file generated with mandoc
since the initial checkin of the formatter in July 2010.
Bug reported by Jan Stary <hans at stare dot cz> on misc@.
Ingo Schwarze [Mon, 23 Oct 2017 13:54:41 +0000 (13:54 +0000)]
Modernize documentation of .Ao and .Aq.
I looked through our whole tree and failed to find a single use
that is really convincing, except those with .Mt. Putting it around
character and key names is somewhat widespread and maybe acceptable,
even if hardly useful.
So for now, delete the bogus examples and explain what these macros
are really used for. Discourage the most common abuses.
Triggered by a question from Raf Czlonka <rczlonka at gmail dot com>.
Do not segfault when there are two .Dt macros, the first without
an architecture argument and the second with an invalid one.
Bug found by jsg@ with afl(1).
Ingo Schwarze [Sat, 26 Aug 2017 15:55:46 +0000 (15:55 +0000)]
Do not fork and exec cmp(1); instead, simply fstat(2), mmap(2), and
compare the files directly, allowing a much stricter pledge(2), at
very little cost: merely 15 additional lines of very simple code.
Suggested by George Brown <321 dot george at gmail dot com> on misc@.
Ingo Schwarze [Sat, 26 Aug 2017 12:59:17 +0000 (12:59 +0000)]
No need to fork and exec rm(1) -rf, we know that we have exactly
one file and exactly one directory to remove. While here, increase
the size of the buffer such that the file name actually fits.
Minus 17 lines of code, no functional change.
Opportunity for simplification reported by George Brown <321 dot
george at gmail dot com> on misc@.
Ingo Schwarze [Wed, 23 Aug 2017 20:03:17 +0000 (20:03 +0000)]
Suppress spacing before certain kinds of lists.
One benefit is a reduced probablity that a blank appears between
a function name and the opening parenthesis introducing the arguments.
The heuristics isn't perfect and may occasionally suppress a blank
that wouldn't do harm.
Ingo Schwarze [Wed, 23 Aug 2017 10:50:15 +0000 (10:50 +0000)]
Switch ASCII rendering of the same mathematical symbols and greek
letters as in groff commit babca15f from trying to imitate the
characters' graphical shapes, which resulted in unintelligible
renderings in many cases, to transliterations conveying the characters'
meanings. One benefit is making these characters usable for portable
manual pages.
Ingo Schwarze [Mon, 21 Aug 2017 15:42:58 +0000 (15:42 +0000)]
When the stdout stream gets broken, there is no point in reading
any more input files, and it would be misleading to start a parser,
because that would show randomly truncated text.
Instead, print an error message and exit the program.
Issue found by Leah Neukirchen <leah at vuxu dot org>, who was
surprised to see half a manpage when her /tmp/ overflew.
Ingo Schwarze [Fri, 11 Aug 2017 16:56:21 +0000 (16:56 +0000)]
Make the "new sentence, new line" check stricter, allowing digits
in the last two letters of the last word of the sentence.
No false positives in base or Xenocara.
Suggested by and OK jmc@.
Ingo Schwarze [Wed, 9 Aug 2017 12:49:04 +0000 (12:49 +0000)]
Explain how to transform markup for the terminal when not using a
pager, and how to remove markup. Add related cross references.
While here, as suggested by jmc@, replace the excessive cross
references to the intro pages by a more relevant one to mandoc(1).
Triggered by a question from, using feedback from, and OK jmc@.
Ingo Schwarze [Wed, 2 Aug 2017 13:29:04 +0000 (13:29 +0000)]
No longer use names that only occur in the SYNOPSIS section as names
for man(1) lookup. For OpenBSD base and Xenocara, that functionality
was never intended to be required, and i just fixed the last handful
of offenders using it - not counting the horribly ill-designed
interfaces engine(3) and lh_new(3) which are impossible to properly
document in the first place.
Of course, apropos(1) and whatis(1) continue to use SYNOPSIS .Nm,
.Fn, and .Fo macros, so "man -k ENGINE_get_load_privkey_function"
still works.
This change also gets rid of a few bogus warnings "cross reference
to self" which actually are *not* to self, like in yp(8).
This former functionality was intended to help third-party software
in the ports tree and on non-OpenBSD systems containing manual pages
with incomplete or corrupt NAME sections. But it turned out it did
more harm than good, and caused more confusion than relief,
specifically for third party manuals and for maintainers of
mandoc-portable on other operating systems. So kill it.
Problems reported, among others, by Yuri Pankov (illumos).
Ignore explicitly specified negative column widths rather than
wrapping around to huge numbers and risking memory exhaustion;
fixes Debian ps(1). Bug reported by Dr. Markus Waldeck.
Fix an out of bounds read access to a constant array that caused
segfaults on certain hardened versions of glibc. Triggered by .sp
or blank lines right before .SS or .SH, or before the first .Sh.
Found the hard way by Dr. Markus Waldner on Debian
and by Leah Neukirchen on Void Linux.
When the mparse_alloc() prototype changed in read.c 1.179, updating
the enum constant was forgotten in this call. No functional change
since the mmsg argument is NULL anyway.
Found by florian@ with clang.
Cast the return value of chdir(2) to void. We already have a comment
above explaining to human auditors why no error checking is needed
here, so it's only fair to tell the compiler, too.
Worried compiler reported by Michael <Stapelberg at debian>.
Avoid cross reference to mandoc(1) because it may cause a message
on other operating systems where mandoc is not installed,
causing the test to fail in the portable test suite.
For -Tlint, put parser messages on stdout instead of stderr.
Originally, naddy@ requested this in 2011 (or maybe even earlier).
It was discussed with joerg@, kristaps@, naddy@, and espie@ in 2011,
and everybody agreed in principle, but it was postponed because
kristaps@ wanted to do some cleanup of the message system first.
Meanwhile, message infrastructure was improved about a dozen times...
This makes long, tedious commands like "mandoc -Tlint *.1 2>&1 | less"
unnecessary and allows simple ones like "man -l -Tlint *.1".
* clean catman.o which was missing
* delete WWW_OBJS which i don't use
* do not complain about *.out_markdown
* bump VERSION to 1.14.2 (not released yet)
Prefer arch-dependent over arch-independent pages if the name priority,
the section number, and all names match. Changes little on installed
systems except the ordering of apropos(1) results, because we install
base and Xenocara manuals in different trees, but fixes lookup of pages
like apm(4) vs. apm(4/amd64) in man.cgi(8).
Issue discovered by martian67 on freenode and reported via tj@.
Run the regression tests iteratively rather than recursively.
Simpler user interface, better summary output, simpler code,
and slightly faster.
Inspired by espie@'s request to avoid needless recursive make(1)
in the OpenBSD regression testing tree.