CVS log for mandoc/tbl_html.c

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

Request diff between arbitrary revisions


Default branch: MAIN
Current tag: MAIN


Revision 1.41 / (download) - annotate - [select for diffs], Sat Apr 23 14:02:17 2022 UTC (22 months, 3 weeks ago) by schwarze
Branch: MAIN
CVS Tags: HEAD
Changes since 1.40: +5 -3 lines
Diff to previous 1.40 (unified)

If the last data row of a tbl(7) contains nothing but a horizontal line,
do not skip closing the table and cleaning up memory at the end of the
table in the HTML output module.

This bug resulted in skipping the tblcalc() function and reusing
the existing roffcol array for the next tbl(7) processed.  If the
next table had more columns than the one ending with a horizontal
line in the last data row, uninitialized memory was read, potentially
resulting in near-infinite output.

The bug was introduced in rev. 1.29 (2018/11/26) but only fully exposed
by rev. 1.38 (2021/09/09).  Until rev. 1.37, it could only cause
misformatting and invalid HTML output syntax but not huge output
because up to that point, the function did not use the roffcol array.

Nasty bug found the hard way by Michael Stapelberg on the production
server manpages.debian.org.  Michael also supplied example files
and excellent instructions how to reproduce the bug, which was very
difficult because no real-world manual page is known that triggers
the bug by itself, so to reproduce the bug, mandoc(1) had to be
invoked with at least two file name arguments.

Revision 1.40 / (download) - annotate - [select for diffs], Thu Apr 14 16:43:44 2022 UTC (23 months ago) by schwarze
Branch: MAIN
Changes since 1.39: +5 -2 lines
Diff to previous 1.39 (unified)

support for hunting memory leaks;
designed and written last autumn, polished today

Revision 1.39 / (download) - annotate - [select for diffs], Wed Jan 12 04:43:26 2022 UTC (2 years, 2 months ago) by schwarze
Branch: MAIN
Changes since 1.38: +4 -2 lines
Diff to previous 1.38 (unified)

According to the tbl(7) manual, if a data cell contains only the
two character sequence "\_" or "\=", a single or double horizontal
line is supposed to be drawn inside the cell, not joining its
neighbours.

I am not aware of any way to do that with HTML and/or CSS.
Still, it seems closer to the intent of the document author to draw
a horizontal line with <hr/>, even though that line will join the
neighbour cells, rather than printing a literal '_' or '=' character.

Formatting tweak inspired by a related question from
Ted Bullock <tbullock at comlore dot com>.

Revision 1.38 / (download) - annotate - [select for diffs], Thu Sep 9 16:52:52 2021 UTC (2 years, 6 months ago) by schwarze
Branch: MAIN
CVS Tags: VERSION_1_14_6
Changes since 1.37: +25 -1 lines
Diff to previous 1.37 (unified)

In HTML output, in cells with an "n" (number) layout, pad numbers
on the right side with UTF-8 punctuation and figure spaces such
that numbers in different tbl(7) rows align at the decimal point.

The exact HTML output format was suggested
by <Oliver dot Corff at email dot de>;
the implementation in C is mine.

Revision 1.37 / (download) - annotate - [select for diffs], Thu Sep 9 14:47:24 2021 UTC (2 years, 6 months ago) by schwarze
Branch: MAIN
Changes since 1.36: +7 -2 lines
Diff to previous 1.36 (unified)

If the layout or data of an individual cell in a tbl(7) contains
only "_", "-", or "=", requesting a horizontal line to be drawn
across the middle of the cell, print <hr/> in that cell in HTML
output.

That is arguably slightly ugly because HTML 5 regards <hr/> as
semantic markup, meaning "thematic break".  If somebody knowns
a better way to render a horizontal line across the middle of a
table cell with pure HTML and CSS, and without implying a specific
meaning, please tell me.

Missing feature reported by <Oliver dot Corff at email dot de>.

