OpenBSD CVS

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


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

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.37 / (download) - annotate - [select for diffs], Tue Aug 10 12:36:42 2021 UTC (2 years, 9 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_7_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, HEAD
Changes since 1.36: +27 -29 lines
Diff to previous 1.36 (colored)

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

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

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

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

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

Revision 1.36 / (download) - annotate - [select for diffs], Tue Sep 1 18:24:10 2020 UTC (3 years, 8 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_6_9_BASE, OPENBSD_6_9, OPENBSD_6_8_BASE, OPENBSD_6_8
Changes since 1.35: +7 -2 lines
Diff to previous 1.35 (colored)

Ignore unreasonably large spacing modifiers in tbl layouts.

Jan Schreiber <jes at posteo dot de> ran afl on mandoc and it turned
out mandoc tried to use spacing modifiers so large that they would
trigger assertion failures in term_ascii.c, function locale_advance().

Revision 1.35 / (download) - annotate - [select for diffs], Fri Dec 14 05:17:45 2018 UTC (5 years, 5 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_6_7_BASE, OPENBSD_6_7, OPENBSD_6_6_BASE, OPENBSD_6_6, OPENBSD_6_5_BASE, OPENBSD_6_5
Changes since 1.34: +12 -16 lines
Diff to previous 1.34 (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.34 / (download) - annotate - [select for diffs], Fri Dec 14 01:17:46 2018 UTC (5 years, 5 months ago) by schwarze
Branch: MAIN
Changes since 1.33: +2 -1 lines
Diff to previous 1.33 (colored)

Major cleanup; may imply minor changes in edge cases of error reporting.

Finally, drop support for the run-time configurable mandocmsg()
callback.  It was over-engineered from the start, never used for
anything in a decade, and repeatedly caused maintenance headaches.

Consolidate reporting infrastructure into two files, mandoc.h and
mandoc_msg.c, mopping up the bits and pieces that were scattered
around main.c, read.c, mandoc_parse.h, libmandoc.h, the prototypes
of four parsing-related functions, and both parser structs.

Revision 1.33 / (download) - annotate - [select for diffs], Thu Dec 13 02:05:57 2018 UTC (5 years, 5 months ago) by schwarze
Branch: MAIN
Changes since 1.32: +2 -2 lines
Diff to previous 1.32 (colored)

Cleanup, no functional change:
Move tbl(7)-specific parser internals out of libroff.h.
Move some tbl(7)-internal processing from roff.c to tbl.c.

Revision 1.32 / (download) - annotate - [select for diffs], Wed Dec 12 21:54:30 2018 UTC (5 years, 5 months ago) by schwarze
Branch: MAIN
Changes since 1.31: +3 -2 lines
Diff to previous 1.31 (colored)

Cleanup, no functional change:
No need to expose the tbl(7) syntax tree data structures everywhere.
Move them to their own include file, "tbl.h", and improve comments.

Revision 1.31 / (download) - annotate - [select for diffs], Tue Jun 27 18:23:29 2017 UTC (6 years, 10 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_6_4_BASE, OPENBSD_6_4, OPENBSD_6_3_BASE, OPENBSD_6_3, OPENBSD_6_2_BASE, OPENBSD_6_2
Changes since 1.30: +3 -1 lines
Diff to previous 1.30 (colored)

Implement spacing of columns as defined in the table layout;
this is for example used by lftp(1)
and, ironically, misused by our very own tbl(7) manual...

Revision 1.30 / (download) - annotate - [select for diffs], Tue Jun 13 16:11:58 2017 UTC (6 years, 11 months ago) by schwarze
Branch: MAIN
Changes since 1.29: +3 -1 lines
Diff to previous 1.29 (colored)

If the layout is empty except for requesting a left vertical frame,
record that detail in struct tbl_opts, such that term_tbl() can do
correct column calculations and doesn't prematurely break lines.
Fixes the tbl/layout/empty regression test that got broken when
line breaking in text block cells was implemented.

Revision 1.29 / (download) - annotate - [select for diffs], Thu Jun 8 18:11:15 2017 UTC (6 years, 11 months ago) by schwarze
Branch: MAIN
Changes since 1.28: +19 -3 lines
Diff to previous 1.28 (colored)

Implement w layout specifier (minimum column width).
Improve width calculation of text blocks.
Reduces the groff/mandoc diff in Base+Xenocara by about 800 lines.

Revision 1.28 / (download) - annotate - [select for diffs], Mon Oct 12 00:07:27 2015 UTC (8 years, 7 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_6_1_BASE, OPENBSD_6_1, OPENBSD_6_0_BASE, OPENBSD_6_0, OPENBSD_5_9_BASE, OPENBSD_5_9
Changes since 1.27: +1 -5 lines
Diff to previous 1.27 (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.27 / (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.26: +2 -2 lines
Diff to previous 1.26 (colored)

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

Revision 1.26 / (download) - annotate - [select for diffs], Wed Apr 29 12:44:10 2015 UTC (9 years ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_5_8_BASE, OPENBSD_5_8
Changes since 1.25: +2 -1 lines
Diff to previous 1.25 (colored)

When the last line of a table layout turns out to be empty, it is deleted.
Do not just free the struct tbl_row but also make sure that no pointer
to it remains.  Fixing a use after free found by jsg@ with afl.

Revision 1.25 / (download) - annotate - [select for diffs], Tue Feb 10 11:02:19 2015 UTC (9 years, 3 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_5_7_BASE, OPENBSD_5_7
Changes since 1.24: +27 -11 lines
Diff to previous 1.24 (colored)

Do not read past the end of the buffer if an "f" layout font modifier
is followed by the end of the input line instead of a font specifier.
Found by jsg@ with afl, test case #591.

While here, improve functionality as well:
* There is no "r" font modifier.
* Font specifiers (as opposed to font modifiers) are case sensitive.
* One-character font specifiers require trailing whitespace.
* Ignore parenthised and two-letter font specifiers.

Revision 1.24 / (download) - annotate - [select for diffs], Fri Jan 30 04:08:37 2015 UTC (9 years, 3 months ago) by schwarze
Branch: MAIN
Changes since 1.23: +7 -26 lines
Diff to previous 1.23 (colored)

Abolish struct tbl_head and replace it by an "int col" member in
struct tbl_cell.  No functional change, minus 40 lines of code.

Revision 1.23 / (download) - annotate - [select for diffs], Fri Jan 30 02:08:37 2015 UTC (9 years, 3 months ago) by schwarze
Branch: MAIN
Changes since 1.22: +6 -6 lines
Diff to previous 1.22 (colored)

Auditing the tbl(7) code for more NULL pointer accesses, i came out
empty-handed; so this is just KNF and some code simplifications,
no functional change.

Revision 1.22 / (download) - annotate - [select for diffs], Fri Jan 30 00:27:09 2015 UTC (9 years, 3 months ago) by schwarze
Branch: MAIN
Changes since 1.21: +31 -11 lines
Diff to previous 1.21 (colored)

Make sure every layout line contains at least one cell;
fixing a NULL pointer access in term_tbl() that jsg@ found with afl.

Revision 1.21 / (download) - annotate - [select for diffs], Wed Jan 28 15:02:25 2015 UTC (9 years, 3 months ago) by schwarze
Branch: MAIN
Changes since 1.20: +2 -5 lines
Diff to previous 1.20 (colored)

For now, it can't be helped that mandoc tbl(7) ignores high-level macros,
but stop throwing away their arguments.  This fixes information loss in a
handful of Xenocara manuals, at the price of a small amount of formatting
noise creeping through.

Revision 1.20 / (download) - annotate - [select for diffs], Tue Jan 27 05:20:30 2015 UTC (9 years, 3 months ago) by schwarze
Branch: MAIN
Changes since 1.19: +47 -24 lines
Diff to previous 1.19 (colored)

Multiple parser and formatter fixes for line drawing in tbl(7).
* Allow mixing vertical line bars with the layout options
of the preceding layout cell.
* Correctly combine box options with layout lines.
* Correctly print vertical lines in data rows, with the right spacing.
* Correctly print cross markers and left and right ends of
horizontal lines even if vertical lines differ above and below.
* Avoid the bogus error message "no table data cells"
when a table data section starts with a horizontal line.
No increase in code size.

Revision 1.19 / (download) - annotate - [select for diffs], Mon Jan 26 18:41:45 2015 UTC (9 years, 3 months ago) by schwarze
Branch: MAIN
Changes since 1.18: +83 -155 lines
Diff to previous 1.18 (colored)

Rework tbl(7) layout parsing:
* Continue parsing even if part of the input is invalid.
* Do not require whitespace between cell specifications.
* Allow tabs as well as blanks between modifiers.
* Mark the 'm' modifier as unsupported.
* Parse and ignore the 'p' and 'v' modifiers.
* Better warning and error messages.
* Get rid of a static buffer.
Improved functionality but minus 50 lines of code.

Revision 1.18 / (download) - annotate - [select for diffs], Wed Jan 14 22:44:51 2015 UTC (9 years, 4 months ago) by schwarze
Branch: MAIN
Changes since 1.17: +6 -6 lines
Diff to previous 1.17 (colored)

simplify by getting rid of ROFF_ERR in tbl(7) parsing; no functional change

Revision 1.17 / (download) - annotate - [select for diffs], Tue Nov 25 05:39:00 2014 UTC (9 years, 5 months ago) by schwarze
Branch: MAIN
Changes since 1.16: +41 -56 lines
Diff to previous 1.16 (colored)

Completely rewrite the top level of the layout parser.
* Do not allocate lines unless there are cells.
* Make the MANDOCERR_TBLNOLAYOUT message actually work.
Also get rid of one static function and two goto statements.

Revision 1.16 / (download) - annotate - [select for diffs], Tue Oct 14 02:16:02 2014 UTC (9 years, 7 months ago) by schwarze
Branch: MAIN
Changes since 1.15: +6 -1 lines
Diff to previous 1.15 (colored)

Rudimentary implementation of the e, x, and z table layout modifiers
to equalize, maximize, and ignore the width of columns.
Does not yet take vertical rulers into account,
and does not do line breaks within table cells.
Considerably improves the lftp(1) manual; issue noticed by sthen@.

Revision 1.15 / (download) - annotate - [select for diffs], Tue Oct 7 14:06:14 2014 UTC (9 years, 7 months ago) by schwarze
Branch: MAIN
Changes since 1.14: +6 -1 lines
Diff to previous 1.14 (colored)

If a tbl(7) layout contains unknown font modifiers, fall back to the
default font rather than failing the whole table.
Needed by some pages in books/man-pages-posix.
Written on the plane back from EuroBSDCon in Sofia.

Revision 1.14 / (download) - annotate - [select for diffs], Sun Apr 20 16:44:44 2014 UTC (10 years, 1 month ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_5_6_BASE, OPENBSD_5_6
Changes since 1.13: +50 -49 lines
Diff to previous 1.13 (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.13 / (download) - annotate - [select for diffs], Fri Mar 28 23:25:54 2014 UTC (10 years, 1 month ago) by schwarze
Branch: MAIN
Changes since 1.12: +11 -2 lines
Diff to previous 1.12 (colored)

Allow leading and trailing vertical lines,
and format them in the same way as groff.
While here, do not require whitespace before vertical lines
in layout specifications.
Issues found by bentley@ in mpv(1).

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

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

Revision 1.11 / (download) - annotate - [select for diffs], Sat May 26 20:03:34 2012 UTC (11 years, 11 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_5_5_BASE, OPENBSD_5_5, OPENBSD_5_4_BASE, OPENBSD_5_4, OPENBSD_5_3_BASE, OPENBSD_5_3, OPENBSD_5_2_BASE, OPENBSD_5_2
Changes since 1.10: +36 -118 lines
Diff to previous 1.10 (colored)

Do not handle vertical lines as additional tbl(7) columns,
instead save their properties with the following column.
This simplifies layout parsing and saves a lot of code
related to column handling.

At output time, print all white space and vertical lines
separating columns before printing the following column,
and none after printing the preceding column, considerably
simplifying white space handling and width calculations.

No functional change, but it saves 150 lines of code,
and it allows the next patch to tbl_term.c, tbl_literal().

Revision 1.10 / (download) - annotate - [select for diffs], Sun Sep 18 15:54:48 2011 UTC (12 years, 8 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_5_1_BASE, OPENBSD_5_1
Changes since 1.9: +11 -1 lines
Diff to previous 1.9 (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.9 / (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.8: +23 -6 lines
Diff to previous 1.8 (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.8 / (download) - annotate - [select for diffs], Sun Apr 24 16:22:02 2011 UTC (13 years ago) by schwarze
Branch: MAIN
Changes since 1.7: +19 -11 lines
Diff to previous 1.7 (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.7 / (download) - annotate - [select for diffs], Sun Jan 16 01:11:50 2011 UTC (13 years, 4 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_4_9_BASE, OPENBSD_4_9
Changes since 1.6: +29 -4 lines
Diff to previous 1.6 (colored)

Various tbl improvements from kristaps@:
* horizontal lines do not consume layout lines
* skip excessive data cells
* prepare rendering of spanned cells
* support vertical spans

Revision 1.6 / (download) - annotate - [select for diffs], Sun Jan 9 14:30:48 2011 UTC (13 years, 4 months ago) by schwarze
Branch: MAIN
Changes since 1.5: +36 -5 lines
Diff to previous 1.5 (colored)

Sync tbl handling to bsd.lv release 1.10.9:
* .T} can be followed by a delimiter, then more data.
* Do not limit table column widths (improves terminfo(5)).
* Let numerical cells respect explicitly specified minimum cell widths.
* Let terminal output survive missing data cells.
* Parse and ignore arguments in parentheses on layout cell specifications.
* Move tbl_calc() into out.c such that it can be used by all frontends.
* Give tables an HTML class.
* Some cleanup in tbl -Thtml code.
All code by kristaps@.

Revision 1.5 / (download) - annotate - [select for diffs], Tue Jan 4 23:44:20 2011 UTC (13 years, 4 months ago) by schwarze
Branch: MAIN
Changes since 1.4: +3 -1 lines
Diff to previous 1.4 (colored)

Bring back my fix from -r 1.3 (Oct 15, 2010) after the merge.
Original commit message:

For now, parse and ignore minimal column width specifications.
First step to get terminfo(5) to build.

Revision 1.4 / (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.3: +235 -147 lines
Diff to previous 1.3 (colored)

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

Revision 1.3 / (download) - annotate - [select for diffs], Fri Oct 15 22:50:28 2010 UTC (13 years, 7 months ago) by schwarze
Branch: MAIN
Changes since 1.2: +6 -1 lines
Diff to previous 1.2 (colored)

For now, parse and ignore minimal column width specifications.
First step to get terminfo(5) to build.

Revision 1.2 / (download) - annotate - [select for diffs], Fri Oct 15 21:33:47 2010 UTC (13 years, 7 months ago) by schwarze
Branch: MAIN
Changes since 1.1: +2 -0 lines
Diff to previous 1.1 (colored)

Move tbl output from plain stdio to mandoc terminal output routines.
This fixes (1) all escape sequences and (2) some aspects of indentation.
Table column widths are still way off, though.
"move forward" deraadt@

Revision 1.1 / (download) - annotate - [select for diffs], Fri Oct 15 19:20:03 2010 UTC (13 years, 7 months ago) by schwarze
Branch: MAIN

Import tbl parser and renderer written by kristaps@.
Unchanged code from bsd.lv release 0.1.5, but without the main program.
Not yet linked to the build; next commit will integrate it into mandoc.

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.