Ingo Schwarze [Fri, 16 Jun 2017 20:01:06 +0000 (20:01 +0000)]
Multiple tbl(7) improvements:
* Do not discard data that lacks a matching layout cell but remains
within the number of columns of the table as a whole.
* Do not insert dummy data rows for any layout row starting with a
horizontal line, but only for layout rows that would discard all
the data on a matching non-empty data row.
* Print horizontal lines specified in the layout even if there is
no matching data cell.
* Improve the logic for extending vertical lines to adjacent rows,
for choosing cross marks versus line segments, and some related details.
Ingo Schwarze [Wed, 14 Jun 2017 22:51:25 +0000 (22:51 +0000)]
Naive implementation of the roff(7) .po (page offset) request.
This clearly works when .po is called on the top level, but might
not be sophisticated enough if people call .po inside indentation-changing
contexts, but i haven't seen that in manual pages (yet :).
Ingo Schwarze [Tue, 13 Jun 2017 19:34:40 +0000 (19:34 +0000)]
Partial support for the \n[an-margin] number register.
Manuals autogenerated from reStructuredText are reckless enough
to peek at this non-portable, implementation-dependent, highly
groff-specific internal register - for no good reason, because the
man(7) language natively provides in a much simpler way what they
are trying to emulate here with much fragility.
A full implementation would be very hard because it would require
access to output-device-specific formatting data at the roff(7)
preprocessor stage, which mandoc doesn't support at all.
So hardcode a few magic numbers as reStructuredText expects them
for terminal output. For other output modes (like HTML), code using
this register is utterly broken anyway.
Ingo Schwarze [Tue, 13 Jun 2017 16:12:01 +0000 (16:12 +0000)]
If the layout is empty except for requesting a left vertical frame,
record that detail in struct tbl_opts, such that term_tbl() can do
correct column calculations and doesn't prematurely break lines.
Fixes the tbl/layout/empty regression test that got broken when
line breaking in text block cells was implemented.
Ingo Schwarze [Tue, 13 Jun 2017 15:06:56 +0000 (15:06 +0000)]
Delete the arbitrary range restriction for -Owidth.
We provide users with tools. We don't attempt to prevent them from
using them in stupid ways: depending on the context, not every
stupid-looking use is necessarily actually stupid, and not every
stupidity can be automatically detected anyway, so don't even try.
Ingo Schwarze [Tue, 13 Jun 2017 13:51:11 +0000 (13:51 +0000)]
Explicitly ignore .br, .ce, and .sp inside tbl(7) text blocks.
With the current code structure, they would appear at the wrong
place in the syntax tree, so it is better to not insert them
into the tree at all and issue an UNSUPP message instead.
Ingo Schwarze [Mon, 12 Jun 2017 22:49:16 +0000 (22:49 +0000)]
Two minor fixes for the "allbox" modifier:
1. It does not reduce explicit "||" in the layout to "|".
2. It does not cause three horizontal lines at the end of a table,
even if the table ends with an explicit "_" data line.
Ingo Schwarze [Mon, 12 Jun 2017 22:05:57 +0000 (22:05 +0000)]
If a tbl(7) layout contains a 'w' (minimum width) modifier for a
given column, that column contains no literal or numeric cell of
larger width, and all text block cells in that column can be line
wrapped to fit into that minimum width, groff does not increase
that column width beyond the specified minimum: so do the same.
Ingo Schwarze [Sun, 11 Jun 2017 19:45:05 +0000 (19:45 +0000)]
Style message about legacy man(7) date format in mdoc(7) documents
and operating system dependent messages about missing or unexpected
Mdocdate; inspired by mdoclint(1).
Ingo Schwarze [Sun, 11 Jun 2017 19:37:00 +0000 (19:37 +0000)]
Style message about legacy man(7) date format in mdoc(7) documents
and operating system dependent messages about missing or unexpected
Mdocdate; inspired by mdoclint(1).
Ingo Schwarze [Sun, 11 Jun 2017 14:24:55 +0000 (14:24 +0000)]
Do not issue the message "no blank before trailing delimiter" for .No.
In practice, that message only matters inside .Bf, and even there, it
can occasionally be a false positive. In all other cases, it usually
is a false positive, so it is better to drop it outright.
Suggested by jmc@.
Ingo Schwarze [Thu, 8 Jun 2017 18:11:22 +0000 (18:11 +0000)]
Implement w layout specifier (minimum column width).
Improve width calculation of text blocks.
Reduces the groff/mandoc diff in Base+Xenocara by about 800 lines.
Ingo Schwarze [Wed, 7 Jun 2017 20:58:49 +0000 (20:58 +0000)]
Also catch "new sentence, new line" if there are three blanks
between the sentences. Thomas Klausner says he has seen some
of these, and i don't see any false positives.
Ingo Schwarze [Wed, 7 Jun 2017 20:30:40 +0000 (20:30 +0000)]
Make "new sentence, new line" detection stricter:
Also catch cases where the new sentence starts with a one-letter word
and the input line is broken right after that word.
Suggested by Thomas Klausner <wiz @ NetBSD>.
It's merely a three-bit diff, changing one byte from 0x34 to 0x33,
so what can possibly go wrong...
Ingo Schwarze [Wed, 7 Jun 2017 20:01:19 +0000 (20:01 +0000)]
Prepare the terminal driver for filling multiple columns in parallel,
second step: make the per-column byte pointer persistent across
term_flushln() calls, such that a subsequent call can continue at
the point where the previous call left. If more than one column
is in use, return from term_flushln() when the column is full,
rather than breaking the output line.
No functional change, because nothing sets up multiple columns yet.
Ingo Schwarze [Wed, 7 Jun 2017 17:38:26 +0000 (17:38 +0000)]
Prepare the terminal driver for filling multiple columns in parallel,
first step: split column data out of the terminal state struct into
a new column state struct and use an array of such column state
structs. No functional change.
Ingo Schwarze [Wed, 7 Jun 2017 02:14:09 +0000 (02:14 +0000)]
The \h escape sequence provides another method for moving backwards,
and after that, previously written output gets overwritten, but
overwriting with blanks does *not* erase previously written content.
Yes, manual pages exist that are crazy enough to rely on that...
Ingo Schwarze [Wed, 7 Jun 2017 00:50:34 +0000 (00:50 +0000)]
Implement the roff(7) .rn (rename macro or string) request.
Renaming a user-defined macro is very simple: just copy
the definition to the new name and delete the old name.
Renaming high-level macros is a bit tricky: use a dedicated
key-value-table, with non-standard names as keys and standard
names as values. When a macro is found that is not user-defined,
look it up in the "renamed" table and translate it back to the
standard name before passing it on to the high-level parsers.
Ingo Schwarze [Tue, 6 Jun 2017 15:01:04 +0000 (15:01 +0000)]
Minimal implementation of the roff(7) .ce request (center a number
of input lines without filling).
Contrary to groff, high-level macros abort .ce mode for now.
Ingo Schwarze [Sun, 4 Jun 2017 22:44:15 +0000 (22:44 +0000)]
Implement the roff(7) .mc (right margin character) request.
The Tcl/Tk manual pages use this extensively.
Delete the TERM_MAXMARGIN hack, it breaks .mc inside .nf;
instead, implement a proper TERMP_BRNEVER flag.
Ingo Schwarze [Sun, 4 Jun 2017 18:50:35 +0000 (18:50 +0000)]
Make term_flushln() simpler and more robust:
Eliminate the "overstep" state variable.
The information is already contained in "viscol".
Minus 60 lines of code, no functional change intended.
Ingo Schwarze [Sun, 4 Jun 2017 00:13:15 +0000 (00:13 +0000)]
Pure preprocessor implementation of the roff(7) .ec and .eo requests
(escape character control), touching nothing after the preprocessing
stage and keeping even the state variable local to the preprocessor.
Since the escape character is also used for line continuation, this
requires pulling the implementation of line continuation from the
input reader to the preprocessor, which also considerably shortens
the code required for that.
When the escape character is changed, simply let the preprocessor
replace bare by escaped backslashes and instances of the non-standard
escape character with bare backslashes - that's all we need.
Oh, and if anybody dares to use these requests in OpenBSD manuals,
sending a medium-sized pack of axe-murderers after them might be a
worthwhile part of the punishment, but probably insuffient on its own.
Ingo Schwarze [Fri, 2 Jun 2017 19:21:23 +0000 (19:21 +0000)]
Partial implementation of \h (horizontal line drawing function).
A full implementation would require access to output device properties
and state variables (both only available after the main parser has
finalized the parse tree) before numerical expansions in the roff
preprocessor (i.e., before the main parser is even started).
Not trying to pull that stunt right now because the static-width
implementation committed here is sufficient for tcl-style manual pages
and already more complicated than i would have suspected.
Ingo Schwarze [Tue, 30 May 2017 16:22:03 +0000 (16:22 +0000)]
Macro argument quoting does not prevent recognition of punctuation
and of called macros.
This bug affects almost all macros, and fixing it simplifies the
code. It is amazing that the bogus ARGS_QWORD feature got implemented
in the first place, and then carrier along for more than eight years
without anybody ever noticing that it was pointless.
Reported by Leah Neukirchen <leah at vuxu dot org>, found on Void Linux.
Ingo Schwarze [Thu, 18 May 2017 14:45:34 +0000 (14:45 +0000)]
Use [ rather than [[ for portability,
in particular since it makes no difference in the case at hand.
Reported by Leah Neukirchen <leah at vuxu dot org> (Void Linux).
Ingo Schwarze [Wed, 17 May 2017 23:23:00 +0000 (23:23 +0000)]
Fix documentation bug:
man(1) does not ignore manpath directories lacking mandoc.db(5) files;
instead, it uses filename lookup to find manuals in such directories.
Ingo Schwarze [Wed, 17 May 2017 22:27:12 +0000 (22:27 +0000)]
Never create empty databases.
When pkg_add(1)ing packages installing manual pages into some directory,
the database in that directory automatically gets created or updated,
no change so far. This patch causes the database file to be
automatically unlinked when pkg_delete(1)ing the last package having
manual pages in that directory, to leave less cruft behind.
Ingo Schwarze [Wed, 17 May 2017 17:54:45 +0000 (17:54 +0000)]
Delete pointless width calculation for SYNOPSIS .Nm block heads.
Just let HTML <table> do its work of selecting the needed width.
<Anton dot Lindqvist at gmail dot com> reported that the manually
calculated width was insufficient in some manual pages.
Ingo Schwarze [Tue, 16 May 2017 19:06:30 +0000 (19:06 +0000)]
Introduce a new mandoc(1) message level, -W style, below -W warning.
Switch -W all from meaning -W warning to meaning -W style.
The meaning of -T lint does *not* change, it still implies -W warning.
No messages on the new level yet, but they will come.
Usually, i do not lightly make the user interface larger.
But this has been planned for years, and EXIT STATUS 1
was reserved for it all the time. The message system
is now stable enough to finally implement it.
Ingo Schwarze [Sun, 14 May 2017 12:27:28 +0000 (12:27 +0000)]
Tweak previous: tb@ noticed that some browser/font combinations
have so amazingly wide bold fonts (for the same nominal font size)
that adding 15% to the column width still isn't sufficient to make
text reliably fit, so go for 20%.
Ingo Schwarze [Fri, 12 May 2017 17:58:21 +0000 (17:58 +0000)]
Make the tag column in .Bl -tag lists wider:
1. I forgot about the 2n padding between tag and body.
2. The factor 1.1 was too small for bold fold, make it *1.15 + 1n.
Ugliness spotted by tb@.
Ingo Schwarze [Mon, 8 May 2017 20:33:53 +0000 (20:33 +0000)]
Line-breaking roff(7) requests also break man(7) next-line scope.
Considering that real roff implements next-line scope using input
line traps, that isn't all that surprising.
Issue found in the games/xbattle port.
Ingo Schwarze [Mon, 8 May 2017 03:55:25 +0000 (03:55 +0000)]
Convert REQUEST REFERENCE from using .Ss to .Bl -tag, allowing to
specify request arguments and supporting tag searching in less(1).
Improve some entries and document .ta.
Ingo Schwarze [Sun, 7 May 2017 17:31:45 +0000 (17:31 +0000)]
Basic implementation of the roff(7) .ta (define tab stops) request.
This is the first feature made possible by the parser reorganization.
Improves the formatting of the SYNOPSIS in many Xenocara GL manuals.
Also important for ports, as reported by many, including naddy@.
Ingo Schwarze [Fri, 5 May 2017 02:06:19 +0000 (02:06 +0000)]
Move handling of the roff(7) .ft request from the man(7)
modules to the new roff(7) modules. As a side effect,
mdoc(7) now handles .ft, too. Of course, do not use that.
Ingo Schwarze [Thu, 4 May 2017 22:16:09 +0000 (22:16 +0000)]
Start roff formatter modules for HTML and termininal output,
used by both the mdoc and man formatters, with the ultimate
goal of reducing code duplication between the two macro formatters.
Made possible by the parser unification.
Add the first formatting function (for the .br request).
Ingo Schwarze [Mon, 1 May 2017 23:27:39 +0000 (23:27 +0000)]
A few days ago, a patch from <G dot Branden dot Robinson at gmail dot com>
got committed to groff which changed .TP from using .it to using .itc,
such that groff now supports more than one man(7) macro line in the .TP
head if all but the last line in the head end with \c.
Of course, relying on that behaviour is utterly non-portable, but if
authors are reckless enough to use that idiom, let's do what they want.
Ingo Schwarze [Mon, 1 May 2017 20:54:59 +0000 (20:54 +0000)]
When trying to expand some columns in a table where the sum of the
widths of the remaining columns is already wider than the line
length, underflowing size_t and dying from ENOMEM is the wrong plan.
Instead, simply refrain from expanding anything in such a situation,
avoiding a crash that tb@ found with afl.
Delete the manpage(1) utility.
It was never enabled in any release, nor was a manual ever written.
In general, we want to simplify the user interface rather than
succumb to featurism. Consequently, integrating manpage(1)
into the main binary would seem like a dubious direction.
Continue parser unification:
* Make enum rofft an internal interface as enum roff_tok in "roff.h".
* Represent mdoc and man macros in enum roff_tok.
* Make TOKEN_NONE a proper enum value and use it throughout.
* Put the prologue macros first in the macro tables.
* Unify mdoc_macroname[] and man_macroname[] into roff_name[].
More thoroughly reject direct access to unintended files, such that
URIs like http://man.openbsd.org/OpenBSD-current/mandoc.db and
http://man.openbsd.org/OpenBSD-current/man1/ do not cause display
of garbage.