Revision 1.36 / (download) - annotate - [select for diffs], Tue Aug 10 12:55:04 2021 UTC (2 years, 7 months ago) by schwarze
Branch: MAIN
Changes since 1.35: +2 -5 lines
Diff to previous 1.35 (unified)

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.35 / (download) - annotate - [select for diffs], Sun May 16 23:18:35 2021 UTC (2 years, 10 months ago) by schwarze
Branch: MAIN
Changes since 1.34: +3 -1 lines
Diff to previous 1.34 (unified)

Implement the layout specification "a" (left justify with 1em indentation)
in HTML output mode; before this patch, the indentation was missing.
Terminal output already supported the "a" specifier since 2010.
Issue reported and patch tested by Oliver dot Corff at email dot de.

Revision 1.34 / (download) - annotate - [select for diffs], Sun May 16 18:11:20 2021 UTC (2 years, 10 months ago) by schwarze
Branch: MAIN
Changes since 1.33: +11 -3 lines
Diff to previous 1.33 (unified)

implement the tbl(7) layout modifiers "b" (bold) and "i" (italic)
in HTML output mode, similar to tbl_term.c, function tbl_word();
issue reported by Oliver dot Corff at email dot de

Revision 1.33 / (download) - annotate - [select for diffs], Sun Mar 17 18:21:45 2019 UTC (5 years ago) by schwarze
Branch: MAIN
Changes since 1.32: +2 -1 lines
Diff to previous 1.32 (unified)

The header file "html.h" uses enum roff_tok,
so "roff.h" must be included before it.
Diff from bcallah@ tweaked by me;
he found the bug by compiling with pcc.

Revision 1.32 / (download) - annotate - [select for diffs], Sun Jan 6 04:55:09 2019 UTC (5 years, 2 months ago) by schwarze
Branch: MAIN
CVS Tags: VERSION_1_14_5
Changes since 1.31: +2 -1 lines
Diff to previous 1.31 (unified)

Finally, represent the man(7) .PP and .HP macros by the natural
choice, which is the <p> HTML element.  On top of the previous
fill-mode improvements, the key to making this possible is to
automatically close the <p> when required: before headers, subsequent
paragraphs, lists, indented blocks, synopsis blocks, tbl(7) blocks,
and before blocks using no-fill mode.

In man(7) documents, represent the .sp request by a blank line in
no-fill mode and in the same way as .PP in fill mode.

Revision 1.31 / (download) - annotate - [select for diffs], Sun Dec 16 00:17:02 2018 UTC (5 years, 3 months ago) by schwarze
Branch: MAIN
Changes since 1.30: +2 -1 lines
Diff to previous 1.30 (unified)

Yet another round of improvements to manual font selection.

