diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2018-12-13 11:55:46 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2018-12-13 11:55:46 +0000 |
commit | 92f8786f6ad5b622da1afc6b267a40001731571b (patch) | |
tree | 14fe0b38d0e173279a5834b1f18bcfd3efc3209e | |
parent | ef2d1ed7915b0e62315dcecce1bc447b55254b7c (diff) | |
download | mandoc-92f8786f6ad5b622da1afc6b267a40001731571b.tar.gz mandoc-92f8786f6ad5b622da1afc6b267a40001731571b.tar.zst mandoc-92f8786f6ad5b622da1afc6b267a40001731571b.zip |
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.
-rw-r--r-- | Makefile | 9 | ||||
-rw-r--r-- | Makefile.depend | 34 | ||||
-rw-r--r-- | att.c | 3 | ||||
-rw-r--r-- | cgi.c | 3 | ||||
-rw-r--r-- | demandoc.c | 3 | ||||
-rw-r--r-- | lib.c | 5 | ||||
-rw-r--r-- | main.c | 3 | ||||
-rw-r--r-- | man_html.c | 3 | ||||
-rw-r--r-- | man_term.c | 3 | ||||
-rw-r--r-- | mandoc.h | 39 | ||||
-rw-r--r-- | mandoc_headers.3 | 110 | ||||
-rw-r--r-- | mandoc_parse.h | 49 | ||||
-rw-r--r-- | mandocd.c | 3 | ||||
-rw-r--r-- | mandocdb.c | 3 | ||||
-rw-r--r-- | mansearch.c | 3 | ||||
-rw-r--r-- | mdoc_html.c | 3 | ||||
-rw-r--r-- | mdoc_term.c | 3 | ||||
-rw-r--r-- | out.c | 3 | ||||
-rw-r--r-- | preconv.c | 5 | ||||
-rw-r--r-- | read.c | 3 | ||||
-rw-r--r-- | roff.c | 3 | ||||
-rw-r--r-- | roff.h | 8 | ||||
-rw-r--r-- | roff_html.c | 3 |
23 files changed, 168 insertions, 136 deletions
@@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.525 2018/12/13 07:28:27 schwarze Exp $ +# $Id: Makefile,v 1.526 2018/12/13 11:55:46 schwarze Exp $ # # Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv> # Copyright (c) 2011, 2013-2018 Ingo Schwarze <schwarze@openbsd.org> @@ -185,6 +185,7 @@ DISTFILES = INSTALL \ mandoc_html.3 \ mandoc_malloc.3 \ mandoc_ohash.h \ + mandoc_parse.h \ mandoc_xr.h \ mandocd.8 \ mansearch.3 \ @@ -353,6 +354,7 @@ WWW_INCS = eqn.h.html \ manconf.h.html \ mandoc.h.html \ mandoc_aux.h.html \ + mandoc_parse.h.html \ mansearch.h.html \ mdoc.h.html \ roff.h.html \ @@ -427,8 +429,8 @@ lib-install: libmandoc.a mkdir -p $(DESTDIR)$(INCLUDEDIR) mkdir -p $(DESTDIR)$(MANDIR)/man3 $(INSTALL_LIB) libmandoc.a $(DESTDIR)$(LIBDIR) - $(INSTALL_LIB) eqn.h man.h mandoc.h mandoc_aux.h mdoc.h roff.h tbl.h \ - $(DESTDIR)$(INCLUDEDIR) + $(INSTALL_LIB) eqn.h man.h mandoc.h mandoc_aux.h mandoc_parse.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 @@ -486,6 +488,7 @@ uninstall: rm -f $(DESTDIR)$(INCLUDEDIR)/man.h rm -f $(DESTDIR)$(INCLUDEDIR)/mandoc.h rm -f $(DESTDIR)$(INCLUDEDIR)/mandoc_aux.h + rm -f $(DESTDIR)$(INCLUDEDIR)/mandoc_parse.h rm -f $(DESTDIR)$(INCLUDEDIR)/mdoc.h rm -f $(DESTDIR)$(INCLUDEDIR)/roff.h rm -f $(DESTDIR)$(INCLUDEDIR)/tbl.h diff --git a/Makefile.depend b/Makefile.depend index 7aa73869..1e989baf 100644 --- a/Makefile.depend +++ b/Makefile.depend @@ -1,6 +1,6 @@ -att.o: att.c config.h mandoc.h roff.h libmdoc.h +att.o: att.c config.h roff.h libmdoc.h catman.o: catman.c config.h compat_fts.h -cgi.o: cgi.c config.h mandoc_aux.h mandoc.h roff.h mdoc.h man.h main.h manconf.h mansearch.h cgi.h +cgi.o: cgi.c config.h mandoc_aux.h mandoc.h roff.h mdoc.h man.h mandoc_parse.h main.h manconf.h mansearch.h cgi.h chars.o: chars.c config.h mandoc.h mandoc_aux.h mandoc_ohash.h compat_ohash.h libmandoc.h compat_err.o: compat_err.c config.h compat_fts.o: compat_fts.c config.h compat_fts.h @@ -26,41 +26,41 @@ dba_read.o: dba_read.c mandoc_aux.h mansearch.h dba_array.h dba.h dbm.h dba_write.o: dba_write.c config.h dba_write.h dbm.o: dbm.c config.h mansearch.h dbm_map.h dbm.h dbm_map.o: dbm_map.c config.h mansearch.h dbm_map.h dbm.h -demandoc.o: demandoc.c config.h mandoc.h roff.h man.h mdoc.h +demandoc.o: demandoc.c config.h mandoc.h roff.h man.h mdoc.h mandoc_parse.h eqn.o: eqn.c config.h mandoc_aux.h mandoc.h roff.h eqn.h libmandoc.h eqn_parse.h eqn_html.o: eqn_html.c config.h mandoc.h eqn.h out.h html.h eqn_term.o: eqn_term.c config.h eqn.h out.h term.h html.o: html.c config.h mandoc_aux.h mandoc_ohash.h compat_ohash.h mandoc.h roff.h out.h html.h manconf.h main.h -lib.o: lib.c config.h mandoc.h roff.h mdoc.h libmdoc.h lib.in -main.o: main.c config.h mandoc_aux.h mandoc.h mandoc_xr.h roff.h mdoc.h man.h tag.h main.h manconf.h mansearch.h +lib.o: lib.c config.h roff.h libmdoc.h lib.in +main.o: main.c config.h mandoc_aux.h mandoc.h mandoc_xr.h roff.h mdoc.h man.h mandoc_parse.h tag.h main.h manconf.h mansearch.h man.o: man.c config.h mandoc_aux.h mandoc.h roff.h man.h libmandoc.h roff_int.h libman.h -man_html.o: man_html.c config.h mandoc_aux.h mandoc.h roff.h man.h out.h html.h main.h +man_html.o: man_html.c config.h mandoc_aux.h roff.h man.h out.h html.h main.h man_macro.o: man_macro.c config.h mandoc.h roff.h man.h libmandoc.h roff_int.h libman.h -man_term.o: man_term.c config.h mandoc_aux.h mandoc.h roff.h man.h out.h term.h main.h +man_term.o: man_term.c config.h mandoc_aux.h roff.h man.h out.h term.h main.h man_validate.o: man_validate.c config.h mandoc_aux.h mandoc.h roff.h man.h libmandoc.h roff_int.h libman.h mandoc.o: mandoc.c config.h mandoc_aux.h mandoc.h roff.h libmandoc.h mandoc_aux.o: mandoc_aux.c config.h mandoc.h mandoc_aux.h mandoc_ohash.o: mandoc_ohash.c mandoc_aux.h mandoc_ohash.h compat_ohash.h mandoc_xr.o: mandoc_xr.c mandoc_aux.h mandoc_ohash.h compat_ohash.h mandoc_xr.h -mandocd.o: mandocd.c config.h mandoc.h roff.h mdoc.h man.h main.h manconf.h -mandocdb.o: mandocdb.c config.h compat_fts.h mandoc_aux.h mandoc_ohash.h compat_ohash.h mandoc.h roff.h mdoc.h man.h manconf.h mansearch.h dba_array.h dba.h +mandocd.o: mandocd.c config.h mandoc.h roff.h mdoc.h man.h mandoc_parse.h main.h manconf.h +mandocdb.o: mandocdb.c config.h compat_fts.h mandoc_aux.h mandoc_ohash.h compat_ohash.h mandoc.h roff.h mdoc.h man.h mandoc_parse.h manconf.h mansearch.h dba_array.h dba.h manpath.o: manpath.c config.h mandoc_aux.h manconf.h -mansearch.o: mansearch.c config.h mandoc.h mandoc_aux.h mandoc_ohash.h compat_ohash.h manconf.h mansearch.h dbm.h +mansearch.o: mansearch.c config.h mandoc_aux.h mandoc_ohash.h compat_ohash.h manconf.h mansearch.h dbm.h mdoc.o: mdoc.c config.h mandoc_aux.h mandoc.h roff.h mdoc.h libmandoc.h roff_int.h libmdoc.h mdoc_argv.o: mdoc_argv.c config.h mandoc_aux.h mandoc.h roff.h mdoc.h libmandoc.h roff_int.h libmdoc.h -mdoc_html.o: mdoc_html.c config.h mandoc_aux.h mandoc.h roff.h mdoc.h out.h html.h main.h +mdoc_html.o: mdoc_html.c config.h mandoc_aux.h roff.h mdoc.h out.h html.h main.h mdoc_macro.o: mdoc_macro.c config.h mandoc.h roff.h mdoc.h libmandoc.h roff_int.h libmdoc.h mdoc_man.o: mdoc_man.c config.h mandoc_aux.h mandoc.h roff.h mdoc.h man.h out.h main.h mdoc_markdown.o: mdoc_markdown.c mandoc_aux.h mandoc.h roff.h mdoc.h main.h mdoc_state.o: mdoc_state.c mandoc.h roff.h mdoc.h libmandoc.h libmdoc.h -mdoc_term.o: mdoc_term.c config.h mandoc_aux.h mandoc.h roff.h mdoc.h out.h term.h tag.h main.h +mdoc_term.o: mdoc_term.c config.h mandoc_aux.h roff.h mdoc.h out.h term.h tag.h main.h mdoc_validate.o: mdoc_validate.c config.h mandoc_aux.h mandoc.h mandoc_xr.h roff.h mdoc.h libmandoc.h roff_int.h libmdoc.h msec.o: msec.c config.h mandoc.h libmandoc.h msec.in -out.o: out.c config.h mandoc_aux.h mandoc.h tbl.h out.h -preconv.o: preconv.c config.h mandoc.h libmandoc.h -read.o: read.c config.h mandoc_aux.h mandoc.h roff.h mdoc.h man.h libmandoc.h roff_int.h -roff.o: roff.c config.h mandoc_aux.h mandoc_ohash.h compat_ohash.h mandoc.h roff.h libmandoc.h roff_int.h tbl_parse.h eqn_parse.h predefs.in -roff_html.o: roff_html.c mandoc.h roff.h out.h html.h +out.o: out.c config.h mandoc_aux.h tbl.h out.h +preconv.o: preconv.c config.h mandoc.h roff.h mandoc_parse.h libmandoc.h +read.o: read.c config.h mandoc_aux.h mandoc.h roff.h mdoc.h man.h mandoc_parse.h libmandoc.h roff_int.h +roff.o: roff.c config.h mandoc_aux.h mandoc_ohash.h compat_ohash.h mandoc.h roff.h mandoc_parse.h libmandoc.h roff_int.h tbl_parse.h eqn_parse.h predefs.in +roff_html.o: roff_html.c roff.h out.h html.h roff_term.o: roff_term.c mandoc.h roff.h out.h term.h roff_validate.o: roff_validate.c mandoc.h roff.h libmandoc.h roff_int.h soelim.o: soelim.c config.h compat_stringlist.h @@ -1,4 +1,4 @@ -/* $Id: att.c,v 1.17 2018/12/13 07:30:21 schwarze Exp $ */ +/* $Id: att.c,v 1.18 2018/12/13 11:55:46 schwarze Exp $ */ /* * Copyright (c) 2009 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -19,7 +19,6 @@ #include <sys/types.h> #include <string.h> -#include "mandoc.h" #include "roff.h" #include "libmdoc.h" @@ -1,4 +1,4 @@ -/* $Id: cgi.c,v 1.161 2018/10/19 21:10:56 schwarze Exp $ */ +/* $Id: cgi.c,v 1.162 2018/12/13 11:55:46 schwarze Exp $ */ /* * Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2014, 2015, 2016, 2017, 2018 Ingo Schwarze <schwarze@usta.de> @@ -38,6 +38,7 @@ #include "roff.h" #include "mdoc.h" #include "man.h" +#include "mandoc_parse.h" #include "main.h" #include "manconf.h" #include "mansearch.h" @@ -1,4 +1,4 @@ -/* $Id: demandoc.c,v 1.29 2017/06/24 14:38:32 schwarze Exp $ */ +/* $Id: demandoc.c,v 1.30 2018/12/13 11:55:46 schwarze Exp $ */ /* * Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -29,6 +29,7 @@ #include "roff.h" #include "man.h" #include "mdoc.h" +#include "mandoc_parse.h" static void pline(int, int *, int *, int); static void pman(const struct roff_node *, int *, int *, int); @@ -1,4 +1,4 @@ -/* $Id: lib.c,v 1.14 2017/06/24 14:38:32 schwarze Exp $ */ +/* $Id: lib.c,v 1.15 2018/12/13 11:55:46 schwarze Exp $ */ /* * Copyright (c) 2009 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -17,12 +17,9 @@ #include "config.h" #include <sys/types.h> - #include <string.h> -#include "mandoc.h" #include "roff.h" -#include "mdoc.h" #include "libmdoc.h" #define LINE(x, y) \ @@ -1,4 +1,4 @@ -/* $Id: main.c,v 1.310 2018/11/22 12:01:46 schwarze Exp $ */ +/* $Id: main.c,v 1.311 2018/12/13 11:55:46 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2012, 2014-2018 Ingo Schwarze <schwarze@openbsd.org> @@ -49,6 +49,7 @@ #include "roff.h" #include "mdoc.h" #include "man.h" +#include "mandoc_parse.h" #include "tag.h" #include "main.h" #include "manconf.h" @@ -1,4 +1,4 @@ -/* $Id: man_html.c,v 1.158 2018/12/03 21:00:10 schwarze Exp $ */ +/* $Id: man_html.c,v 1.159 2018/12/13 11:55:46 schwarze Exp $ */ /* * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2013,2014,2015,2017,2018 Ingo Schwarze <schwarze@openbsd.org> @@ -26,7 +26,6 @@ #include <string.h> #include "mandoc_aux.h" -#include "mandoc.h" #include "roff.h" #include "man.h" #include "out.h" @@ -1,4 +1,4 @@ -/* $Id: man_term.c,v 1.221 2018/12/03 21:00:10 schwarze Exp $ */ +/* $Id: man_term.c,v 1.222 2018/12/13 11:55:46 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2015, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org> @@ -27,7 +27,6 @@ #include <string.h> #include "mandoc_aux.h" -#include "mandoc.h" #include "roff.h" #include "man.h" #include "out.h" @@ -1,7 +1,7 @@ -/* $Id: mandoc.h,v 1.257 2018/12/13 05:23:38 schwarze Exp $ */ +/* $Id: mandoc.h,v 1.258 2018/12/13 11:55:46 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,17 +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 *); -enum mandoclevel mparse_readmem(struct mparse *, void *, size_t, - 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/mandoc_headers.3 b/mandoc_headers.3 index f4d15885..c728a271 100644 --- a/mandoc_headers.3 +++ b/mandoc_headers.3 @@ -84,7 +84,7 @@ Includes and provides .Fn mandoc_ohash_init . .It Qq Pa mandoc.h -Error handling utilities and top level parser interface; +Error handling, escape sequence, and character utilities; can be used everywhere. .Pp Requires @@ -96,28 +96,45 @@ Provides .Vt enum mandoc_esc , .Vt enum mandocerr , .Vt enum mandoclevel , -.Vt enum mandoc_os , the function prototype typedef .Fn mandocmsg , the function .Xr mandoc_escape 3 , -the functions described in -.Xr mchars_alloc 3 , +and the functions described in +.Xr mchars_alloc 3 . +.It Qq Pa roff.h +Common data types for all syntax trees and related functions; +can be used everywhere. +.Pp +Provides +.Vt enum mandoc_os , +.Vt enum mdoc_endbody , +.Vt enum roff_macroset , +.Vt enum roff_next , +.Vt enum roff_sec , +.Vt enum roff_tok , +.Vt enum roff_type , +.Vt struct roff_man , +.Vt struct roff_meta , +.Vt struct roff_node , +the constant array +.Va roff_name and the functions -.Fn mparse_* -described in -.Xr mandoc 3 . +.Fn deroff +and +.Fn roff_validate . .Pp -Uses the opaque type -.Vt struct mparse +Uses pointers to the types +.Vt struct ohash from -.Pa read.c -for function prototypes. -Uses the type -.Vt struct roff_man +.Pa mandoc_ohash.h +and +.Vt struct mdoc_arg +and +.Vt union mdoc_data from -.Pa roff.h -as an opaque type for function prototypes. +.Pa mdoc.h +as opaque struct members. .It Qq Pa tbl.h Data structures for the .Xr tbl 7 @@ -154,6 +171,32 @@ Provides .Vt enum eqn_post , and .Vt struct eqn_box . +.It Qq Pa mandoc_parse.h +Top level parser interface, for use in the main program +and in the main parser, but not in formatters. +.Pp +Requires +.Pa mandoc.h +for +.Vt enum mandocerr , +.Vt enum mandoclevel , +and +.Fn mandocmsg , +and +.Pa roff.h +for +.Vt enum mandoc_os . +.Pp +Uses to opaque type +.Vt struct mparse +from +.Pa read.c +for function prototypes. +Uses +.Vt struct roff_man +from +.Pa roff.h +as an opaque type for function prototypes. .It Qq Pa mandoc_xr.h Cross reference validation; intended for use in the main program and in parsers, but not in formatters. @@ -166,43 +209,6 @@ and the functions .Fn mandoc_xr_get , and .Fn mandoc_xr_free . -.It Qq Pa roff.h -Common data types for all syntax trees and related functions; -can be used everywhere. -.Pp -Requires -.Qq Pa mandoc.h -for -.Vt enum mandoc_os . -.Pp -Provides -.Vt enum mdoc_endbody , -.Vt enum roff_macroset , -.Vt enum roff_next , -.Vt enum roff_sec , -.Vt enum roff_tok , -.Vt enum roff_type , -.Vt struct roff_man , -.Vt struct roff_meta , -.Vt struct roff_node , -the constant array -.Va roff_name -and the functions -.Fn deroff -and -.Fn roff_validate . -.Pp -Uses pointers to the types -.Vt struct ohash -from -.Pa mandoc_ohash.h -and -.Vt struct mdoc_arg -and -.Vt union mdoc_data -from -.Pa mdoc.h -as opaque struct members. .El .Pp The following two require diff --git a/mandoc_parse.h b/mandoc_parse.h new file mode 100644 index 00000000..d93e9101 --- /dev/null +++ b/mandoc_parse.h @@ -0,0 +1,49 @@ +/* $Id: mandoc_parse.h,v 1.1 2018/12/13 11:55:46 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 *); +enum mandoclevel mparse_readmem(struct mparse *, void *, size_t, + 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 *); @@ -1,4 +1,4 @@ -/* $Id: mandocd.c,v 1.6 2017/06/24 14:38:32 schwarze Exp $ */ +/* $Id: mandocd.c,v 1.7 2018/12/13 11:55:46 schwarze Exp $ */ /* * Copyright (c) 2017 Michael Stapelberg <stapelberg@debian.org> * Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org> @@ -38,6 +38,7 @@ #include "roff.h" #include "mdoc.h" #include "man.h" +#include "mandoc_parse.h" #include "main.h" #include "manconf.h" @@ -1,4 +1,4 @@ -/* $Id: mandocdb.c,v 1.259 2018/08/17 20:33:37 schwarze Exp $ */ +/* $Id: mandocdb.c,v 1.260 2018/12/13 11:55:46 schwarze Exp $ */ /* * Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2011-2018 Ingo Schwarze <schwarze@openbsd.org> @@ -52,6 +52,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/mansearch.c b/mansearch.c index 92bb68db..0c457f95 100644 --- a/mansearch.c +++ b/mansearch.c @@ -1,4 +1,4 @@ -/* $Id: mansearch.c,v 1.79 2018/11/22 12:01:46 schwarze Exp $ */ +/* $Id: mansearch.c,v 1.80 2018/12/13 11:55:46 schwarze Exp $ */ /* * Copyright (c) 2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2013-2018 Ingo Schwarze <schwarze@openbsd.org> @@ -36,7 +36,6 @@ #include <string.h> #include <unistd.h> -#include "mandoc.h" #include "mandoc_aux.h" #include "mandoc_ohash.h" #include "manconf.h" diff --git a/mdoc_html.c b/mdoc_html.c index 02842650..b4138b2e 100644 --- a/mdoc_html.c +++ b/mdoc_html.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_html.c,v 1.316 2018/12/03 21:00:10 schwarze Exp $ */ +/* $Id: mdoc_html.c,v 1.317 2018/12/13 11:55:46 schwarze Exp $ */ /* * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2014,2015,2016,2017,2018 Ingo Schwarze <schwarze@openbsd.org> @@ -27,7 +27,6 @@ #include <unistd.h> #include "mandoc_aux.h" -#include "mandoc.h" #include "roff.h" #include "mdoc.h" #include "out.h" diff --git a/mdoc_term.c b/mdoc_term.c index 13ed6880..590a41ee 100644 --- a/mdoc_term.c +++ b/mdoc_term.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_term.c,v 1.369 2018/12/03 21:00:11 schwarze Exp $ */ +/* $Id: mdoc_term.c,v 1.370 2018/12/13 11:55:47 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010, 2012-2018 Ingo Schwarze <schwarze@openbsd.org> @@ -29,7 +29,6 @@ #include <string.h> #include "mandoc_aux.h" -#include "mandoc.h" #include "roff.h" #include "mdoc.h" #include "out.h" @@ -1,4 +1,4 @@ -/* $Id: out.c,v 1.76 2018/12/12 21:54:35 schwarze Exp $ */ +/* $Id: out.c,v 1.77 2018/12/13 11:55:47 schwarze Exp $ */ /* * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2011,2014,2015,2017,2018 Ingo Schwarze <schwarze@openbsd.org> @@ -27,7 +27,6 @@ #include <time.h> #include "mandoc_aux.h" -#include "mandoc.h" #include "tbl.h" #include "out.h" @@ -1,4 +1,4 @@ -/* $Id: preconv.c,v 1.16 2017/02/18 13:43:52 schwarze Exp $ */ +/* $Id: preconv.c,v 1.17 2018/12/13 11:55:47 schwarze Exp $ */ /* * Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org> @@ -22,7 +22,10 @@ #include <assert.h> #include <stdio.h> #include <string.h> + #include "mandoc.h" +#include "roff.h" +#include "mandoc_parse.h" #include "libmandoc.h" int @@ -1,4 +1,4 @@ -/* $Id: read.c,v 1.201 2018/12/13 06:18:20 schwarze Exp $ */ +/* $Id: read.c,v 1.202 2018/12/13 11:55:47 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2018 Ingo Schwarze <schwarze@openbsd.org> @@ -38,6 +38,7 @@ #include "roff.h" #include "mdoc.h" #include "man.h" +#include "mandoc_parse.h" #include "libmandoc.h" #include "roff_int.h" @@ -1,4 +1,4 @@ -/* $Id: roff.c,v 1.348 2018/12/13 05:23:38 schwarze Exp $ */ +/* $Id: roff.c,v 1.349 2018/12/13 11:55:47 schwarze Exp $ */ /* * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2015, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org> @@ -32,6 +32,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" @@ -1,4 +1,4 @@ -/* $Id: roff.h,v 1.63 2018/12/13 06:18:20 schwarze Exp $ */ +/* $Id: roff.h,v 1.64 2018/12/13 11:55:47 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/roff_html.c b/roff_html.c index b26d9be9..aec483e4 100644 --- a/roff_html.c +++ b/roff_html.c @@ -1,4 +1,4 @@ -/* $Id: roff_html.c,v 1.13 2018/12/03 16:18:02 schwarze Exp $ */ +/* $Id: roff_html.c,v 1.14 2018/12/13 11:55:47 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" |