OpenBSD CVS

CVS log for src/usr.bin/mandoc/mandoc.c


[BACK] Up to [local] / src / usr.bin / mandoc

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.89 / (download) - annotate - [select for diffs], Thu May 19 15:17:50 2022 UTC (2 years ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_7_5_BASE, OPENBSD_7_5, OPENBSD_7_4_BASE, OPENBSD_7_4, OPENBSD_7_3_BASE, OPENBSD_7_3, OPENBSD_7_2_BASE, OPENBSD_7_2, HEAD
Changes since 1.88: +9 -385 lines
Diff to previous 1.88 (colored)

Make roff_expand() parse left-to-right rather than right-to-left.
Some escape sequences have side effects on global state, implying
that the order of evaluation matters.  For example, this fixes the
long-standing bug that "\n+x\n+x\n+x" after ".nr x 0 1" used to
print "321"; now it correctly prints "123".

Right-to-left parsing was convenient because it implicitly handled
nested escape sequences.  With correct left-to-right parsing, nesting
now requires an explicit implementation, here solved as follows:
1. Handle nested expanding escape sequences iteratively.
When finding one, expand it, then retry parsing the enclosing escape
sequence from the beginning, which will ultimately succeed as soon
as it no longer contains any nested expanding escape sequences.
2. Handle nested non-expanding escape sequences recursively.
When finding one, the escape sequence parser calls itself to find
the end of the inner sequence, then continues parsing the outer
sequence after that point.

This requires the mandoc_escape() function to operate in two different
modes.  The roff(7) parser uses it in a mode where it generates
diagnostics and may return an expansion request instead of a parse
result.  All other callers, in particular the formatters, use it
in a simpler mode that never generates diagnostics and always returns
a definite parsing result, but that requires all expanding escape
sequences to already have been expanded earlier.  The bulk of the
code is the same for both modes.
Since this required a major rewrite of the function anyway, move
it into its own new file roff_escape.c and out of the file mandoc.c,
which was misnamed in the first place and lacks a clear focus.

As a side benefit, this also fixes a number of assertion failures
that tb@ found with afl(1), for example "\n\\\\*0", "\v\-\\*0",
and "\w\-\\\\\$0*0".

As another side benefit, it also resolves some code duplication
between mandoc_escape() and roff_expand() and centralizes all
handling of escape sequences (except for expansion) in roff_escape.c,
hopefully easing maintenance and feature improvements in the future.

While here, also move end-of-input handling out of the complicated
function roff_expand() and into the simpler function roff_parse_comment(),
making the logic easier to understand.

Since this is a major reorganization of a central component of
mandoc(1), stability of the program might slightly suffer for a few
weeks, but i believe that's not a problem at this point of the
release cycle.  The new code already satisfies the regression suite,
but more tweaking and regression testing to further improve the
handling of various escape sequences will likely follow in the near
future.

Revision 1.88 / (download) - annotate - [select for diffs], Wed Apr 13 13:11:33 2022 UTC (2 years, 1 month ago) by schwarze
Branch: MAIN
Changes since 1.87: +3 -3 lines
Diff to previous 1.87 (colored)

Surprisingly, groff supports multiple copy mode escapes at the
beginning of an escape sequence: \, \E, \EE, \EEE, and so on all do
the same outside copy mode, so let them do the same in mandoc(1), too.

This fixes an assertion failure triggered by \EE*X that tb@ found
with afl(1).  The first E was consumed by roff_expand(), but that
function failed to recognize the escape sequence as the expansion
of a user-defined string and handed it over to mandoc_escape(),
which consumed the second E and then died on an assertion because
it is not prepared to handle user-defined strings.  Fix this by
letting *both* functions handly arbitrary numbers of 'E's correctly.

Revision 1.87 / (download) - annotate - [select for diffs], Tue Aug 10 12:36:42 2021 UTC (2 years, 9 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_7_1_BASE, OPENBSD_7_1, OPENBSD_7_0_BASE, OPENBSD_7_0
Changes since 1.86: +5 -5 lines
Diff to previous 1.86 (colored)

Support two-character font names (BI, CW, CR, CB, CI)
in the tbl(7) layout font modifier.

Get rid of the TBL_CELL_BOLD and TBL_CELL_ITALIC flags and use
the usual ESCAPE_FONT* enum mandoc_esc members from mandoc.h instead,
which simplifies and unifies some code.

While here, also support CB and CI in roff(7) \f escape sequences
and in roff(7) .ft requests for all output modes.  Using those is
certainly not recommended because portability is limited even with
groff, but supporting them makes some existing third-party manual
pages look better, in particular in HTML output mode.

Bug-compatible with groff as far as i'm aware, except that i consider
font names starting with the '\n' (ASCII 0x0a line feed) character
so insane that i decided to not support them.

Missing feature reported by nabijaczleweli dot xyz in
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=992002.
I used none of the code from the initial patch submitted by
nabijaczleweli, but some of their ideas.
Final patch tested by them, too.

Revision 1.86 / (download) - annotate - [select for diffs], Sat Oct 24 22:52:34 2020 UTC (3 years, 6 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_6_9_BASE, OPENBSD_6_9
Changes since 1.85: +16 -9 lines
Diff to previous 1.85 (colored)

Treat \*[.T] in the same way as \*(.T rather than calling abort(3).
Bug found because the groff-current manual pages started using the
variant form of this predefined string.

Revision 1.85 / (download) - annotate - [select for diffs], Sun Jan 19 16:16:32 2020 UTC (4 years, 4 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_6_8_BASE, OPENBSD_6_8, OPENBSD_6_7_BASE, OPENBSD_6_7
Changes since 1.84: +35 -21 lines
Diff to previous 1.84 (colored)

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.

Revision 1.84 / (download) - annotate - [select for diffs], Thu Jun 27 15:05:14 2019 UTC (4 years, 10 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_6_6_BASE, OPENBSD_6_6
Changes since 1.83: +9 -4 lines
Diff to previous 1.83 (colored)

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().

Revision 1.83 / (download) - annotate - [select for diffs], Tue May 21 08:03:43 2019 UTC (5 years ago) by schwarze
Branch: MAIN
Changes since 1.82: +3 -3 lines
Diff to previous 1.82 (colored)

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@.

Revision 1.82 / (download) - annotate - [select for diffs], Sun Dec 30 00:48:47 2018 UTC (5 years, 4 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_6_5_BASE, OPENBSD_6_5
Changes since 1.81: +3 -2 lines
Diff to previous 1.81 (colored)

Cleanup, no functional change:

The struct roff_man used to be a bad mixture of internal parser
state and public parsing results.  Move the public results to the
parsing result struct roff_meta, which is already public.  Move the
rest of struct roff_man to the parser-internal header roff_int.h.

Since the validators need access to the parser state, call them
from the top level parser during mparse_result() rather than from
the main programs, also reducing code duplication.

This keeps parser internal state out of thee main programs (five
in mandoc portable) and out of eight formatters.

Revision 1.81 / (download) - annotate - [select for diffs], Tue Dec 18 21:58:41 2018 UTC (5 years, 5 months ago) by schwarze
Branch: MAIN
Changes since 1.80: +1 -97 lines
Diff to previous 1.80 (colored)

As a first step towards making roff_res() callable from mandoc_getarg(),
move the function mandoc_getarg() from mandoc.c to roff.c.  It was
misplaced in mandoc.c in the first place; that file is intended for
utilities needed both by parsers and by formatters, while reading
macro arguments in copy mode is purely a task of the roff(7) parser.
Needed as a preliminary for an upcoming bugfix.
No code change.

Revision 1.80 / (download) - annotate - [select for diffs], Sat Dec 15 23:33:20 2018 UTC (5 years, 5 months ago) by schwarze
Branch: MAIN
Changes since 1.79: +55 -42 lines
Diff to previous 1.79 (colored)

Yet another round of improvements to manual font selection.

Unify handling of \f and .ft.
Support \f4 (bold+italic).
Support ".ft BI" and ".ft CW" for terminal output.
Support the .ft request in HTML output.
Reject the bogus fonts \f(C1, \f(C2, \f(C3, and \f(CP.

Revision 1.79 / (download) - annotate - [select for diffs], Sat Dec 15 19:30:19 2018 UTC (5 years, 5 months ago) by schwarze
Branch: MAIN
Changes since 1.78: +79 -17 lines
Diff to previous 1.78 (colored)

Several improvements to escape sequence handling.

* Add the missing special character \_ (underscore).
* Partial implementations of \a (leader character)
and \E (uninterpreted escape character).
* Parse and ignore \r (reverse line feed).
* Add a WARNING message about undefined escape sequences.
* Add an UNSUPP message about unsupported escape sequences.
* Mark \! and \? (transparent throughput)
and \O (suppress output) as unsupported.
* Treat the various variants of zero-width spaces as one-byte escape
sequences rather than as special characters, to avoid defining bogus
forms with square brackets.
* For special characters with one-byte names, do not define bogus
forms with square brackets, except for \[-], which is valid.
* In the form with square brackets, undefined special characters do not
fall back to printing the name verbatim, not even for one-byte names.
* Starting a special character name with a blank is an error.
* Undefined escape sequences never abort formatting of the input
string, not even in HTML output mode.
* Document the newly handled escapes, and a few that were missing.
* Regression tests for most of the above.

Revision 1.78 / (download) - annotate - [select for diffs], Fri Dec 14 06:33:03 2018 UTC (5 years, 5 months ago) by schwarze
Branch: MAIN
Changes since 1.77: +2 -2 lines
Diff to previous 1.77 (colored)

Cleanup, no functional change:
Now that message handling is properly encapsulated,
remove struct mparse pointers from four structs (roff, roff_man,
tbl_node, eqn_node) and from the argument lists of five functions
(roff_alloc, roff_man_alloc, mandoc_getarg, tbl_alloc, eqn_alloc).
Except for being passed to the main program as an opaque object,
it now only occurs in read.c, as it should, and not across 15 files
like in the past.

Revision 1.77 / (download) - annotate - [select for diffs], Fri Dec 14 05:17:45 2018 UTC (5 years, 5 months ago) by schwarze
Branch: MAIN
Changes since 1.76: +9 -12 lines
Diff to previous 1.76 (colored)

Almost mechanical diff to remove the "struct mparse *" argument
from mandoc_msg(), where it is no longer used.
While here, rename mandoc_vmsg() to mandoc_msg() and retire the
old version:  There is really no point in having another function
merely to save "%s" in a few places.
Minus 140 lines of code.

Revision 1.76 / (download) - annotate - [select for diffs], Thu Oct 25 01:21:30 2018 UTC (5 years, 6 months ago) by schwarze
Branch: MAIN
Changes since 1.75: +7 -2 lines
Diff to previous 1.75 (colored)

Implement the \f(CW and \f(CR (constant width font) escape sequences
for HTML output.  Somewhat relevant because pod2man(1) relies on this.
Missing feature reported by Pali dot Rohar at gmail dot com.

Note that constant width font was already correctly selected before
this when required by semantic markup.  Only attempting physical
markup with the low-level escape sequence was ineffective.

Revision 1.75 / (download) - annotate - [select for diffs], Mon Aug 20 18:06:42 2018 UTC (5 years, 9 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_6_4_BASE, OPENBSD_6_4
Changes since 1.74: +8 -5 lines
Diff to previous 1.74 (colored)

\f[] means \fP, not \fR

Revision 1.74 / (download) - annotate - [select for diffs], Thu Aug 16 13:49:40 2018 UTC (5 years, 9 months ago) by schwarze
Branch: MAIN
Changes since 1.73: +8 -1 lines
Diff to previous 1.73 (colored)

Implement the \*(.T predefined string (interpolate device name)
by allowing the preprocessor to pass it through to the formatters.
Used for example by the groff_char(7) manual page.

Revision 1.73 / (download) - annotate - [select for diffs], Fri Aug 10 22:12:40 2018 UTC (5 years, 9 months ago) by schwarze
Branch: MAIN
Changes since 1.72: +22 -4 lines
Diff to previous 1.72 (colored)

handle the non-portable GNU-style \[charNN], \[charNNN] character
escape sequences, used for example in the groff_char(7) manual page

Revision 1.72 / (download) - annotate - [select for diffs], Sat Jul 28 18:32:30 2018 UTC (5 years, 9 months ago) by schwarze
Branch: MAIN
Changes since 1.71: +5 -2 lines
Diff to previous 1.71 (colored)

Issue a STYLE message when normalizing the date format in .Dd/.TH.
Leah Neukirchen pointed out that mdoclint(1) used to warn about a
leading zero before the day number, so we know that both NetBSD and
Void Linux want the message.  It does no harm on OpenBSD because
Mdocdate always does the right thing anyway.
jmc@ agrees that it makes sense in contexts not using Mdocdate.

Revision 1.71 / (download) - annotate - [select for diffs], Mon Jul 3 13:40:00 2017 UTC (6 years, 10 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_6_3_BASE, OPENBSD_6_3, OPENBSD_6_2_BASE, OPENBSD_6_2
Changes since 1.70: +11 -3 lines
Diff to previous 1.70 (colored)

warn about time machines; suggested by Thomas Klausner <wiz @ NetBSD>

Revision 1.70 / (download) - annotate - [select for diffs], Wed Jun 14 01:31:19 2017 UTC (6 years, 11 months ago) by schwarze
Branch: MAIN
Changes since 1.69: +3 -1 lines
Diff to previous 1.69 (colored)

implement the roff(7) \p (break output line) escape sequence

Revision 1.69 / (download) - annotate - [select for diffs], Sun Jun 11 19:36:31 2017 UTC (6 years, 11 months ago) by schwarze
Branch: MAIN
Changes since 1.68: +11 -7 lines
Diff to previous 1.68 (colored)

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).

Revision 1.68 / (download) - annotate - [select for diffs], Fri Jun 2 19:21:03 2017 UTC (6 years, 11 months ago) by schwarze
Branch: MAIN
Changes since 1.67: +13 -3 lines
Diff to previous 1.67 (colored)

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.

Revision 1.67 / (download) - annotate - [select for diffs], Thu Jun 1 19:05:15 2017 UTC (6 years, 11 months ago) by schwarze
Branch: MAIN
Changes since 1.66: +2 -2 lines
Diff to previous 1.66 (colored)

Minimal implementation of the \h (horizontal motion) escape sequence.
Good enough to cope with the average DocBook insanity.

Revision 1.66 / (download) - annotate - [select for diffs], Thu Nov 12 22:43:30 2015 UTC (8 years, 6 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_6_1_BASE, OPENBSD_6_1, OPENBSD_6_0_BASE, OPENBSD_6_0, OPENBSD_5_9_BASE, OPENBSD_5_9
Changes since 1.65: +32 -16 lines
Diff to previous 1.65 (colored)

Simplify the logic in mandoc_normdate() and add some comments.
Also add a comment in time2a() explaining why it isn't possible
to use just one single call to strftime().
Do some style cleanup while here.
No functional change.
Triggered by a very different patch from des@FreeBSD.

Revision 1.65 / (download) - annotate - [select for diffs], Thu Oct 15 23:35:38 2015 UTC (8 years, 7 months ago) by schwarze
Branch: MAIN
Changes since 1.64: +1 -3 lines
Diff to previous 1.64 (colored)

Delete two preprocessor constants that are no longer used.
Patch from Michael Reed <m dot reed at mykolab dot com>.

Revision 1.64 / (download) - annotate - [select for diffs], Tue Oct 13 23:30:42 2015 UTC (8 years, 7 months ago) by schwarze
Branch: MAIN
Changes since 1.63: +4 -1 lines
Diff to previous 1.63 (colored)

Reject the escape sequences \[uD800] to \[uDFFF] in the parser.
These surrogates are not valid Unicode codepoints,
so treat them just like any other undefined character escapes:
Warn about them and do not produce output.
Issue noticed while talking to stsp@, semarie@, and bentley@.

Revision 1.63 / (download) - annotate - [select for diffs], Mon Oct 12 00:07:27 2015 UTC (8 years, 7 months ago) by schwarze
Branch: MAIN
Changes since 1.62: +1 -32 lines
Diff to previous 1.62 (colored)

To make the code more readable, delete 283 /* FALLTHROUGH */ comments
that were right between two adjacent case statement.  Keep only
those 24 where the first case actually executes some code before
falling through to the next case.

Revision 1.62 / (download) - annotate - [select for diffs], Tue Oct 6 18:30:43 2015 UTC (8 years, 7 months ago) by schwarze
Branch: MAIN
Changes since 1.61: +27 -26 lines
Diff to previous 1.61 (colored)

modernize style: "return" is not a function; ok cmp(1)

Revision 1.61 / (download) - annotate - [select for diffs], Sat Aug 29 22:39:59 2015 UTC (8 years, 8 months ago) by schwarze
Branch: MAIN
Changes since 1.60: +5 -1 lines
Diff to previous 1.60 (colored)

Parse and ignore the escape sequences \, and \/ (italic corrections).
Actually using these is very stupid because they are groff extensions
and other roff(7) implementations typically print unintended characters
at the places where they are used.
Nevertheless, some manuals contain them, for example ocserv(8).
Problem reported by Kurt Jaeger <pi at FreeBSD>.

Revision 1.60 / (download) - annotate - [select for diffs], Fri Feb 20 23:51:54 2015 UTC (9 years, 2 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_5_8_BASE, OPENBSD_5_8, OPENBSD_5_7_BASE, OPENBSD_5_7
Changes since 1.59: +9 -1 lines
Diff to previous 1.59 (colored)

For selecting a two-digit font size, support the historic syntax \s12
in addition to the classic syntax \s(12, the modern syntax \s[12],
and the alternative syntax \s'12'.  The historic syntax only works
for the font sizes 10-39.
Real-world usage found by naddy@ in plan9/rc.

Revision 1.59 / (download) - annotate - [select for diffs], Wed Jan 21 20:20:49 2015 UTC (9 years, 3 months ago) by schwarze
Branch: MAIN
Changes since 1.58: +7 -5 lines
Diff to previous 1.58 (colored)

Rudimentary implementation of the roff(7) \o escape sequence (overstrike).
This is of some relevance because the pod2man(1) preamble abuses it
for the icelandic letter Thorn, instead of simply using \(TP and \(Tp.
Missing feature found by sthen@ in DateTime::Locale::is_IS(3p).

Revision 1.58 / (download) - annotate - [select for diffs], Thu Jan 1 18:10:09 2015 UTC (9 years, 4 months ago) by schwarze
Branch: MAIN
Changes since 1.57: +4 -4 lines
Diff to previous 1.57 (colored)

Fix a read buffer overrun triggered by trailing \s- or trailing \s+
without the required subsequent argument; found by jsg@ with afl.

Revision 1.57 / (download) - annotate - [select for diffs], Mon Dec 15 17:29:58 2014 UTC (9 years, 5 months ago) by schwarze
Branch: MAIN
Changes since 1.56: +3 -1 lines
Diff to previous 1.56 (colored)

Catch localtime() failure for additional safety;
patch from Jan Stary <hans at stare dot cz> some time ago.

Revision 1.56 / (download) - annotate - [select for diffs], Fri Nov 28 19:25:03 2014 UTC (9 years, 5 months ago) by schwarze
Branch: MAIN
Changes since 1.55: +1 -1 lines
Diff to previous 1.55 (colored)

Add some missing OpenBSD RCS markers
and a few missing <sys/types.h> inclusions; no code change.

Revision 1.55 / (download) - annotate - [select for diffs], Tue Oct 28 13:22:57 2014 UTC (9 years, 6 months ago) by schwarze
Branch: MAIN
Changes since 1.54: +10 -5 lines
Diff to previous 1.54 (colored)

Tighten Unicode escape name parsing.
Accept only 0xXXXX, 0xYXXXX, 0x10XXXX with Y != 0.
This simplifies mchars_num2uc().

Revision 1.54 / (download) - annotate - [select for diffs], Mon Oct 13 17:16:25 2014 UTC (9 years, 7 months ago) by schwarze
Branch: MAIN
Changes since 1.53: +12 -13 lines
Diff to previous 1.53 (colored)

Stricter syntax checking of Unicode character names:
Require exactly 4, 5 or 6 hex digits and allow nothing else.
This avoids mishandling stuff like \[ua] and \C'uA' as Unicode
and also fixes underlining in eqn(7) -Thtml output which uses \[ul].
Problem found and semantics suggested by kristaps@.

Revision 1.53 / (download) - annotate - [select for diffs], Mon Aug 18 13:25:54 2014 UTC (9 years, 9 months ago) by schwarze
Branch: MAIN
Changes since 1.52: +3 -2 lines
Diff to previous 1.52 (colored)

kristaps@ found this with valgrind, merge his patch from bsd.lv:
Fix a corner case where \H<nil> (where <nil> is the \0 character) would
cause mandoc_escape() to read past the end of an allocated string.
Found when a script scanning of all Mac OSX manuals accidentally also
scanned binary (gzip'd) files, discussed with schwarze@ on tech@mdocml.

Revision 1.52 / (download) - annotate - [select for diffs], Sun Jul 6 19:08:56 2014 UTC (9 years, 10 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_5_6_BASE, OPENBSD_5_6
Changes since 1.51: +3 -3 lines
Diff to previous 1.51 (colored)

Clean up messages related to plain text and to escape sequences.
* Mention invalid escape sequences and string names, and fallbacks.
* Hierarchical naming.

Revision 1.51 / (download) - annotate - [select for diffs], Sun Jul 6 18:36:49 2014 UTC (9 years, 10 months ago) by schwarze
Branch: MAIN
Changes since 1.50: +4 -2 lines
Diff to previous 1.50 (colored)

Fix handling of escape sequences taking numeric arguments.
* Repair detection of invalid delimiters.
* Discard the invalid delimiter together with the invalid sequence.

Note to self: In general, strchr("\0...", c) is a thoroughly bad idea.

Revision 1.50 / (download) - annotate - [select for diffs], Tue Jul 1 22:36:35 2014 UTC (9 years, 10 months ago) by schwarze
Branch: MAIN
Changes since 1.49: +2 -2 lines
Diff to previous 1.49 (colored)

Clean up the warnings related to document structure.
* Hierarchical naming of the related enum mandocerr items.
* Mention the offending macro, section title, or string.
While here, improve some wordings:
* Descriptive instead of imperative style.
* Uniform style for "missing" and "skipping".
* Where applicable, mention the fallback used.

Revision 1.49 / (download) - annotate - [select for diffs], Fri Jun 20 17:23:09 2014 UTC (9 years, 11 months ago) by schwarze
Branch: MAIN
Changes since 1.48: +3 -3 lines
Diff to previous 1.48 (colored)

Start systematic improvements of error reporting.
So far, this covers all WARNINGs related to the prologue.

1) hierarchical naming of MANDOCERR_* constants
2) mention the macro name in messages where that adds clarity
3) add one missing MANDOCERR_DATE_MISSING msg
4) fix the wording of one message related to the man(7) prologue

Started on the plane back from Ottawa.

Revision 1.48 / (download) - annotate - [select for diffs], Sun Apr 20 16:44:44 2014 UTC (10 years, 1 month ago) by schwarze
Branch: MAIN
Changes since 1.47: +62 -62 lines
Diff to previous 1.47 (colored)

KNF: case (FOO):  ->  case FOO, remove /* LINTED */ and /* ARGSUSED */,
remove trailing whitespace and blanks before tabs, improve some indenting;
no functional change

Revision 1.47 / (download) - annotate - [select for diffs], Tue Apr 8 01:36:50 2014 UTC (10 years, 1 month ago) by schwarze
Branch: MAIN
Changes since 1.46: +3 -6 lines
Diff to previous 1.46 (colored)

Fully implement the \B (validate numerical expression) and
partially implement the \w (measure text width) escape sequence
in a way that makes them usable in numerical expressions and in
conditional requests, similar to how \n (interpolate number register)
and \* (expand user-defined string) are implemented.

This lets mandoc(1) handle the baroque low-level roff code
found at the beginning of the ggrep(1) manual.
Thanks to pascal@ for the report.

Revision 1.46 / (download) - annotate - [select for diffs], Mon Apr 7 17:50:43 2014 UTC (10 years, 1 month ago) by schwarze
Branch: MAIN
Changes since 1.45: +5 -5 lines
Diff to previous 1.45 (colored)

Accept arbitrary argument delimiters for various roff(7) escape sequences.
Needed for example by the new Perl pod2man(1) preamble.

Revision 1.45 / (download) - annotate - [select for diffs], Fri Mar 21 22:17:01 2014 UTC (10 years, 2 months ago) by schwarze
Branch: MAIN
Changes since 1.44: +2 -69 lines
Diff to previous 1.44 (colored)

The files mandoc.c and mandoc.h contained both specialised low-level
functions used for multiple languages (mdoc, man, roff), for example
mandoc_escape(), mandoc_getarg(), mandoc_eos(), and generic auxiliary
functions.  Split the auxiliaries out into their own file and header.
While here, do some #include cleanup.

Revision 1.44 / (download) - annotate - [select for diffs], Mon Dec 30 18:27:15 2013 UTC (10 years, 4 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_5_5_BASE, OPENBSD_5_5
Changes since 1.43: +2 -2 lines
Diff to previous 1.43 (colored)

Remove duplicate const specifiers from the declaration of mandoc_escape().
Found by Thomas Klausner <wiz at NetBSD dot org> using clang.
No functional change.

Revision 1.43 / (download) - annotate - [select for diffs], Mon Dec 30 00:52:18 2013 UTC (10 years, 4 months ago) by schwarze
Branch: MAIN
Changes since 1.42: +5 -5 lines
Diff to previous 1.42 (colored)

Simplify: Remove an unused argument from the mandoc_eos() function.
No functional change.

Revision 1.42 / (download) - annotate - [select for diffs], Thu Dec 26 02:55:35 2013 UTC (10 years, 4 months ago) by schwarze
Branch: MAIN
Changes since 1.41: +6 -8 lines
Diff to previous 1.41 (colored)

I have no idea how it happened that \B, \H, \h, \L, and \l got
mapped to ESCAPE_NUMBERED (which is for \N and only for \N), that
made no sense at all.  Properly remap them to ESCAPE_IGNORE.

While here, move \B and \w from the group taking number arguments
to the group taking string arguments; right now, that doesn't imply
any functional change, but if we ever go ahead and implement a
parser for roff(7) numerical expressions, it will suddenly start
to matter, and cause confusion.

Revision 1.41 / (download) - annotate - [select for diffs], Wed Dec 25 22:45:16 2013 UTC (10 years, 4 months ago) by schwarze
Branch: MAIN
Changes since 1.40: +9 -1 lines
Diff to previous 1.40 (colored)

Parse and ignore the roff(7) escape sequences \d (move half line down)
und \u (move half line up).  Found by bentley@ in some DocBook crap.
Surprisingly, these two do actually occur in our terminfo(5),
so this patch reduces groff-mandoc differences in base by 0.03%.

Revision 1.40 / (download) - annotate - [select for diffs], Wed Dec 25 00:50:03 2013 UTC (10 years, 4 months ago) by schwarze
Branch: MAIN
Changes since 1.39: +4 -4 lines
Diff to previous 1.39 (colored)

s/[Nn]ull/NUL/ in comments where appropriate;
suggested by Thomas Klausner <wiz @ NetBSD dot org>.

Revision 1.39 / (download) - annotate - [select for diffs], Sun Nov 10 20:17:14 2013 UTC (10 years, 6 months ago) by schwarze
Branch: MAIN
Changes since 1.38: +5 -2 lines
Diff to previous 1.38 (colored)

Support the alternative syntax \C'uXXXX' for Unicode characters.
It is already documented in the Heirloom troff manual,
and groff handles it as well.

Bug reported by Bjarni Ingi Gislason <bjarniig at rhi dot hi dot is>
on <bug-groff at gnu dot org>.  Well, admittedly, that bug was reported
against groff, but mandoc was even more broken than groff with respect
to this syntax...

Revision 1.38 / (download) - annotate - [select for diffs], Sat Oct 5 21:17:29 2013 UTC (10 years, 7 months ago) by schwarze
Branch: MAIN
Changes since 1.37: +2 -2 lines
Diff to previous 1.37 (colored)

Cleanup suggested by gcc-4.8.1, following hints by Christos Zoulas:
- avoid bad qualifier casting in roff.c, roff_parsetext()
  by changing the mandoc_escape arguments to "const char const **"
- avoid bad qualifier casting in mandocdb.c, index_merge()
- garbage collect a few unused variables elsewhere

Revision 1.37 / (download) - annotate - [select for diffs], Thu Aug 8 20:07:24 2013 UTC (10 years, 9 months ago) by schwarze
Branch: MAIN
Changes since 1.36: +15 -9 lines
Diff to previous 1.36 (colored)

Implement the roff(7) font-escape sequence \f(BI "bold+italic".
This improves the formatting of about 40 base manuals
and reduces groff-mandoc formatting differences in base by about 5%.

Revision 1.36 / (download) - annotate - [select for diffs], Thu Jun 20 22:29:38 2013 UTC (10 years, 11 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_5_4_BASE, OPENBSD_5_4
Changes since 1.35: +24 -6 lines
Diff to previous 1.35 (colored)

Improve handling of the roff(7) "\t" escape sequence:
* Parsing macro arguments has to be done in copy mode,
  which implies replacing "\t" by a literal tab character.
* Otherwise, render "\t" as the empty string, not as a 't' character.

This fixes formatting of the distfile example in the oldrdist(1) manual.
This also shows up in the unzip(1) manual as one of several issues
preventing the removal of USE_GROFF from the archivers/unzip port.
Thanks to espie@ for attracting my attention to the unzip(1) manual.

Revision 1.35 / (download) - annotate - [select for diffs], Sat Jul 7 18:27:36 2012 UTC (11 years, 10 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_5_3_BASE, OPENBSD_5_3, OPENBSD_5_2_BASE, OPENBSD_5_2
Changes since 1.34: +1 -27 lines
Diff to previous 1.34 (colored)

Support the .cc request; code by kristaps@, tests by me.
Needed for sqlite3(1) as reported by espie@.

Revision 1.34 / (download) - annotate - [select for diffs], Mon May 28 22:45:33 2012 UTC (11 years, 11 months ago) by schwarze
Branch: MAIN
Changes since 1.33: +65 -68 lines
Diff to previous 1.33 (colored)

While i already got my fingers dirty on mandoc_escape(),
profit of the occasion to pull out some spaghetti, that is,
three confusing variables and fourteen pointless assignments
among them; instead, always operate on the official pointers
**start, **end, and *sz, each of which conveys an obvious meaning.

No functional change intended, and the new tests confirm that
everything still (err...) "works", as far as that word can be
applied to the kind of roff(7) mock-up code i'm polishing here.

Revision 1.33 / (download) - annotate - [select for diffs], Mon May 28 17:08:48 2012 UTC (11 years, 11 months ago) by schwarze
Branch: MAIN
Changes since 1.32: +37 -118 lines
Diff to previous 1.32 (colored)

Make recursive parsing of roff(7) escapes actually work in the general case,
in particular when the inner escapes are preceded or followed by other terms.
While doing so, remove lots of bogus code that was trying to make pointless
distinctions between numeric and non-numeric escape sequences, while both
actually share the same syntax and we ignore the semantics anyway.

This prevents some of the strings defined in the pod2man(1) preamble
from producing garbage output, in particular in scandinavian words.
Of course, proper rendering of scandinavian national characters
cannot be expected even with these fixes.

Revision 1.32 / (download) - annotate - [select for diffs], Mon May 28 13:00:51 2012 UTC (11 years, 11 months ago) by schwarze
Branch: MAIN
Changes since 1.31: +12 -2 lines
Diff to previous 1.31 (colored)

Implement the roff \z escape sequence, intended to output the next
character without advancing the cursor position; implement it to
simply skip the next character, as it will usually be overwritten.

With this change, the pod2man(1) preamble user-defined string \*:,
intended to render as a diaeresis or umlaut diacritic above the
preceding character, is rendered in a slightly less ugly way,
though still not correctly.  It was rendered as "z.." and is now
rendered as ".".

Given that the definition of \*: uses elaborate manual \h positioning,
there is little chance for mandoc(1) to ever render it correctly,
but at least we can refrain from printing out a spurious "z", and
we can make the \z do something semi-reasonable for easier cases.

Revision 1.31 / (download) - annotate - [select for diffs], Thu Nov 17 11:58:11 2011 UTC (12 years, 6 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_5_1_BASE, OPENBSD_5_1
Changes since 1.30: +4 -3 lines
Diff to previous 1.30 (colored)

ISO style "%Y-%m-%d" dates are common in man(7) .TH.
They have been considered valid in the past, but were reformatted
to the mdoc(7) "Month day, year" style.
To make page footers more similar to groff, no longer reformat them,
just print them as they are.
This doesn't change anything with respect to what's considered valid
or what is warned about.

Putting this in now such that i can improve the unit test suite.

Revision 1.30 / (download) - annotate - [select for diffs], Sat Nov 12 22:31:22 2011 UTC (12 years, 6 months ago) by schwarze
Branch: MAIN
Changes since 1.29: +9 -2 lines
Diff to previous 1.29 (colored)

Parse and ignore the C font family in \f escapes.
Helps with some real-world manuals that (incorrectly)
assume that the C font family means "constant width".
Suggested by Andreas Vogele, patch by kristaps@.

Revision 1.29 / (download) - annotate - [select for diffs], Mon Oct 24 20:29:21 2011 UTC (12 years, 6 months ago) by schwarze
Branch: MAIN
Changes since 1.28: +23 -7 lines
Diff to previous 1.28 (colored)

Handle \N numbered character escapes the same way as groff:
If \N is followed by a digit, ignore \N and the digit.
If \N is followed by a non-digit, the next non-digit
ends the character number; the two delimiters need not match.
Kristaps calls that "gross, but not our fault".

This fixes most of src/regress/usr.bin/mandoc/char/N/basic.in, except
that handling of non-printable characters still differs from groff.

For now, i'm fixing \N only.  Other escapes taking numeric arguments
may or may not need similar handling, but \N is by far the most
important for practical purposes.

ok kristaps@

Revision 1.28 / (download) - annotate - [select for diffs], Sun Sep 18 15:54:48 2011 UTC (12 years, 8 months ago) by schwarze
Branch: MAIN
Changes since 1.27: +6 -33 lines
Diff to previous 1.27 (colored)

sync to version 1.11.7 from kristaps@
main new feature: support the roff(7) .tr request
plus various bugfixes and some refactoring

regressions are so minor that it's better to get this in
and fix them in the tree

Revision 1.27 / (download) - annotate - [select for diffs], Sun Sep 18 10:25:28 2011 UTC (12 years, 8 months ago) by schwarze
Branch: MAIN
Changes since 1.26: +16 -7 lines
Diff to previous 1.26 (colored)

sync to version 1.11.5:
adding an implementation of the eqn(7) language
by kristaps@

So far, only .EQ/.EN blocks are handled, in-line equations are not, and
rendering is not yet very pretty, but the parser is fairly complete.

Revision 1.26 / (download) - annotate - [select for diffs], Sun May 29 21:22:18 2011 UTC (12 years, 11 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_5_0_BASE, OPENBSD_5_0
Changes since 1.25: +337 -144 lines
Diff to previous 1.25 (colored)

Merge release 1.11.3, almost all code by kristaps@:
* Unicode output support (no Unicode input yet, though).
* Refactoring: completely handle predefined strings in roff.c.
- New function mandoc_escape() replaces a2roffdeco() and mandoc_special().
- Start using mandoc_getarg() in mdoc_argv.c.
- Clean up parsing of delimiters in mdoc(7).
* And many minor fixes and lots of cleanup.

Revision 1.25 / (download) - annotate - [select for diffs], Sun Apr 24 16:22:02 2011 UTC (13 years ago) by schwarze
Branch: MAIN
Changes since 1.24: +26 -51 lines
Diff to previous 1.24 (colored)

Merge version 1.11.1:
Again lots of cleanup and maintenance work by kristaps@.
- simplify error reporting: less function pointers, more mandoc_[v]msg
- main: split document parsing out of main.c into read.c
- roff, mdoc, man: improved recognition of control characters
- roff: better handling of if/else stack overflows
- roff: add some predefined strings for backward compatibility
- mdoc, man: empty sections are not errors
- mdoc: move delimiter handling to libmdoc
- some header restructuring and some minor features and fixes
This merge causes two minor regressions
that i will fix in separate commits right afterwards.

Revision 1.24 / (download) - annotate - [select for diffs], Thu Apr 21 22:59:54 2011 UTC (13 years, 1 month ago) by schwarze
Branch: MAIN
Changes since 1.23: +54 -8 lines
Diff to previous 1.23 (colored)

Merge version 1.10.10:
lots of cleanup and maintenance work by kristaps@.
- move some main.c globals into struct curparse
- move mandoc_*alloc to mandoc.h such that all code can use them
- make mandoc_isdelim available to formatting frontends
- dissolve mdoc_strings.c, move the code where it is used
- make all error reporting functions void, their return values were useless
- and various minor cleanups and fixes

Revision 1.23 / (download) - annotate - [select for diffs], Tue Mar 15 03:03:49 2011 UTC (13 years, 2 months ago) by schwarze
Branch: MAIN
Changes since 1.22: +24 -18 lines
Diff to previous 1.22 (colored)

my $buf = "string"; return $string;  is cool in Perl, but not in C;
found by Ulrich Spoerlein <uqs at freebsd> using the clang static analyzer;
"ok, but please document the numbers" kristaps@

Revision 1.22 / (download) - annotate - [select for diffs], Mon Mar 7 01:35:33 2011 UTC (13 years, 2 months ago) by schwarze
Branch: MAIN
Changes since 1.21: +49 -30 lines
Diff to previous 1.21 (colored)

Clean up date handling,
as a first step to get rid of the frequent petty warnings in this area:
 - always store dates as strings, not as seconds since the Epoch
 - for input, try the three most common formats everywhere
 - for unrecognized format, just pass the date though verbatim
 - when there is no date at all, still use the current date
Originally triggered by a one-line patch from Tim van der Molen,
<tbvdm at xs4all dot nl>, which is included here.
Feedback and OK on manual parts from jmc@.
"please check this in" kristaps@

Revision 1.21 / (download) - annotate - [select for diffs], Mon Jan 3 22:27:21 2011 UTC (13 years, 4 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_4_9_BASE, OPENBSD_4_9
Changes since 1.20: +81 -3 lines
Diff to previous 1.20 (colored)

Unify roff macro argument parsing (in roff.c, roff_userdef()) and man macro
argument parsing (in man_argv.c, man_args()), both having different bugs,
to use one common macro argument parser (in mandoc.c, mandoc_getarg()),
because from the point of view of roff, man macros are just roff macros,
hence their arguments are parsed in exactly the same way.

While doing so, fix these bugs:
 * Escaped blanks (i.e. those preceded by an odd number of backslashes)
   were mishandled as argument separators in unquoted arguments to
   user-defined roff macros.
 * Unescaped blanks preceded by an even number of backslashes were not
   recognized as argument separators in unquoted arguments to man macros.
 * Escaped backslashes (i.e. pairs of backslashes) were not reduced
   to single backslashes both in unquoted and quoted arguments both
   to user-defined roff macros and to man macros.
 * Escaped quotes (i.e. pairs of quotes inside quoted arguments) were
   not reduced to single quotes in man macros.

OK kristaps@

Note that mdoc macro argument parsing is yet another beast for no good
reason and is probably afflicted by similar bugs.  But i don't attempt
to fix that right now because it is intricately entangled with lots of
unrelated high-level mdoc(7) functionality, like delimiter handling and
column list phrase handling.  Disentagling that would waste too much
time now.

Revision 1.20 / (download) - annotate - [select for diffs], Mon Sep 27 21:25:28 2010 UTC (13 years, 7 months ago) by schwarze
Branch: MAIN
Changes since 1.19: +6 -6 lines
Diff to previous 1.19 (colored)

Merge the last bits of 1.10.6 (released today), most were already in:
* ignore double-.Pp
* ignore .Pp before .Bd and .Bl (unless -compact in specified)
* avoid double blank line upon .Pp, .br and friends in literal context
* cast enums to int when passing them to exit(3) to please lint(1)
While merging, fix a regression introduced by kristaps@:
Outside literal mode, double blank lines must both be printed.
To achieve this again after kristaps@ improvements in 1.10.6,
treat such blank lines as .sp (instead of .Pp as in 1.10.5)
and drop .Pp before .sp just like dropping .Pp before .Pp.

Revision 1.19 / (download) - annotate - [select for diffs], Mon Sep 13 22:04:01 2010 UTC (13 years, 8 months ago) by schwarze
Branch: MAIN
Changes since 1.18: +40 -6 lines
Diff to previous 1.18 (colored)

Parse and ignore the \k, \o, \w, and \z roff escapes, and recursively
ignore embedded escapes and mathematical roff subexpressions.
In roff copy mode, resolve "\\" to '\'.
Allow ".xx\}" where xx is a macro to close roff conditional scope.
Mandoc now handles the special character definitions in the pod2man(1)
preamble, so remove the explicit redefinitions in chars.c/chars.in.
From kristaps@.

I have checked that this causes no relevant change to the Perl manuals.
The only change introduced is that some non-ASCII characters rendered
incorrectly before are now rendered incorrectly in a different way.
For example, e accent aigu was "e", now is "e'"
and c cedille was "c", now is "c,".

Revision 1.18 / (download) - annotate - [select for diffs], Fri Aug 20 00:53:35 2010 UTC (13 years, 9 months ago) by schwarze
Branch: MAIN
Changes since 1.17: +5 -5 lines
Diff to previous 1.17 (colored)

Implement a simple, consistent user interface for error handling.
We now have sufficient practical experience to know what we want,
so this is intended to be final:
- provide -Wlevel (warning, error or fatal) to select what you care about
- provide -Wstop to stop after parsing a file with warnings you care about
- provide consistent exit status codes for those warnings you care about
- fully document what warnings, errors and fatal errors mean
- remove all other cruft from the user interface, less is more:
- remove all -f knobs along with the whole -f option
- remove the old -Werror because calling warnings "fatal" is silly
- always finish parsing each file, unless fatal errors prevent that
This commit also includes a couple of related simplifications behind
the scenes regarding error handling.
Feedback and OK  kristaps@;  Joerg Sonnenberger (NetBSD) and
Sascha Wildner (DragonFly BSD) agree with the general direction.

Revision 1.17 / (download) - annotate - [select for diffs], Wed Aug 18 02:38:40 2010 UTC (13 years, 9 months ago) by schwarze
Branch: MAIN
Changes since 1.16: +12 -10 lines
Diff to previous 1.16 (colored)

Ignore \h (local horizontal motion) and \v (local vertical motion) escapes
just in the same way as \s (font size) escapes, and handle \s escapes
not having an explicit plus or minus sign.
This fixes the very ugly rendering of "C++" in gcc(1).
Reported by Thomas Jeunet, fixed by kristaps@.

Revision 1.16 / (download) - annotate - [select for diffs], Sun Jul 25 18:05:54 2010 UTC (13 years, 9 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_4_8_BASE, OPENBSD_4_8
Changes since 1.15: +111 -136 lines
Diff to previous 1.15 (colored)

Sync to bsd.lv; in particular, pull in lots of bug fixes.
new features:
* support the .in macro in man(7)
* support minimal PDF output
* support .Sm in mdoc(7) HTML output
* support .Vb and .nf in man(7) HTML output
* complete the mdoc(7) manual
bug fixes:
* do not let mdoc(7) .Pp produce a newline before/after .Sh; reported by jmc@
* avoid double blank lines related to man(7) .sp and .br
* let man(7) .nf and .fi flush the line; reported by jsg@ and naddy@
* let "\ " produce a non-breaking space; reported by deraadt@
* discard \m colour escape sequences; reported by J.C. Roberts
* map undefined 1-character-escapes to the literal character itself
maintenance:
* express mdoc(7) arguments in terms of an enum for additional type-safety
* simplify mandoc_special() and a2roffdeco()
* use strcspn in term_word() in place of a manual loop
* minor optimisations in the -Tps and -Thtml formatting frontends

Revision 1.15 / (download) - annotate - [select for diffs], Fri Jul 16 00:34:33 2010 UTC (13 years, 10 months ago) by schwarze
Branch: MAIN
Changes since 1.14: +13 -11 lines
Diff to previous 1.14 (colored)

Text ending in a full stop, exclamation mark or question mark
should not flag the end of a sentence if:

1) The punctuation is followed by closing delimiters
and not preceded by alphanumeric characters, like in
"There is no full stop (.) in this sentence"

or

2) The punctuation is a child of a macro
and not preceded by alphanumeric characters, like in
"There is no full stop
.Pq \&.
in this sentence"

jmc@ and sobrado@ like this

Revision 1.14 / (download) - annotate - [select for diffs], Sat Jun 26 17:56:43 2010 UTC (13 years, 10 months ago) by schwarze
Branch: MAIN
Changes since 1.13: +55 -31 lines
Diff to previous 1.13 (colored)

merge release 1.10.2
* bug fixes:
- interaction of ASCII_HYPH with special chars (found by Ulrich Spoerlein)
- handling of roff conditionals (found by Ulrich Spoerlein)
- .Bd -offset will no more default to 6n
* maintenance:
- more caching of .Bd and .Bl arguments for efficiency
- deconstify man(7) validation routines
- add FreeBSD library names (provided by Ulrich Spoerlein)
* start PostScript font-switching

Revision 1.13 / (download) - annotate - [select for diffs], Sun Jun 6 20:30:08 2010 UTC (13 years, 11 months ago) by schwarze
Branch: MAIN
Changes since 1.12: +3 -1 lines
Diff to previous 1.12 (colored)

Merge bsd.lv version 1.10.1 (to be released soon).

The main step forward is that this now has *much* better .Bl -column
support, now supporting many manuals that previously errored out
without producing any output.

Other fixes include:
* do not die from multiple list types, use the first and warn
* in .Bl without a type, default to -item
* various tweaks to .Dt
* fix .In, .Fd, .Ft, .Fn and .Fo formatting
* some documentation fixes and additions
* and fix a couple of bugs reported by Ulrich Spoerlein:
* better support for roff block-end "\}" without a preceding dot
* .In must not break the line outside SYNOPSIS
* spelling in some error messages

While merging, fix one regression in .In spacing
that needs to go to bsd.lv, too.

Revision 1.12 / (download) - annotate - [select for diffs], Wed May 26 02:39:58 2010 UTC (13 years, 11 months ago) by schwarze
Branch: MAIN
Changes since 1.11: +29 -1 lines
Diff to previous 1.11 (colored)

When a word does not fully fit onto the output line, but it contains
at least one hyphen, we already had support for breaking the line a the
last fitting hyphen.  This patch improves this functionality by only
breaking at hyphens in free-form text, and by not breaking at hyphens
* at the beginning or end of a word   or
* immediately preceded or followed by another hyphen   or
* escaped by a preceding backslash.

Before this patch, differences in break-at-hyphen support were one
of the major sources of noise in automatic comparisons to mdoc(7)
groff output.  Now, the remaining differences are hard to find among
the noise coming from other sources.

Where there are still differences, what we do seems to be better than
what groff does, see e.g. the chio(1) exchange and position commands
for one of the now rare examples.

idea and coding by kristaps@

Besides, this was the last substantial code difference left
between bsd.lv and openbsd.org.  We are now in full sync.

Revision 1.11 / (download) - annotate - [select for diffs], Sat May 15 15:37:53 2010 UTC (14 years ago) by schwarze
Branch: MAIN
Changes since 1.10: +29 -13 lines
Diff to previous 1.10 (colored)

more end-of-sentence (EOS) handling:
* recognize the end of quoted sentences, and of those in parantheses
* detect EOS in append_delims, so it works after all macros
by kristaps@

Revision 1.10 / (download) - annotate - [select for diffs], Sat May 15 09:20:01 2010 UTC (14 years ago) by schwarze
Branch: MAIN
Changes since 1.9: +3 -2 lines
Diff to previous 1.9 (colored)

block-implicit macros now up-propogate end-of-sentence spacing;
from bsd.lv mandoc.c 1.13 and mdoc_macro.c 1.64

Revision 1.9 / (download) - annotate - [select for diffs], Fri May 14 19:52:43 2010 UTC (14 years ago) by schwarze
Branch: MAIN
Changes since 1.8: +24 -1 lines
Diff to previous 1.8 (colored)

Integrate kristaps@' end-of-sentence (EOS) framework
which is simpler and more powerful than mine, and remove mine.

* man(7) now has EOS handling, too
* put EOS detection into its own function in libmandoc
* use node and termp flags to communicate the EOS condition
* no more EOS pseudo-macro
* no more non-printable EOS marker character on the formatter level

This slightly breaks EOS detection after trailing punctuation
in mdoc(7) macros, but that will be restored soon.

Revision 1.8 / (download) - annotate - [select for diffs], Wed Apr 7 23:15:05 2010 UTC (14 years, 1 month ago) by schwarze
Branch: MAIN
Changes since 1.7: +5 -5 lines
Diff to previous 1.7 (colored)

Merge the good parts of 1.9.23,
avoid the bad parts of 1.9.23, and keep local patches.

Input in general:
 * Basic handling of roff-style font escapes \f, \F.
 * Quoted punctuation does not count as punctuation.

mdoc(7) parser:
 * Make .Pf callable; noted by Claus Assmann.
 * Let .Bd and .Bl ignore unknown arguments; noted by deraadt@.
 * Do not warn when .Er is used outside certain sections.
 * Replace mdoc_node_free[list] by mdoc_node_delete.
 * Replace #define by enum for rew*() return values.

man(7) parser:
 * When .TH is missing, use default section and date.

Output in general:
 * Curly braces do not count as punctuation.
 * No space after .Fl w/o args when a macro follows on the same line.

HTML output:
 * Unify PAIR_*_INIT macros, introduce new PAIR_ID_INIT().
 * Print whitespace after, not before .Vt .Fn .Ft .Fo.

Checked that all manuals in base still build.

Revision 1.7 / (download) - annotate - [select for diffs], Thu Feb 18 02:11:26 2010 UTC (14 years, 3 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_4_7_BASE, OPENBSD_4_7
Changes since 1.6: +1 -3 lines
Diff to previous 1.6 (colored)

sync to release 1.9.15:
 * corrected .Vt handling (spotted by Joerg Sonnenberger)
 * corrected .Xr argument handling (based on my patch)
 * removed \\ escape sequence (because it is for low-level roff only)
 * warn about trailing whitespace (suggested by jmc@)
 * -Txhtml support
 * and some general cleanup and doc improvements

Revision 1.6 / (download) - annotate - [select for diffs], Thu Dec 24 02:08:14 2009 UTC (14 years, 4 months ago) by schwarze
Branch: MAIN
Changes since 1.5: +80 -3 lines
Diff to previous 1.5 (colored)

sync to 1.9.14: rewrite escape sequence handling:
- new function a2roffdeco
- font modes (\f) only affect the current stack point
- implement scaling (\s)
- implement space suppression (\c)
- implement non-breaking space (\~) in -Tascii
- many manual improvements

Revision 1.5 / (download) - annotate - [select for diffs], Wed Dec 23 22:30:17 2009 UTC (14 years, 4 months ago) by schwarze
Branch: MAIN
Changes since 1.4: +59 -1 lines
Diff to previous 1.4 (colored)

sync to 1.9.13: minor fixes:

correctness/functionality:
 - bugfix: properly ignore lines with only a dot in -man
 - bugfix: .Bl -ohang doesn't allow -width, warn about this
 - improve date string handling by new function mandoc_a2time
 - some HTML improvements
 - significant documentation additions in man.7 and mdoc.7

portability:
 - replace __dead by __attribute__((noreturn))
 - bugfix: correct .Dx rendering
 - some more library names for NetBSD

simplicity:
 - replace hand-rolled putchar(3)-loops by fwrite(3)
 - replace single-character printf(3) by putchar(3)

Revision 1.4 / (download) - annotate - [select for diffs], Tue Dec 22 23:58:00 2009 UTC (14 years, 4 months ago) by schwarze
Branch: MAIN
Changes since 1.3: +61 -1 lines
Diff to previous 1.3 (colored)

sync to 1.9.12, mostly portability and refactoring:

correctness/functionality:
- bugfix: do not die when overstep hits the right margin
- new option: -fign-escape
- and various HTML features

portability:
- replace bzero(3) by memset(3), which is ANSI C
- replace err(3)/warn(3) by perror(3)/exit(3), which is ANSI C
- iuse argv[0] instead of __progname
- add time.h to various files for FreeBSD compilation

simplicity:
- do not allocate header/footer data dynamically in *_term.c
- provide and use malloc frontends that error out on failure

for full changelogs, see http://bsd.lv/cgi-bin/cvsweb.cgi/

Revision 1.3 / (download) - annotate - [select for diffs], Sat Aug 22 15:18:11 2009 UTC (14 years, 9 months ago) by schwarze
Branch: MAIN
Changes since 1.2: +3 -1 lines
Diff to previous 1.2 (colored)

sync to 1.8.4: recognize the \c escape (only used in -man)

Revision 1.2 / (download) - annotate - [select for diffs], Sat Jul 18 14:44:54 2009 UTC (14 years, 10 months ago) by schwarze
Branch: MAIN
Changes since 1.1: +3 -1 lines
Diff to previous 1.1 (colored)

sync to 1.8.0: <sys/types.h> needed for u_char; <uqs at spoerlein dot net>

Revision 1.1 / (download) - annotate - [select for diffs], Wed Jul 8 00:04:10 2009 UTC (14 years, 10 months ago) by schwarze
Branch: MAIN

sync to 1.7.21: unified escape sequence validation for mdoc and man
checking is still incomplete, but a bit better, in particular for man
now in sync with 1.7.22: the only 1.7.22 diff was already in

This form allows you to request diff's between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.