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.
The only elements using floats are dt.It-tag,
so the only elements allowed to the right of them are dd.It-tag.
Fixes overlapping rendering after long tag lists without bodies,
for example in the Xenocara apm(4) manual. Issue reported by tj@.
In .Bl -tag and -hang, do not print a margin-left style attribute
for each individual item if the -width argument matches the default
of 6n. Suggested by Steffen Nurpmeso <steffen at sdaoden dot eu>
on <groff at GNU dot org> in April 2017.
If -column, -diag, -inset, -item, or -ohang lists have a -width,
don't just talk about ignoring it, actually do ignore it.
No change for terminal output, improves HTML output.
Improve rev. 1.250 further:
If a database is empty, we already don't write a database file and
delete an existing one. If none exists, that only means the database
was empty and remains so, which is not an error. So don't nag about
it, in particular because that would be a weekly(8) annoyance.
Issue reported by jmc@.
Explicitly initialize a variable where the compiler is (understandably)
unable to figure out that it is never used uninitialized.
While here, tweak the content of the variable to make its usage
easier to understand. No functional change.
Fix an assertion failure triggered by print_otag("sw+-l", NULL).
Even though we skip the style when the argument is NULL,
we must still consume the options.
Not found with afl(1), but during manual testing of the previous patch...
Handle .Bl -compact via CSS rather than writing individual style
attributes into .It blocks; suggested by Steffen Nurpmeso <steffen
at sdaoden dot eu> on <groff at GNU dot org> in April 2017.
Delete margin-bottom and margin-top style names and the 'v' argument
letter from print_otag() because they are no longer used.
Simplify by creating struct roff_node syntax tree nodes for tbl(7)
right from roff_parseln() rather than delegating to read.c,
similar to what i just did for eqn(7).
The interface function roff_span() becomes obsolete and is deleted,
the former interface function roff_addtbl() becomes static,
the interface functions tbl_read() and tbl_cdata() become void,
and minus twelve linus of code.
1. Eliminate struct eqn, instead use the existing members
of struct roff_node which is allocated for each equation anyway.
2. Do not keep a list of equation parsers, one parser is enough.
Minus fifty lines of code, no functional change.
Correctly handle horizontal spans at the beginning of rows,
fixing an assertion failure found by jsg@ with afl(1).
While here, also drop printing of whitespace in tbl_data()
which makes no difference because column positioning code
in term_tbl() already takes care of that.