CVS log for mandoc/roff_int.h

[BACK] Up to [cvsweb.bsd.lv] / mandoc

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.20 / (download) - annotate - [select for diffs], Thu Jun 2 11:29:07 2022 UTC (21 months, 3 weeks ago) by schwarze
Branch: MAIN
CVS Tags: HEAD
Changes since 1.19: +1 -1 lines
Diff to previous 1.19 (unified) to selected 1.8 (unified)

Avoid the layering violation of re-parsing for \E in roff_expand().
To that end, add another argument to roff_escape()
returning the index of the escape name.
This also makes the code in roff_escape() a bit more uniform
in so far as it no longer needs the "char esc_name" local variable
but now does everything with indices into buf[].
No functional change.

Revision 1.19 / (download) - annotate - [select for diffs], Thu May 19 15:37:47 2022 UTC (22 months, 1 week ago) by schwarze
Branch: MAIN
Changes since 1.18: +3 -1 lines
Diff to previous 1.18 (unified) to selected 1.8 (unified)

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

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

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

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

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

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

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

Revision 1.18 / (download) - annotate - [select for diffs], Mon Oct 4 14:19:14 2021 UTC (2 years, 5 months ago) by schwarze
Branch: MAIN
Changes since 1.17: +1 -0 lines
Diff to previous 1.17 (unified) to selected 1.8 (unified)

store the operating system name obtained from uname(3) in the adequate
struct together with similar state date rather than in a function-scope
static variable, such that it can be free(3)d in roff_man_free();
no functional change

Revision 1.17 / (download) - annotate - [select for diffs], Fri Apr 24 12:02:34 2020 UTC (3 years, 11 months ago) by schwarze
Branch: MAIN
CVS Tags: VERSION_1_14_6
Changes since 1.16: +3 -2 lines
Diff to previous 1.16 (unified) to selected 1.8 (unified)

provide a STYLE message when mandoc knows the file name and the extension
disagrees with the section number given in the .Dt or .TH macro;
feature suggested and patch tested by jmc@

Revision 1.16 / (download) - annotate - [select for diffs], Sat Jan 5 00:36:50 2019 UTC (5 years, 2 months ago) by schwarze
Branch: MAIN
CVS Tags: VERSION_1_14_5
Changes since 1.15: +3 -2 lines
Diff to previous 1.15 (unified) to selected 1.8 (unified)

Some high-level block macros have an effect similar to temporarily
suspending no-fill mode during their head.  Model this with an
additional roff parser state flag ROFF_NONOFILL.  That is much
simpler than it would be to save and restore the ROFF_NOFILL flag
itself, in particular since the latter can be switched (with lasting
effect) by the .nf and .fi requests even while its effect is
temporarily suspended.

This commit does not change formatting yet, but prepares for future
formatting simplifications and improvements.

Revision 1.15 / (download) - annotate - [select for diffs], Mon Dec 31 07:46:07 2018 UTC (5 years, 2 months ago) by schwarze
Branch: MAIN
Changes since 1.14: +1 -2 lines
Diff to previous 1.14 (unified) to selected 1.8 (unified)

Cleanup, no functional change:
Use the new parser flag ROFF_NOFILL in the mdoc(7) parser, too,
instead of the old MDOC_LITERAL, which was an alias for the
former MAN_LITERAL.

Revision 1.14 / (download) - annotate - [select for diffs], Mon Dec 31 07:08:12 2018 UTC (5 years, 2 months ago) by schwarze
Branch: MAIN
Changes since 1.13: +3 -3 lines
Diff to previous 1.13 (unified) to selected 1.8 (unified)

Move parsing of the .nf and .fi (fill mode) requests from the man(7)
parser to the roff(7) parser.  As a side effect, .nf and .fi are
now also parsed in mdoc(7) input, though the mdoc(7) formatters
still ignore most of their effect.

Revision 1.13 / (download) - annotate - [select for diffs], Mon Dec 31 04:55:47 2018 UTC (5 years, 2 months ago) by schwarze
Branch: MAIN
Changes since 1.12: +2 -1 lines
Diff to previous 1.12 (unified) to selected 1.8 (unified)

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.12 / (download) - annotate - [select for diffs], Sun Dec 30 00:49:56 2018 UTC (5 years, 2 months ago) by schwarze
Branch: MAIN
Changes since 1.11: +47 -1 lines
Diff to previous 1.11 (unified) to selected 1.8 (unified)

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.11 / (download) - annotate - [select for diffs], Thu Dec 13 06:18:20 2018 UTC (5 years, 3 months ago) by schwarze
Branch: MAIN
Changes since 1.10: +8 -2 lines
Diff to previous 1.10 (unified) to selected 1.8 (unified)

