summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc/tbl_data.c
AgeCommit message (Collapse)Author
2015-10-06modernize style: "return" is not a function; ok cmp(1)Ingo Schwarze
2015-04-19More than one data field may follow T} on the same input line.Ingo Schwarze
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).
2015-01-30Delete the redundant tbl span flags, just inspect the actual dataIngo Schwarze
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.
2015-01-30Abolish struct tbl_head and replace it by an "int col" member inIngo Schwarze
struct tbl_cell. No functional change, minus 40 lines of code.
2015-01-30Auditing the tbl(7) code for more NULL pointer accesses, i came outIngo Schwarze
empty-handed; so this is just KNF and some code simplifications, no functional change.
2015-01-28* Polish tbl(7) error reporting.Ingo Schwarze
* 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.
2015-01-28For now, it can't be helped that mandoc tbl(7) ignores high-level macros,Ingo Schwarze
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.
2015-01-27Multiple parser and formatter fixes for line drawing in tbl(7).Ingo Schwarze
* 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.
2015-01-21blank lines in tables do not need special handling; simplifies codeIngo Schwarze
and reduces groff/mandoc differences in base by about 1%
2014-11-28Add some missing OpenBSD RCS markersIngo Schwarze
and a few missing <sys/types.h> inclusions; no code change.
2014-04-23Audit strlcpy(3)/strlcat(3) usage.Ingo Schwarze
* 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.
2014-04-20KNF: case (FOO): -> case FOO, remove /* LINTED */ and /* ARGSUSED */,Ingo Schwarze
remove trailing whitespace and blanks before tabs, improve some indenting; no functional change
2014-03-21The files mandoc.c and mandoc.h contained both specialised low-levelIngo Schwarze
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.
2014-01-05Merge NetBSD rev. 1.4:Ingo Schwarze
Rename static function data() to getdata() to work around bugs in the NetBSD PPC64 toolchain. Original author of the patch: Christos Zoulas <christos@NetBSD>. Received via Joerg Sonnenberger <joerg@NetBSD>.
2013-06-01If a table contained at least one complete lineIngo Schwarze
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.
2013-05-31The name "struct tbl" was badly misleading for two reasons:Ingo Schwarze
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.
2012-05-26Do not handle vertical lines as additional tbl(7) columns,Ingo Schwarze
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().
2011-04-24Merge version 1.11.1:Ingo Schwarze
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.
2011-04-21Merge version 1.10.10:Ingo Schwarze
lots of cleanup and maintenance work by kristaps@. - move some main.c globals into struct curparse - move mandoc_*alloc to mandoc.h such that all code can use them - make mandoc_isdelim available to formatting frontends - dissolve mdoc_strings.c, move the code where it is used - make all error reporting functions void, their return values were useless - and various minor cleanups and fixes
2011-02-10Tbl code maintenance by kristaps@.Ingo Schwarze
- Remember the line-number of a tbl_span, and use it in messages. - Put *_span_alloc() functions right into the *_addspan() ones, since these are the only places they are called from.
2011-01-25Since tbl_data() can now produce multiple spans, let parsebuf()Ingo Schwarze
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@
2011-01-25Do not skip data after horizontal lines in the layout.Ingo Schwarze
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@
2011-01-16Various tbl improvements from kristaps@:Ingo Schwarze
* horizontal lines do not consume layout lines * skip excessive data cells * prepare rendering of spanned cells * support vertical spans
2011-01-09Sync tbl handling to bsd.lv release 1.10.9:Ingo Schwarze
* .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@.
2011-01-04Merge kristaps@' cleaner tbl integration, removing mine;Ingo Schwarze
there are still a few bugs, but fixing these will be easier in tree.
2010-10-15Allow blank lines and ignore comments in tbl data.Ingo Schwarze
This finally allows terminfo(5) to build. Now we can build all man(7)-tbl(1) in base without loss of information, though some still look ugly.
2010-10-15Move tbl output from plain stdio to mandoc terminal output routines.Ingo Schwarze
This fixes (1) all escape sequences and (2) some aspects of indentation. Table column widths are still way off, though. "move forward" deraadt@
2010-10-15Import tbl parser and renderer written by kristaps@.Ingo Schwarze
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.