OpenBSD CVS

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


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

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.191 / (download) - annotate - [select for diffs], Sun Jan 19 17:59:01 2020 UTC (4 years, 4 months 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, OPENBSD_7_1_BASE, OPENBSD_7_1, OPENBSD_7_0_BASE, OPENBSD_7_0, OPENBSD_6_9_BASE, OPENBSD_6_9, OPENBSD_6_8_BASE, OPENBSD_6_8, OPENBSD_6_7_BASE, OPENBSD_6_7, HEAD
Changes since 1.190: +3 -2 lines
Diff to previous 1.190 (colored)

Introduce a new mdoc(7) macro .Tg ("tag") to explicitly mark a place
as defining a term.  Please only use it when automatic tagging does
not work.  Manual page authors will not be required to add the new
macro; using it remains optional.  HTML output is still rudimentary
in this version and will be polished later.

Thanks to kn@ for reminding me that i have been considering since
BSDCan 2014 whether something like this might be useful.  Given
that possibilities of making automatic tagging better are running
out and there are still several situations where automatic tagging
cannot do the job, i think the time is now ripe.

Feedback and no objection from millert@; OK espie@ inoguchi@ kn@.

Revision 1.190 / (download) - annotate - [select for diffs], Sun Jan 19 16:16:33 2020 UTC (4 years, 4 months ago) by schwarze
Branch: MAIN
Changes since 1.189: +2 -2 lines
Diff to previous 1.189 (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.189 / (download) - annotate - [select for diffs], Mon Jan 7 06:51:37 2019 UTC (5 years, 4 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_6_6_BASE, OPENBSD_6_6, OPENBSD_6_5_BASE, OPENBSD_6_5
Changes since 1.188: +14 -3 lines
Diff to previous 1.188 (colored)

Represent mdoc(7) .Pp (and .sp, and some SYNOPSIS and .Rs features)
by the <p> HTML element and use the html_fillmode() mechanism
for .Bd -unfilled, just like it was done for man(7) earlier, finally
getting rid both of the horrible <div class="Pp"></div> hack and
of the worst HTML syntax violations caused by nested displays.

Care is needed because in some situations, paragraphs have to remain
open across several subsequent macros, whereas in other situations,
they must get closed together with a block containing them.

Some implementation details include:
* Always close paragraphs before emitting HTML flow content.
* Let html_close_paragraph() also close <pre> for extra safety.
* Drop the old, now unused function print_paragraph().
* Minor adjustments in the top-level man(7) node formatter for symmetry.
* Bugfix: .Ss heads suspend no-fill mode, even though .Ss doesn't end it.
* Bugfix: give up on .Op semantic markup for now, see the comment.

Revision 1.188 / (download) - annotate - [select for diffs], Tue Jan 1 07:41:22 2019 UTC (5 years, 4 months ago) by schwarze
Branch: MAIN
Changes since 1.187: +46 -4 lines
Diff to previous 1.187 (colored)

Correctly set the ROFF_NOFILL parser flag for .Bd .Ed .Sh, such
that children and later siblings get correct NODE_NOFILL assignments.
This doesn't change rendering yet but prepares for future rendering
improvements.

Revision 1.187 / (download) - annotate - [select for diffs], Mon Dec 31 04:55:42 2018 UTC (5 years, 4 months ago) by schwarze
Branch: MAIN
Changes since 1.186: +1 -2 lines
Diff to previous 1.186 (colored)

Cleanup, minus 15 LOC, no functional change:
Simplify the way the man(7) and mdoc(7) validators are called.
Reset the parser state with a common function before calling them.
There is no need to again reset the parser state afterwards,
the parsers are no longer used after validation.
This allows getting rid of man_node_validate() and mdoc_node_validate()
as separate functions.

Revision 1.186 / (download) - annotate - [select for diffs], Sun Dec 30 00:48:48 2018 UTC (5 years, 4 months ago) by schwarze
Branch: MAIN
Changes since 1.185: +2 -2 lines
Diff to previous 1.185 (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.185 / (download) - annotate - [select for diffs], Fri Dec 21 16:58:49 2018 UTC (5 years, 4 months ago) by schwarze
Branch: MAIN
Changes since 1.184: +66 -23 lines
Diff to previous 1.184 (colored)

Rename mandoc_getarg() to roff_getarg() and pass it the roff parser
struct as an argument such that after copy-in, it can call roff_expand()
once again, which used to be called roff_res() before this.  This
fixes a subtle low-level roff(7) parsing bug reported by Fabio
Scotoni <fabio at esse dot ch> in the 4.4BSD-Lite2 mdoc.samples(7)
manual page, because that page used an escaped escape sequence in
a macro argument.

To expand escaped escape sequences in quoted mdoc(7) arguments, too,
stop bypassing the call to roff_getarg() in mdoc_argv.c, function args()
for this case.  This does not solve the case of escaped escape sequences
in quoted .Bl -column phrases yet.

Because roff_expand() can make the string longer, roff_getarg() can no
longer operate in-place but needs to malloc(3) the returned string.
In the high-level parsers, free(3) that string after processing it.

Revision 1.184 / (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.183: +33 -42 lines
Diff to previous 1.183 (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.183 / (download) - annotate - [select for diffs], Tue Dec 4 02:53:45 2018 UTC (5 years, 5 months ago) by schwarze
Branch: MAIN
Changes since 1.182: +2 -2 lines
Diff to previous 1.182 (colored)

Clean up the validation of .Pp, .PP, .sp, and .br.  Make sure all
combinations are handled, and are handled in a systematic manner.
This resolves some erratic duplicate handling, handles a number of
missing cases, and improves diagnostics in various respects.

Move validation of .br and .sp to the roff validation module
rather than doing that twice in the mdoc and man validation modules.
Move the node relinking function to the roff library where it belongs.

In validation functions, only look at the node itself, at previous
nodes, and at descendants, not at following nodes or ancestors,
such that only nodes are inspected which are already validated.

Revision 1.182 / (download) - annotate - [select for diffs], Fri Aug 17 20:31:52 2018 UTC (5 years, 9 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_6_4_BASE, OPENBSD_6_4
Changes since 1.181: +30 -22 lines
Diff to previous 1.181 (colored)

Remove more pointer arithmetic passing via regions outside the array
that is undefined according to the C standard.  Robert Elz <kre at
munnari dot oz dot au> pointed out i wasn't quite done yet.

Revision 1.181 / (download) - annotate - [select for diffs], Tue May 30 16:21:07 2017 UTC (6 years, 11 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.180: +17 -23 lines
Diff to previous 1.180 (colored)

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.

Revision 1.180 / (download) - annotate - [select for diffs], Fri May 5 15:16:25 2017 UTC (7 years ago) by schwarze
Branch: MAIN
Changes since 1.179: +3 -5 lines
Diff to previous 1.179 (colored)

Move .sp to the roff modules.  Enough infrastructure is in place
now that this actually saves code: -70 LOC.

Revision 1.179 / (download) - annotate - [select for diffs], Fri May 5 13:17:04 2017 UTC (7 years ago) by schwarze
Branch: MAIN
Changes since 1.178: +2 -3 lines
Diff to previous 1.178 (colored)

move .ll to the roff modules

Revision 1.178 / (download) - annotate - [select for diffs], Thu May 4 17:48:24 2017 UTC (7 years ago) by schwarze
Branch: MAIN
Changes since 1.177: +6 -7 lines
Diff to previous 1.177 (colored)

Parser reorg:
Generate the first node on the roff level: .br
Fix some column numbers in diagnostic messages while here.

Revision 1.177 / (download) - annotate - [select for diffs], Sat Apr 29 12:43:55 2017 UTC (7 years ago) by schwarze
Branch: MAIN
Changes since 1.176: +2 -2 lines
Diff to previous 1.176 (colored)

Parser unification: use nice ohashes for all three request and macro tables;
no functional change, minus two source files, minus 200 lines of code.

Revision 1.176 / (download) - annotate - [select for diffs], Mon Apr 24 23:06:09 2017 UTC (7 years ago) by schwarze
Branch: MAIN
Changes since 1.175: +42 -43 lines
Diff to previous 1.175 (colored)

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[].

Revision 1.175 / (download) - annotate - [select for diffs], Mon Apr 17 12:52:00 2017 UTC (7 years, 1 month ago) by schwarze
Branch: MAIN
Changes since 1.174: +6 -2 lines
Diff to previous 1.174 (colored)

Fix handling of trailing punctuation in .Lk.
This macro is unusual in so far as trailing punction needs to remain
inside the scope because it must be inside, not after the display
of long URIs in terminal output mode.
Improves formatting of fw_update(1), help(1), less(1), sendbug(1),
acx(4), inet6(4), ipsec(4), oce(4), isakmpd.conf(5), afterboot(8),
release(8), traceroute(8).

Revision 1.174 / (download) - annotate - [select for diffs], Thu Feb 16 09:47:10 2017 UTC (7 years, 3 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_6_1_BASE, OPENBSD_6_1
Changes since 1.173: +6 -3 lines
Diff to previous 1.173 (colored)

Fix block scoping error if an explicit block is broken by two
implicit blocks (.Aq Bq Po .Pc) that left the outer breaker open
and could in exceptional cases, like between .Bl and .It, cause
tree corruption leading to NULL dereference.
Found by tb@ with afl(1).

While here, do not mark intermediate ENDBODY markers as broken.

Revision 1.173 / (download) - annotate - [select for diffs], Thu Feb 16 02:59:42 2017 UTC (7 years, 3 months ago) by schwarze
Branch: MAIN
Changes since 1.172: +4 -4 lines
Diff to previous 1.172 (colored)

Remove the ENDBODY_NOSPACE flag, simplifying the code.

Comparing to groff output, it appears that all cases where it was used
and made a difference actually require the opposite, ENDBODY_SPACE.

I have no idea why i added it back in 2010; maybe to compensate for
some other bug that has long been fixed.

Revision 1.172 / (download) - annotate - [select for diffs], Sat Feb 11 15:44:11 2017 UTC (7 years, 3 months ago) by schwarze
Branch: MAIN
Changes since 1.171: +5 -4 lines
Diff to previous 1.171 (colored)

Never look for broken blocks inside blocks that are already closed.
Fixes the last the of tree corruptions sometimes causing NULL dereference
reported by tb@; this one triggered in cases like: .Bl -column .It Pq Ta

Revision 1.171 / (download) - annotate - [select for diffs], Sat Feb 11 14:08:35 2017 UTC (7 years, 3 months ago) by schwarze
Branch: MAIN
Changes since 1.170: +9 -3 lines
Diff to previous 1.170 (colored)

Do not prematurely close .Nd containing a broken child.
Fixes tree corruption leading to NULL dereference
in insane cases like .Oo Oo .Nd .Pq Oc .Oc Oc
found by tb@ with afl(1).

Revision 1.170 / (download) - annotate - [select for diffs], Sat Feb 11 13:23:11 2017 UTC (7 years, 3 months ago) by schwarze
Branch: MAIN
Changes since 1.169: +17 -10 lines
Diff to previous 1.169 (colored)

Do not prematurely mark intermediate blocks as broken while scanning
backwards.  Only do so when a block is found that is actually broken.
Logic error found while investigating crashes reported by tb@.

Revision 1.169 / (download) - annotate - [select for diffs], Fri Feb 10 22:19:11 2017 UTC (7 years, 3 months ago) by schwarze
Branch: MAIN
Changes since 1.168: +8 -7 lines
Diff to previous 1.168 (colored)

For child macros of block-end macros, only scan backwards for pending
breakers unless the parent of the block is already closed.  While
the scanning is needed in cases like ".Ac Bo" for broken Ao, it is
useless and crashy in cases like ".Ac Bc" for non-broken Ao.

This fixes a NULL pointer dereference that tb@ found with afl(1).

Revision 1.168 / (download) - annotate - [select for diffs], Fri Feb 10 16:20:58 2017 UTC (7 years, 3 months ago) by schwarze
Branch: MAIN
Changes since 1.167: +1 -1 lines
Diff to previous 1.167 (colored)

Oops, the previous commit unintentionally included this file.
The intended commit message for rev. 1.167 is:

In the SYNOPSIS, .Nm blocks can get broken if one of their children
gets broken.  In that case, mark them as BROKEN and ENDED and make
sure they get closed out together with the child.

Fixes tree corruption leeding to a NULL dereference found by tb@
with afl(1) in: .Sh SYNOPSIS .Bl .Oo .Nm .Bk .Oc .It (where .Bk is
the child and .Oo is the breaker).
A simpler form of the same corruption (without crash) is visible in:
.Sh SYNOPSIS .Ao .Nm .Bo .Ac .Bc text
where the text ended up inside the .Nm (child .Bo, breaker .Ao).

Revision 1.167 / (download) - annotate - [select for diffs], Fri Feb 10 15:44:31 2017 UTC (7 years, 3 months ago) by schwarze
Branch: MAIN
Changes since 1.166: +15 -7 lines
Diff to previous 1.166 (colored)

In -Ttree output mode, show the BROKEN node flag and
provide a -Onoval output option to show the unvalidated tree.

Revision 1.166 / (download) - annotate - [select for diffs], Tue Jan 10 13:46:53 2017 UTC (7 years, 4 months ago) by schwarze
Branch: MAIN
Changes since 1.165: +31 -31 lines
Diff to previous 1.165 (colored)

unify names of AST node flags; no change of cpp output

Revision 1.165 / (download) - annotate - [select for diffs], Sat Aug 20 17:58:09 2016 UTC (7 years, 9 months ago) by schwarze
Branch: MAIN
Changes since 1.164: +23 -14 lines
Diff to previous 1.164 (colored)

When a mismatching end macro occurs while at least two nested blocks
are open, all except the innermost open block got a bogus MDOC_ENDED
marker, in some situations triggering segfaults down the road
which tb@ found with afl(1).
Fix the logic error by figuring out up front whether an end macro
has a matching body, and if it hasn't, don't mark any blocks as broken.

Revision 1.164 / (download) - annotate - [select for diffs], Sat Aug 20 15:58:16 2016 UTC (7 years, 9 months ago) by schwarze
Branch: MAIN
Changes since 1.163: +2 -2 lines
Diff to previous 1.163 (colored)

When scanning upwards for a column list to put a .Ta macro in,
ignore body end markers of lists breaking other blocks.
Fixing a logical error that caused a NULL deref found by tb@ with afl(1).

Revision 1.163 / (download) - annotate - [select for diffs], Sat Aug 13 09:14:56 2016 UTC (7 years, 9 months ago) by schwarze
Branch: MAIN
Changes since 1.162: +2 -2 lines
Diff to previous 1.162 (colored)

Even after switching from a pending head to the body, we have to
continue scanning upwards, because the enclosing block might already
be pending as well, e.g. .Bl .Bl .It Bo .El .It.
Tree corruption leading to a later NULL deref found by tb@ with afl(1).

Revision 1.162 / (download) - annotate - [select for diffs], Tue Oct 20 02:00:49 2015 UTC (8 years, 7 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_6_0_BASE, OPENBSD_6_0, OPENBSD_5_9_BASE, OPENBSD_5_9
Changes since 1.161: +7 -13 lines
Diff to previous 1.161 (colored)

In order to become able to generate syntax tree nodes on the roff(7)
level, validation must be separated from parsing and rewinding.
This first big step moves calling of the mdoc(7) post_*() functions
out of the parser loop into their own mdoc_validate() pass, while
using a new mdoc_state() module to make syntax tree state handling
available to both the parser loop and the validation pass.

Revision 1.161 / (download) - annotate - [select for diffs], Sat Oct 17 00:19:58 2015 UTC (8 years, 7 months ago) by schwarze
Branch: MAIN
Changes since 1.160: +29 -23 lines
Diff to previous 1.160 (colored)

Very tricky diff to fix macro interpretation and spacing around tabs
in .Bl -column; it took me more than a day to get this right.
Triggered by a loosely related bug report from tim@.

The lesson for you is:  Use .Ta macros in .Bl -column, avoid tabs,
or you are in for surprises:  The last word before a tab is not
interpreted as a macro (unless there is a blank in between), the
first word after a tab isn't either (unless there is a blank in
between), and a blank after a tab causes a leading blank in the
respective output cell.  Yes, "blank", "tab", "blank tab" and "tab
blank" all have different semantics; if you write code relying on
that, good luck maintaining it afterwards...

Revision 1.160 / (download) - annotate - [select for diffs], Thu Oct 15 22:27:09 2015 UTC (8 years, 7 months ago) by schwarze
Branch: MAIN
Changes since 1.159: +6 -1 lines
Diff to previous 1.159 (colored)

When blk_full() handles an .It line in .Bl -column and indirectly
calls phrase_ta() to handle a .Ta child macro, advance the body
pointer accordingly, such that a subsequent tab character rewinds
the right body block and doesn't fail an assertion.  That happened
when there was nothing between the .Ta and the tab character.
Bug reported by tim@ some time ago.

Revision 1.159 / (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.158: +1 -11 lines
Diff to previous 1.158 (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.158 / (download) - annotate - [select for diffs], Tue Oct 6 18:30:44 2015 UTC (8 years, 7 months ago) by schwarze
Branch: MAIN
Changes since 1.157: +25 -25 lines
Diff to previous 1.157 (colored)

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

Revision 1.157 / (download) - annotate - [select for diffs], Sat Sep 26 00:53:15 2015 UTC (8 years, 7 months ago) by schwarze
Branch: MAIN
Changes since 1.156: +1 -2 lines
Diff to previous 1.156 (colored)

/* NOTREACHED */ after abort() is silly, delete it

Revision 1.156 / (download) - annotate - [select for diffs], Fri May 1 16:56:36 2015 UTC (9 years ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_5_8_BASE, OPENBSD_5_8
Changes since 1.155: +2 -2 lines
Diff to previous 1.155 (colored)

mdoc_valid_post() may indirectly call roff_node_unlink() which may
set ROFF_NEXT_CHILD, which is desirable for the final call to
mdoc_valid_post() - in case the target itself gets deleted, the
parse point may need this adjustment - but not for the intermediate
calls - if intermediate nodes get deleted, that mustn't clobber the
parse point.  So move setting ROFF_NEXT_SIBLING to the proper place
in rew_last().

This fixes the assertion failure in jsg@'s afl test case 108/Apr27.

Revision 1.155 / (download) - annotate - [select for diffs], Fri May 1 16:01:53 2015 UTC (9 years ago) by schwarze
Branch: MAIN
Changes since 1.154: +2 -4 lines
Diff to previous 1.154 (colored)

Setting the "last" member of struct roff_node was done at an extremely
weird place.  Move it to the obviously correct place.
Surprisingly, this didn't cause any misformatting in the test suite
or in any base system manuals, but i cannot believe the code was
really correct for all conceivable input, and it would be very hard
to verify.  At the very least, it cannot have worked for man(7).

Revision 1.154 / (download) - annotate - [select for diffs], Fri May 1 15:27:17 2015 UTC (9 years ago) by schwarze
Branch: MAIN
Changes since 1.153: +2 -2 lines
Diff to previous 1.153 (colored)

Minor bug fix:  When .Pp rewinds .Nm, rewind the whole block,
not just the body.  In some unusual edge cases, this caused
the .Pp to become a sibling of the .Nm body inside the .Nm block.

Revision 1.153 / (download) - annotate - [select for diffs], Wed Apr 29 21:57:50 2015 UTC (9 years ago) by schwarze
Branch: MAIN
Changes since 1.152: +4 -2 lines
Diff to previous 1.152 (colored)

If a block body gets broken, that's no good reason to extend the
scope of the end macro.  Instead, only keep the tail scope open if
the end macro macro calls an explicit macro and actually breaks
that.  This corrects syntax tree structure and fixes an assertion
found by jsg@ with afl (test case 098/Apr27).

Revision 1.152 / (download) - annotate - [select for diffs], Wed Apr 29 14:48:17 2015 UTC (9 years ago) by schwarze
Branch: MAIN
Changes since 1.151: +3 -1 lines
Diff to previous 1.151 (colored)

Do not mark a block with the MDOC_BROKEN flag if it merely contains
a mismatching explicit end macro without actually being broken.
Avoids a subsequent upward search for the non-existent breaker
ending up in a NULL pointer access; afl test case 005/Apr27 from jsg@.

Revision 1.151 / (download) - annotate - [select for diffs], Thu Apr 23 15:35:39 2015 UTC (9 years ago) by schwarze
Branch: MAIN
Changes since 1.150: +2 -2 lines
Diff to previous 1.150 (colored)

Get rid of two empty wrapper functions.  No functional change.

Revision 1.150 / (download) - annotate - [select for diffs], Tue Apr 21 16:13:54 2015 UTC (9 years, 1 month ago) by schwarze
Branch: MAIN
Changes since 1.149: +16 -13 lines
Diff to previous 1.149 (colored)

Avoid a use after free when the target node is deleted during validation.
Bug reported by jsg@.

Revision 1.149 / (download) - annotate - [select for diffs], Sun Apr 19 14:57:16 2015 UTC (9 years, 1 month ago) by schwarze
Branch: MAIN
Changes since 1.148: +4 -4 lines
Diff to previous 1.148 (colored)

Unify trickier node handling functions.
* man_elem_alloc() -> roff_elem_alloc()
* man_block_alloc() -> roff_block_alloc()
The functions mdoc_elem_alloc() and mdoc_block_alloc() remain for
now because they need to do mdoc(7)-specific argument processing.

Revision 1.148 / (download) - annotate - [select for diffs], Sun Apr 19 14:25:05 2015 UTC (9 years, 1 month ago) by schwarze
Branch: MAIN
Changes since 1.147: +3 -3 lines
Diff to previous 1.147 (colored)

Unify some node handling functions that use TOKEN_NONE.
* mdoc_word_alloc(), man_word_alloc() -> roff_word_alloc()
* mdoc_word_append(), man_word_append() -> roff_word_append()
* mdoc_addspan(), man_addspan() -> roff_addtbl()
* mdoc_addeqn(), man_addeqn() -> roff_addeqn()
Minus 50 lines of code, no functional change.

Revision 1.147 / (download) - annotate - [select for diffs], Sun Apr 19 13:59:37 2015 UTC (9 years, 1 month ago) by schwarze
Branch: MAIN
Changes since 1.146: +19 -18 lines
Diff to previous 1.146 (colored)

Decouple the token code for "no request or macro" from the individual
high-level parsers to allow further unification of functions that
only need to recognize this code, but that don't care about different
high-level macrosets beyond that.

Revision 1.146 / (download) - annotate - [select for diffs], Sun Apr 19 13:50:10 2015 UTC (9 years, 1 month ago) by schwarze
Branch: MAIN
Changes since 1.145: +18 -17 lines
Diff to previous 1.145 (colored)

Unify node handling functions:
* node_alloc() for mdoc and man_node_alloc() -> roff_node_alloc()
* node_append() for mdoc and man_node_append() -> roff_node_append()
* mdoc_head_alloc() and man_head_alloc() -> roff_head_alloc()
* mdoc_body_alloc() and man_body_alloc() -> roff_body_alloc()
* mdoc_node_unlink() and man_node_unlink() -> roff_node_unlink()
* mdoc_node_free() and man_node_free() -> roff_node_free()
* mdoc_node_delete() and man_node_delete() -> roff_node_delete()
Minus 130 lines of code, no functional change.

Revision 1.145 / (download) - annotate - [select for diffs], Sat Apr 18 16:04:40 2015 UTC (9 years, 1 month ago) by schwarze
Branch: MAIN
Changes since 1.144: +22 -21 lines
Diff to previous 1.144 (colored)

Replace the structs mdoc and man by a unified struct roff_man.
Almost completely mechanical, no functional change.
Written on the train from Exeter to London returning from p2k15.

Revision 1.144 / (download) - annotate - [select for diffs], Sun Apr 5 23:04:22 2015 UTC (9 years, 1 month ago) by schwarze
Branch: MAIN
Changes since 1.143: +16 -4 lines
Diff to previous 1.143 (colored)

If a partial explicit block extending to the next input line follows
the end macro of a broken block, put all of it into the breaking block.
Needed for example by mutella(1).

Revision 1.143 / (download) - annotate - [select for diffs], Sun Apr 5 22:43:40 2015 UTC (9 years, 1 month ago) by schwarze
Branch: MAIN
Changes since 1.142: +45 -51 lines
Diff to previous 1.142 (colored)

Reduce code duplication, no functional change:
Both partial and full implicit blocks can break explicit blocks.
Put the code to handle both cases into a common function.

Revision 1.142 / (download) - annotate - [select for diffs], Sun Apr 5 14:43:10 2015 UTC (9 years, 1 month ago) by schwarze
Branch: MAIN
Changes since 1.141: +8 -10 lines
Diff to previous 1.141 (colored)

Arguments to end macros of broken partial explicit blocks
must go inside the breaking block.  For example, in
.It Ic cmd Oo
.Ar optional_arg Oc Ar mandatory_arg
the mandatory_arg is still inside the .It block.
Used for example by mutella(1).

Revision 1.141 / (download) - annotate - [select for diffs], Thu Apr 2 22:06:17 2015 UTC (9 years, 1 month ago) by schwarze
Branch: MAIN
Changes since 1.140: +38 -40 lines
Diff to previous 1.140 (colored)

Second step towards parser unification:
Replace struct mdoc_node and struct man_node by a unified struct roff_node.
To be able to use the tok member for both mdoc(7) and man(7) without
defining all the macros in roff.h, sacrifice a tiny bit of type safety
and make tok an int rather than an enum.
Almost mechanical, no functional change.
Written on the Eurostar from Bruxelles to London on the way to p2k15.

Revision 1.140 / (download) - annotate - [select for diffs], Thu Apr 2 21:03:18 2015 UTC (9 years, 1 month ago) by schwarze
Branch: MAIN
Changes since 1.139: +21 -20 lines
Diff to previous 1.139 (colored)

First step towards parser unification:
Replace enum mdoc_type and enum man_type by a unified enum roff_type.
Almost mechanical, no functional change.
Written on the ICE train from Frankfurt to Bruxelles on the way to p2k15.

Revision 1.139 / (download) - annotate - [select for diffs], Thu Feb 12 12:20:47 2015 UTC (9 years, 3 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_5_7_BASE, OPENBSD_5_7
Changes since 1.138: +78 -110 lines
Diff to previous 1.138 (colored)

Delete the mdoc_node.pending pointer and the function calculating
it, make_pending(), which was the most difficult function of the
whole mdoc(7) parser.  After almost five years of maintaining this
hellhole, i just noticed the pointer isn't needed after all.

Blocks are always rewound in the reverse order they were opened;
that even holds for broken blocks.  Consequently, it is sufficient
to just mark broken blogs with the flag MDOC_BROKEN and breaking
blocks with the flag MDOC_ENDED.  When rewinding, instead of iterating
the pending pointers, just iterate from each broken block to its
parents, rewinding all that are MDOC_ENDED and stopping after
processing the first ancestor that it not MDOC_BROKEN.  For ENDBODY
markers, use the mdoc_node.body pointer in place of the former
mdoc_node.pending.

This also fixes an assertion failure found by jsg@ with afl,
test case #467 (Bo Bl It Bd Bc It), where (surprise surprise)
the pending pointer got corrupted.

Improved functionality, minus one function, minus one struct field,
minus 50 lines of code.

Revision 1.138 / (download) - annotate - [select for diffs], Wed Feb 11 13:37:31 2015 UTC (9 years, 3 months ago) by schwarze
Branch: MAIN
Changes since 1.137: +8 -1 lines
Diff to previous 1.137 (colored)

explicit blocks close out .Nd; fixing data structure corruption
eventually leading to NULL pointer access;
found by jsg@ with afl, text case #455.

Revision 1.137 / (download) - annotate - [select for diffs], Tue Feb 10 17:47:19 2015 UTC (9 years, 3 months ago) by schwarze
Branch: MAIN
Changes since 1.136: +44 -34 lines
Diff to previous 1.136 (colored)

Be more careful to not generate empty .In, .St, and .Xr nodes.
That could happen when their first argument was another called macro,
causing a NULL pointer access in .St validation found by jsg@ with afl.

Make in_line_argn() easier to understand by using one state
variable rather than two.

Revision 1.136 / (download) - annotate - [select for diffs], Sat Feb 7 16:39:44 2015 UTC (9 years, 3 months ago) by schwarze
Branch: MAIN
Changes since 1.135: +2 -1 lines
Diff to previous 1.135 (colored)

Closing a block validates it, which may end up deleting it,
so if we are in a loop over blocks, cleanly restart the loop
rather than risking use after free; found by jsg@ with afl.

Revision 1.135 / (download) - annotate - [select for diffs], Fri Feb 6 07:12:34 2015 UTC (9 years, 3 months ago) by schwarze
Branch: MAIN
Changes since 1.134: +4 -3 lines
Diff to previous 1.134 (colored)

Delete the legacy generic warning type MANDOCERR_ARGCWARN,
replacing the last instances by more specific warnings.
Improved functionality, minus 50 lines of code.

Revision 1.134 / (download) - annotate - [select for diffs], Fri Feb 6 03:31:11 2015 UTC (9 years, 3 months ago) by schwarze
Branch: MAIN
Changes since 1.133: +7 -1 lines
Diff to previous 1.133 (colored)

better handle .Fo and .Fd without argument
better handle .Fo with more than one argument

Revision 1.133 / (download) - annotate - [select for diffs], Fri Feb 6 01:07:07 2015 UTC (9 years, 3 months ago) by schwarze
Branch: MAIN
Changes since 1.132: +12 -1 lines
Diff to previous 1.132 (colored)

better handle .In .Sh .Ss .St .Xr without arguments

Revision 1.132 / (download) - annotate - [select for diffs], Thu Feb 5 01:46:38 2015 UTC (9 years, 3 months ago) by schwarze
Branch: MAIN
Changes since 1.131: +2 -2 lines
Diff to previous 1.131 (colored)

fix handling of empty .An macros

Revision 1.131 / (download) - annotate - [select for diffs], Thu Feb 5 00:13:34 2015 UTC (9 years, 3 months ago) by schwarze
Branch: MAIN
Changes since 1.130: +2 -8 lines
Diff to previous 1.130 (colored)

Simplify by deleting the "lastline" member of struct mdoc_node.
Minus one struct member, minus 17 lines of code, no functional change.

Revision 1.130 / (download) - annotate - [select for diffs], Wed Feb 4 22:29:27 2015 UTC (9 years, 3 months ago) by schwarze
Branch: MAIN
Changes since 1.129: +8 -2 lines
Diff to previous 1.129 (colored)

Discard excess head arguments for .Bd .Bl .Bk and delete hwarn_eq0().
Discard empty .Bk blocks.
Improve related diagnostics.

Revision 1.129 / (download) - annotate - [select for diffs], Wed Feb 4 18:03:28 2015 UTC (9 years, 3 months ago) by schwarze
Branch: MAIN
Changes since 1.128: +9 -4 lines
Diff to previous 1.128 (colored)

discard .Rs head arguments and improve .Rs diagnostics

Revision 1.128 / (download) - annotate - [select for diffs], Tue Feb 3 18:19:27 2015 UTC (9 years, 3 months ago) by schwarze
Branch: MAIN
Changes since 1.127: +2 -1 lines
Diff to previous 1.127 (colored)

Avoid closing out an explicit block twice when broken by .It
(assertion failure); regression found in jsg@'s afl test case 847.

Revision 1.127 / (download) - annotate - [select for diffs], Tue Feb 3 01:13:48 2015 UTC (9 years, 3 months ago) by schwarze
Branch: MAIN
Changes since 1.126: +75 -160 lines
Diff to previous 1.126 (colored)

Finally delete the kitchensink functions rew_sub() and rew_dohalt().
They were a maintenance and auditing nightmare because if you changed
one bit in there, stuff tended to break at seemingly unrelated places.
No functional change except getting rid of one bogus error message,
but minus 80 lines of code.

Revision 1.126 / (download) - annotate - [select for diffs], Tue Feb 3 00:48:27 2015 UTC (9 years, 3 months ago) by schwarze
Branch: MAIN
Changes since 1.125: +11 -4 lines
Diff to previous 1.125 (colored)

Bring .Pp/.Lp handling inside .Nm blocks closer to groff;
as a bonus, get rid of another call to rew_sub().

Revision 1.125 / (download) - annotate - [select for diffs], Mon Feb 2 19:22:46 2015 UTC (9 years, 3 months ago) by schwarze
Branch: MAIN
Changes since 1.124: +50 -57 lines
Diff to previous 1.124 (colored)

Simplify and reindent make_pending().  No functional change
except that some error messages become less confusing.
Now the function is almost readable (but still requires
nineteen lines of comments for fourteen lines of code).

Revision 1.124 / (download) - annotate - [select for diffs], Mon Feb 2 18:26:06 2015 UTC (9 years, 3 months ago) by schwarze
Branch: MAIN
Changes since 1.123: +21 -31 lines
Diff to previous 1.123 (colored)

Simplify: Do not call rew_dohalt() from make_pending(),
the calling macro handler already found the breaking block.
No functional change except tiny variations in error messages.

Revision 1.123 / (download) - annotate - [select for diffs], Mon Feb 2 15:02:17 2015 UTC (9 years, 3 months ago) by schwarze
Branch: MAIN
Changes since 1.122: +37 -66 lines
Diff to previous 1.122 (colored)

Get rid of all remaining calls to rew_sub() where the target block
is known.  This only leaves three that do actual searching.
No functional change, minus 30 lines of code.

Revision 1.122 / (download) - annotate - [select for diffs], Mon Feb 2 04:26:03 2015 UTC (9 years, 3 months ago) by schwarze
Branch: MAIN
Changes since 1.121: +67 -65 lines
Diff to previous 1.121 (colored)

Get rid of all calls to rew_sub() in blk_exp_close(); only ten calls
remain in other functions.  As a bonus, this fixes an assertion failure
jsg@ found some time ago with afl (test case 982) and improves minor
details in error reporting.

Revision 1.121 / (download) - annotate - [select for diffs], Mon Feb 2 04:04:18 2015 UTC (9 years, 3 months ago) by schwarze
Branch: MAIN
Changes since 1.120: +7 -4 lines
Diff to previous 1.120 (colored)

When a full block macro gets closed out by a mismatching
block closure macro it calls, do not attempt to open its body.
This can for example happen for (nonsensical) constructions like
.Fo
.Nm Fc
in the SYNOPSIS.  Fixing an assertion failure jsg@ found with afl
some time ago (test case number 731).

Revision 1.120 / (download) - annotate - [select for diffs], Sun Feb 1 23:55:37 2015 UTC (9 years, 3 months ago) by schwarze
Branch: MAIN
Changes since 1.119: +14 -3 lines
Diff to previous 1.119 (colored)

get rid of rew_sub() in blk_part_imp(); no functional change

Revision 1.119 / (download) - annotate - [select for diffs], Sun Feb 1 17:30:34 2015 UTC (9 years, 3 months ago) by schwarze
Branch: MAIN
Changes since 1.118: +8 -24 lines
Diff to previous 1.118 (colored)

Simplify blk_part_exp(), no functional change.
* Replace calls to rew_sub() with rew_last() - two less out of 18.
* No need to keep track of the body, it's always opened right after
the head and never used for anything in this function.

Revision 1.118 / (download) - annotate - [select for diffs], Sun Feb 1 16:46:57 2015 UTC (9 years, 3 months ago) by schwarze
Branch: MAIN
Changes since 1.117: +4 -5 lines
Diff to previous 1.117 (colored)

The function rew_sub() tries to rewind any all all kinds of blocks
and elements under any and all circumstances, even handling some
bad block nesting now and then.  Little surprisingly, this ends up
in excessive complexity and has caused many bugs in the past.
Start to slowly disentangle this mess by replacing calls to rew_sub()
immediately following mdoc_head_alloc() by the much simpler rew_last().
Gets rid of the first two rew_sub() calls out of twenty.
No functional change.

Revision 1.117 / (download) - annotate - [select for diffs], Mon Dec 22 23:26:20 2014 UTC (9 years, 4 months ago) by schwarze
Branch: MAIN
Changes since 1.116: +3 -3 lines
Diff to previous 1.116 (colored)

The code already pays attention not to close the same block twice.
Similarly, avoid having the same block break two other blocks.
In some situations, this could lead to an endless loop in rew_sub()
found by jsg@ with afl.
Minimal example:  .Po Ao Pc Bo Pc Ac Bc

Revision 1.116 / (download) - annotate - [select for diffs], Sat Dec 20 02:26:42 2014 UTC (9 years, 5 months ago) by schwarze
Branch: MAIN
Changes since 1.115: +20 -9 lines
Diff to previous 1.115 (colored)

Fix two issues causing a class of assertion failures found by jsg@ with afl.
1) rew_sub(): Make sure REWIND_MORE is acted upon even when followed by
REWIND_NONE.  This prevents .It from ending up inside other children of .Bl.
2) blk_exp_close(): Only allow extension of .Bl when it has at least
one .It.  Otherwise, a broken child block could be moved in front of
the .Bl, effectively resulting in a .Bl that ended before it began.

Revision 1.115 / (download) - annotate - [select for diffs], Thu Dec 18 20:58:00 2014 UTC (9 years, 5 months ago) by schwarze
Branch: MAIN
Changes since 1.114: +3 -2 lines
Diff to previous 1.114 (colored)

Don't let .Ta creep into an already-closed list; same as for .It.
Fixes an assertion found by jsg@ with afl.

Revision 1.114 / (download) - annotate - [select for diffs], Thu Dec 18 03:09:42 2014 UTC (9 years, 5 months ago) by schwarze
Branch: MAIN
Changes since 1.113: +32 -21 lines
Diff to previous 1.113 (colored)

The code is already careful to not add items to lists that were
already closed.  In this respect, also consider lists closed
that have broken another block, their closure pending until the
end of the broken block.  This avoids syntax tree corruption
leading to a NULL pointer access found by jsg@ with afl.

Revision 1.113 / (download) - annotate - [select for diffs], Sat Dec 13 13:13:26 2014 UTC (9 years, 5 months ago) by schwarze
Branch: MAIN
Changes since 1.112: +3 -5 lines
Diff to previous 1.112 (colored)

Fix a regression found by Carsten dot Kunze at arcor dot de:
Do not show bogus quotes when .Bl -column phrases are quoted.

Revision 1.112 / (download) - annotate - [select for diffs], Sun Nov 30 05:28:00 2014 UTC (9 years, 5 months ago) by schwarze
Branch: MAIN
Changes since 1.111: +17 -7 lines
Diff to previous 1.111 (colored)

Multiple fixes with respect to .Pf:
* The first argument of .Pf is not parsed.
* Normal delimiter handling does not apply to the first argument of .Pf.
* Warn if nothing follows a prefix (inspired by groff_mdoc(7)).
* In that case, do not suppress spacing.

Revision 1.111 / (download) - annotate - [select for diffs], Sun Nov 30 02:31:32 2014 UTC (9 years, 5 months ago) by schwarze
Branch: MAIN
Changes since 1.110: +17 -9 lines
Diff to previous 1.110 (colored)

warn about attempts to call non-callable macros;
inspired by a similar warning in the groff_mdoc(7) macros

Revision 1.110 / (download) - annotate - [select for diffs], Sat Nov 29 04:31:33 2014 UTC (9 years, 5 months ago) by schwarze
Branch: MAIN
Changes since 1.109: +21 -19 lines
Diff to previous 1.109 (colored)

Reduce code duplication by reusing the same argument parser
for in_line_eoln() macros and .Bl -column phrases.
No functional change.

Revision 1.109 / (download) - annotate - [select for diffs], Sat Nov 29 03:37:28 2014 UTC (9 years, 5 months ago) by schwarze
Branch: MAIN
Changes since 1.108: +63 -116 lines
Diff to previous 1.108 (colored)

Provide a helper function macro_or_word() and use it to prune the
same chunk of argument parsing code out of five of the eight callback
functions.  The other three have too much special handling to
participate.
As a bonus, let lookup() and mdoc_args() deal with line macros and
retire the lookup_raw() helper and the mdoc_zargs() internal interface
function.
No functional change, minus 40 lines of code.

Revision 1.108 / (download) - annotate - [select for diffs], Fri Nov 28 23:20:55 2014 UTC (9 years, 5 months ago) by schwarze
Branch: MAIN
Changes since 1.107: +5 -47 lines
Diff to previous 1.107 (colored)

Fold the loop around mdoc_argv() into the function itself,
it was the same in all four cases.  As a bonus, get rid
of one enum type that was used for internal communication.
No functional change, minus 40 lines of code.

Revision 1.107 / (download) - annotate - [select for diffs], Fri Nov 28 04:46:30 2014 UTC (9 years, 5 months ago) by schwarze
Branch: MAIN
Changes since 1.106: +117 -199 lines
Diff to previous 1.106 (colored)

Simplify by making the mdoc parser callbacks void, and some cleanup;
no functional change, minus 50 lines of code.

Revision 1.106 / (download) - annotate - [select for diffs], Fri Nov 28 03:13:58 2014 UTC (9 years, 5 months ago) by schwarze
Branch: MAIN
Changes since 1.105: +234 -376 lines
Diff to previous 1.105 (colored)

Simplify the code by making various mdoc parser helper functions void.
No functional change, minus 130 lines of code.

Revision 1.105 / (download) - annotate - [select for diffs], Fri Nov 28 01:05:40 2014 UTC (9 years, 5 months ago) by schwarze
Branch: MAIN
Changes since 1.104: +45 -53 lines
Diff to previous 1.104 (colored)

Simplify code by making mdoc validation handlers void.
No functional change, minus 90 lines of code.

Revision 1.104 / (download) - annotate - [select for diffs], Thu Nov 27 22:27:40 2014 UTC (9 years, 5 months ago) by schwarze
Branch: MAIN
Changes since 1.103: +28 -8 lines
Diff to previous 1.103 (colored)

Multiple fixes with respect to .Eo:
1. Correctly parse stray .Ec without preceding .Eo,
avoiding an assertion violation found by jsg@ with afl.
2. Correctly parse .Ec arguments when breaking another block.
3. Correct spacing around closing delimiter when breaking another block.
4. Sync some related formatting control from -Tascii to -Thtml.

Revision 1.103 / (download) - annotate - [select for diffs], Wed Nov 26 19:22:44 2014 UTC (9 years, 5 months ago) by schwarze
Branch: MAIN
Changes since 1.102: +2 -2 lines
Diff to previous 1.102 (colored)

The .Sm macro accepts at most one argument;
fixing an assertion failure found by jsg@ with afl.

Revision 1.102 / (download) - annotate - [select for diffs], Tue Nov 25 03:04:32 2014 UTC (9 years, 5 months ago) by schwarze
Branch: MAIN
Changes since 1.101: +4 -2 lines
Diff to previous 1.101 (colored)

Do not access a NULL pointer when a section has no body,
which can for example happen for .Sh Xo .Sh without .Xc.
Crash found by jsg@ with afl.

Revision 1.101 / (download) - annotate - [select for diffs], Thu Nov 20 00:30:34 2014 UTC (9 years, 6 months ago) by schwarze
Branch: MAIN
Changes since 1.100: +5 -2 lines
Diff to previous 1.100 (colored)

Fix two minibugs reported by Thomas Klausner <wiz at NetBSD>:
1. The first argument of .Fn is not supposed to be parsed.
2. The .Fn macro is not supposed to reopen its scope after punctuation.

Revision 1.100 / (download) - annotate - [select for diffs], Mon Nov 17 06:44:35 2014 UTC (9 years, 6 months ago) by schwarze
Branch: MAIN
Changes since 1.99: +53 -25 lines
Diff to previous 1.99 (colored)

Multiple fixes with respect to in-line macros:
* .No selects the default font; relevant e.g. in .Bf blocks
* no need to force empty .Li elements
* closing delimiters as leading macro arguments do not suppress space
* opening delimiters at the end of a macro line do not suppress space
* correctly handle delimiter spacing in -Tman
As a side effect, these fixes let mandoc warn about empty .No macros
as requested by bentley@.

Revision 1.99 / (download) - annotate - [select for diffs], Sun Sep 7 00:04:47 2014 UTC (9 years, 8 months ago) by schwarze
Branch: MAIN
Changes since 1.98: +3 -3 lines
Diff to previous 1.98 (colored)

Allow .ll in the prologue; Daniel Levai reports Slackware Linux uses this.

Revision 1.98 / (download) - annotate - [select for diffs], Thu Aug 21 12:56:24 2014 UTC (9 years, 9 months ago) by schwarze
Branch: MAIN
Changes since 1.97: +13 -14 lines
Diff to previous 1.97 (colored)

Right after .Fl, a middle delimiter triggers an empty scope,
just like a closing delimiter.  This didn't work in groff-1.15,
but it now works in groff-1.22.

After being closed by delimiters, .Nm scopes do not reopen.

Do not suppress white space after .Fl if the next node is a text node
on the same input line; that can happen for middle delimiters.

Fixing an issue reported by jmc@.

Revision 1.97 / (download) - annotate - [select for diffs], Sat Aug 16 19:47:17 2014 UTC (9 years, 9 months ago) by schwarze
Branch: MAIN
Changes since 1.96: +3 -2 lines
Diff to previous 1.96 (colored)

If a stray .It follows .El, we are no longer in the list,
even though the list is still the last processed macro.
This fixes a regression introduced in mdoc_macro.c rev. 1.95:
Ulrich Spoerlein <uqs at FreeBSD> reports that various of their
kernel manuals trigger assertions.

Revision 1.96 / (download) - annotate - [select for diffs], Fri Aug 8 15:54:10 2014 UTC (9 years, 9 months ago) by schwarze
Branch: MAIN
Changes since 1.95: +2 -2 lines
Diff to previous 1.95 (colored)

mention requests and macros in more messages

Revision 1.95 / (download) - annotate - [select for diffs], Fri Aug 8 15:26:28 2014 UTC (9 years, 9 months ago) by schwarze
Branch: MAIN
Changes since 1.94: +19 -1 lines
Diff to previous 1.94 (colored)

Get rid of the useless FATAL error "child violates parent syntax".
When finding items outside lists, simply skip them and throw an ERROR.
Handle subsections before the first section instead of bailing out.

Revision 1.94 / (download) - annotate - [select for diffs], Mon Jul 7 21:35:42 2014 UTC (9 years, 10 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_5_6_BASE, OPENBSD_5_6
Changes since 1.93: +10 -6 lines
Diff to previous 1.93 (colored)

Clean up ERROR messages related to document structure and macros:
Hierarchical naming and mention macro names in messages.

Revision 1.93 / (download) - annotate - [select for diffs], Fri Jul 4 16:11:41 2014 UTC (9 years, 10 months ago) by schwarze
Branch: MAIN
Changes since 1.92: +7 -6 lines
Diff to previous 1.92 (colored)

Clean up messages regarding excess arguments:
* Downgrade ".Bf -emphasis Em" from FATAL to WARNING.
* Mention the macros, the arguments, and the fallbacks.
* Hierarchical naming.
Also fix the handling of excess .It head arguments in -Tman.

Revision 1.92 / (download) - annotate - [select for diffs], Wed Jul 2 20:18:42 2014 UTC (9 years, 10 months ago) by schwarze
Branch: MAIN
Changes since 1.91: +6 -4 lines
Diff to previous 1.91 (colored)

Improve and test the messages about empty macros,
in particular reporting the macro names involved.

Revision 1.91 / (download) - annotate - [select for diffs], Wed Jul 2 11:42:56 2014 UTC (9 years, 10 months ago) by schwarze
Branch: MAIN
Changes since 1.90: +5 -14 lines
Diff to previous 1.90 (colored)

Clean up warnings related to macros and nesting.
* Hierarchical naming of enum mandocerr items.
* Improve the wording to make it comprehensible.
* Mention the offending macro.
* Garbage collect one chunk of ancient, long unreachable code.

Revision 1.90 / (download) - annotate - [select for diffs], Wed Jul 2 08:21:12 2014 UTC (9 years, 10 months ago) by schwarze
Branch: MAIN
Changes since 1.89: +3 -3 lines
Diff to previous 1.89 (colored)

Fix the column numbers associated with in_line_argn() macros;
this bug is more than four years old, introduced by kristaps@
in mdocml.bsd.lv rev. 1.46, March 30, 2010.

Revision 1.89 / (download) - annotate - [select for diffs], Wed Jul 2 03:47:07 2014 UTC (9 years, 10 months ago) by schwarze
Branch: MAIN
Changes since 1.88: +7 -14 lines
Diff to previous 1.88 (colored)

Implement the obsolete macros .En .Es .Fr .Ot for backward compatibility,
since this is hardly more complicated than explicitly ignoring them
as we did in the past.  Of course, do not use them!

Revision 1.88 / (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.87: +130 -153 lines
Diff to previous 1.87 (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.87 / (download) - annotate - [select for diffs], Sun Mar 30 19:47:32 2014 UTC (10 years, 1 month ago) by schwarze
Branch: MAIN
Changes since 1.86: +2 -1 lines
Diff to previous 1.86 (colored)

Implement the roff(7) .ll (line length) request.
Found by naddy@ in the textproc/enchant(1) port.
Of course, do not use this in new manuals.

Revision 1.86 / (download) - annotate - [select for diffs], Tue Jan 21 10:26:49 2014 UTC (10 years, 3 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_5_5_BASE, OPENBSD_5_5
Changes since 1.85: +2 -2 lines
Diff to previous 1.85 (colored)

Treat the line after .Cd as a single argument.
This doesn't hurt normal manual display
and makes the mandocdb(8) database more useful.

Revision 1.85 / (download) - annotate - [select for diffs], Mon Jan 20 11:27:53 2014 UTC (10 years, 4 months ago) by schwarze
Branch: MAIN
Changes since 1.84: +2 -2 lines
Diff to previous 1.84 (colored)

Keep words after .Ic together in a single argument.
This doesn't hurt normal manual display
and makes the mandocdb(8) database more useful.

Revision 1.84 / (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.83: +2 -2 lines
Diff to previous 1.83 (colored)

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

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

Do not trigger end-of-sentence spacing by trailing punctuation
at the end of partial implicit macros.  Prodded by jmc@.

Actually, this is a revert of rev. 1.39 Sat May 15 09:20:01 2010 UTC,
which in turn is mdocml.bsd.lv rev. 1.64 Fri May 14 14:09:13 2010 UTC
by kristaps@, with this original commit message:
"Block-implicit macros now up-propogate end-of-sentence spacing.
NOTE: GROFF IS NOT SMART ENOUGH TO DO THIS."
Please speak after me: Then why the hell should we?

We already weakened this in rev. 1.55 Fri Jul 16 00:34:33 2010 UTC,
but that weakening was insufficient.  Let's take it out completely.

Admittedly, there are two places in base where what Kristaps did
made the output nicer, in calloc(3) and in fish(6).  But both are
atypical.  There are 18 other places where this revert makes the
output nicer, the typical case being:
"Mail status is shown as ``No Mail.''  if there is no mail."
You do *not* want the EOS spacing after ``No Mail.'' in that sentence.

Revision 1.82 / (download) - annotate - [select for diffs], Tue Dec 24 20:45:21 2013 UTC (10 years, 4 months ago) by schwarze
Branch: MAIN
Changes since 1.81: +2 -3 lines
Diff to previous 1.81 (colored)

It turns out SYNOPSIS mode does not imply .Bk in general,
but only within .Nm blocks.  Simplify the code accordingly.
This reduces groff-mandoc differences in base by about 2%.

Triggered by research done by Franco Fichtner.

Revision 1.81 / (download) - annotate - [select for diffs], Tue Dec 24 19:10:34 2013 UTC (10 years, 4 months ago) by schwarze
Branch: MAIN
Changes since 1.80: +6 -1 lines
Diff to previous 1.80 (colored)

When deciding whether two consecutive macros are on the same input line,
we have to compare the line where the first one *ends* (not where it begins)
to the line where the second one starts.
This fixes the bug that .Bk allowed output line breaks right after block
macros spanning more than one input line, even when the next macro follows
on the same line.

Revision 1.80 / (download) - annotate - [select for diffs], Mon Oct 21 23:32:32 2013 UTC (10 years, 6 months ago) by schwarze
Branch: MAIN
Changes since 1.79: +140 -99 lines
Diff to previous 1.79 (colored)

There are three kinds of input lines: text lines, macros taking
positional arguments (like Dt Fn Xr) and macros taking text as
arguments (like Nd Sh Em %T An).  In the past, even the latter put
each word of their arguments into its own MDOC_TEXT node; instead,
concatenate arguments unless delimiters, keeps or spacing mode
prevent that.  Regarding mandoc(1), this is internal refactoring,
no output change intended.

Once we will switch mandocdb(8) from DB to SQLite in the future,
this is going to be required to support search expressions crossing
word boundaries, and it will reduce both database sizes and build
times by a bit more than 5% each.

Revision 1.79 / (download) - annotate - [select for diffs], Sun Sep 15 18:26:39 2013 UTC (10 years, 8 months ago) by schwarze
Branch: MAIN
Changes since 1.78: +4 -1 lines
Diff to previous 1.78 (colored)

Block closing macros do not allocate a new node but finish an existing
one, so they miss the clearing of MDOC_NEWLINE in mdoc.c, node_alloc().
Consequently, MDOC_NEWLINE must be cleared before processing the next
macro on the same line.
This fixes horizontal spacing for input lines beginning like .Oc Ns ...

Issue found by Franco Fichtner <franco at lastsummer dot de>
while working on DragonFly mandoc integration.

Revision 1.78 / (download) - annotate - [select for diffs], Mon Nov 19 22:28:35 2012 UTC (11 years, 6 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_5_4_BASE, OPENBSD_5_4, OPENBSD_5_3_BASE, OPENBSD_5_3
Changes since 1.77: +11 -5 lines
Diff to previous 1.77 (colored)

Do not crash on stray .Ta macros found outside column lists.
Problem reported by jmc@, thanks.

Revision 1.77 / (download) - annotate - [select for diffs], Sun Nov 18 00:05:28 2012 UTC (11 years, 6 months ago) by schwarze
Branch: MAIN
Changes since 1.76: +3 -2 lines
Diff to previous 1.76 (colored)

Fix four small whitespace issues related to trailing punctuation
reported by Nicolas Joly <njoly at pasteur dot fr>:

- add EOS spacing after trailing punctuation after .Cd, .Fc, and .Lb
- suppress spacing before trailing punctuation after .Fd

Revision 1.76 / (download) - annotate - [select for diffs], Sat Nov 17 00:25:20 2012 UTC (11 years, 6 months ago) by schwarze
Branch: MAIN
Changes since 1.75: +181 -176 lines
Diff to previous 1.75 (colored)

Cleanup naming of local variables to make the code easier on the eye:
Settle for "struct man *man", "struct mdoc *mdoc", "struct meta *meta"
and avoid the confusing "*m" which was sometimes this, sometimes that.
No functional change.

ok kristaps@ some time ago

Revision 1.75 / (download) - annotate - [select for diffs], Fri Nov 16 13:25:34 2012 UTC (11 years, 6 months ago) by schwarze
Branch: MAIN
Changes since 1.74: +2 -2 lines
Diff to previous 1.74 (colored)

Fix a crash triggered by .Bl -tag .It Xo .El .Sh found by florian@.

* When allocating a body end marker, copy the pointer to the normalized
block information from the body block, avoiding the risk of subsequent
null pointer derefence.
* When inserting the body end marker into the syntax tree, do not try to
copy that pointer from the parent block, because not being a direkt child
of the block it belongs to is the whole point of a body end marker.
* Even non-callable blocks (like Bd and Bl) can break other blocks;
when this happens, postpone closing them out in the usual way.

Revision 1.74 / (download) - annotate - [select for diffs], Wed Jul 18 16:20:14 2012 UTC (11 years, 10 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_5_2_BASE, OPENBSD_5_2
Changes since 1.73: +10 -3 lines
Diff to previous 1.73 (colored)

Let a trailing .Ns macro take effect
even on an input line containing a partial implicit macro.

Fixes horizontal spacing in vi(1), ddb(4), and ppp(8).

Revision 1.73 / (download) - annotate - [select for diffs], Wed Jan 4 02:17:42 2012 UTC (12 years, 4 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_5_1_BASE, OPENBSD_5_1
Changes since 1.72: +12 -4 lines
Diff to previous 1.72 (colored)

Heads of .It macros in -diag lists are not parsed,
even though .It macros in general are parsed.
Fixing a bug reported by deraadt@,
based on an incomplete fix by kristaps@,
and update the test suite to catch this issue.

Revision 1.72 / (download) - annotate - [select for diffs], Sat Dec 3 23:01:21 2011 UTC (12 years, 5 months ago) by schwarze
Branch: MAIN
Changes since 1.71: +1 -14 lines
Diff to previous 1.71 (colored)

Remove an OpenBSD-specific tweak regarding .Xr spacing
and make it compatible with bsd.lv mandoc and with groff-1.21.
This tweak was originally added for compatibility with groff-1.15,
which is no longer needed.

ok jmc@ kristaps@

Revision 1.71 / (download) - annotate - [select for diffs], Sat Dec 3 22:47:27 2011 UTC (12 years, 5 months ago) by schwarze
Branch: MAIN
Changes since 1.70: +12 -1 lines
Diff to previous 1.70 (colored)

remove useless "#ifdef __linux__" that crept in,
and trivial sync to bsd.lv (two new comments)

Revision 1.70 / (download) - annotate - [select for diffs], Sun Oct 16 12:18:32 2011 UTC (12 years, 7 months ago) by schwarze
Branch: MAIN
Changes since 1.69: +2 -5 lines
Diff to previous 1.69 (colored)

Remove a bunch of useless assignments,
and assert that print_bvspace cannot be called on NULL pointers.
No change in behaviour, none of these were bugs,
but the code becomes easier to understand.
Based on a clang report posted by joerg@; ok kristaps@.

Revision 1.69 / (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.68: +3 -3 lines
Diff to previous 1.68 (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.68 / (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.67: +8 -8 lines
Diff to previous 1.67 (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.67 / (download) - annotate - [select for diffs], Sun Apr 24 16:49:10 2011 UTC (13 years ago) by schwarze
Branch: MAIN
Changes since 1.66: +3 -2 lines
Diff to previous 1.66 (colored)

Closing delimiters only suppress spacing when they follow something.
Fixing a regression introduced in bsd.lv rev. 1.105.

Revision 1.66 / (download) - annotate - [select for diffs], Sun Apr 24 16:22:02 2011 UTC (13 years ago) by schwarze
Branch: MAIN
Changes since 1.65: +57 -32 lines
Diff to previous 1.65 (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.65 / (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.64: +17 -18 lines
Diff to previous 1.64 (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.64 / (download) - annotate - [select for diffs], Sun Jan 30 18:28:01 2011 UTC (13 years, 3 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_4_9_BASE, OPENBSD_4_9
Changes since 1.63: +4 -2 lines
Diff to previous 1.63 (colored)

Make .Bx accept not more than two arguments.
Convert the first character of the second argument to uppercase.
Append the second argument with a hyphen.
Improves chpass(1), column(1), fstat(1), ...
from kristaps@

Revision 1.63 / (download) - annotate - [select for diffs], Sun Jan 16 19:27:25 2011 UTC (13 years, 4 months ago) by schwarze
Branch: MAIN
Changes since 1.62: +10 -3 lines
Diff to previous 1.62 (colored)

Some improvements to error handling from kristaps@:
* Make out-of-context .fi invocations not cause an error, but just a warning.
* Downgrade -man message about ignored empty paragraph to MANDOC_IGNPAR.
* Avoid syntax tree corruption when removing empty block macros.
Triggered by some reports from brad@.

Revision 1.62 / (download) - annotate - [select for diffs], Tue Jan 4 22:28:17 2011 UTC (13 years, 4 months ago) by schwarze
Branch: MAIN
Changes since 1.61: +1 -5 lines
Diff to previous 1.61 (colored)

Merge kristaps@' cleaner tbl integration, removing mine;
there are still a few bugs, but fixing these will be easier in tree.

Revision 1.61 / (download) - annotate - [select for diffs], Tue Dec 21 23:46:18 2010 UTC (13 years, 5 months ago) by schwarze
Branch: MAIN
Changes since 1.60: +4 -1 lines
Diff to previous 1.60 (colored)

Vertical spacing improvements from kristaps@, small tweaks by me:
Add a "last child" member to struct mdoc_node.
Remove .Pp or .Lp if it is the first or last child of an .Sh or .Ss body.
Thus, no need to do the same in the front-ends any longer.
Tolerate some cases of .Pp inside .Bl.

Revision 1.60 / (download) - annotate - [select for diffs], Wed Dec 1 22:02:29 2010 UTC (13 years, 5 months ago) by schwarze
Branch: MAIN
Changes since 1.59: +4 -12 lines
Diff to previous 1.59 (colored)

Merge mdoc_action.c into mdoc_validate.c, because having two places to do
basically the same things just causes code duplication and confusion.
Work by kristaps@, including a few bugfixes he found during the merge,
and reapplying OpenBSD changes on top.

Revision 1.59 / (download) - annotate - [select for diffs], Sun Oct 24 18:15:43 2010 UTC (13 years, 6 months ago) by schwarze
Branch: MAIN
Changes since 1.58: +22 -22 lines
Diff to previous 1.58 (colored)

Do not throw FATAL errors when there is no need to:
 - when encountering nested displays (.Bd containing .Bd, .D1, .D1)
 - when a block end macro was forgotten
 - when ending a block that was never started
 - when the uname(3) system call failed
along with a little related cleanup

Revision 1.58 / (download) - annotate - [select for diffs], Sat Oct 16 13:38:29 2010 UTC (13 years, 7 months ago) by schwarze
Branch: MAIN
Changes since 1.57: +5 -1 lines
Diff to previous 1.57 (colored)

Support tbl(1) code embedded into mdoc(7) input files.
Very similar to what i have done in man(7) yesterday.
Allows to build cpu(4) on HPPA, wi(4), and phantasia(6).
Now we are able to build all tbl code in base.

Revision 1.57 / (download) - annotate - [select for diffs], Fri Oct 1 21:38:26 2010 UTC (13 years, 7 months ago) by schwarze
Branch: MAIN
Changes since 1.56: +3 -3 lines
Diff to previous 1.56 (colored)

* need a space before .No even if it starts with a closing delimiter
* slightly simplify .Pf *_IGNDELIM code, and share part of it with .No
* do not let opening delimiters fall out of the front of .Ns (from kristaps@)
This fixes a few spacing issues in csh(1) and ksh(1).
OK kristaps@

Revision 1.56 / (download) - annotate - [select for diffs], Sun Sep 26 20:19:58 2010 UTC (13 years, 7 months ago) by schwarze
Branch: MAIN
Changes since 1.55: +5 -9 lines
Diff to previous 1.55 (colored)

If an explicit scope is still open at the end of an input file,
report an ERROR:  We can still render the page by just closing
the open scope, but it is likely that information will be missing
or document structure mangled.
Before, man(7) only reported a WARNING (which is dangerous because
we cannot be sure rendering is correct) and mdoc(7) ran into FATAL
(which is too drastic, there is no reason not to show what we have).
While here, add a few explicit casts to appease lint.
"looks good" kristaps@

Revision 1.55 / (download) - annotate - [select for diffs], Fri Jul 16 00:34:33 2010 UTC (13 years, 10 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_4_8_BASE, OPENBSD_4_8
Changes since 1.54: +3 -3 lines
Diff to previous 1.54 (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.54 / (download) - annotate - [select for diffs], Tue Jul 13 01:09:13 2010 UTC (13 years, 10 months ago) by schwarze
Branch: MAIN
Changes since 1.53: +8 -5 lines
Diff to previous 1.53 (colored)

Merge release 1.10.4 (all code by kristaps@), providing four new features:
1) Proper .Bk support: allow output line breaks at input line breaks,
but keep input lines together in the output, finally fixing
synopses like aucat(1), mail(1) and tmux(1).
2) Mostly finished -Tps (PostScript) output.
3) Implement -Thtml output for .Nm blocks and .Bk -words.
4) Allow iterative interpolation of user-defined roff(7) strings.
Also contains some minor bugfixes and some performance improvements.

Revision 1.53 / (download) - annotate - [select for diffs], Thu Jul 1 22:31:52 2010 UTC (13 years, 10 months ago) by schwarze
Branch: MAIN
Changes since 1.52: +5 -2 lines
Diff to previous 1.52 (colored)

In the mdoc(7) parser, inspect roff registers early such that all parts
of the parser can use the resulting cues.  In particular, this allows
to use .nr nS to force SYNOPSIS-style .Nm indentation outside the
SYNOPSIS as needed by ifconfig(8).

To actually make this useable, .Pp must rewind .Nm, or the rest of the
section would end up indented.  Implement a quick hack for now,
a generic solution can be designed later.

ok kristaps@ sobrado@

Revision 1.52 / (download) - annotate - [select for diffs], Thu Jul 1 21:08:50 2010 UTC (13 years, 10 months ago) by schwarze
Branch: MAIN
Changes since 1.51: +4 -1 lines
Diff to previous 1.51 (colored)

Correct handling of trailing punctuation in MDOC_DELIM blk_full HEADs.
The bug was uncovered by SYNOPSIS .Nm as this happened to be the first
block with this particular combination of properties.
Found the hard way by kristaps@ in NetBSD gcc-contrib(1),
fix by me.

Revision 1.51 / (download) - annotate - [select for diffs], Thu Jul 1 15:36:59 2010 UTC (13 years, 10 months ago) by schwarze
Branch: MAIN
Changes since 1.50: +20 -11 lines
Diff to previous 1.50 (colored)

Improve .Nm indentation in the SYNOPSIS;
kristaps@ will do the missing HTML part soon.
"looks nicer" jmc@
"seems perfect to me" sobrado@
"slap it in" kristaps@

Revision 1.50 / (download) - annotate - [select for diffs], Wed Jun 30 03:57:49 2010 UTC (13 years, 10 months ago) by schwarze
Branch: MAIN
Changes since 1.49: +43 -4 lines
Diff to previous 1.49 (colored)

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.

Revision 1.49 / (download) - annotate - [select for diffs], Tue Jun 29 19:42:03 2010 UTC (13 years, 10 months ago) by schwarze
Branch: MAIN
Changes since 1.48: +2 -2 lines
Diff to previous 1.48 (colored)

fix a typo in the function declaration;
seems like gcc3 didn't catch it :-(
thanks to thib@ and kristaps@ for reporting

Revision 1.48 / (download) - annotate - [select for diffs], Tue Jun 29 18:01:10 2010 UTC (13 years, 10 months ago) by schwarze
Branch: MAIN
Changes since 1.47: +70 -207 lines
Diff to previous 1.47 (colored)

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.

"get it in" kristaps@

Revision 1.47 / (download) - annotate - [select for diffs], Tue Jun 29 17:10:29 2010 UTC (13 years, 10 months ago) by schwarze
Branch: MAIN
Changes since 1.46: +195 -71 lines
Diff to previous 1.46 (colored)

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.

"get it in" kristaps@

Revision 1.46 / (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.45: +125 -34 lines
Diff to previous 1.45 (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.45 / (download) - annotate - [select for diffs], Sun Jun 6 18:08:41 2010 UTC (13 years, 11 months ago) by schwarze
Branch: MAIN
Changes since 1.44: +34 -13 lines
Diff to previous 1.44 (colored)

Merge bsd.lv release 1.10.0,
which is mostly the post-hackathon release,
bringing in the OpenBSD changes to bsd.lv,
but which also has a few additional minor fixes:

* .Lb is an in-line macro, not in_line_eoln
* .Bt, .Ud now warn when discarding arguments
* allow bad -man dates to flow verbatim into the front-ends
- so far all reported by Ulrich Spoerlein
* .Ar, .Fl and .Li starting with closing punctuation emit an empty element
* empty .Li macros print nothing, but may cause spacing
* proper EOS handling for .Bt, .Ex, .Rv, and .Ud.
* cleanup: collapse posts_xr into posts_wtext (which is the same)
* efficiency: very simple table lookup for roff.c

Revision 1.44 / (download) - annotate - [select for diffs], Sun May 23 22:45:00 2010 UTC (13 years, 11 months ago) by schwarze
Branch: MAIN
Changes since 1.43: +19 -15 lines
Diff to previous 1.43 (colored)

Unified error and warning message system for all of mandoc,
featuring three message levels, as agreed during the mandoc hackathon:
* FATAL parser failure, cannot produce any output from this input file:
  eventually, we hope to convert most of these to ERRORs.
* ERROR, meaning mandoc cannot cope fully with the input syntax and will
  probably lose information or produce structurally garbled output;
  it will try to produce output anyway but exit non-zero at the end,
  which is eventually intended to make the ports infrastructure happy.
* WARNING, meaning you should clean up the input file, but output
  is probably mostly OK, so this will not cause error-exit at the end.
This commit is mostly just converting the old system to the new one; before
the classification will become really reliable, we must check all messages.

In particular,
* set up a new central message string table in main.c
* drop the old message string tables from man.c and mdoc.c
* get rid of the piece-meal merr enums in libman and libmdoc
* reduce number of error/warning functions from 16 to 6 (still a lot...)

While here, handle a few problems more gracefully:
* allow .Rv and .Ex to work without a prior .Nm
* allow .An to ignore extra arguments
* allow undeclared columns in .Bl -column

Written by kristaps@.

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

merge bsd.lv rev. 1.63:
remove "1 == ppos" conditions that remained after rev. 1.60

Revision 1.42 / (download) - annotate - [select for diffs], Sat May 15 15:37:53 2010 UTC (14 years ago) by schwarze
Branch: MAIN
Changes since 1.41: +21 -7 lines
Diff to previous 1.41 (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.41 / (download) - annotate - [select for diffs], Sat May 15 13:12:55 2010 UTC (14 years ago) by schwarze
Branch: MAIN
Changes since 1.40: +19 -32 lines
Diff to previous 1.40 (colored)

proper handling of quoted tab-separated column lists
by kristaps@

Revision 1.40 / (download) - annotate - [select for diffs], Sat May 15 12:30:59 2010 UTC (14 years ago) by schwarze
Branch: MAIN
Changes since 1.39: +14 -37 lines
Diff to previous 1.39 (colored)

Distinguish OPEN, MIDDLE and CLOSE delimiters (using an enum).
Only OPEN are drawn before the beginning of a macro;
this is new, before this, MIDDLE ('|') were drawn in front, too.
Only CLOSE are pushed after the end of a macro (as before).
ok kristaps@

This allows us to finally enable handling of leading punctuation
without regressions.

Revision 1.39 / (download) - annotate - [select for diffs], Sat May 15 09:20:01 2010 UTC (14 years ago) by schwarze
Branch: MAIN
Changes since 1.38: +21 -1 lines
Diff to previous 1.38 (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.38 / (download) - annotate - [select for diffs], Fri May 14 19:52:43 2010 UTC (14 years ago) by schwarze
Branch: MAIN
Changes since 1.37: +1 -2 lines
Diff to previous 1.37 (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.37 / (download) - annotate - [select for diffs], Fri May 14 14:47:44 2010 UTC (14 years ago) by schwarze
Branch: MAIN
Changes since 1.36: +67 -27 lines
Diff to previous 1.36 (colored)

Merge 1.9.25, keeping local patches;
this does not merge kristaps' end-of-sentences handling yet,
i will check that separately.  This one includes:
* handle \*(Ba as a delimiter
* introduce ARGS_PEND for .Bl -column .It end-of-line special casing
* section ordering: expect EXIT STATUS at the right place
* line break fixes in SYNOPSIS
* allow literal contexts to have arbitrary line lengths
* the input file column number can not be used to identify the beginning
  of a line because white space is allowed after the initial '.'
* proper leading spaces in -man -Tascii mode
* do not let Lb break lines in -mdoc -Thtml LIBRARY

Revision 1.36 / (download) - annotate - [select for diffs], Fri May 14 01:54:37 2010 UTC (14 years ago) by schwarze
Branch: MAIN
Changes since 1.35: +186 -156 lines
Diff to previous 1.35 (colored)

merge 1.9.24, keeping local patches; some changes:
* preserve multiple consecutive space characters in input
* do not restrict .Cd and .Rv to certain sections (requested by Joerg)
* do not run lookup() on quoted words
* enum return types for mdoc_args and mdoc_argv
* fix auto-closing of LINK tag in -Txhtml (from Daniel Friesel)
* various lint and manual fixes

Revision 1.35 / (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.34: +18 -11 lines
Diff to previous 1.34 (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.34 / (download) - annotate - [select for diffs], Fri Apr 2 12:39:47 2010 UTC (14 years, 1 month ago) by schwarze
Branch: MAIN
Changes since 1.33: +31 -26 lines
Diff to previous 1.33 (colored)

merge 1.9.22, keeping local patches
* convert mdoc tokens from #define to enum
* fix a segfault with .Xo/.Xc in explicit blocks
* Thorn is \*(Th, not \*(TH; noticed by Joerg Sonnenberger

Revision 1.33 / (download) - annotate - [select for diffs], Fri Apr 2 11:39:00 2010 UTC (14 years, 1 month ago) by schwarze
Branch: MAIN
Changes since 1.32: +26 -1 lines
Diff to previous 1.32 (colored)

Temporarily disable the handling of leading punctuation.
We must investigate the fallout before enabling this.

Revision 1.32 / (download) - annotate - [select for diffs], Fri Apr 2 11:37:07 2010 UTC (14 years, 1 month ago) by schwarze
Branch: MAIN
Changes since 1.31: +201 -150 lines
Diff to previous 1.31 (colored)

merge 1.9.20, keeping local patches
* prevent roff instructions in man(7) from clobbering scopes and line modes
  (noted by Sascha Wildner)
* handle leading punctuation in mdoc(7) blocks and line macros
  (looks good in principle, but is causing some fallout in OpenBSD,
   so i will disable it locally for now with the next commit)

Revision 1.31 / (download) - annotate - [select for diffs], Tue Mar 2 00:38:59 2010 UTC (14 years, 2 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_4_7_BASE, OPENBSD_4_7
Changes since 1.30: +1 -0 lines
Diff to previous 1.30 (colored)

Proper inter-sentence spacing for mdoc(7).
When a text line or a non-block macro line in the source code ends
in any of ".!?", consider that an end of sentence (EOS).
This makes Jason's rule "new sentence, new line" even more important.
Let the parser detect the EOS and insert a token into the AST.
Let the -Tascii frontend render the EOS token as a double space before
the next word.

Revision 1.30 / (download) - annotate - [select for diffs], Tue Mar 2 00:13:57 2010 UTC (14 years, 2 months ago) by schwarze
Branch: MAIN
Changes since 1.29: +2 -2 lines
Diff to previous 1.29 (colored)

Distinguish opening and closing delimiters, and close out block
macros after closing delimiters only, not after opening ones.  Besides,
neither roff nor old nor new groff consider braces { } as delimiters.

This fixes some frequent misrenderings by mandoc,
for example ".Ql (" being rendered as "`'(" instead of "`('".

Revision 1.29 / (download) - annotate - [select for diffs], Fri Feb 26 12:12:24 2010 UTC (14 years, 2 months ago) by schwarze
Branch: MAIN
Changes since 1.28: +34 -7 lines
Diff to previous 1.28 (colored)

Support .It .Xo.
The trick is to not switch from the .It header to the body at EOL, but,
in case an explicit block macro follows, at the end of the block.

Revision 1.28 / (download) - annotate - [select for diffs], Thu Feb 18 02:11:26 2010 UTC (14 years, 3 months ago) by schwarze
Branch: MAIN
Changes since 1.27: +45 -3 lines
Diff to previous 1.27 (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.27 / (download) - annotate - [select for diffs], Fri Jan 1 19:24:07 2010 UTC (14 years, 4 months ago) by schwarze
Branch: MAIN
Changes since 1.26: +12 -1 lines
Diff to previous 1.26 (colored)

When multiple arguments are passed to .Fl,
each should be rendered with its own dash.

Fixes regress/usr.bin/mandoc/mdoc/Fl/multiarg.in;
ok kristaps@ and merged upstream in rev. 1.39.

Revision 1.26 / (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.25: +2 -1 lines
Diff to previous 1.25 (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.25 / (download) - annotate - [select for diffs], Tue Oct 27 21:40:07 2009 UTC (14 years, 6 months ago) by schwarze
Branch: MAIN
Changes since 1.24: +2 -1 lines
Diff to previous 1.24 (colored)

sync to 1.9.11: adapt printing of dates to groff conventions,
NetBSD portability fixes and some minor bugfixes and feature enhancements;
also checked that my hyphenation code still works on top of this

Revision 1.24 / (download) - annotate - [select for diffs], Mon Sep 21 21:11:37 2009 UTC (14 years, 8 months ago) by schwarze
Branch: MAIN
Changes since 1.23: +16 -15 lines
Diff to previous 1.23 (colored)

sync to 1.9.5: lookup hashes are now static tables
shortening the code, and, according to kristaps@, speeding it up

Revision 1.23 / (download) - annotate - [select for diffs], Sat Aug 22 22:39:55 2009 UTC (14 years, 8 months ago) by schwarze
Branch: MAIN
Changes since 1.22: +3 -3 lines
Diff to previous 1.22 (colored)

sync to 1.9.1: correctly flag delimiter whitespace

Revision 1.22 / (download) - annotate - [select for diffs], Sat Aug 22 21:55:06 2009 UTC (14 years, 8 months ago) by schwarze
Branch: MAIN
Changes since 1.21: +202 -274 lines
Diff to previous 1.21 (colored)

sync to 1.9.1: set mdoc_next flags in mdoc_*_alloc routines, where they belong

Revision 1.21 / (download) - annotate - [select for diffs], Sat Aug 22 19:43:33 2009 UTC (14 years, 8 months ago) by schwarze
Branch: MAIN
Changes since 1.20: +33 -41 lines
Diff to previous 1.20 (colored)

sync to 1.9.0: polishing the core code of mdoc macro handling
1) If a macro is not parsed, do not parse it.  Of course, without
parsing it, we cannot produce "macro-like parameter" warnings,
but these were useless anyway.
2) If a macro is not callable, do not print a useless warning when
it occurs as a parameter, just display the raw characters.
3) Below .Bl -column, check whether macros are callable.
4) Like groff, allow whitespace after the initial dot on macro lines.

Revision 1.20 / (download) - annotate - [select for diffs], Sat Aug 22 15:36:58 2009 UTC (14 years, 9 months ago) by schwarze
Branch: MAIN
Changes since 1.19: +5 -6 lines
Diff to previous 1.19 (colored)

sync to 1.8.4: LLVM findings from <uqs at spoerlein dot net>

Revision 1.19 / (download) - annotate - [select for diffs], Sun Aug 9 21:59:41 2009 UTC (14 years, 9 months ago) by schwarze
Branch: MAIN
Changes since 1.18: +6 -4 lines
Diff to previous 1.18 (colored)

sync to 1.8.4: full .An -[no]split support

Revision 1.18 / (download) - annotate - [select for diffs], Sun Aug 9 19:59:13 2009 UTC (14 years, 9 months ago) by schwarze
Branch: MAIN
Changes since 1.17: +3 -1 lines
Diff to previous 1.17 (colored)

sync to 1.8.3: .Pa without arguments is a synonym for .Pa ~

Revision 1.17 / (download) - annotate - [select for diffs], Sun Aug 9 17:13:00 2009 UTC (14 years, 9 months ago) by schwarze
Branch: MAIN
Changes since 1.16: +26 -60 lines
Diff to previous 1.16 (colored)

sync to 1.8.2: fix and cleanup .Bl -column phrase handling
by using the normal argument parsing from mdoc_argv.c

Revision 1.16 / (download) - annotate - [select for diffs], Sun Aug 9 17:02:46 2009 UTC (14 years, 9 months ago) by schwarze
Branch: MAIN
Changes since 1.15: +3 -7 lines
Diff to previous 1.15 (colored)

sync to 1.8.2: use in_line_eoln instead of in_line for .Pp and .Lp
no functional change, but shorter code

Revision 1.15 / (download) - annotate - [select for diffs], Sun Aug 9 16:36:45 2009 UTC (14 years, 9 months ago) by schwarze
Branch: MAIN
Changes since 1.14: +2 -2 lines
Diff to previous 1.14 (colored)

sync to 1.8.1: make .Cd parsed
kristaps@ says many SYNOPSIS sections use this; my impression is
that's not in OpenBSD, but it won't do much harm here, either

Revision 1.14 / (download) - annotate - [select for diffs], Sun Jul 26 23:48:01 2009 UTC (14 years, 9 months ago) by schwarze
Branch: MAIN
Changes since 1.13: +7 -7 lines
Diff to previous 1.13 (colored)

sync to 1.8.1: explicit-close macros now only warn when encountering
trailing terms and do not error out any more, try:  .Ed foo

Revision 1.13 / (download) - annotate - [select for diffs], Sun Jul 26 01:59:46 2009 UTC (14 years, 9 months ago) by schwarze
Branch: MAIN
Changes since 1.12: +3 -1 lines
Diff to previous 1.12 (colored)

sync to 1.8.1: support .br and .sp

Revision 1.12 / (download) - annotate - [select for diffs], Sat Jul 18 15:34:27 2009 UTC (14 years, 10 months ago) by schwarze
Branch: MAIN
Changes since 1.11: +41 -4 lines
Diff to previous 1.11 (colored)

sync to 1.8.0: .Nd is now a BFI, was an ELEM,
and use \(en instead of \- for .Nd

Revision 1.11 / (download) - annotate - [select for diffs], Sun Jul 12 23:19:48 2009 UTC (14 years, 10 months ago) by schwarze
Branch: MAIN
Changes since 1.10: +2 -2 lines
Diff to previous 1.10 (colored)

sync to 1.7.24: make .In handling more similar to new groff

Revision 1.10 / (download) - annotate - [select for diffs], Sun Jul 12 22:35:08 2009 UTC (14 years, 10 months ago) by schwarze
Branch: MAIN
Changes since 1.9: +6 -39 lines
Diff to previous 1.9 (colored)

sync to 1.7.23: pass warning code to mdoc_pwarn() instead of warning message
define additional warning macro mdoc_nwarn()
remove obsolete warning functions mdoc_warn(), pwarn(), vwarn(), nwarn()
remove various now unused "enum mdoc_warn" and "enum mwarn"

Revision 1.9 / (download) - annotate - [select for diffs], Sun Jul 12 21:45:44 2009 UTC (14 years, 10 months ago) by schwarze
Branch: MAIN
Changes since 1.8: +4 -32 lines
Diff to previous 1.8 (colored)

sync to 1.7.23: pass error code to mdoc_perr() instead of error string
and use the so improved mdoc_nerr() at many places;
get rid of now unused static functions perr()

Revision 1.8 / (download) - annotate - [select for diffs], Sun Jul 12 21:08:29 2009 UTC (14 years, 10 months ago) by schwarze
Branch: MAIN
Changes since 1.7: +2 -2 lines
Diff to previous 1.7 (colored)

sync to 1.7.23: pass error code to mdoc_nerr() instead of error string
and use the so improved mdoc_nerr() at many places

Revision 1.7 / (download) - annotate - [select for diffs], Sun Jul 12 20:30:27 2009 UTC (14 years, 10 months ago) by schwarze
Branch: MAIN
Changes since 1.6: +5 -12 lines
Diff to previous 1.6 (colored)

sync to 1.7.23: unify the various "enum merr" into libman.h and libmdoc.h,
use it as a new argument to mdoc_err(), the same way as for for man_err(),
and use string tables instead of switch statements to select error messages

Revision 1.6 / (download) - annotate - [select for diffs], Sun Jul 12 19:05:52 2009 UTC (14 years, 10 months ago) by schwarze
Branch: MAIN
Changes since 1.5: +2 -2 lines
Diff to previous 1.5 (colored)

sync to 1.7.23: third step to get rid of enum mdoc_warn:
mdoc_verr is not using enum mdoc_warn, so use it at a few more places

Revision 1.5 / (download) - annotate - [select for diffs], Sun Jul 12 18:35:57 2009 UTC (14 years, 10 months ago) by schwarze
Branch: MAIN
Changes since 1.4: +2 -2 lines
Diff to previous 1.4 (colored)

sync to 1.7.23: second step to get rid of enum mdoc_warn:
remove type from mdoc_vwarn arguments, and use this function where apropriate

Revision 1.4 / (download) - annotate - [select for diffs], Thu Jun 18 23:34:53 2009 UTC (14 years, 11 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_4_6_BASE, OPENBSD_4_6
Changes since 1.3: +2 -5 lines
Diff to previous 1.3 (colored)

sync to 1.7.19: improved comment handling

Revision 1.3 / (download) - annotate - [select for diffs], Thu Jun 18 01:19:02 2009 UTC (14 years, 11 months ago) by schwarze
Branch: MAIN
Changes since 1.2: +14 -10 lines
Diff to previous 1.2 (colored)

sync to 1.7.16: make a couple of macros callable, reserve "|",
and some tweaks to .Lk

Revision 1.2 / (download) - annotate - [select for diffs], Sun Jun 14 23:00:57 2009 UTC (14 years, 11 months ago) by schwarze
Branch: MAIN
Changes since 1.1: +11 -13 lines
Diff to previous 1.1 (colored)

sync to 1.7.16: comments, whitespace and spelling fixes; no functional change

Revision 1.1 / (download) - annotate - [select for diffs], Mon Apr 6 20:30:40 2009 UTC (15 years, 1 month ago) by kristaps
Branch: MAIN

Initial check-in of mandoc for formatting manuals. ok deraadt@

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.