summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2018-12-13 11:55:15 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2018-12-13 11:55:15 +0000
commit0fa8e821432dd6cc1d2501a630d98df5a1aaa801 (patch)
tree9e9eaedba025f2a90b90593396197aed441be734 /usr.bin/mandoc
parent51c4953491e90121a5704ee639e7e84874a6263c (diff)
Cleanup, no functional change:
Split the top level parser interface out of the utility header mandoc.h, into a new header mandoc_parse.h, for use in the main program and in the main parser only. Move enum mandoc_os into roff.h because struct roff_man is the place where it is stored. This allows removal of mandoc.h from seven files in low-level parsers and in formatters.
Diffstat (limited to 'usr.bin/mandoc')
-rw-r--r--usr.bin/mandoc/Makefile6
-rw-r--r--usr.bin/mandoc/att.c3
-rw-r--r--usr.bin/mandoc/cgi.c3
-rw-r--r--usr.bin/mandoc/main.c3
-rw-r--r--usr.bin/mandoc/man_html.c3
-rw-r--r--usr.bin/mandoc/man_term.c3
-rw-r--r--usr.bin/mandoc/mandoc.h37
-rw-r--r--usr.bin/mandoc/mandoc_parse.h47
-rw-r--r--usr.bin/mandoc/mandocdb.c3
-rw-r--r--usr.bin/mandoc/mansearch.c3
-rw-r--r--usr.bin/mandoc/mdoc_html.c3
-rw-r--r--usr.bin/mandoc/mdoc_term.c3
-rw-r--r--usr.bin/mandoc/out.c3
-rw-r--r--usr.bin/mandoc/preconv.c5
-rw-r--r--usr.bin/mandoc/read.c3
-rw-r--r--usr.bin/mandoc/roff.c3
-rw-r--r--usr.bin/mandoc/roff.h8
-rw-r--r--usr.bin/mandoc/roff_html.c3
18 files changed, 83 insertions, 59 deletions
diff --git a/usr.bin/mandoc/Makefile b/usr.bin/mandoc/Makefile
index e62fdec6323..d069a94f493 100644
--- a/usr.bin/mandoc/Makefile
+++ b/usr.bin/mandoc/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.111 2017/07/01 09:47:23 schwarze Exp $
+# $OpenBSD: Makefile,v 1.112 2018/12/13 11:55:14 schwarze Exp $
.include <bsd.own.mk>
@@ -57,8 +57,8 @@ HTML_OBJS = html.o roff_html.o mdoc_html.o man_html.o \
CGI_OBJS = ${LIBMANDOC_OBJS} ${HTML_OBJS} \
dbm_map.o dbm.o mansearch.o cgi.o
-cgi.o: cgi.h main.h manconf.h mandoc.h mandoc_aux.h mansearch.h \
- man.h mdoc.h roff.h
+cgi.o: cgi.h main.h manconf.h mandoc.h mandoc_aux.h mandoc_parse.h \
+ mansearch.h man.h mdoc.h roff.h
man.cgi: ${CGI_OBJS}
${CC} ${LDFLAGS} ${STATIC} -o ${.TARGET} ${CGI_OBJS} ${LDADD}
diff --git a/usr.bin/mandoc/att.c b/usr.bin/mandoc/att.c
index b77a8c9b922..85c184ebd63 100644
--- a/usr.bin/mandoc/att.c
+++ b/usr.bin/mandoc/att.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: att.c,v 1.13 2018/12/13 07:29:35 schwarze Exp $ */
+/* $OpenBSD: att.c,v 1.14 2018/12/13 11:55:14 schwarze Exp $ */
/*
* Copyright (c) 2009 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -17,7 +17,6 @@
#include <sys/types.h>
#include <string.h>
-#include "mandoc.h"
#include "roff.h"
#include "libmdoc.h"
diff --git a/usr.bin/mandoc/cgi.c b/usr.bin/mandoc/cgi.c
index 4f41a1c7e58..00d392d2f90 100644
--- a/usr.bin/mandoc/cgi.c
+++ b/usr.bin/mandoc/cgi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cgi.c,v 1.99 2018/10/19 21:10:00 schwarze Exp $ */
+/* $OpenBSD: cgi.c,v 1.100 2018/12/13 11:55:14 schwarze Exp $ */
/*
* Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014, 2015, 2016, 2017, 2018 Ingo Schwarze <schwarze@usta.de>
@@ -34,6 +34,7 @@
#include "roff.h"
#include "mdoc.h"
#include "man.h"
+#include "mandoc_parse.h"
#include "main.h"
#include "manconf.h"
#include "mansearch.h"
diff --git a/usr.bin/mandoc/main.c b/usr.bin/mandoc/main.c
index a30037230c3..9edce62b755 100644
--- a/usr.bin/mandoc/main.c
+++ b/usr.bin/mandoc/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.213 2018/11/22 12:01:42 schwarze Exp $ */
+/* $OpenBSD: main.c,v 1.214 2018/12/13 11:55:14 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2012, 2014-2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -43,6 +43,7 @@
#include "roff.h"
#include "mdoc.h"
#include "man.h"
+#include "mandoc_parse.h"
#include "tag.h"
#include "main.h"
#include "manconf.h"
diff --git a/usr.bin/mandoc/man_html.c b/usr.bin/mandoc/man_html.c
index bba005d9bd8..2d8fe40de4d 100644
--- a/usr.bin/mandoc/man_html.c
+++ b/usr.bin/mandoc/man_html.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: man_html.c,v 1.111 2018/12/03 21:00:06 schwarze Exp $ */
+/* $OpenBSD: man_html.c,v 1.112 2018/12/13 11:55:14 schwarze Exp $ */
/*
* Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013,2014,2015,2017,2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -24,7 +24,6 @@
#include <string.h>
#include "mandoc_aux.h"
-#include "mandoc.h"
#include "roff.h"
#include "man.h"
#include "out.h"
diff --git a/usr.bin/mandoc/man_term.c b/usr.bin/mandoc/man_term.c
index 06de2443213..11c5fb4770e 100644
--- a/usr.bin/mandoc/man_term.c
+++ b/usr.bin/mandoc/man_term.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: man_term.c,v 1.174 2018/12/03 21:00:06 schwarze Exp $ */
+/* $OpenBSD: man_term.c,v 1.175 2018/12/13 11:55:14 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -25,7 +25,6 @@
#include <string.h>
#include "mandoc_aux.h"
-#include "mandoc.h"
#include "roff.h"
#include "man.h"
#include "out.h"
diff --git a/usr.bin/mandoc/mandoc.h b/usr.bin/mandoc/mandoc.h
index 24e4c0336f7..5abba9a0377 100644
--- a/usr.bin/mandoc/mandoc.h
+++ b/usr.bin/mandoc/mandoc.h
@@ -1,7 +1,7 @@
-/* $OpenBSD: mandoc.h,v 1.199 2018/12/13 05:13:15 schwarze Exp $ */
+/* $OpenBSD: mandoc.h,v 1.200 2018/12/13 11:55:14 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2010, 2012-2018 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 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
@@ -14,6 +14,8 @@
* 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.
+ *
+ * Error handling, escape sequence, and character utilities.
*/
#define ASCII_NBRSP 31 /* non-breaking space */
@@ -241,22 +243,6 @@ enum mandocerr {
MANDOCERR_MAX
};
-/*
- * Parse options.
- */
-#define MPARSE_MDOC 1 /* assume -mdoc */
-#define MPARSE_MAN 2 /* assume -man */
-#define MPARSE_SO 4 /* honour .so requests */
-#define MPARSE_QUICK 8 /* abort the parse early */
-#define MPARSE_UTF8 16 /* accept UTF-8 input */
-#define MPARSE_LATIN1 32 /* accept ISO-LATIN-1 input */
-
-enum mandoc_os {
- MANDOC_OS_OTHER = 0,
- MANDOC_OS_NETBSD,
- MANDOC_OS_OPENBSD
-};
-
enum mandoc_esc {
ESCAPE_ERROR = 0, /* bail! unparsable escape */
ESCAPE_IGNORE, /* escape to be ignored */
@@ -283,9 +269,6 @@ typedef void (*mandocmsg)(enum mandocerr, enum mandoclevel,
const char *, int, int, const char *);
-struct mparse;
-struct roff_man;
-
enum mandoc_esc mandoc_escape(const char **, const char **, int *);
void mchars_alloc(void);
void mchars_free(void);
@@ -294,15 +277,3 @@ const char *mchars_uc2str(int);
int mchars_num2uc(const char *, size_t);
int mchars_spec2cp(const char *, size_t);
const char *mchars_spec2str(const char *, size_t, size_t *);
-struct mparse *mparse_alloc(int, enum mandocerr, mandocmsg,
- enum mandoc_os, const char *);
-void mparse_free(struct mparse *);
-int mparse_open(struct mparse *, const char *);
-enum mandoclevel mparse_readfd(struct mparse *, int, const char *);
-void mparse_reset(struct mparse *);
-void mparse_result(struct mparse *,
- struct roff_man **, char **);
-void mparse_copy(const struct mparse *);
-const char *mparse_strerror(enum mandocerr);
-const char *mparse_strlevel(enum mandoclevel);
-void mparse_updaterc(struct mparse *, enum mandoclevel *);
diff --git a/usr.bin/mandoc/mandoc_parse.h b/usr.bin/mandoc/mandoc_parse.h
new file mode 100644
index 00000000000..f3a0e982f97
--- /dev/null
+++ b/usr.bin/mandoc/mandoc_parse.h
@@ -0,0 +1,47 @@
+/* $OpenBSD: mandoc_parse.h,v 1.1 2018/12/13 11:55:14 schwarze Exp $ */
+/*
+ * Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
+ * Copyright (c) 2014,2015,2016,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.
+ *
+ * Top level parser interface. For use in the main program
+ * and in the main parser, but not in formatters.
+ */
+
+/*
+ * Parse options.
+ */
+#define MPARSE_MDOC (1 << 0) /* assume -mdoc */
+#define MPARSE_MAN (1 << 1) /* assume -man */
+#define MPARSE_SO (1 << 2) /* honour .so requests */
+#define MPARSE_QUICK (1 << 3) /* abort the parse early */
+#define MPARSE_UTF8 (1 << 4) /* accept UTF-8 input */
+#define MPARSE_LATIN1 (1 << 5) /* accept ISO-LATIN-1 input */
+
+
+struct mparse;
+struct roff_man;
+
+struct mparse *mparse_alloc(int, enum mandocerr, mandocmsg,
+ enum mandoc_os, const char *);
+void mparse_copy(const struct mparse *);
+void mparse_free(struct mparse *);
+int mparse_open(struct mparse *, const char *);
+enum mandoclevel mparse_readfd(struct mparse *, int, const char *);
+void mparse_reset(struct mparse *);
+void mparse_result(struct mparse *,
+ struct roff_man **, char **);
+const char *mparse_strerror(enum mandocerr);
+const char *mparse_strlevel(enum mandoclevel);
+void mparse_updaterc(struct mparse *, enum mandoclevel *);
diff --git a/usr.bin/mandoc/mandocdb.c b/usr.bin/mandoc/mandocdb.c
index 37de0458dac..2bed68e7a9d 100644
--- a/usr.bin/mandoc/mandocdb.c
+++ b/usr.bin/mandoc/mandocdb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mandocdb.c,v 1.208 2018/08/17 20:31:52 schwarze Exp $ */
+/* $OpenBSD: mandocdb.c,v 1.209 2018/12/13 11:55:14 schwarze Exp $ */
/*
* Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011-2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -41,6 +41,7 @@
#include "roff.h"
#include "mdoc.h"
#include "man.h"
+#include "mandoc_parse.h"
#include "manconf.h"
#include "mansearch.h"
#include "dba_array.h"
diff --git a/usr.bin/mandoc/mansearch.c b/usr.bin/mandoc/mansearch.c
index 324e7358eef..1ac4558a0f1 100644
--- a/usr.bin/mandoc/mansearch.c
+++ b/usr.bin/mandoc/mansearch.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mansearch.c,v 1.62 2018/11/22 12:01:42 schwarze Exp $ */
+/* $OpenBSD: mansearch.c,v 1.63 2018/12/13 11:55:14 schwarze Exp $ */
/*
* Copyright (c) 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013-2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -33,7 +33,6 @@
#include <string.h>
#include <unistd.h>
-#include "mandoc.h"
#include "mandoc_aux.h"
#include "mandoc_ohash.h"
#include "manconf.h"
diff --git a/usr.bin/mandoc/mdoc_html.c b/usr.bin/mandoc/mdoc_html.c
index 5e6f7eabb04..2c2d0c0842a 100644
--- a/usr.bin/mandoc/mdoc_html.c
+++ b/usr.bin/mandoc/mdoc_html.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mdoc_html.c,v 1.191 2018/12/03 21:00:06 schwarze Exp $ */
+/* $OpenBSD: mdoc_html.c,v 1.192 2018/12/13 11:55:14 schwarze Exp $ */
/*
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014,2015,2016,2017,2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -25,7 +25,6 @@
#include <unistd.h>
#include "mandoc_aux.h"
-#include "mandoc.h"
#include "roff.h"
#include "mdoc.h"
#include "out.h"
diff --git a/usr.bin/mandoc/mdoc_term.c b/usr.bin/mandoc/mdoc_term.c
index 4b054666418..075c09a0b89 100644
--- a/usr.bin/mandoc/mdoc_term.c
+++ b/usr.bin/mandoc/mdoc_term.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mdoc_term.c,v 1.268 2018/12/03 21:00:06 schwarze Exp $ */
+/* $OpenBSD: mdoc_term.c,v 1.269 2018/12/13 11:55:14 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012-2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -27,7 +27,6 @@
#include <string.h>
#include "mandoc_aux.h"
-#include "mandoc.h"
#include "roff.h"
#include "mdoc.h"
#include "out.h"
diff --git a/usr.bin/mandoc/out.c b/usr.bin/mandoc/out.c
index d0b42a65309..67672a402f0 100644
--- a/usr.bin/mandoc/out.c
+++ b/usr.bin/mandoc/out.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: out.c,v 1.48 2018/12/12 21:54:30 schwarze Exp $ */
+/* $OpenBSD: out.c,v 1.49 2018/12/13 11:55:14 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011,2014,2015,2017,2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -25,7 +25,6 @@
#include <time.h>
#include "mandoc_aux.h"
-#include "mandoc.h"
#include "tbl.h"
#include "out.h"
diff --git a/usr.bin/mandoc/preconv.c b/usr.bin/mandoc/preconv.c
index 43a1e2d4eae..2cbdcda86fd 100644
--- a/usr.bin/mandoc/preconv.c
+++ b/usr.bin/mandoc/preconv.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: preconv.c,v 1.8 2017/02/18 13:43:34 schwarze Exp $ */
+/* $OpenBSD: preconv.c,v 1.9 2018/12/13 11:55:14 schwarze Exp $ */
/*
* Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -20,7 +20,10 @@
#include <assert.h>
#include <stdio.h>
#include <string.h>
+
#include "mandoc.h"
+#include "roff.h"
+#include "mandoc_parse.h"
#include "libmandoc.h"
int
diff --git a/usr.bin/mandoc/read.c b/usr.bin/mandoc/read.c
index 551a7971ca6..42c524090ec 100644
--- a/usr.bin/mandoc/read.c
+++ b/usr.bin/mandoc/read.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: read.c,v 1.173 2018/12/13 06:17:17 schwarze Exp $ */
+/* $OpenBSD: read.c,v 1.174 2018/12/13 11:55:14 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -36,6 +36,7 @@
#include "roff.h"
#include "mdoc.h"
#include "man.h"
+#include "mandoc_parse.h"
#include "libmandoc.h"
#include "roff_int.h"
diff --git a/usr.bin/mandoc/roff.c b/usr.bin/mandoc/roff.c
index 037cf99192b..9e6dce3d421 100644
--- a/usr.bin/mandoc/roff.c
+++ b/usr.bin/mandoc/roff.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: roff.c,v 1.220 2018/12/13 05:13:15 schwarze Exp $ */
+/* $OpenBSD: roff.c,v 1.221 2018/12/13 11:55:14 schwarze Exp $ */
/*
* Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -30,6 +30,7 @@
#include "mandoc_ohash.h"
#include "mandoc.h"
#include "roff.h"
+#include "mandoc_parse.h"
#include "libmandoc.h"
#include "roff_int.h"
#include "tbl_parse.h"
diff --git a/usr.bin/mandoc/roff.h b/usr.bin/mandoc/roff.h
index 151500ba3f4..b5709cd29e7 100644
--- a/usr.bin/mandoc/roff.h
+++ b/usr.bin/mandoc/roff.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: roff.h,v 1.45 2018/12/13 06:17:17 schwarze Exp $ */
+/* $OpenBSD: roff.h,v 1.46 2018/12/13 11:55:14 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013,2014,2015,2017,2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -492,6 +492,12 @@ enum mdoc_endbody {
ENDBODY_SPACE /* Is broken: append a space. */
};
+enum mandoc_os {
+ MANDOC_OS_OTHER = 0,
+ MANDOC_OS_NETBSD,
+ MANDOC_OS_OPENBSD
+};
+
struct roff_node {
struct roff_node *parent; /* Parent AST node. */
struct roff_node *child; /* First child AST node. */
diff --git a/usr.bin/mandoc/roff_html.c b/usr.bin/mandoc/roff_html.c
index 8d57de5b3b9..cf3e198af15 100644
--- a/usr.bin/mandoc/roff_html.c
+++ b/usr.bin/mandoc/roff_html.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: roff_html.c,v 1.13 2018/12/03 16:17:58 schwarze Exp $ */
+/* $OpenBSD: roff_html.c,v 1.14 2018/12/13 11:55:14 schwarze Exp $ */
/*
* Copyright (c) 2010 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -20,7 +20,6 @@
#include <assert.h>
#include <stddef.h>
-#include "mandoc.h"
#include "roff.h"
#include "out.h"
#include "html.h"