source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mandoc: Cleanup, no functional change: No need to expose the tbl(7)
@ 2018-12-12 21:55 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2018-12-12 21:55 UTC (permalink / raw)
  To: source

Log Message:
-----------
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.

Modified Files:
--------------
    mandoc:
        Makefile
        eqn.c
        mandoc.h
        mandoc_headers.3
        out.c
        roff.c
        tbl.3
        tbl.c
        tbl_data.c
        tbl_html.c
        tbl_layout.c
        tbl_opts.c
        tbl_term.c
        tree.c

Added Files:
-----------
    mandoc:
        tbl.h

Revision Data
-------------
Index: tbl_opts.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/tbl_opts.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -Ltbl_opts.c -Ltbl_opts.c -u -p -r1.21 -r1.22
--- tbl_opts.c
+++ tbl_opts.c
@@ -25,6 +25,7 @@
 #include <string.h>
 
 #include "mandoc.h"
+#include "tbl.h"
 #include "libmandoc.h"
 #include "libroff.h"
 
Index: eqn.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/eqn.c,v
retrieving revision 1.78
retrieving revision 1.79
diff -Leqn.c -Leqn.c -u -p -r1.78 -r1.79
--- eqn.c
+++ 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"
 
Index: tbl_term.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/tbl_term.c,v
retrieving revision 1.65
retrieving revision 1.66
diff -Ltbl_term.c -Ltbl_term.c -u -p -r1.65 -r1.66
--- tbl_term.c
+++ tbl_term.c
@@ -26,6 +26,7 @@
 #include <string.h>
 
 #include "mandoc.h"
+#include "tbl.h"
 #include "out.h"
 #include "term.h"
 
Index: tbl_data.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/tbl_data.c,v
retrieving revision 1.47
retrieving revision 1.48
diff -Ltbl_data.c -Ltbl_data.c -u -p -r1.47 -r1.48
--- tbl_data.c
+++ 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"
 
Index: out.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/out.c,v
retrieving revision 1.75
retrieving revision 1.76
diff -Lout.c -Lout.c -u -p -r1.75 -r1.76
--- out.c
+++ out.c
@@ -28,6 +28,7 @@
 
 #include "mandoc_aux.h"
 #include "mandoc.h"
+#include "tbl.h"
 #include "out.h"
 
 struct	tbl_colgroup {
Index: mandoc_headers.3
===================================================================
RCS file: /home/cvs/mandoc/mandoc/mandoc_headers.3,v
retrieving revision 1.19
retrieving revision 1.20
diff -Lmandoc_headers.3 -Lmandoc_headers.3 -u -p -r1.19 -r1.20
--- mandoc_headers.3
+++ 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
Index: tbl_layout.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/tbl_layout.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -Ltbl_layout.c -Ltbl_layout.c -u -p -r1.44 -r1.45
--- tbl_layout.c
+++ 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"
 
Index: tbl.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/tbl.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -Ltbl.c -Ltbl.c -u -p -r1.42 -r1.43
--- tbl.c
+++ 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"
 
Index: tbl.3
===================================================================
RCS file: /home/cvs/mandoc/mandoc/tbl.3,v
retrieving revision 1.3
retrieving revision 1.4
diff -Ltbl.3 -Ltbl.3 -u -p -r1.3 -r1.4
--- tbl.3
+++ 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 *
Index: Makefile
===================================================================
RCS file: /home/cvs/mandoc/mandoc/Makefile,v
retrieving revision 1.520
retrieving revision 1.521
diff -LMakefile -LMakefile -u -p -r1.520 -r1.521
--- Makefile
+++ 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
Index: tbl_html.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/tbl_html.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -Ltbl_html.c -Ltbl_html.c -u -p -r1.29 -r1.30
--- tbl_html.c
+++ 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"
 
Index: tree.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/tree.c,v
retrieving revision 1.80
retrieving revision 1.81
diff -Ltree.c -Ltree.c -u -p -r1.80 -r1.81
--- tree.c
+++ 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);
Index: mandoc.h
===================================================================
RCS file: /home/cvs/mandoc/mandoc/mandoc.h,v
retrieving revision 1.255
retrieving revision 1.256
diff -Lmandoc.h -Lmandoc.h -u -p -r1.255 -r1.256
--- mandoc.h
+++ 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
@@ -239,111 +239,6 @@ enum	mandocerr {
 	MANDOCERR_TBLMACRO, /* ignoring macro in table: macro */
 
 	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 {
Index: roff.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/roff.c,v
retrieving revision 1.344
retrieving revision 1.345
diff -Lroff.c -Lroff.c -u -p -r1.344 -r1.345
--- roff.c
+++ 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"
--- /dev/null
+++ tbl.h
@@ -0,0 +1,122 @@
+/*	$Id: tbl.h,v 1.1 2018/12/12 21:54:35 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;
+};
--
 To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2018-12-12 21:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-12 21:55 mandoc: Cleanup, no functional change: No need to expose the tbl(7) schwarze

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).