Cleanup, no functional change:
Move the roffhash_*() functions from roff.h to roff_int.h
because they are only intended for use by parsers,
neither by main programs nor by formatters.

Revision 1.10 / (download) - annotate - [select for diffs], Tue Dec 4 02:53:51 2018 UTC (5 years, 3 months ago) by schwarze
Branch: MAIN
Changes since 1.9: +3 -2 lines
Diff to previous 1.9 (unified) to selected 1.8 (unified)

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.9 / (download) - annotate - [select for diffs], Sat Jul 8 17:52:50 2017 UTC (6 years, 8 months ago) by schwarze
Branch: MAIN
CVS Tags: VERSION_1_14_4, VERSION_1_14_3, VERSION_1_14_2
Changes since 1.8: +1 -2 lines
Diff to previous 1.8 (unified)

Simplify by creating struct roff_node syntax tree nodes for tbl(7)
right from roff_parseln() rather than delegating to read.c,
similar to what i just did for eqn(7).

The interface function roff_span() becomes obsolete and is deleted,
the former interface function roff_addtbl() becomes static,
the interface functions tbl_read() and tbl_cdata() become void,
and minus twelve linus of code.

No functional change.

Revision 1.8 / (download) - annotate - [selected], Sat Jul 8 14:51:05 2017 UTC (6 years, 8 months ago) by schwarze
Branch: MAIN
Changes since 1.7: +1 -2 lines
Diff to previous 1.7 (unified)

1. Eliminate struct eqn, instead use the existing members
of struct roff_node which is allocated for each equation anyway.
2. Do not keep a list of equation parsers, one parser is enough.
Minus fifty lines of code, no functional change.

Revision 1.7 / (download) - annotate - [select for diffs], Sat Nov 7 14:01:16 2015 UTC (8 years, 4 months ago) by schwarze
Branch: MAIN
CVS Tags: VERSION_1_14_1, VERSION_1_13_4, VERSION_1_13
Changes since 1.6: +1 -5 lines
Diff to previous 1.6 (unified) to selected 1.8 (unified)

In private header files, __BEGIN_DECLS and __END_DECLS are pointless.
Because these work slightly differently on different systems,
they are becoming a maintenance burden in the portable version,
so delete them.

Besides, one of the chief design goals of the mandoc toolbox is to
make sure that nothing related to documentation requires C++.
Consequently, linking mandoc against any kind of C++ program would
defeat the purpose and is not supported.
I don't understand why kristaps@ added them in the first place.

Revision 1.6 / (download) - annotate - [select for diffs], Thu Oct 22 21:54:23 2015 UTC (8 years, 5 months ago) by schwarze
Branch: MAIN
Changes since 1.5: +1 -2 lines
Diff to previous 1.5 (unified) to selected 1.8 (unified)

move man(7) validation into the dedicated validation phase, too

Revision 1.5 / (download) - annotate - [select for diffs], Wed Oct 21 23:51:11 2015 UTC (8 years, 5 months ago) by schwarze
Branch: MAIN
Changes since 1.4: +1 -3 lines
Diff to previous 1.4 (unified) to selected 1.8 (unified)

Move all mdoc(7) node validation done before child parsing
to the new separate validation pass, except for a tiny bit
needed by the parser which goes to the new mdoc_state() module;
cleaner, simpler, and surprisingly also shorter by 15 lines.

Revision 1.4 / (download) - annotate - [select for diffs], Tue Oct 20 02:01:32 2015 UTC (8 years, 5 months ago) by schwarze
Branch: MAIN
Changes since 1.3: +1 -2 lines
Diff to previous 1.3 (unified) to selected 1.8 (unified)

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.3 / (download) - annotate - [select for diffs], Sun Apr 19 14:57:38 2015 UTC (8 years, 11 months ago) by schwarze
Branch: MAIN
Changes since 1.2: +3 -1 lines
Diff to previous 1.2 (unified) to selected 1.8 (unified)

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.2 / (download) - annotate - [select for diffs], Sun Apr 19 14:25:41 2015 UTC (8 years, 11 months ago) by schwarze
Branch: MAIN
Changes since 1.1: +19 -2 lines
Diff to previous 1.1 (unified) to selected 1.8 (unified)

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.1 / (download) - annotate - [select for diffs], Sun Apr 19 13:50:26 2015 UTC (8 years, 11 months ago) by schwarze
Branch: MAIN
Diff to selected 1.8 (unified)

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.

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.




CVSweb