diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2018-12-12 21:54:31 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2018-12-12 21:54:31 +0000 |
commit | 792b929c5006534de41ea34a8bd64ae250bb1c6e (patch) | |
tree | 94e3a4b3727c706007f6facf70d525343f11d503 /usr.bin/mandoc | |
parent | b3fe6064e4c91a05d76e7426870e458ebfaf189d (diff) |
Cleanup, no functional change:
No need to expose the tbl(7) syntax tree data structures everywhere.
Move them to their own include file, "tbl.h", and improve comments.
Diffstat (limited to 'usr.bin/mandoc')
-rw-r--r-- | usr.bin/mandoc/eqn.c | 3 | ||||
-rw-r--r-- | usr.bin/mandoc/mandoc.h | 109 | ||||
-rw-r--r-- | usr.bin/mandoc/out.c | 3 | ||||
-rw-r--r-- | usr.bin/mandoc/roff.c | 5 | ||||
-rw-r--r-- | usr.bin/mandoc/tbl.c | 5 | ||||
-rw-r--r-- | usr.bin/mandoc/tbl.h | 122 | ||||
-rw-r--r-- | usr.bin/mandoc/tbl_data.c | 5 | ||||
-rw-r--r-- | usr.bin/mandoc/tbl_html.c | 4 | ||||
-rw-r--r-- | usr.bin/mandoc/tbl_layout.c | 5 | ||||
-rw-r--r-- | usr.bin/mandoc/tbl_opts.c | 3 | ||||
-rw-r--r-- | usr.bin/mandoc/tbl_term.c | 3 | ||||
-rw-r--r-- | usr.bin/mandoc/tree.c | 3 |
12 files changed, 148 insertions, 122 deletions
diff --git a/usr.bin/mandoc/eqn.c b/usr.bin/mandoc/eqn.c index dd814cc6e0d..ef6ef0d80ef 100644 --- a/usr.bin/mandoc/eqn.c +++ b/usr.bin/mandoc/eqn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eqn.c,v 1.41 2017/07/15 15:06:31 bentley Exp $ */ +/* $OpenBSD: eqn.c,v 1.42 2018/12/12 21:54:30 schwarze Exp $ */ /* * Copyright (c) 2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2014, 2015, 2017 Ingo Schwarze <schwarze@openbsd.org> @@ -28,6 +28,7 @@ #include "mandoc_aux.h" #include "mandoc.h" #include "roff.h" +#include "tbl.h" #include "libmandoc.h" #include "libroff.h" diff --git a/usr.bin/mandoc/mandoc.h b/usr.bin/mandoc/mandoc.h index e787c104530..056f53765ca 100644 --- a/usr.bin/mandoc/mandoc.h +++ b/usr.bin/mandoc/mandoc.h @@ -1,7 +1,7 @@ -/* $OpenBSD: mandoc.h,v 1.197 2018/11/25 19:23:59 schwarze Exp $ */ +/* $OpenBSD: mandoc.h,v 1.198 2018/12/12 21:54:30 schwarze Exp $ */ /* * 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/usr.bin/mandoc/out.c b/usr.bin/mandoc/out.c index d5d2837f023..d0b42a65309 100644 --- a/usr.bin/mandoc/out.c +++ b/usr.bin/mandoc/out.c @@ -1,4 +1,4 @@ -/* $OpenBSD: out.c,v 1.47 2018/11/29 01:54:58 schwarze Exp $ */ +/* $OpenBSD: out.c,v 1.48 2018/12/12 21:54:30 schwarze Exp $ */ /* * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2011,2014,2015,2017,2018 Ingo Schwarze <schwarze@openbsd.org> @@ -26,6 +26,7 @@ #include "mandoc_aux.h" #include "mandoc.h" +#include "tbl.h" #include "out.h" struct tbl_colgroup { diff --git a/usr.bin/mandoc/roff.c b/usr.bin/mandoc/roff.c index 796c01fb4e1..a3ef67721e1 100644 --- a/usr.bin/mandoc/roff.c +++ b/usr.bin/mandoc/roff.c @@ -1,4 +1,4 @@ -/* $OpenBSD: roff.c,v 1.216 2018/12/04 02:53:45 schwarze Exp $ */ +/* $OpenBSD: roff.c,v 1.217 2018/12/12 21:54:30 schwarze Exp $ */ /* * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2015, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org> @@ -26,10 +26,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/usr.bin/mandoc/tbl.c b/usr.bin/mandoc/tbl.c index d8bca8dd4af..9aebcc624cf 100644 --- a/usr.bin/mandoc/tbl.c +++ b/usr.bin/mandoc/tbl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tbl.c,v 1.23 2017/07/08 17:52:42 schwarze Exp $ */ +/* $OpenBSD: tbl.c,v 1.24 2018/12/12 21:54:30 schwarze Exp $ */ /* * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2011, 2015 Ingo Schwarze <schwarze@openbsd.org> @@ -23,8 +23,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/usr.bin/mandoc/tbl.h b/usr.bin/mandoc/tbl.h new file mode 100644 index 00000000000..2e77ac108be --- /dev/null +++ b/usr.bin/mandoc/tbl.h @@ -0,0 +1,122 @@ +/* $OpenBSD: tbl.h,v 1.5 2018/12/12 21:54:30 schwarze Exp $ */ +/* + * 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/usr.bin/mandoc/tbl_data.c b/usr.bin/mandoc/tbl_data.c index 11495bfc3f4..4f91de629bc 100644 --- a/usr.bin/mandoc/tbl_data.c +++ b/usr.bin/mandoc/tbl_data.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tbl_data.c,v 1.34 2018/11/25 21:17:30 schwarze Exp $ */ +/* $OpenBSD: tbl_data.c,v 1.35 2018/12/12 21:54:30 schwarze Exp $ */ /* * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2011, 2015, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org> @@ -23,8 +23,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/usr.bin/mandoc/tbl_html.c b/usr.bin/mandoc/tbl_html.c index be5f07bdcaa..6bfe462aea3 100644 --- a/usr.bin/mandoc/tbl_html.c +++ b/usr.bin/mandoc/tbl_html.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tbl_html.c,v 1.24 2018/11/26 21:05:54 schwarze Exp $ */ +/* $OpenBSD: tbl_html.c,v 1.25 2018/12/12 21:54:30 schwarze Exp $ */ /* * Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2014, 2015, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org> @@ -22,7 +22,7 @@ #include <stdlib.h> #include <string.h> -#include "mandoc.h" +#include "tbl.h" #include "out.h" #include "html.h" diff --git a/usr.bin/mandoc/tbl_layout.c b/usr.bin/mandoc/tbl_layout.c index e2d683b8f98..98ff9df9b2b 100644 --- a/usr.bin/mandoc/tbl_layout.c +++ b/usr.bin/mandoc/tbl_layout.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tbl_layout.c,v 1.31 2017/06/27 18:23:29 schwarze Exp $ */ +/* $OpenBSD: tbl_layout.c,v 1.32 2018/12/12 21:54:30 schwarze Exp $ */ /* * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2012, 2014, 2015, 2017 Ingo Schwarze <schwarze@openbsd.org> @@ -23,8 +23,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/usr.bin/mandoc/tbl_opts.c b/usr.bin/mandoc/tbl_opts.c index ea5ec7c073e..8538c51ad46 100644 --- a/usr.bin/mandoc/tbl_opts.c +++ b/usr.bin/mandoc/tbl_opts.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tbl_opts.c,v 1.13 2015/09/26 00:53:15 schwarze Exp $ */ +/* $OpenBSD: tbl_opts.c,v 1.14 2018/12/12 21:54:30 schwarze Exp $ */ /* * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2015 Ingo Schwarze <schwarze@openbsd.org> @@ -23,6 +23,7 @@ #include <string.h> #include "mandoc.h" +#include "tbl.h" #include "libmandoc.h" #include "libroff.h" diff --git a/usr.bin/mandoc/tbl_term.c b/usr.bin/mandoc/tbl_term.c index 443da673375..286bf065648 100644 --- a/usr.bin/mandoc/tbl_term.c +++ b/usr.bin/mandoc/tbl_term.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tbl_term.c,v 1.53 2018/11/29 23:08:08 schwarze Exp $ */ +/* $OpenBSD: tbl_term.c,v 1.54 2018/12/12 21:54:30 schwarze Exp $ */ /* * Copyright (c) 2009, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2011-2018 Ingo Schwarze <schwarze@openbsd.org> @@ -24,6 +24,7 @@ #include <string.h> #include "mandoc.h" +#include "tbl.h" #include "out.h" #include "term.h" diff --git a/usr.bin/mandoc/tree.c b/usr.bin/mandoc/tree.c index ff8d60d8911..2a15b94c58b 100644 --- a/usr.bin/mandoc/tree.c +++ b/usr.bin/mandoc/tree.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tree.c,v 1.47 2018/11/25 19:23:59 schwarze Exp $ */ +/* $OpenBSD: tree.c,v 1.48 2018/12/12 21:54:30 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2013,2014,2015,2017,2018 Ingo Schwarze <schwarze@openbsd.org> @@ -27,6 +27,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); |