diff options
-rw-r--r-- | Makefile | 7 | ||||
-rw-r--r-- | Makefile.depend | 34 | ||||
-rw-r--r-- | att.c | 1 | ||||
-rw-r--r-- | cgi.c | 1 | ||||
-rw-r--r-- | demandoc.c | 1 | ||||
-rw-r--r-- | lib.c | 3 | ||||
-rw-r--r-- | main.c | 1 | ||||
-rw-r--r-- | man_html.c | 1 | ||||
-rw-r--r-- | man_term.c | 1 | ||||
-rw-r--r-- | mandoc.h | 37 | ||||
-rw-r--r-- | mandoc_headers.3 | 110 | ||||
-rw-r--r-- | mandoc_parse.h | 49 | ||||
-rw-r--r-- | mandocd.c | 1 | ||||
-rw-r--r-- | mandocdb.c | 1 | ||||
-rw-r--r-- | mansearch.c | 1 | ||||
-rw-r--r-- | mdoc_html.c | 1 | ||||
-rw-r--r-- | mdoc_term.c | 1 | ||||
-rw-r--r-- | out.c | 1 | ||||
-rw-r--r-- | preconv.c | 3 | ||||
-rw-r--r-- | read.c | 1 | ||||
-rw-r--r-- | roff.c | 1 | ||||
-rw-r--r-- | roff.h | 6 | ||||
-rw-r--r-- | roff_html.c | 1 |
23 files changed, 148 insertions, 116 deletions
@@ -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 @@ -19,7 +19,6 @@ #include <sys/types.h> #include <string.h> -#include "mandoc.h" #include "roff.h" #include "libmdoc.h" @@ -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" @@ -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); @@ -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) \ @@ -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" @@ -26,7 +26,6 @@ #include <string.h> #include "mandoc_aux.h" -#include "mandoc.h" #include "roff.h" #include "man.h" #include "out.h" @@ -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$ */ /* * 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 b25ecc0d..29b8ab20 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..05ac3cbb --- /dev/null +++ b/mandoc_parse.h @@ -0,0 +1,49 @@ +/* $Id$ */ +/* + * 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 *); @@ -38,6 +38,7 @@ #include "roff.h" #include "mdoc.h" #include "man.h" +#include "mandoc_parse.h" #include "main.h" #include "manconf.h" @@ -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 d1552dc4..dfd1d39f 100644 --- a/mansearch.c +++ b/mansearch.c @@ -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 4b9c7eb0..d7678cec 100644 --- a/mdoc_html.c +++ b/mdoc_html.c @@ -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 c16d5131..21499435 100644 --- a/mdoc_term.c +++ b/mdoc_term.c @@ -29,7 +29,6 @@ #include <string.h> #include "mandoc_aux.h" -#include "mandoc.h" #include "roff.h" #include "mdoc.h" #include "out.h" @@ -27,7 +27,6 @@ #include <time.h> #include "mandoc_aux.h" -#include "mandoc.h" #include "tbl.h" #include "out.h" @@ -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 @@ -38,6 +38,7 @@ #include "roff.h" #include "mdoc.h" #include "man.h" +#include "mandoc_parse.h" #include "libmandoc.h" #include "roff_int.h" @@ -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" @@ -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 a9255b02..ea123561 100644 --- a/roff_html.c +++ b/roff_html.c @@ -20,7 +20,6 @@ #include <assert.h> #include <stddef.h> -#include "mandoc.h" #include "roff.h" #include "out.h" #include "html.h" |