summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile7
-rw-r--r--eqn.c1
-rw-r--r--mandoc.h107
-rw-r--r--mandoc_headers.348
-rw-r--r--out.c1
-rw-r--r--roff.c3
-rw-r--r--tbl.31
-rw-r--r--tbl.c3
-rw-r--r--tbl.h122
-rw-r--r--tbl_data.c3
-rw-r--r--tbl_html.c2
-rw-r--r--tbl_layout.c3
-rw-r--r--tbl_opts.c1
-rw-r--r--tbl_term.c1
-rw-r--r--tree.c1
15 files changed, 179 insertions, 125 deletions
diff --git a/Makefile b/Makefile
index b3ec4469..e2f02a98 100644
--- a/Makefile
+++ b/Makefile
@@ -202,6 +202,7 @@ DISTFILES = INSTALL \
tag.h \
tbl.3 \
tbl.7 \
+ tbl.h \
term.h \
$(SRCS) \
$(TESTSRCS)
@@ -351,7 +352,8 @@ WWW_INCS = man.h.html \
mandoc_aux.h.html \
mansearch.h.html \
mdoc.h.html \
- roff.h.html
+ roff.h.html \
+ tbl.h.html
# === USER CONFIGURATION ===============================================
@@ -422,7 +424,7 @@ lib-install: libmandoc.a
mkdir -p $(DESTDIR)$(INCLUDEDIR)
mkdir -p $(DESTDIR)$(MANDIR)/man3
$(INSTALL_LIB) libmandoc.a $(DESTDIR)$(LIBDIR)
- $(INSTALL_LIB) man.h mandoc.h mandoc_aux.h mdoc.h roff.h \
+ $(INSTALL_LIB) man.h mandoc.h mandoc_aux.h mdoc.h roff.h tbl.h \
$(DESTDIR)$(INCLUDEDIR)
$(INSTALL_MAN) mandoc.3 mandoc_escape.3 mandoc_malloc.3 \
mansearch.3 mchars_alloc.3 tbl.3 $(DESTDIR)$(MANDIR)/man3
@@ -482,6 +484,7 @@ uninstall:
rm -f $(DESTDIR)$(INCLUDEDIR)/mandoc_aux.h
rm -f $(DESTDIR)$(INCLUDEDIR)/mdoc.h
rm -f $(DESTDIR)$(INCLUDEDIR)/roff.h
+ rm -f $(DESTDIR)$(INCLUDEDIR)/tbl.h
[ ! -e $(DESTDIR)$(INCLUDEDIR) ] || rmdir $(DESTDIR)$(INCLUDEDIR)
regress: all
diff --git a/eqn.c b/eqn.c
index 82fa5b49..48ce9d36 100644
--- a/eqn.c
+++ b/eqn.c
@@ -30,6 +30,7 @@
#include "mandoc_aux.h"
#include "mandoc.h"
#include "roff.h"
+#include "tbl.h"
#include "libmandoc.h"
#include "libroff.h"
diff --git a/mandoc.h b/mandoc.h
index 541e7d71..ed8a5847 100644
--- a/mandoc.h
+++ b/mandoc.h
@@ -1,7 +1,7 @@
/* $Id$ */
/*
* Copyright (c) 2010, 2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2010-2018 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2010, 2012-2018 Ingo Schwarze <schwarze@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -241,111 +241,6 @@ enum mandocerr {
MANDOCERR_MAX
};
-struct tbl_opts {
- char tab; /* cell-separator */
- char decimal; /* decimal point */
- int opts;
-#define TBL_OPT_CENTRE (1 << 0)
-#define TBL_OPT_EXPAND (1 << 1)
-#define TBL_OPT_BOX (1 << 2)
-#define TBL_OPT_DBOX (1 << 3)
-#define TBL_OPT_ALLBOX (1 << 4)
-#define TBL_OPT_NOKEEP (1 << 5)
-#define TBL_OPT_NOSPACE (1 << 6)
-#define TBL_OPT_NOWARN (1 << 7)
- int cols; /* number of columns */
- int lvert; /* width of left vertical line */
- int rvert; /* width of right vertical line */
-};
-
-enum tbl_cellt {
- TBL_CELL_CENTRE, /* c, C */
- TBL_CELL_RIGHT, /* r, R */
- TBL_CELL_LEFT, /* l, L */
- TBL_CELL_NUMBER, /* n, N */
- TBL_CELL_SPAN, /* s, S */
- TBL_CELL_LONG, /* a, A */
- TBL_CELL_DOWN, /* ^ */
- TBL_CELL_HORIZ, /* _, - */
- TBL_CELL_DHORIZ, /* = */
- TBL_CELL_MAX
-};
-
-/*
- * A cell in a layout row.
- */
-struct tbl_cell {
- struct tbl_cell *next;
- char *wstr; /* min width represented as a string */
- size_t width; /* minimum column width */
- size_t spacing; /* to the right of the column */
- int vert; /* width of subsequent vertical line */
- int col; /* column number, starting from 0 */
- int flags;
-#define TBL_CELL_TALIGN (1 << 0) /* t, T */
-#define TBL_CELL_BALIGN (1 << 1) /* d, D */
-#define TBL_CELL_BOLD (1 << 2) /* fB, B, b */
-#define TBL_CELL_ITALIC (1 << 3) /* fI, I, i */
-#define TBL_CELL_EQUAL (1 << 4) /* e, E */
-#define TBL_CELL_UP (1 << 5) /* u, U */
-#define TBL_CELL_WIGN (1 << 6) /* z, Z */
-#define TBL_CELL_WMAX (1 << 7) /* x, X */
- enum tbl_cellt pos;
-};
-
-/*
- * A layout row.
- */
-struct tbl_row {
- struct tbl_row *next;
- struct tbl_cell *first;
- struct tbl_cell *last;
- int vert; /* width of left vertical line */
-};
-
-enum tbl_datt {
- TBL_DATA_NONE, /* has no data */
- TBL_DATA_DATA, /* consists of data/string */
- TBL_DATA_HORIZ, /* horizontal line */
- TBL_DATA_DHORIZ, /* double-horizontal line */
- TBL_DATA_NHORIZ, /* squeezed horizontal line */
- TBL_DATA_NDHORIZ /* squeezed double-horizontal line */
-};
-
-/*
- * A cell within a row of data. The "string" field contains the actual
- * string value that's in the cell. The rest is layout.
- */
-struct tbl_dat {
- struct tbl_cell *layout; /* layout cell */
- struct tbl_dat *next;
- char *string; /* data (NULL if not TBL_DATA_DATA) */
- int hspans; /* how many horizontal spans follow */
- int vspans; /* how many vertical spans follow */
- int block; /* T{ text block T} */
- enum tbl_datt pos;
-};
-
-enum tbl_spant {
- TBL_SPAN_DATA, /* span consists of data */
- TBL_SPAN_HORIZ, /* span is horizontal line */
- TBL_SPAN_DHORIZ /* span is double horizontal line */
-};
-
-/*
- * A row of data in a table.
- */
-struct tbl_span {
- struct tbl_opts *opts;
- struct tbl_row *layout; /* layout row */
- struct tbl_dat *first;
- struct tbl_dat *last;
- struct tbl_span *prev;
- struct tbl_span *next;
- int line; /* parse line */
- enum tbl_spant pos;
-};
-
enum eqn_boxt {
EQN_TEXT, /* text (number, variable, whatever) */
EQN_SUBEXPR, /* nested `eqn' subexpression */
diff --git a/mandoc_headers.3 b/mandoc_headers.3
index a6e1004c..def4b990 100644
--- a/mandoc_headers.3
+++ b/mandoc_headers.3
@@ -25,13 +25,13 @@ separate from each other:
.Pp
.Bl -dash -offset indent -compact
.It
-.Xr mdoc 7
+.Xr roff 7
parser
.It
-.Xr man 7
+.Xr mdoc 7
parser
.It
-.Xr roff 7
+.Xr man 7
parser
.It
.Xr tbl 7
@@ -45,6 +45,8 @@ terminal formatters
HTML formatters
.It
search tools
+.It
+main programs
.El
.Pp
Note that mere usage of an opaque struct type does
@@ -56,14 +58,18 @@ any other mandoc header.
These headers should be included before any other mandoc headers.
.Bl -tag -width Ds
.It Qq Pa mandoc_aux.h
+Memory allocation utility functions; can be used everywhere.
+.Pp
Requires
.In sys/types.h
for
.Vt size_t .
.Pp
-Provides the utility functions documented in
+Provides the functions documented in
.Xr mandoc_malloc 3 .
.It Qq Pa mandoc_ohash.h
+Hashing utility functions; can be used everywhere.
+.Pp
Requires
.In stddef.h
for
@@ -78,6 +84,9 @@ Includes
and provides
.Fn mandoc_ohash_init .
.It Qq Pa mandoc.h
+Error handling utilities and top level parser interface;
+can be used everywhere.
+.Pp
Requires
.In sys/types.h
for
@@ -88,18 +97,10 @@ Provides
.Vt enum mandocerr ,
.Vt enum mandoclevel ,
.Vt enum mandoc_os ,
-.Vt enum tbl_cellt ,
-.Vt enum tbl_datt ,
-.Vt enum tbl_spant ,
.Vt enum eqn_boxt ,
.Vt enum eqn_fontt ,
.Vt enum eqn_pilet ,
.Vt enum eqn_post ,
-.Vt struct tbl_opts ,
-.Vt struct tbl_cell ,
-.Vt struct tbl_row ,
-.Vt struct tbl_dat ,
-.Vt struct tbl_span ,
.Vt struct eqn_box ,
the function prototype typedef
.Fn mandocmsg ,
@@ -122,7 +123,30 @@ Uses the type
from
.Pa roff.h
as an opaque type for function prototypes.
+.It Qq Pa tbl.h
+Data structures for the
+.Xr tbl 7
+parse tree; can be used everywhere.
+.Pp
+Requires
+.In sys/types.h
+for
+.Vt size_t .
+.Pp
+Provides
+.Vt enum tbl_cellt ,
+.Vt enum tbl_datt ,
+.Vt enum tbl_spant ,
+.Vt struct tbl_opts ,
+.Vt struct tbl_cell ,
+.Vt struct tbl_row ,
+.Vt struct tbl_dat ,
+and
+.Vt struct tbl_span .
.It Qq Pa mandoc_xr.h
+Cross reference validation; intended for use in the main program
+and in parsers, but not in formatters.
+.Pp
Provides
.Vt struct mandoc_xr
and the functions
diff --git a/out.c b/out.c
index 3dc9400d..8bfda102 100644
--- a/out.c
+++ b/out.c
@@ -28,6 +28,7 @@
#include "mandoc_aux.h"
#include "mandoc.h"
+#include "tbl.h"
#include "out.h"
struct tbl_colgroup {
diff --git a/roff.c b/roff.c
index 5810afbe..98902a43 100644
--- a/roff.c
+++ b/roff.c
@@ -28,10 +28,11 @@
#include <stdlib.h>
#include <string.h>
-#include "mandoc.h"
#include "mandoc_aux.h"
#include "mandoc_ohash.h"
+#include "mandoc.h"
#include "roff.h"
+#include "tbl.h"
#include "libmandoc.h"
#include "roff_int.h"
#include "libroff.h"
diff --git a/tbl.3 b/tbl.3
index 5734b6c6..29f90509 100644
--- a/tbl.3
+++ b/tbl.3
@@ -27,6 +27,7 @@
.Nd roff table parser library for mandoc
.Sh SYNOPSIS
.In mandoc.h
+.In tbl.h
.In libmandoc.h
.In libroff.h
.Ft struct tbl_node *
diff --git a/tbl.c b/tbl.c
index 107c4c49..73b4ee1a 100644
--- a/tbl.c
+++ b/tbl.c
@@ -25,8 +25,9 @@
#include <string.h>
#include <time.h>
-#include "mandoc.h"
#include "mandoc_aux.h"
+#include "mandoc.h"
+#include "tbl.h"
#include "libmandoc.h"
#include "libroff.h"
diff --git a/tbl.h b/tbl.h
new file mode 100644
index 00000000..8e5e83bc
--- /dev/null
+++ b/tbl.h
@@ -0,0 +1,122 @@
+/* $Id$ */
+/*
+ * Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
+ * Copyright (c) 2014, 2015, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+struct tbl_opts {
+ int opts;
+#define TBL_OPT_ALLBOX (1 << 0) /* Option "allbox". */
+#define TBL_OPT_BOX (1 << 1) /* Option "box". */
+#define TBL_OPT_CENTRE (1 << 2) /* Option "center". */
+#define TBL_OPT_DBOX (1 << 3) /* Option "doublebox". */
+#define TBL_OPT_EXPAND (1 << 4) /* Option "expand". */
+#define TBL_OPT_NOKEEP (1 << 5) /* Option "nokeep". */
+#define TBL_OPT_NOSPACE (1 << 6) /* Option "nospaces". */
+#define TBL_OPT_NOWARN (1 << 7) /* Option "nowarn". */
+ int cols; /* Number of columns. */
+ int lvert; /* Width of left vertical line. */
+ int rvert; /* Width of right vertical line. */
+ char tab; /* Option "tab": cell separator. */
+ char decimal; /* Option "decimalpoint". */
+};
+
+enum tbl_cellt {
+ TBL_CELL_CENTRE, /* c, C */
+ TBL_CELL_RIGHT, /* r, R */
+ TBL_CELL_LEFT, /* l, L */
+ TBL_CELL_NUMBER, /* n, N */
+ TBL_CELL_SPAN, /* s, S */
+ TBL_CELL_LONG, /* a, A */
+ TBL_CELL_DOWN, /* ^ */
+ TBL_CELL_HORIZ, /* _, - */
+ TBL_CELL_DHORIZ, /* = */
+ TBL_CELL_MAX
+};
+
+/*
+ * A cell in a layout row.
+ */
+struct tbl_cell {
+ struct tbl_cell *next; /* Layout cell to the right. */
+ char *wstr; /* Min width represented as a string. */
+ size_t width; /* Minimum column width. */
+ size_t spacing; /* To the right of the column. */
+ int vert; /* Width of subsequent vertical line. */
+ int col; /* Column number, starting from 0. */
+ int flags;
+#define TBL_CELL_BOLD (1 << 0) /* b, B, fB */
+#define TBL_CELL_ITALIC (1 << 1) /* i, I, fI */
+#define TBL_CELL_TALIGN (1 << 2) /* t, T */
+#define TBL_CELL_UP (1 << 3) /* u, U */
+#define TBL_CELL_BALIGN (1 << 4) /* d, D */
+#define TBL_CELL_WIGN (1 << 5) /* z, Z */
+#define TBL_CELL_EQUAL (1 << 6) /* e, E */
+#define TBL_CELL_WMAX (1 << 7) /* x, X */
+ enum tbl_cellt pos;
+};
+
+/*
+ * A layout row.
+ */
+struct tbl_row {
+ struct tbl_row *next; /* Layout row below. */
+ struct tbl_cell *first; /* Leftmost layout cell. */
+ struct tbl_cell *last; /* Rightmost layout cell. */
+ int vert; /* Width of left vertical line. */
+};
+
+enum tbl_datt {
+ TBL_DATA_NONE, /* Uninitialized row. */
+ TBL_DATA_DATA, /* Contains data rather than a line. */
+ TBL_DATA_HORIZ, /* _: connecting horizontal line. */
+ TBL_DATA_DHORIZ, /* =: connecting double horizontal line. */
+ TBL_DATA_NHORIZ, /* \_: isolated horizontal line. */
+ TBL_DATA_NDHORIZ /* \=: isolated double horizontal line. */
+};
+
+/*
+ * A cell within a row of data. The "string" field contains the
+ * actual string value that's in the cell. The rest is layout.
+ */
+struct tbl_dat {
+ struct tbl_dat *next; /* Data cell to the right. */
+ struct tbl_cell *layout; /* Associated layout cell. */
+ char *string; /* Data, or NULL if not TBL_DATA_DATA. */
+ int hspans; /* How many horizontal spans follow. */
+ int vspans; /* How many vertical spans follow. */
+ int block; /* T{ text block T} */
+ enum tbl_datt pos;
+};
+
+enum tbl_spant {
+ TBL_SPAN_DATA, /* Contains data rather than a line. */
+ TBL_SPAN_HORIZ, /* _: horizontal line. */
+ TBL_SPAN_DHORIZ /* =: double horizontal line. */
+};
+
+/*
+ * A row of data in a table.
+ */
+struct tbl_span {
+ struct tbl_opts *opts; /* Options for the table as a whole. */
+ struct tbl_span *prev; /* Data row above. */
+ struct tbl_span *next; /* Data row below. */
+ struct tbl_row *layout; /* Associated layout row. */
+ struct tbl_dat *first; /* Leftmost data cell. */
+ struct tbl_dat *last; /* Rightmost data cell. */
+ int line; /* Input file line number. */
+ enum tbl_spant pos;
+};
diff --git a/tbl_data.c b/tbl_data.c
index 9ef58c65..0956c429 100644
--- a/tbl_data.c
+++ b/tbl_data.c
@@ -25,8 +25,9 @@
#include <string.h>
#include <time.h>
-#include "mandoc.h"
#include "mandoc_aux.h"
+#include "mandoc.h"
+#include "tbl.h"
#include "libmandoc.h"
#include "libroff.h"
diff --git a/tbl_html.c b/tbl_html.c
index afc5ff15..dd0778f0 100644
--- a/tbl_html.c
+++ b/tbl_html.c
@@ -24,7 +24,7 @@
#include <stdlib.h>
#include <string.h>
-#include "mandoc.h"
+#include "tbl.h"
#include "out.h"
#include "html.h"
diff --git a/tbl_layout.c b/tbl_layout.c
index 51a3ba37..580667b8 100644
--- a/tbl_layout.c
+++ b/tbl_layout.c
@@ -25,8 +25,9 @@
#include <string.h>
#include <time.h>
-#include "mandoc.h"
#include "mandoc_aux.h"
+#include "mandoc.h"
+#include "tbl.h"
#include "libmandoc.h"
#include "libroff.h"
diff --git a/tbl_opts.c b/tbl_opts.c
index 09cf771a..e3580916 100644
--- a/tbl_opts.c
+++ b/tbl_opts.c
@@ -25,6 +25,7 @@
#include <string.h>
#include "mandoc.h"
+#include "tbl.h"
#include "libmandoc.h"
#include "libroff.h"
diff --git a/tbl_term.c b/tbl_term.c
index a0bfc41b..b7e73a75 100644
--- a/tbl_term.c
+++ b/tbl_term.c
@@ -26,6 +26,7 @@
#include <string.h>
#include "mandoc.h"
+#include "tbl.h"
#include "out.h"
#include "term.h"
diff --git a/tree.c b/tree.c
index 09b53ab3..bc33e59e 100644
--- a/tree.c
+++ b/tree.c
@@ -29,6 +29,7 @@
#include "roff.h"
#include "mdoc.h"
#include "man.h"
+#include "tbl.h"
#include "main.h"
static void print_box(const struct eqn_box *, int);