Unify handling of \f and .ft.
Support \f4 (bold+italic).
Support ".ft BI" and ".ft CW" for terminal output.
Support the .ft request in HTML output.
Reject the bogus fonts \f(C1, \f(C2, \f(C3, and \f(CP.
In regress.pl, only strip leading whitespace in math mode.

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

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.29 / (download) - annotate - [select for diffs], Mon Nov 26 21:06:02 2018 UTC (5 years, 3 months ago) by schwarze
Branch: MAIN
Changes since 1.28: +123 -67 lines
Diff to previous 1.28 (unified)

Implement tbl(7) lines in -T html output,
as far as they are on the edges of table cells
rather than going through the middle of cells:

* the box, doublebox, and allbox options;
* the | and || layout modifiers;
* and the _ and = data lines;
- but not yet _ and = in individual layout and data cells.

Missing feature reported by Pali dot Rohar at gmail dot com.

Revision 1.28 / (download) - annotate - [select for diffs], Mon Nov 26 01:51:46 2018 UTC (5 years, 3 months ago) by schwarze
Branch: MAIN
Changes since 1.27: +5 -17 lines
Diff to previous 1.27 (unified)

Simplify writing of tbl(7) cells by using the new feature of passing
a NULL pointer for the value of a style attribute, in which case
the attribute is omitted from the HTML element.
Minus 12 lines of ugly and repetitive code, no functional change.

Revision 1.27 / (download) - annotate - [select for diffs], Sun Nov 25 21:17:34 2018 UTC (5 years, 3 months ago) by schwarze
Branch: MAIN
Changes since 1.26: +12 -7 lines
Diff to previous 1.26 (unified)

Let cells containing nothing but \^ extend the cell above.
Missing feature reported by Pali dot Rohar at gmail dot com.

Revision 1.26 / (download) - annotate - [select for diffs], Sun Nov 25 19:24:20 2018 UTC (5 years, 3 months ago) by schwarze
Branch: MAIN
Changes since 1.25: +40 -17 lines
Diff to previous 1.25 (unified)

In tbl(7) -T html output,
span cells horizontally and vertically as requested by the layout.
Does not handle spans requested in the data section yet.

To be able to do this, record the number of rows spanned
in the first data cell (struct tbl_dat) of a vertical span.

Missing feature reported by Pali dot Rohar at gmail dot com.

Revision 1.25 / (download) - annotate - [select for diffs], Sat Nov 24 23:03:18 2018 UTC (5 years, 3 months ago) by schwarze
Branch: MAIN
Changes since 1.24: +36 -6 lines
Diff to previous 1.24 (unified)

Implement horizontal and vertical alignment of tbl(7) cell content
in -T html output.  This does not handle spanned cells yet.
Missing feature reported by Pali dot Rohar at gmail dot com.

Revision 1.24 / (download) - annotate - [select for diffs], Mon Jun 25 13:45:57 2018 UTC (5 years, 8 months ago) by schwarze
Branch: MAIN
CVS Tags: VERSION_1_14_4
Changes since 1.23: +1 -10 lines
Diff to previous 1.23 (unified)

Do not write <colgroup> elements.  Their only purpose is to enforce
author-specified column widths, which can harm responsive design and
provide no real benefit: HTML rendering engines usually do just
fine automatically selecting appropriate column widths.

Revision 1.23 / (download) - annotate - [select for diffs], Mon Jul 31 16:14:10 2017 UTC (6 years, 7 months ago) by schwarze
Branch: MAIN
CVS Tags: VERSION_1_14_3
Changes since 1.22: +4 -1 lines
Diff to previous 1.22 (unified)

Ignore explicitly specified negative column widths rather than
wrapping around to huge numbers and risking memory exhaustion;
fixes Debian ps(1).  Bug reported by Dr. Markus Waldeck.

Revision 1.22 / (download) - annotate - [select for diffs], Mon Jun 12 20:14:18 2017 UTC (6 years, 9 months ago) by schwarze
Branch: MAIN
CVS Tags: VERSION_1_14_2
Changes since 1.21: +2 -2 lines
Diff to previous 1.21 (unified)

fix column width calculation for text block cells

Revision 1.21 / (download) - annotate - [select for diffs], Thu Jun 8 18:11:22 2017 UTC (6 years, 9 months ago) by schwarze
Branch: MAIN
Changes since 1.20: +30 -3 lines
Diff to previous 1.20 (unified)

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.20 / (download) - annotate - [select for diffs], Sun Feb 5 18:15:39 2017 UTC (7 years, 1 month ago) by schwarze
Branch: MAIN
CVS Tags: VERSION_1_14_1, VERSION_1_13
Changes since 1.19: +4 -3 lines
Diff to previous 1.19 (unified)

Improve <table> syntax:
The <col> element can only appear inside <colgroup>, so use <colgroup>.
The <tbody> element is optional and useless, so don't use it.
Even if we would ever need <thead> or <tfoot>, <tbody> would still be
optional and useless; besides, we will likely never need <thead> or <tfoot>,
simply because our languages don't support such functionality.

Revision 1.19 / (download) - annotate - [select for diffs], Tue Jan 17 01:47:51 2017 UTC (7 years, 2 months ago) by schwarze
Branch: MAIN
Changes since 1.18: +9 -21 lines
Diff to previous 1.18 (unified)

Simplify the usage of print_otag() by making it accept a variable
number of arguments.

Delete struct htmlpair and all the PAIR_*() macros.
Delete enum htmlattr, handle that in print_otag() instead.

Minus 190 lines of code; no functional change except better ordering
of attributes (class before style) in three cases.

Revision 1.18 / (download) - annotate - [select for diffs], Mon Oct 12 00:08:16 2015 UTC (8 years, 5 months ago) by schwarze
Branch: MAIN
CVS Tags: VERSION_1_13_4
Changes since 1.17: +1 -2 lines
Diff to previous 1.17 (unified)

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.17 / (download) - annotate - [select for diffs], Tue Oct 6 18:32:20 2015 UTC (8 years, 5 months ago) by schwarze
Branch: MAIN
Changes since 1.16: +4 -3 lines
Diff to previous 1.16 (unified)

modernize style: "return" is not a function

Revision 1.16 / (download) - annotate - [select for diffs], Fri Jan 30 17:32:16 2015 UTC (9 years, 1 month ago) by schwarze
Branch: MAIN
CVS Tags: VERSION_1_13_3
Changes since 1.15: +3 -3 lines
Diff to previous 1.15 (unified)

Delete the redundant tbl span flags, just inspect the actual data
where needed, which is less fragile.
This fixes a subtle NULL pointer access to tp->tbl.cols:
Due to a bug in the man(7) parser, the first span of a table can
end up in a .TP head, in which case tblcalc() was never called.
Found by jsg@ with afl.

Revision 1.15 / (download) - annotate - [select for diffs], Fri Jan 30 04:11:50 2015 UTC (9 years, 1 month ago) by schwarze
Branch: MAIN
Changes since 1.14: +8 -8 lines
Diff to previous 1.14 (unified)

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.14 / (download) - annotate - [select for diffs], Fri Jan 30 02:09:04 2015 UTC (9 years, 1 month ago) by schwarze
Branch: MAIN
Changes since 1.13: +7 -7 lines
Diff to previous 1.13 (unified)

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.13 / (download) - annotate - [select for diffs], Tue Oct 14 02:16:06 2014 UTC (9 years, 5 months ago) by schwarze
Branch: MAIN
CVS Tags: VERSION_1_13_2
Changes since 1.12: +2 -2 lines
Diff to previous 1.12 (unified)

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.12 / (download) - annotate - [select for diffs], Sun Aug 10 23:54:41 2014 UTC (9 years, 7 months ago) by schwarze
Branch: MAIN
CVS Tags: VERSION_1_12_4, VERSION_1_12
Changes since 1.11: +3 -3 lines
Diff to previous 1.11 (unified)

Get rid of HAVE_CONFIG_H, it is always defined; idea from libnbcompat.
Include <sys/types.h> where needed, it does not belong in config.h.
Remove <stdio.h> from config.h; if it is missing somewhere, it should
be added, but i cannot find a *.c file where it is missing.

Revision 1.11 / (download) - annotate - [select for diffs], Sun Apr 20 16:46:05 2014 UTC (9 years, 11 months ago) by schwarze
Branch: MAIN
CVS Tags: VERSION_1_13_1
Changes since 1.10: +5 -6 lines
Diff to previous 1.10 (unified)

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

Revision 1.10 / (download) - annotate - [select for diffs], Sun May 27 17:54:54 2012 UTC (11 years, 9 months ago) by schwarze
Branch: MAIN
CVS Tags: VERSION_1_12_3, VERSION_1_12_2
Changes since 1.9: +6 -14 lines
Diff to previous 1.9 (unified)

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

"Please check them in and I'll look into them later!" kristaps@

Revision 1.9 / (download) - annotate - [select for diffs], Sun Sep 18 14:14:15 2011 UTC (12 years, 6 months ago) by schwarze
Branch: MAIN
CVS Tags: VERSION_1_12_1, VERSION_1_12_0
Changes since 1.8: +2 -2 lines
Diff to previous 1.8 (unified)

forgotten Copyright bumps; no code change
found while syncing to OpenBSD

Revision 1.8 / (download) - annotate - [select for diffs], Sun Jul 17 15:43:00 2011 UTC (12 years, 8 months ago) by kristaps
Branch: MAIN
CVS Tags: VERSION_1_11_7, VERSION_1_11_6, VERSION_1_11_5
Changes since 1.7: +2 -2 lines
Diff to previous 1.7 (unified)

Fix copyright email.

Revision 1.7 / (download) - annotate - [select for diffs], Thu Jan 13 14:30:13 2011 UTC (13 years, 2 months ago) by kristaps
Branch: MAIN
CVS Tags: VERSION_1_11_4, VERSION_1_11_3, VERSION_1_11_2, VERSION_1_11_1, VERSION_1_10_10
Changes since 1.6: +62 -45 lines
Diff to previous 1.6 (unified)

Change how -Thtml behaves with tables: use multiple rows, with widths
set by COL, until an external macro is encountered.  At this point in
time, close out the table and process the macro.  When the first table
row is again re-encountered, re-start the table.  This requires a bit of
tracking added to "struct html", but the change is very small and
follows the logic of meta-fonts.  This all follows a bug-report by
joerg@.

Revision 1.6 / (download) - annotate - [select for diffs], Tue Jan 11 14:12:01 2011 UTC (13 years, 2 months ago) by kristaps
Branch: MAIN
Changes since 1.5: +12 -4 lines
Diff to previous 1.5 (unified)

Add support for "^" vertical spanners.  Unlike GNU tbl, raise
error-class messages when data is being ignored by specifying it in "^"
cells (either as-is or in blocks).

Also note again that horizontal spanners aren't really supported...

Revision 1.5 / (download) - annotate - [select for diffs], Thu Jan 6 12:31:39 2011 UTC (13 years, 2 months ago) by kristaps
Branch: MAIN
CVS Tags: VERSION_1_10_9
Changes since 1.4: +42 -39 lines
Diff to previous 1.4 (unified)

Restructured tbl_html() function so that we always clean up our columns.

Revision 1.4 / (download) - annotate - [select for diffs], Thu Jan 6 11:55:39 2011 UTC (13 years, 2 months ago) by kristaps
Branch: MAIN
Changes since 1.3: +49 -2 lines
Diff to previous 1.3 (unified)

Make -T[x]html for tables structure cells with a width.  I don't
anticipate doing much more than this for the coming release.

Also, remove "base" part of struct html (not used anywhere) and put some
comments in struct html.h.

Revision 1.3 / (download) - annotate - [select for diffs], Wed Jan 5 13:00:11 2011 UTC (13 years, 2 months ago) by kristaps
Branch: MAIN
Changes since 1.2: +6 -3 lines
Diff to previous 1.2 (unified)

Give tables an HTML class.

Revision 1.2 / (download) - annotate - [select for diffs], Tue Jan 4 15:02:00 2011 UTC (13 years, 2 months ago) by kristaps
Branch: MAIN
Changes since 1.1: +3 -2 lines
Diff to previous 1.1 (unified)

Support `T{' and `T}' data blocks.  When a standalone `T{' is
encountered as a line's last data cell, move into TBL_PART_CDATA mode
whilst leaving the cell's designation as TBL_DATA_NONE.  When new data
arrives that's not a standalone `T}', append it to the cell contends.
Close out and warn appropriately.

Revision 1.1 / (download) - annotate - [select for diffs], Tue Jan 4 10:29:41 2011 UTC (13 years, 2 months ago) by kristaps
Branch: MAIN

Add skeleton for -T[x]html tbl stuff.  Also start to put in some bits about
the up-coming version, although we're not quite there yet.

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