summaryrefslogtreecommitdiffstats
path: root/tbl_data.c
Commit message (Collapse)AuthorAgeFilesLines
* Quirk-compatibility with GNU tbl(1):Ingo Schwarze2021-09-101-8/+11
| | | | | | | With the "nospaces" option, skip space characters before and after "T{", in addition to skipping those at the beginning and end of data cells. Minor issue reported by <Oliver dot Corff at email dot de>.
* In a tbl(7) having the "nospaces" option, skip space charactersIngo Schwarze2021-09-101-0/+3
| | | | | | | not only at the end of data cells, but also after "T}", aligning the behaviour of the parser with GNU tbl(1). Issue reported by <Oliver dot Corff at email dot de>.
* we already parse the GNU tbl(7) "nospaces" option,Ingo Schwarze2021-09-071-8/+17
| | | | so let it have the intended effect, too
* Support two-character font names (BI, CW, CR, CB, CI)Ingo Schwarze2021-08-101-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* When looking for column separators on tbl(7) data lines, properly skipIngo Schwarze2021-05-181-3/+7
| | | | | | escape sequences; do not misinterpret bytes from the middle of escape sequence names or arguments as column separators. Bug reported and patch tested by Oliver dot Corff at email dot de.
* When looking for the last layout row used, we need to look at the layoutIngo Schwarze2021-05-151-4/+5
| | | | | | | | | | | | | | row used for the previous data line containing data, not at the previous data line outright, which might be a horizontal ruler. If it is, do not restart from the first layout row but still proceed to the next data row, which may have been just read from T&. Bug originally reported by Oliver dot Corff at email dot de on groff at gnu dot org: https://lists.gnu.org/archive/html/groff/2021-03/msg00003.html and forwarded to me by bentley@. Patch OK'ed by bentley@ back in April.
* When autogenerating one layout cell from a data cell just beyond theIngo Schwarze2020-01-111-0/+2
| | | | | | | | | last layout cell that was explicitly specified, properly initialize the spacing attribute to indicate that the default is to be used. Failing to do so and leaving the spacing at zero in this case caused misformatting when another row further down the table had even more explicitly specified cells. Bug found while trying to write regression tests for tbl_term.c rev. 1.73.
* ignore empty request lines in the table data reader;Ingo Schwarze2019-02-091-9/+22
| | | | fixing a minibug reported by bentley@
* Almost mechanical diff to remove the "struct mparse *" argumentIngo Schwarze2018-12-141-5/+5
| | | | | | | | 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.
* Major cleanup; may imply minor changes in edge cases of error reporting.Ingo Schwarze2018-12-141-0/+1
| | | | | | | | | | | 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.
* Cleanup, no functional change:Ingo Schwarze2018-12-131-1/+1
| | | | | Move tbl(7)-specific parser internals out of libroff.h. Move some tbl(7)-internal processing from roff.c to tbl.c.
* 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.
* Let cells containing nothing but \^ extend the cell above.Ingo Schwarze2018-11-251-9/+16
| | | | Missing feature reported by Pali dot Rohar at gmail dot com.
* In tbl(7) -T html output,Ingo Schwarze2018-11-251-5/+42
| | | | | | | | | | 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.
* Simplify by creating struct roff_node syntax tree nodes for tbl(7)Ingo Schwarze2017-07-081-5/+3
| | | | | | | | | | | | 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.
* It turns out association of tbl spans with layout rows is simpler thanIngo Schwarze2017-07-041-51/+23
| | | | i thought. Fixing a bug in curs_addch(3) and minus 25 lines of code.
* Multiple tbl(7) improvements:Ingo Schwarze2017-06-161-50/+79
| | | | | | | | | | | | * 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.
* Implement w layout specifier (minimum column width).Ingo Schwarze2017-06-081-1/+2
| | | | | Improve width calculation of text blocks. Reduces the groff/mandoc diff in Base+Xenocara by about 800 lines.
* modernize style: "return" is not a functionIngo Schwarze2015-10-061-4/+4
|
* More than one data field may follow T} on the same input line.Ingo Schwarze2015-04-191-1/+2
| | | | | | | | Issue found by Christian Neukirchen <chneukirchen at gmail dot com> in the socket(2) manual on Linux. Also fixes major rendering bugs (including partial loss of content) in XkbChangeControls(3), XkbFreeClientMap(3), XkbGetMap(3), XkbKeyNumGroups(3), and XkbSetMap(3).
* Delete the redundant tbl span flags, just inspect the actual dataIngo Schwarze2015-01-301-1/+0
| | | | | | | | 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-7/+2
| | | | 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-44/+30
| | | | | empty-handed; so this is just KNF and some code simplifications, no functional change.
* * Polish tbl(7) error reporting.Ingo Schwarze2015-01-281-9/+9
| | | | | | * Do not print out macro names in tbl(7) data blocks. * Like with GNU tbl, let empty tables cause a blank line. * Avoid producing empty tables in -Tman.
* For now, it can't be helped that mandoc tbl(7) ignores high-level macros,Ingo Schwarze2015-01-281-7/+2
| | | | | | 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.
* Multiple parser and formatter fixes for line drawing in tbl(7).Ingo Schwarze2015-01-271-7/+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.
* blank lines in tables do not need special handling; simplifies codeIngo Schwarze2015-01-211-22/+12
| | | | and reduces groff/mandoc differences in OpenBSD base by about 1%
* Get rid of HAVE_CONFIG_H, it is always defined; idea from libnbcompat.Ingo Schwarze2014-08-101-2/+2
| | | | | | 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.
* Audit strlcpy(3)/strlcat(3) usage.Ingo Schwarze2014-04-231-2/+2
| | | | | | | | | | | | | * Repair three instances of silent truncation, use asprintf(3). * Change two instances of strlen(3)+malloc(3)+strlcpy(3)+strlcat(3)+... to use asprintf(3) instead to make them less error prone. * Cast the return value of four instances where the destination buffer is known to be large enough to (void). * Completely remove three useless instances of strlcpy(3)/strlcat(3). * Mark two places in -Thtml with XXX that can cause information loss and crashes but are not easy to fix, requiring design changes of some internal interfaces. * The file mandocdb.c remains to be audited.
* KNF: case (FOO): -> case FOO:, remove /* LINTED */ and /* ARGSUSED */,Ingo Schwarze2014-04-201-19/+19
| | | | | remove trailing whitespace and blanks before tabs, improve some indenting; no functional change
* The files mandoc.c and mandoc.h contained both specialised low-levelIngo Schwarze2014-03-231-0/+1
| | | | | | | 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.
* Merge NetBSD's r1.4: Rename data to getdata to work around bugs in theJoerg Sonnenberger2014-01-051-4/+4
| | | | PPC64 toolchain.
* If a table contained at least one complete lineIngo Schwarze2013-06-011-1/+1
| | | | | | | | | | | | | | | | | | | | and on its last line, the first T{ remained unclosed, roff_parseln() never returned ROFF_TBL for that last line, so {man,mdoc}_addspan() never got called for that last line, so we ended up with a table where no line associated with a node had TBL_SPAN_LAST set, so tbl_term() never free()'d the cols in struct roffcol, so tblcalc() crashed on the NULL == tbl->cols assertion when starting the *next* table in the same file. Fix this by returning ROFF_TBL as soon as we open a data cell, not only when finishing it - as explained above, it may never get properly closed but instead be interrupted by .TE. Problem reported by bentley@ in latex2man.1. I love it when bugs take half a day to debug but the fix turns out to be flipping one single bit in the source code.
* The name "struct tbl" was badly misleading for two reasons:Ingo Schwarze2013-05-311-1/+1
| | | | | | | 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.
* Do not handle vertical lines as additional tbl(7) columns,Ingo Schwarze2012-05-271-4/+2
| | | | | | | | | | | | | | | | 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@
* Consolidate messages. Have all parse-time messages (in libmdoc,Kristaps Dzonsons2011-03-201-4/+7
| | | | | | | | | libroff, etc., etc.) route into mandoc_msg() and mandoc_vmsg(), for the time being in libmandoc.h. This requires struct mparse to be passed into the allocation routines instead of mandocmsg and a void pointer. Then, move some of the functionality of the old mmsg() into read.c's mparse_mmsg() (check against wlevel and setting of file_status) and use main.c's mmsg() as simply a printing tool.
* Make lint shut up a little bit.Kristaps Dzonsons2011-03-151-2/+4
|
* Let the line-number of a tbl_span be remembered.Kristaps Dzonsons2011-02-061-8/+9
|
* Since tbl_data() can now produce multiple spans, let parsebuf()Ingo Schwarze2011-01-251-0/+1
| | | | | | | generate man(7) or mdoc(7) nodes for all these spans, not only for the last one. Restores the horizontal lines in the cpu(4/hppa) tables. ok kristaps@
* Do not skip data after horizontal lines in the layout.Ingo Schwarze2011-01-251-16/+44
| | | | | | | | | | Instead, let one line of input data add two new spans to the tbl tree during one single call of tbl_data(). Note that this causes the horizontal line to get parsed into the tbl tree, but not yet used in the output, which will be fixed next. Avoids data loss in cpu(4/hppa). ok kristaps@
* Add support for "^" vertical spanners. Unlike GNU tbl, raiseKristaps Dzonsons2011-01-111-1/+5
| | | | | | | 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...
* Clarify what members may be NULL or not in calculating widths. MakeKristaps Dzonsons2011-01-101-2/+3
| | | | | sure signedness is correct. Verify that layouts MUST exit for data cells.
* Make dp->string always consist of a value.Kristaps Dzonsons2011-01-101-1/+2
|
* First, make extra data cells be thrown away. This makes "dp->layout"Kristaps Dzonsons2011-01-101-6/+23
| | | | | | | | | | | | always hold, which cleans up the table stuff a bit. Second, set a "spans" value per data cell consisting of the number of skipped TBL_CELL_SPAN layout cells. Third, make tbl_term.c understand how to skip over spanned sections when iterating over the header queue. What remains is to calculate the widths of spanned cells.
* When a row of data is being parsed and it's a line or double-lineKristaps Dzonsons2011-01-091-3/+9
| | | | | | | (instead of data), re-use the last "layout" pointer instead of advancing to the next one. This fixes a segfault report by joerg@.
* Fixes: T} can be followed by a delimiter then more data. Make thisKristaps Dzonsons2011-01-071-4/+16
| | | | | | | | | work and add documentation for it. Also make tbl_term() not puke if the number of data cells is less than the number of layout cells (which happens from time to time). This still needs work because we should pad out empty cells so that the borders all work out.
* Quiesce lint with some type handling. Does not change anything.Kristaps Dzonsons2011-01-071-0/+1
|
* Tiny bits in place for tbl horizontal spans. This will wait for the nextKristaps Dzonsons2011-01-071-2/+6
| | | | release to be implemented in full.
* Support `T{' and `T}' data blocks. When a standalone `T{' isKristaps Dzonsons2011-01-041-5/+52
| | | | | | | 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.
* Fix to make horizontal spanners in the layout be properly printed.Kristaps Dzonsons2011-01-041-0/+5
| | | | | | | mandoc also now warns (so does tbl(1)) if a horizontal spanner is specified along with data. While here, fix up some documentation and uncomment the tbl reference.