aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/tbl_term.c
Commit message (Collapse)AuthorAgeFilesLines
* The GNU tbl(1) program contained in the groff package internallyIngo Schwarze2020-10-251-12/+1
| | | | | | | | | | | | | | | | | | uses roff(7) tabulator settings to implement tables, and it used to leak the changed tabulator settings from tables to the subsequent roff(7) code. In mandoc/tbl_term.c rev. 1.54 (June 17, 2017), code was added to be bug-compatible with groff. In commit d0e03cf6 (Oct 20, 2020), GNU tbl(1) changed behaviour to save the tabulator settings before starting a table and restore them afterwards. Adjust mandoc for compatibility. Since mandoc implements tables without using roff(7) tabulator settings, saving and restoring tabulator settings is not needed in mandoc. Simply deleting the code that changed tabulator settings by reverting tbl_term.c rev. 1.54 is sufficient in mandoc. Also adjust the desired output of the regression tests to match the new behaviour of both groff and mandoc.
* Fix a logic error:Ingo Schwarze2020-01-111-14/+13
| | | | | | | | | | | | | When both the first and the third column are spans, do not use the number of columns of the span starting in column two for the span starting in column zero. With afl, Jan Schreiber <jes at posteo dot de> found cases where this caused NULL pointer accesses because too many layout cells were consumed. While here, make the code more similar at the three places that iterate over data cells.
* delete trailing whitespace and space-tab sequences; no code change;Ingo Schwarze2019-07-011-2/+2
| | | | | patch from Michal Nowak <mnowak at startmail dot com> who found these with git pbchk in the illumos tree
* Do not access a NULL pointer if a table contains a horizontal lineIngo Schwarze2019-06-111-5/+11
| | | | | | next to a table line having fewer columns than the table as a whole. Bug found by Stephen Gregoratto <dev at sgregoratto dot me> with aerc-config(5).
* fix a NULL pointer access on empty tbl(7) data cellsIngo Schwarze2019-03-181-3/+5
| | | | that bentley@ found in syncthing-bep(7)
* When drawing a horizontal line in tbl(7) UTF-8 output, it is notIngo Schwarze2019-03-161-13/+18
| | | | | | | | | | | | | sufficient to look at two data rows, but up to three are needed: the one above to identify vertical lines branching off upward, the row itself (in case the line is in a data row rather than a layout line) to figure out the horizontal line style, and the row below to identify vertical lines branching off downward. As an example, bentley@ reported from the mpv(1) manual page that in a tbl(7) having a vertical line in the middle and a horizontal line in the bottom data row, the vertical line extended below the bottom horizontal line.
* The horizontal line in a data cell containing only "_" or "="Ingo Schwarze2019-02-091-48/+45
| | | | | connects to the horizontally adjacent vertical line or cell; fixing a bug reported by bentley@.
* Fix tbl(7) centering in mdoc(7) documents.Ingo Schwarze2019-01-311-4/+8
| | | | | | | | | | Since resetting of offsets works quite differently in the mdoc(7) and man(7) formatters, the tbl(7) formatter needs to save the global offset on entry and restore it on exit. The additional indentation needed for table centering has to be added to its own offset variable and applied to each line of the table, rather than only to the first. Bug found by bentley@ in emulators/fceux(6).
* Cleanup, no functional change:Ingo Schwarze2018-12-121-1/+2
| | | | | No need to expose the tbl(7) syntax tree data structures everywhere. Move them to their own include file, "tbl.h", and improve comments.
* Do not draw horizontal lines through vertical spansIngo Schwarze2018-11-291-5/+19
| | | | | which are requested in the data section rather than in the layout. Mini-feature found in misc/pfm(1).
* Now that it is better understood how borders work,Ingo Schwarze2018-11-291-72/+106
| | | | | | | | | | | rewrite tbl_hrule() in a simpler way. Fix several bugs in the process. No more special flags, just use the existing TBL_OPT_* from mandoc.h. Reduce the number of tracked rows from three to two, which is more logical: one above the line and one below is sufficient to figure out crossings. No more magic quirks, all conditions are readily comprehensible now. Add comments.
* additional check needed after the previous (box drawing) patchIngo Schwarze2018-11-281-5/+8
|
* In -T utf8 output mode, render tbl(7) borders with the UnicodeIngo Schwarze2018-11-281-151/+318
| | | | | | | | | | | | | box drawing characters, U+2500 to U+257F. Originally suggested by bentley@ four years ago, reminded this summer by Pali Rohar. Binary and decimal arithmetics are boring, so let's use some ternary arithmetics for a change. That said, some other aspects are too complicated for my liking, so this could use some polishing in the future.
* In tbl(7) -T html output,Ingo Schwarze2018-11-251-18/+18
| | | | | | | | | | 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.
* Do alignment of non-numeric strings in numeric cells the same wayIngo Schwarze2018-08-191-26/+51
| | | | | | as groff, and also honour the explicit alignment indicator "\&". This required an almost complete rewrite of both the measurement function and the formatter function for numeric cells.
* do not print horizontal lines inside vertical spansIngo Schwarze2018-08-191-7/+21
|
* Do not allocate a column for decimal points if all numbers are integers.Ingo Schwarze2018-08-181-7/+5
|
* Ignore explicitly specified negative column widths rather thanIngo Schwarze2017-07-311-2/+5
| | | | | wrapping around to huge numbers and risking memory exhaustion; fixes Debian ps(1). Bug reported by Dr. Markus Waldeck.
* Correctly handle horizontal spans at the beginning of rows,Ingo Schwarze2017-07-081-9/+10
| | | | | | | | fixing an assertion failure found by jsg@ with afl(1). While here, also drop printing of whitespace in tbl_data() which makes no difference because column positioning code in term_tbl() already takes care of that.
* Implement spacing of columns as defined in the table layout;Ingo Schwarze2017-06-271-21/+28
| | | | | this is for example used by lftp(1) and, ironically, misused by our very own tbl(7) manual...
* tables leak tab settings to subsequent textIngo Schwarze2017-06-171-1/+12
|
* Multiple tbl(7) improvements:Ingo Schwarze2017-06-161-63/+176
| | | | | | | | | | | | * Do not discard data that lacks a matching layout cell but remains within the number of columns of the table as a whole. * Do not insert dummy data rows for any layout row starting with a horizontal line, but only for layout rows that would discard all the data on a matching non-empty data row. * Print horizontal lines specified in the layout even if there is no matching data cell. * Improve the logic for extending vertical lines to adjacent rows, for choosing cross marks versus line segments, and some related details.
* improve rounding rules for scaling unitsIngo Schwarze2017-06-141-2/+2
| | | | in horizontal orientation in the terminal formatter
* fix the interaction of the allbox option with spanned cells in the layoutIngo Schwarze2017-06-131-17/+32
|
* Two minor fixes for the "allbox" modifier:Ingo Schwarze2017-06-121-3/+6
| | | | | | 1. It does not reduce explicit "||" in the layout to "|". 2. It does not cause three horizontal lines at the end of a table, even if the table ends with an explicit "_" data line.
* implement the tbl(7) "allbox" option;Ingo Schwarze2017-06-121-2/+8
| | | | used for example by curs_getch(3) and GLwDrawingArea(3)
* fix column width calculation for text block cellsIngo Schwarze2017-06-121-2/+2
|
* Implement automatic line breakingIngo Schwarze2017-06-121-57/+157
| | | | | inside individual table cells that contain text blocks. This cures overlong lines in various Xenocara manuals.
* Implement w layout specifier (minimum column width).Ingo Schwarze2017-06-081-3/+9
| | | | | Improve width calculation of text blocks. Reduces the groff/mandoc diff in Base+Xenocara by about 800 lines.
* Prepare the terminal driver for filling multiple columns in parallel,Ingo Schwarze2017-06-071-7/+7
| | | | | | first step: split column data out of the terminal state struct into a new column state struct and use an array of such column state structs. No functional change.
* Implement the roff(7) .mc (right margin character) request.Ingo Schwarze2017-06-041-18/+9
| | | | | | The Tcl/Tk manual pages use this extensively. Delete the TERM_MAXMARGIN hack, it breaks .mc inside .nf; instead, implement a proper TERMP_BRNEVER flag.
* To make the code more readable, delete 283 /* FALLTHROUGH */ commentsIngo Schwarze2015-10-121-6/+1
| | | | | | 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.
* modernize style: "return" is not a functionIngo Schwarze2015-10-061-3/+3
|
* /* NOTREACHED */ after abort() is silly, delete itIngo Schwarze2015-09-261-2/+1
|
* Fix vertical spacing at the beginning of tables.Ingo Schwarze2015-03-061-4/+1
| | | | | | man(7) always prints a blank line, mdoc(7) doesn't. Problem in mdoc(7) reported by kristaps@. mdoc(7) part of the patch tested by kristaps@.
* Flush the line preceding a table before clearing the right margin,Ingo Schwarze2015-03-061-3/+4
| | | | | such that that line isn't output with unlimited width. Problem reported and fix OK by kristaps@.
* Use relative offsets instead of absolute pointers for the terminalIngo Schwarze2015-01-311-3/+3
| | | | | | font stack. The latter fail after the stack is grown with realloc(). Fixing an assertion failure found by jsg@ with afl some time ago (test case number 51).
* Delete the redundant tbl span flags, just inspect the actual dataIngo Schwarze2015-01-301-3/+3
| | | | | | | | 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.
* Abolish struct tbl_head and replace it by an "int col" member inIngo Schwarze2015-01-301-21/+16
| | | | struct tbl_cell. No functional change, minus 40 lines of code.
* Auditing the tbl(7) code for more NULL pointer accesses, i came outIngo Schwarze2015-01-301-5/+3
| | | | | empty-handed; so this is just KNF and some code simplifications, no functional change.
* implement the tbl(7) "center" layout optionIngo Schwarze2015-01-281-3/+19
|
* Multiple parser and formatter fixes for line drawing in tbl(7).Ingo Schwarze2015-01-271-124/+97
| | | | | | | | | | | | * 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.
* Prevent unsigned integer underflow when a number is too wideIngo Schwarze2014-12-241-4/+8
| | | | | for a table cell with an "nz" layout specification, causing essentially infinite output as found by jsg@ with afl.
* even if a table has zero columns, do not segfault in the formatter;Ingo Schwarze2014-10-141-2/+2
| | | | bug reported by bentley@
* Rudimentary implementation of the e, x, and z table layout modifiersIngo Schwarze2014-10-141-2/+2
| | | | | | | 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@.
* implement font modifiers in table layoutsIngo Schwarze2014-10-131-3/+19
|
* Get rid of HAVE_CONFIG_H, it is always defined; idea from libnbcompat.Ingo Schwarze2014-08-101-3/+3
| | | | | | 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.
* KNF: case (FOO): -> case FOO:, remove /* LINTED */ and /* ARGSUSED */,Ingo Schwarze2014-04-201-33/+33
| | | | | remove trailing whitespace and blanks before tabs, improve some indenting; no functional change
* Allow leading and trailing vertical lines,Ingo Schwarze2014-03-281-4/+6
| | | | | | | 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).
* The name "struct tbl" was badly misleading for two reasons:Ingo Schwarze2013-05-311-17/+17
| | | | | | | 1) This struct almost exclusively contains the table options. 2) Information about the table as a whole is actually in "struct tbl_node". Besides, "struct tbl" was almost impossible to search for. So rename it to "struct tbl_opts". No functional change.