summaryrefslogtreecommitdiffstats
path: root/tbl_data.c
Commit message (Collapse)AuthorAgeFilesLines
* 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.
* Add some final bits necessary in the upcoming -Tascii tbl stuff.Kristaps Dzonsons2011-01-021-1/+5
|
* Churn to get parts of 'struct tbl' visible from mandoc.h: rename theKristaps Dzonsons2011-01-021-4/+4
| | | | | | | existing 'struct tbl' as 'struct tbl_node', then move all option stuff into a 'struct tbl' in mandoc.h. This conflicted with a structure in chars.c, which was renamed.
* Add a warning if a data cell has no layout. Also make -Ttree show thisKristaps Dzonsons2011-01-011-0/+3
| | | | with a little star next to the entry (yeah, this is mostly for testing).
* Add bits for compilation on Mac.Kristaps Dzonsons2011-01-011-0/+1
|
* Make some bit-flags into enums as they should be. Make printing of -TtreeKristaps Dzonsons2011-01-011-8/+10
| | | | tables a little bit smarter.
* Switch on tbl rows being added to the parse stream. Here we go!Kristaps Dzonsons2011-01-011-1/+1
|
* Assign layout cells to parsed data. This follows primarily fromKristaps Dzonsons2010-12-301-0/+31
| | | | tbl.bsd.lv, although it has been reimplemented.
* Move clean-up of parsed tbl nodes into the tbl_clear() function, calledKristaps Dzonsons2010-12-301-5/+11
| | | | once per invocation.
* Initial check-in of table data-row processing. For the time being, thisKristaps Dzonsons2010-12-291-0/+96
parses table data then throws it away immediately. It does not yet try to cross-check data rows against layout or anything. This copied more or less completely from tbl.bsd.lv.