summaryrefslogtreecommitdiffstats
path: root/usr.bin/mandoc/libmdoc.h
diff options
context:
space:
mode:
authorschwarze <schwarze@openbsd.org>2011-04-24 16:22:02 +0000
committerschwarze <schwarze@openbsd.org>2011-04-24 16:22:02 +0000
commita35fc07a7b65d6566e1bba15498dda44c9e03769 (patch)
treeef8339a28f07e5deb4794584b290addf14483c9e /usr.bin/mandoc/libmdoc.h
parentfenv for sh (diff)
downloadwireguard-openbsd-a35fc07a7b65d6566e1bba15498dda44c9e03769.tar.xz
wireguard-openbsd-a35fc07a7b65d6566e1bba15498dda44c9e03769.zip
Merge version 1.11.1:
Again lots of cleanup and maintenance work by kristaps@. - simplify error reporting: less function pointers, more mandoc_[v]msg - main: split document parsing out of main.c into read.c - roff, mdoc, man: improved recognition of control characters - roff: better handling of if/else stack overflows - roff: add some predefined strings for backward compatibility - mdoc, man: empty sections are not errors - mdoc: move delimiter handling to libmdoc - some header restructuring and some minor features and fixes This merge causes two minor regressions that i will fix in separate commits right afterwards.
Diffstat (limited to 'usr.bin/mandoc/libmdoc.h')
-rw-r--r--usr.bin/mandoc/libmdoc.h38
1 files changed, 26 insertions, 12 deletions
diff --git a/usr.bin/mandoc/libmdoc.h b/usr.bin/mandoc/libmdoc.h
index 9a06007e6ee..ceffcb05332 100644
--- a/usr.bin/mandoc/libmdoc.h
+++ b/usr.bin/mandoc/libmdoc.h
@@ -1,6 +1,6 @@
-/* $Id: libmdoc.h,v 1.44 2011/04/21 22:59:54 schwarze Exp $ */
+/* $Id: libmdoc.h,v 1.45 2011/04/24 16:22:02 schwarze Exp $ */
/*
- * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
+ * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -17,17 +17,14 @@
#ifndef LIBMDOC_H
#define LIBMDOC_H
-#include "mdoc.h"
-
enum mdoc_next {
MDOC_NEXT_SIBLING = 0,
MDOC_NEXT_CHILD
};
struct mdoc {
- void *data; /* private application data */
- mandocmsg msg; /* message callback */
- int flags;
+ struct mparse *parse; /* parse pointer */
+ int flags; /* parse flags */
#define MDOC_HALT (1 << 0) /* error in parse: halt */
#define MDOC_LITERAL (1 << 1) /* in a literal scope */
#define MDOC_PBODY (1 << 2) /* in the document body */
@@ -81,16 +78,31 @@ enum margverr {
ARGV_WORD
};
+/*
+ * A punctuation delimiter is opening, closing, or "middle mark"
+ * punctuation. These govern spacing.
+ * Opening punctuation (e.g., the opening parenthesis) suppresses the
+ * following space; closing punctuation (e.g., the closing parenthesis)
+ * suppresses the leading space; middle punctuation (e.g., the vertical
+ * bar) can do either. The middle punctuation delimiter bends the rules
+ * depending on usage.
+ */
+enum mdelim {
+ DELIM_NONE = 0,
+ DELIM_OPEN,
+ DELIM_MIDDLE,
+ DELIM_CLOSE,
+ DELIM_MAX
+};
+
extern const struct mdoc_macro *const mdoc_macros;
__BEGIN_DECLS
#define mdoc_pmsg(m, l, p, t) \
- (*(m)->msg)((t), (m)->data, (l), (p), NULL)
+ mandoc_msg((t), (m)->parse, (l), (p), NULL)
#define mdoc_nmsg(m, n, t) \
- (*(m)->msg)((t), (m)->data, (n)->line, (n)->pos, NULL)
-void mdoc_vmsg(struct mdoc *, enum mandocerr,
- int, int, const char *, ...);
+ mandoc_msg((t), (m)->parse, (n)->line, (n)->pos, NULL)
int mdoc_macro(MACRO_PROT_ARGS);
int mdoc_word_alloc(struct mdoc *,
int, int, const char *);
@@ -118,7 +130,6 @@ int mdoc_valid_post(struct mdoc *);
enum margverr mdoc_argv(struct mdoc *, int, enum mdoct,
struct mdoc_arg **, int *, char *);
void mdoc_argv_free(struct mdoc_arg *);
-void mdoc_argn_free(struct mdoc_arg *, int);
enum margserr mdoc_args(struct mdoc *, int,
int *, char *, enum mdoct, char **);
enum margserr mdoc_zargs(struct mdoc *, int,
@@ -129,6 +140,9 @@ enum margserr mdoc_zargs(struct mdoc *, int,
int mdoc_macroend(struct mdoc *);
+#define DELIMSZ 6 /* hint: max possible size of a delimiter */
+enum mdelim mdoc_isdelim(const char *);
+
__END_DECLS
#endif /*!LIBMDOC_H*/