Print this page
Update to 1.12.3.
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/mandoc/libmdoc.h
+++ new/usr/src/cmd/mandoc/libmdoc.h
1 -/* $Id: libmdoc.h,v 1.78 2011/12/02 01:37:14 schwarze Exp $ */
1 +/* $Id: libmdoc.h,v 1.82 2013/10/21 23:47:58 schwarze Exp $ */
2 2 /*
3 3 * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
4 + * Copyright (c) 2013 Ingo Schwarze <schwarze@openbsd.org>
4 5 *
5 6 * Permission to use, copy, modify, and distribute this software for any
6 7 * purpose with or without fee is hereby granted, provided that the above
7 8 * copyright notice and this permission notice appear in all copies.
8 9 *
9 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 17 */
↓ open down ↓ |
3 lines elided |
↑ open up ↑ |
17 18 #ifndef LIBMDOC_H
18 19 #define LIBMDOC_H
19 20
20 21 enum mdoc_next {
21 22 MDOC_NEXT_SIBLING = 0,
22 23 MDOC_NEXT_CHILD
23 24 };
24 25
25 26 struct mdoc {
26 27 struct mparse *parse; /* parse pointer */
28 + char *defos; /* default argument for .Os */
27 29 int flags; /* parse flags */
28 30 #define MDOC_HALT (1 << 0) /* error in parse: halt */
29 31 #define MDOC_LITERAL (1 << 1) /* in a literal scope */
30 32 #define MDOC_PBODY (1 << 2) /* in the document body */
31 33 #define MDOC_NEWLINE (1 << 3) /* first macro/text in a line */
32 34 #define MDOC_PHRASELIT (1 << 4) /* literal within a partila phrase */
33 35 #define MDOC_PPHRASE (1 << 5) /* within a partial phrase */
34 36 #define MDOC_FREECOL (1 << 6) /* `It' invocation should close */
35 37 #define MDOC_SYNOPSIS (1 << 7) /* SYNOPSIS-style formatting */
38 +#define MDOC_KEEP (1 << 8) /* in a word keep */
39 +#define MDOC_SMOFF (1 << 9) /* spacing is off */
36 40 enum mdoc_next next; /* where to put the next node */
37 41 struct mdoc_node *last; /* the last node parsed */
38 42 struct mdoc_node *first; /* the first node parsed */
39 43 struct mdoc_meta meta; /* document meta-data */
40 44 enum mdoc_sec lastnamed;
41 45 enum mdoc_sec lastsec;
42 46 struct roff *roff;
43 47 };
44 48
45 -#define MACRO_PROT_ARGS struct mdoc *m, \
49 +#define MACRO_PROT_ARGS struct mdoc *mdoc, \
46 50 enum mdoct tok, \
47 51 int line, \
48 52 int ppos, \
49 53 int *pos, \
50 54 char *buf
51 55
52 56 struct mdoc_macro {
53 57 int (*fp)(MACRO_PROT_ARGS);
54 58 int flags;
55 59 #define MDOC_CALLABLE (1 << 0)
56 60 #define MDOC_PARSED (1 << 1)
57 61 #define MDOC_EXPLICIT (1 << 2)
58 62 #define MDOC_PROLOGUE (1 << 3)
59 -#define MDOC_IGNDELIM (1 << 4)
60 - /* Reserved words in arguments treated as text. */
63 +#define MDOC_IGNDELIM (1 << 4)
64 +#define MDOC_JOIN (1 << 5)
61 65 };
62 66
63 67 enum margserr {
64 68 ARGS_ERROR,
65 69 ARGS_EOLN, /* end-of-line */
66 70 ARGS_WORD, /* normal word */
67 71 ARGS_PUNCT, /* series of punctuation */
68 72 ARGS_QWORD, /* quoted word */
69 73 ARGS_PHRASE, /* Ta'd phrase (-column) */
70 74 ARGS_PPHRASE, /* tabbed phrase (-column) */
71 75 ARGS_PEND /* last phrase (-column) */
72 76 };
73 77
74 78 enum margverr {
75 79 ARGV_ERROR,
76 80 ARGV_EOLN, /* end of line */
77 81 ARGV_ARG, /* valid argument */
78 82 ARGV_WORD /* normal word (or bad argument---same thing) */
79 83 };
80 84
81 85 /*
82 86 * A punctuation delimiter is opening, closing, or "middle mark"
83 87 * punctuation. These govern spacing.
84 88 * Opening punctuation (e.g., the opening parenthesis) suppresses the
85 89 * following space; closing punctuation (e.g., the closing parenthesis)
86 90 * suppresses the leading space; middle punctuation (e.g., the vertical
87 91 * bar) can do either. The middle punctuation delimiter bends the rules
88 92 * depending on usage.
89 93 */
90 94 enum mdelim {
91 95 DELIM_NONE = 0,
↓ open down ↓ |
21 lines elided |
↑ open up ↑ |
92 96 DELIM_OPEN,
93 97 DELIM_MIDDLE,
94 98 DELIM_CLOSE,
95 99 DELIM_MAX
96 100 };
97 101
98 102 extern const struct mdoc_macro *const mdoc_macros;
99 103
100 104 __BEGIN_DECLS
101 105
102 -#define mdoc_pmsg(m, l, p, t) \
103 - mandoc_msg((t), (m)->parse, (l), (p), NULL)
104 -#define mdoc_nmsg(m, n, t) \
105 - mandoc_msg((t), (m)->parse, (n)->line, (n)->pos, NULL)
106 +#define mdoc_pmsg(mdoc, l, p, t) \
107 + mandoc_msg((t), (mdoc)->parse, (l), (p), NULL)
108 +#define mdoc_nmsg(mdoc, n, t) \
109 + mandoc_msg((t), (mdoc)->parse, (n)->line, (n)->pos, NULL)
106 110 int mdoc_macro(MACRO_PROT_ARGS);
107 111 int mdoc_word_alloc(struct mdoc *,
108 112 int, int, const char *);
113 +void mdoc_word_append(struct mdoc *, const char *);
109 114 int mdoc_elem_alloc(struct mdoc *, int, int,
110 115 enum mdoct, struct mdoc_arg *);
111 116 int mdoc_block_alloc(struct mdoc *, int, int,
112 117 enum mdoct, struct mdoc_arg *);
113 118 int mdoc_head_alloc(struct mdoc *, int, int, enum mdoct);
114 119 int mdoc_tail_alloc(struct mdoc *, int, int, enum mdoct);
115 120 int mdoc_body_alloc(struct mdoc *, int, int, enum mdoct);
116 -int mdoc_endbody_alloc(struct mdoc *m, int line, int pos,
117 - enum mdoct tok, struct mdoc_node *body,
118 - enum mdoc_endbody end);
121 +int mdoc_endbody_alloc(struct mdoc *, int, int, enum mdoct,
122 + struct mdoc_node *, enum mdoc_endbody);
119 123 void mdoc_node_delete(struct mdoc *, struct mdoc_node *);
124 +int mdoc_node_relink(struct mdoc *, struct mdoc_node *);
120 125 void mdoc_hash_init(void);
121 126 enum mdoct mdoc_hash_find(const char *);
122 127 const char *mdoc_a2att(const char *);
123 128 const char *mdoc_a2lib(const char *);
124 129 const char *mdoc_a2st(const char *);
125 130 const char *mdoc_a2arch(const char *);
126 131 const char *mdoc_a2vol(const char *);
127 132 int mdoc_valid_pre(struct mdoc *, struct mdoc_node *);
128 133 int mdoc_valid_post(struct mdoc *);
129 134 enum margverr mdoc_argv(struct mdoc *, int, enum mdoct,
130 135 struct mdoc_arg **, int *, char *);
131 136 void mdoc_argv_free(struct mdoc_arg *);
132 137 enum margserr mdoc_args(struct mdoc *, int,
133 138 int *, char *, enum mdoct, char **);
134 139 enum margserr mdoc_zargs(struct mdoc *, int,
135 140 int *, char *, char **);
136 141 int mdoc_macroend(struct mdoc *);
137 142 enum mdelim mdoc_isdelim(const char *);
138 143
139 144 __END_DECLS
140 145
141 146 #endif /*!LIBMDOC_H*/
↓ open down ↓ |
12 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX