First, I'm defaulting to 11-point font, which renders much nicer (the
"Internet" vaguely suggests using 11- or 9-Point for serifed fonts).
This verified on GNU/Linux, Mac OSX, Windows, and OpenBSD. Noted in
mandoc.1.
Then added a3, a4, a5, letter, legal, and custom page dimensions. These
seem to be the main players. Noted in mandoc.1.
Ingo Schwarze [Wed, 30 Jun 2010 20:32:15 +0000 (20:32 +0000)]
improve error reporting:
* avoid error exit code after mere warnings
* add ERROR: and FATAL: to messages when appropriate
* sort the code in mmsg() to make it easier on the eye
* make the mandocerrs[] list easier to maintain
* update a few comments in mandoc.h
ok kristaps@
Ingo Schwarze [Wed, 30 Jun 2010 04:05:02 +0000 (04:05 +0000)]
Closing of full blocks (Bd Bf Bk Bl It Fo Nd Rs Sh Ss) may never be
delayed: It must either succeed right away or fail outright.
As noticed by Kristaps, neglecting to fail properly when required
could make invalid input screw up the syntax tree and ultimately
trigger assertions in other, unrelated parts of the program.
This fix tested by and OK by kristaps@.
While here, comment the rather tricky function rew_dohalt().
This function will probably need more tweaks later on.
Ingo Schwarze [Tue, 29 Jun 2010 19:24:14 +0000 (19:24 +0000)]
Considerably simplify block rewind rules; no functional change intended.
* Let rew_alt() always succeed, obsoleting tons of case statements.
* Merge rew_dobreak() into rew_dohalt().
* Encode all rewinding cases uniformly in terms of "enum rew".
Required because i'm too dumb to get SYNOPSIS .Nm rewinding right
without cleaning this up first.
Ingo Schwarze [Tue, 29 Jun 2010 19:20:38 +0000 (19:20 +0000)]
Support for badly nested blocks, written around the time of
the Rostock mandoc hackathon and tested and polished since,
supporting constructs like:
.Ao Bo Ac Bc (exp breaking exp)
.Aq Bo eol Bc (imp breaking exp)
.Ao Bq Ac eol (exp breaking imp)
.Ao Bo So Bc Ac Sc (double break, inner before outer)
.Ao Bo So Ac Bc Sc (double break, outer before inner)
.Ao Bo Ac So Bc Sc (broken breaker)
.Ao Bo So Bc Do Ac Sc Dc (broken double breaker)
There are still two known issues which are tricky:
1) Breaking two identical explicit blocks (Ao Bo Bo Ac or Aq Bo Bo eol)
fails outright, triggering a bogus syntax error.
2) Breaking a block by two identical explicit blocks (Ao Ao Bo Ac Ac Bc
or Ao Ao Bq Ac Ac eol) still has a minor rendering error left:
"<ao1 <ao2 [bo ac2> ac1> bc]>" should not have the final ">".
We can fix these later in the tree, let's not grow this diff too large.
Remove some incorrect data from mandoc.1 (that of non-macro lines and
spacing, which is for mdoc.7/man.7 anyway). Also document -Opage=xxx
and push the per-output options into the output subsections. Makes the
manual shorter and more readable.
Add in -Opaper=xxx support for -Tps postscript. This doesn't have any
functional changes beyond the getsubopt() parse in term_ps.c. If you
want to test this (it only does -Opaper=a4 and -Opaper=letter; adding
more is trivial), make sure you specify (e.g.) -sPAPERSIZE=a4 to gs(1).
Give -Tps better PostScript hinting. Note that we're using Adobe-3.0
constructs. Push the stupid CPP defines for page boundaries and margins
into proper variables. Give enum termfont a proper TERMFONT__MAX.
Clean-up of variable-width glyph support. Adds no new code; only
restructured to make a bit more readable. Also removed an unused entry
in the PS engine structure.
This enables variable glyph-width output. The checkin will be followed
by a [functionless] clean-up in term_ps.c, but this makes the
appropriate changes to "enable" initial proportional-width functionality
in term.c and fixes some areas of term_ps.c that were causing errors.
Tiny commit clarifying flushln() documentation as to what refers to
visual screen output and what's an array index (getting closer to
variable-width fonting).
Ingo Schwarze [Sun, 27 Jun 2010 17:53:27 +0000 (17:53 +0000)]
minor .Bk fixes:
* do not print invalid arguments verbatim (no groffs prints them, either)
* do not trigger TERMP_PREKEEP twice
* do not die from invlid arguments (groff won't die, either)
* continue to ignore even valid arguments (just like groff)
ok kristaps@ on the previous version, before removing my last bug ;)
First step of adding register support. This is inspired by a significant
patch by schwarze@. This commit adds support to libroff parsing `nr'
into register set defined in regs.h. This will propogate into libmdoc
and libman in later commits.
Remove "pt" from struct roffsu, as CSS (the only reason it was there) is
unclear about which units accept floats/integers, which leads me to
assume that it handles either and rounds as appropriate.
Initial chunks for variable-width fonts. Pushes all width calculations
in mdoc_term.c and man_term.c down into term.c. This is still not
implemented in term.c, although stubs for width calculations are in
place. From now on, offset, rmargin, and other layout variables are
abstract screen widths. They will resolve to the the familiar values
for -Tascii but -Tps will eventually use points instead of chars.
Allow -width for lists to be cached in mdoc_bl. This requires some
trickery because widths may be on-the-fly recalculated. I don't like
how these are split between mdoc_action.c and mdoc_validate.c, but for
the time being, it'll do.
Cached `Bl -offset' into mdoc_bl. Removed erroneous "-offset defaults
to 6n if no value is specified" and added regression tests for `Bl'
testing against the empty -offset argument.
Reverted to mdoc_term.c 1.149 (`It' does not inherit `Bl's cache,
obviously, which was causing fallout) and again remove the loop code.
Tested more thoroughly.
Removed stipulation that an empty `Bd -offset' will default to 6n. Not
sure where this came about. Added regression tests to convince myself
that this is so. Also consolidated COMPATIBILITY notes regarding `Bd'.
Added COMPATIBILITY note to the effect that old groff pukes on `Bd
-compact -ragged' (regression test will fail on old groff).
Cache all of `Bd's resolved arguments into mdoc_bd, which is stashed in
the "data" union in mdoc_node. Allows me to remove some ugly loops in
the front-end and duplicate tests in mdoc_action.c. Add a regression
test to make sure we're not doing anything bad (more to come).
Added enum mdoc_disp (similar to enum mdoc_list). Display types are now
only calculated once in mdoc_validate.c.
Noted that `Bd -file xxx' is not supported: it now raises a fatal
warning. This is noted in mdoc.7.
Empty `Bd' now defaults to LIST_ragged, which is not quite what groff
does, but close enough (gross just throws away the `Bd' and gets upset
when it encounters an `Ed').
Implement font-switching for PostScript. -Tps now supports
TERMFONT_BOLD (Courier-Bold) and TERMFONT_UNDER (Courier-Oblique). It
doesn't look half bad. This accomplished through tricksy juggling of
the one-char back-buffer.
Allow open word contexts in -Tps to preserve whitespace, as whitespace
apparently doesn't collapse in PostScript (surprise!). Makes output
files much more compact.
Ingo Schwarze [Thu, 10 Jun 2010 23:24:37 +0000 (23:24 +0000)]
Fix a regression that crept in in man_term.c 1.73 and mdoc_term.c 1.144.
When the title line uses special characters, mandoc will segfault.
Thus, first set up the character tables, then print the header,
as we always did.
Found in OpenBSD /usr/src/usr.sbin/bind/bin/check/named-checkconf.8.
While here, set p->tabwidth in terminal_man() for symmetry
with terminal_mdoc(), as suggested by millert@ (and already
committed to OpenBSD earlier). Since 5 is the default, this
is not strictly required, but it is certainly clearer and more
robust.
Fix adding some minimal intelligence to conditional parser. See roff.7
for what's supported. This simplified the roff_cond() function quite
nicely. From a bug report by uqs@.
Added regression test based on bug-report example by uqs@.
Also added ROFF_DEBUG to see what the hell the parser is actually doing.
Obviously turned off by default.
Squash bug noted by Ulrich Spoerlein where "-" were being converted to
ASCII_HYPH, as per normal, but were screwing up mandoc_special(). Fixed
by making mandoc_special() first check isspace() instead of ! isgraph(),
then normalise its string as it passes out. This require de-constifying
some validation routines not already de-constified (those in libman),
but that's ok, because I'd like to be pushing actions into validation
routines to save on space and redundant calculations.
Have the standard manpage header and footer print on every page of -Tps
output. This is more tricky than you may think: we can't just call the
header function out-of-state (i.e., before a flushln has occured)
because we'd clobber our current state. Thus, we call at the beginning
and dump the output into an auxiliary buffer.
For the record, I don't think there's any other clean way to do this.
The only other Way That Works is to copy-aside *all* termp state, zero
it, and do the necessary headf/footf. This is just as complex, as
memory needs to be alloc'd and free'd per margin.
Unfortunately, this prohibits page numbering (the margin is only printed
once), so I'll probably end up re-writing this down the line.
No functionality changes: just restructuring. Deprecated
terminal_free() in favour of ps_free() and ascii_free(). Moved ps_*()
functions into term_ps.c so that they don't clutter up term.c.
First check-in of PostScript output. This does not change any logic
within term.c, but does add a small shim over putchar() that switches on
the output engine. Prints, for this initial version, only monospace and
without font decorations. It's a start.
Normalise SYNOPSIS behaviour after I gave up on following groff's
inconsistent behaviour. In short:
Some macros are displayed differently in the SYNOPSIS
section, particularly Nm, Cd, Fd, Fn, Fo, In, Vt, and Ft.
All of these macros are output on their own line. If two
such dissimilar macros are pair-wise invoked (except for Ft
before Fo or Fn), they are separated by a vertical space,
unless in the case of Fo, Fn, and Ft, which are always
separated by vertical space.
Behaviour ok Jason McIntyre, ingo@. Fallout will be treated
case-by-case.
I had to clear out some regressions that were testing against groff's
stranger behaviours: these will now break, as we don't care about such
invocations.
Also removed the newline for `Cd' invocation in a non-SYNOPSIS context.
Ingo Schwarze [Sun, 6 Jun 2010 22:08:15 +0000 (22:08 +0000)]
Merge a fix to avoid a regression in OpenBSD:
Restore the blank line before .In in SYNOPSIS
except right after .Sh or right after another .In.
Even though Kristaps says SYNOPSIS blank-line handling
is still very much work in progress and more is probably needed,
this one is useful to keep in sync with OpenBSD.
Fixed `In' to behave properly: it wasn't properly breaking lines,
formatting, or really anything else. Noted COMPATIBILITY with
OpenBSD's groff, which pukes all over `In'.
Fixed `Fd' to format in the right way. Found when confused by what the
hell `Fd' is supposed to do anyway (answer: it's a historical macro and
we shouldn't be doing anything with it anyway).
Complete, rigorous documentation of the `Bl' and `It' macros, including
the peculiarities with `It'-less `Bl -column' invocations, column
phrases, per-type syntax of `It', etc.
Consolidated list processing to a single loop in mdoc_validate.c. This
relieves having to repeat running over the argument list in
mdoc_action.c and mdoc_validate.c.
Default to LIST_item for type-less lists (groff technically doesn't do
this: it just ignores the `It' lines altogether).