Sortix volatile manual
This manual documents Sortix volatile, a development build that has not been officially released. You can instead view this document in the latest official manual.
NAME
tbl_alloc, tbl_read, tbl_restart, tbl_span, tbl_end, tbl_free — roff table parser library for mandocSYNOPSIS
#include <mandoc.h>#include <libmandoc.h>
#include <libroff.h>
tbl_alloc(int pos, int line, struct mparse *parse);
tbl_read(struct tbl_node *tbl, int ln, const char *p, int offs);
tbl_restart(int line, int pos, struct tbl_node *tbl);
tbl_span(struct tbl_node *tbl);
tbl_end(struct tbl_node **tblp);
tbl_free(struct tbl_node *tbl);
DESCRIPTION
This library is tightly integrated into the mandoc(1) utility and not designed for stand-alone use. The present manual is intended as a reference for developers working on mandoc(1).Data structures
Unless otherwise noted, all of the following data structures are defined in <mandoc.h> and are deleted in tbl_free().- struct tbl_node
-
This structure describes a complete table. It is defined in <libroff.h>, created in tbl_alloc(), and stored in the members first_tbl, last_tbl, and tbl of struct roff [roff.c].
- struct tbl_opts
- This structure describes the options of one table. It is used as a substructure of struct tbl_node and thus created and deleted together with it. It is filled in tbl_options().
- struct tbl_row
-
This structure describes one layout line in a table by maintaining a list of all the cells in that line. It is allocated and filled in row() [tbl_layout.c] and referenced from the layout member of struct tbl_node.
- struct tbl_cell
-
This structure describes one layout cell in a table, in particular its alignment, membership in spans, and usage for lines. It is allocated and filled in cell_alloc() [tbl_layout.c] and referenced from the first and last members of struct tbl_row.
- struct tbl_span
-
This structure describes one data line in a table by maintaining a list of all data cells in that line or by specifying that it is a horizontal line. It is allocated and filled in newspan() [tbl_data.c] which is called from tbl_data() and referenced from the first_span, current_span, and last_span members of struct tbl_node, and from the span members of struct man_node and struct mdoc_node from <man.h> and <mdoc.h>.
- struct tbl_dat
-
This structure describes one data cell in a table by specifying whether it contains a line or data, whether it spans additional layout cells, and by storing the data. It is allocated and filled in tbl_data() and referenced from the first and last members of struct tbl_span.
Interface functions
The following functions are implemented in tbl.c, and all callers in roff.c.- tbl_alloc()
- Allocates, initializes, and returns a new struct tbl_node. Called from roff_TS().
- tbl_read()
- Dispatches to tbl_option(), tbl_layout(), tbl_cdata(), and tbl_data(), see below. Called from roff_parseln().
- tbl_restart()
- Resets the part member of struct tbl_node to TBL_PART_LAYOUT. Called from roff_T_().
- tbl_span()
- On the first call, return the first struct tbl_span; for later calls, return the next one or NULL. Called from roff_span().
- tbl_end()
- Flags the last span as TBL_SPAN_LAST and clears the pointer passed as an argment. Called from roff_TE() and roff_endparse().
- tbl_free()
- Frees the specified struct tbl_node and all the tbl_row, tbl_cell, tbl_span, and tbl_dat structures referenced from it. Called from roff_free() and roff_reset().
Private functions
- int tbl_options(struct tbl_node *tbl, int ln, const char *p)
- Parses the options line into struct tbl_opts. Implemented in tbl_opts.c, called from tbl_read().
- int tbl_layout(struct tbl_node *tbl, int ln, const char *p)
- Allocates and fills one struct tbl_row for each layout line and one struct tbl_cell for each layout cell. Implemented in tbl_layout.c, called from tbl_read().
- int tbl_data(struct tbl_node *tbl, int ln, const char *p)
- Allocates one struct tbl_span for each data line and calls getdata() for each data cell. Implemented in tbl_data.c, called from tbl_read().
- int tbl_cdata(struct tbl_node *tbl, int ln, const char *p)
- Continues parsing a data line: When finding ‘T}’, switches back to TBL_PART_DATA mode and calls getdata() if there are more data cells on the line. Otherwise, appends the data to the current data cell. Implemented in tbl_data.c, called from tbl_read().
- int getdata(struct tbl_node *tbl, struct tbl_span *dp, int ln, const char *p, int *pos);
- Parses one data cell into one struct tbl_dat. Implemented in tbl_data.c, called from tbl_data() and tbl_cdata().