]>
git.cameronkatri.com Git - mandoc.git/blob - mdoc.c
1 /* $Id: mdoc.c,v 1.208 2014/01/05 20:26:36 schwarze Exp $ */
3 * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
4 * Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 #include <sys/types.h>
34 #include "libmandoc.h"
36 const char *const __mdoc_macronames
[MDOC_MAX
] = {
37 "Ap", "Dd", "Dt", "Os",
38 "Sh", "Ss", "Pp", "D1",
39 "Dl", "Bd", "Ed", "Bl",
40 "El", "It", "Ad", "An",
41 "Ar", "Cd", "Cm", "Dv",
42 "Er", "Ev", "Ex", "Fa",
43 "Fd", "Fl", "Fn", "Ft",
44 "Ic", "In", "Li", "Nd",
45 "Nm", "Op", "Ot", "Pa",
46 "Rv", "St", "Va", "Vt",
48 "Xr", "%A", "%B", "%D",
50 "%I", "%J", "%N", "%O",
52 "%P", "%R", "%T", "%V",
53 "Ac", "Ao", "Aq", "At",
54 "Bc", "Bf", "Bo", "Bq",
55 "Bsx", "Bx", "Db", "Dc",
56 "Do", "Dq", "Ec", "Ef",
57 "Em", "Eo", "Fx", "Ms",
58 "No", "Ns", "Nx", "Ox",
59 "Pc", "Pf", "Po", "Pq",
60 "Qc", "Ql", "Qo", "Qq",
61 "Re", "Rs", "Sc", "So",
62 "Sq", "Sm", "Sx", "Sy",
63 "Tn", "Ux", "Xc", "Xo",
64 "Fo", "Fc", "Oo", "Oc",
65 "Bk", "Ek", "Bt", "Hf",
66 "Fr", "Ud", "Lb", "Lp",
67 "Lk", "Mt", "Brq", "Bro",
69 "Brc", "%C", "Es", "En",
71 "Dx", "%Q", "br", "sp",
76 const char *const __mdoc_argnames
[MDOC_ARG_MAX
] = {
77 "split", "nosplit", "ragged",
78 "unfilled", "literal", "file",
79 "offset", "bullet", "dash",
80 "hyphen", "item", "enum",
81 "tag", "diag", "hang",
82 "ohang", "inset", "column",
83 "width", "compact", "std",
84 "filled", "words", "emphasis",
85 "symbolic", "nested", "centered"
88 const char * const *mdoc_macronames
= __mdoc_macronames
;
89 const char * const *mdoc_argnames
= __mdoc_argnames
;
91 static void mdoc_node_free(struct mdoc_node
*);
92 static void mdoc_node_unlink(struct mdoc
*,
94 static void mdoc_free1(struct mdoc
*);
95 static void mdoc_alloc1(struct mdoc
*);
96 static struct mdoc_node
*node_alloc(struct mdoc
*, int, int,
97 enum mdoct
, enum mdoc_type
);
98 static int node_append(struct mdoc
*,
101 static int mdoc_preptext(struct mdoc
*, int, char *, int);
103 static int mdoc_ptext(struct mdoc
*, int, char *, int);
104 static int mdoc_pmacro(struct mdoc
*, int, char *, int);
106 const struct mdoc_node
*
107 mdoc_node(const struct mdoc
*mdoc
)
110 assert( ! (MDOC_HALT
& mdoc
->flags
));
115 const struct mdoc_meta
*
116 mdoc_meta(const struct mdoc
*mdoc
)
119 assert( ! (MDOC_HALT
& mdoc
->flags
));
125 * Frees volatile resources (parse tree, meta-data, fields).
128 mdoc_free1(struct mdoc
*mdoc
)
132 mdoc_node_delete(mdoc
, mdoc
->first
);
133 if (mdoc
->meta
.title
)
134 free(mdoc
->meta
.title
);
138 free(mdoc
->meta
.name
);
140 free(mdoc
->meta
.arch
);
142 free(mdoc
->meta
.vol
);
144 free(mdoc
->meta
.msec
);
146 free(mdoc
->meta
.date
);
151 * Allocate all volatile resources (parse tree, meta-data, fields).
154 mdoc_alloc1(struct mdoc
*mdoc
)
157 memset(&mdoc
->meta
, 0, sizeof(struct mdoc_meta
));
159 mdoc
->lastnamed
= mdoc
->lastsec
= SEC_NONE
;
160 mdoc
->last
= mandoc_calloc(1, sizeof(struct mdoc_node
));
161 mdoc
->first
= mdoc
->last
;
162 mdoc
->last
->type
= MDOC_ROOT
;
163 mdoc
->last
->tok
= MDOC_MAX
;
164 mdoc
->next
= MDOC_NEXT_CHILD
;
169 * Free up volatile resources (see mdoc_free1()) then re-initialises the
170 * data with mdoc_alloc1(). After invocation, parse data has been reset
171 * and the parser is ready for re-invocation on a new tree; however,
172 * cross-parse non-volatile data is kept intact.
175 mdoc_reset(struct mdoc
*mdoc
)
184 * Completely free up all volatile and non-volatile parse resources.
185 * After invocation, the pointer is no longer usable.
188 mdoc_free(struct mdoc
*mdoc
)
197 * Allocate volatile and non-volatile parse resources.
200 mdoc_alloc(struct roff
*roff
, struct mparse
*parse
,
201 char *defos
, int quick
)
205 p
= mandoc_calloc(1, sizeof(struct mdoc
));
219 * Climb back up the parse tree, validating open scopes. Mostly calls
220 * through to macro_end() in macro.c.
223 mdoc_endparse(struct mdoc
*mdoc
)
226 assert( ! (MDOC_HALT
& mdoc
->flags
));
227 if (mdoc_macroend(mdoc
))
229 mdoc
->flags
|= MDOC_HALT
;
234 mdoc_addeqn(struct mdoc
*mdoc
, const struct eqn
*ep
)
238 assert( ! (MDOC_HALT
& mdoc
->flags
));
240 /* No text before an initial macro. */
242 if (SEC_NONE
== mdoc
->lastnamed
) {
243 mdoc_pmsg(mdoc
, ep
->ln
, ep
->pos
, MANDOCERR_NOTEXT
);
247 n
= node_alloc(mdoc
, ep
->ln
, ep
->pos
, MDOC_MAX
, MDOC_EQN
);
250 if ( ! node_append(mdoc
, n
))
253 mdoc
->next
= MDOC_NEXT_SIBLING
;
258 mdoc_addspan(struct mdoc
*mdoc
, const struct tbl_span
*sp
)
262 assert( ! (MDOC_HALT
& mdoc
->flags
));
264 /* No text before an initial macro. */
266 if (SEC_NONE
== mdoc
->lastnamed
) {
267 mdoc_pmsg(mdoc
, sp
->line
, 0, MANDOCERR_NOTEXT
);
271 n
= node_alloc(mdoc
, sp
->line
, 0, MDOC_MAX
, MDOC_TBL
);
274 if ( ! node_append(mdoc
, n
))
277 mdoc
->next
= MDOC_NEXT_SIBLING
;
283 * Main parse routine. Parses a single line -- really just hands off to
284 * the macro (mdoc_pmacro()) or text parser (mdoc_ptext()).
287 mdoc_parseln(struct mdoc
*mdoc
, int ln
, char *buf
, int offs
)
290 assert( ! (MDOC_HALT
& mdoc
->flags
));
292 mdoc
->flags
|= MDOC_NEWLINE
;
295 * Let the roff nS register switch SYNOPSIS mode early,
296 * such that the parser knows at all times
297 * whether this mode is on or off.
298 * Note that this mode is also switched by the Sh macro.
300 if (roff_getreg(mdoc
->roff
, "nS"))
301 mdoc
->flags
|= MDOC_SYNOPSIS
;
303 mdoc
->flags
&= ~MDOC_SYNOPSIS
;
305 return(roff_getcontrol(mdoc
->roff
, buf
, &offs
) ?
306 mdoc_pmacro(mdoc
, ln
, buf
, offs
) :
307 mdoc_ptext(mdoc
, ln
, buf
, offs
));
311 mdoc_macro(MACRO_PROT_ARGS
)
313 assert(tok
< MDOC_MAX
);
315 /* If we're in the body, deny prologue calls. */
317 if (MDOC_PROLOGUE
& mdoc_macros
[tok
].flags
&&
318 MDOC_PBODY
& mdoc
->flags
) {
319 mdoc_pmsg(mdoc
, line
, ppos
, MANDOCERR_BADBODY
);
323 /* If we're in the prologue, deny "body" macros. */
325 if ( ! (MDOC_PROLOGUE
& mdoc_macros
[tok
].flags
) &&
326 ! (MDOC_PBODY
& mdoc
->flags
)) {
327 mdoc_pmsg(mdoc
, line
, ppos
, MANDOCERR_BADPROLOG
);
328 if (NULL
== mdoc
->meta
.msec
)
329 mdoc
->meta
.msec
= mandoc_strdup("1");
330 if (NULL
== mdoc
->meta
.title
)
331 mdoc
->meta
.title
= mandoc_strdup("UNKNOWN");
332 if (NULL
== mdoc
->meta
.vol
)
333 mdoc
->meta
.vol
= mandoc_strdup("LOCAL");
334 if (NULL
== mdoc
->meta
.os
)
335 mdoc
->meta
.os
= mandoc_strdup("LOCAL");
336 if (NULL
== mdoc
->meta
.date
)
337 mdoc
->meta
.date
= mandoc_normdate
338 (mdoc
->parse
, NULL
, line
, ppos
);
339 mdoc
->flags
|= MDOC_PBODY
;
342 return((*mdoc_macros
[tok
].fp
)(mdoc
, tok
, line
, ppos
, pos
, buf
));
347 node_append(struct mdoc
*mdoc
, struct mdoc_node
*p
)
352 assert(MDOC_ROOT
!= p
->type
);
354 switch (mdoc
->next
) {
355 case (MDOC_NEXT_SIBLING
):
356 mdoc
->last
->next
= p
;
357 p
->prev
= mdoc
->last
;
358 p
->parent
= mdoc
->last
->parent
;
360 case (MDOC_NEXT_CHILD
):
361 mdoc
->last
->child
= p
;
362 p
->parent
= mdoc
->last
;
372 * Copy over the normalised-data pointer of our parent. Not
373 * everybody has one, but copying a null pointer is fine.
378 if (ENDBODY_NOT
!= p
->end
)
384 p
->norm
= p
->parent
->norm
;
390 if ( ! mdoc_valid_pre(mdoc
, p
))
395 assert(MDOC_BLOCK
== p
->parent
->type
);
399 assert(MDOC_BLOCK
== p
->parent
->type
);
405 assert(MDOC_BLOCK
== p
->parent
->type
);
418 if ( ! mdoc_valid_post(mdoc
))
429 static struct mdoc_node
*
430 node_alloc(struct mdoc
*mdoc
, int line
, int pos
,
431 enum mdoct tok
, enum mdoc_type type
)
435 p
= mandoc_calloc(1, sizeof(struct mdoc_node
));
436 p
->sec
= mdoc
->lastsec
;
445 if (MDOC_SYNOPSIS
& mdoc
->flags
)
446 p
->flags
|= MDOC_SYNPRETTY
;
448 p
->flags
&= ~MDOC_SYNPRETTY
;
449 if (MDOC_NEWLINE
& mdoc
->flags
)
450 p
->flags
|= MDOC_LINE
;
451 mdoc
->flags
&= ~MDOC_NEWLINE
;
458 mdoc_tail_alloc(struct mdoc
*mdoc
, int line
, int pos
, enum mdoct tok
)
462 p
= node_alloc(mdoc
, line
, pos
, tok
, MDOC_TAIL
);
463 if ( ! node_append(mdoc
, p
))
465 mdoc
->next
= MDOC_NEXT_CHILD
;
471 mdoc_head_alloc(struct mdoc
*mdoc
, int line
, int pos
, enum mdoct tok
)
478 p
= node_alloc(mdoc
, line
, pos
, tok
, MDOC_HEAD
);
479 if ( ! node_append(mdoc
, p
))
481 mdoc
->next
= MDOC_NEXT_CHILD
;
487 mdoc_body_alloc(struct mdoc
*mdoc
, int line
, int pos
, enum mdoct tok
)
491 p
= node_alloc(mdoc
, line
, pos
, tok
, MDOC_BODY
);
492 if ( ! node_append(mdoc
, p
))
494 mdoc
->next
= MDOC_NEXT_CHILD
;
500 mdoc_endbody_alloc(struct mdoc
*mdoc
, int line
, int pos
, enum mdoct tok
,
501 struct mdoc_node
*body
, enum mdoc_endbody end
)
505 p
= node_alloc(mdoc
, line
, pos
, tok
, MDOC_BODY
);
507 p
->norm
= body
->norm
;
509 if ( ! node_append(mdoc
, p
))
511 mdoc
->next
= MDOC_NEXT_SIBLING
;
517 mdoc_block_alloc(struct mdoc
*mdoc
, int line
, int pos
,
518 enum mdoct tok
, struct mdoc_arg
*args
)
522 p
= node_alloc(mdoc
, line
, pos
, tok
, MDOC_BLOCK
);
535 p
->norm
= mandoc_calloc(1, sizeof(union mdoc_data
));
541 if ( ! node_append(mdoc
, p
))
543 mdoc
->next
= MDOC_NEXT_CHILD
;
549 mdoc_elem_alloc(struct mdoc
*mdoc
, int line
, int pos
,
550 enum mdoct tok
, struct mdoc_arg
*args
)
554 p
= node_alloc(mdoc
, line
, pos
, tok
, MDOC_ELEM
);
561 p
->norm
= mandoc_calloc(1, sizeof(union mdoc_data
));
567 if ( ! node_append(mdoc
, p
))
569 mdoc
->next
= MDOC_NEXT_CHILD
;
574 mdoc_word_alloc(struct mdoc
*mdoc
, int line
, int pos
, const char *p
)
578 n
= node_alloc(mdoc
, line
, pos
, MDOC_MAX
, MDOC_TEXT
);
579 n
->string
= roff_strdup(mdoc
->roff
, p
);
581 if ( ! node_append(mdoc
, n
))
584 mdoc
->next
= MDOC_NEXT_SIBLING
;
589 mdoc_word_append(struct mdoc
*mdoc
, const char *p
)
592 char *addstr
, *newstr
;
595 addstr
= roff_strdup(mdoc
->roff
, p
);
596 if (-1 == asprintf(&newstr
, "%s %s", n
->string
, addstr
)) {
598 exit((int)MANDOCLEVEL_SYSERR
);
603 mdoc
->next
= MDOC_NEXT_SIBLING
;
607 mdoc_node_free(struct mdoc_node
*p
)
610 if (MDOC_BLOCK
== p
->type
|| MDOC_ELEM
== p
->type
)
615 mdoc_argv_free(p
->args
);
621 mdoc_node_unlink(struct mdoc
*mdoc
, struct mdoc_node
*n
)
624 /* Adjust siblings. */
627 n
->prev
->next
= n
->next
;
629 n
->next
->prev
= n
->prev
;
635 if (n
->parent
->child
== n
)
636 n
->parent
->child
= n
->prev
? n
->prev
: n
->next
;
637 if (n
->parent
->last
== n
)
638 n
->parent
->last
= n
->prev
? n
->prev
: NULL
;
641 /* Adjust parse point, if applicable. */
643 if (mdoc
&& mdoc
->last
== n
) {
645 mdoc
->last
= n
->prev
;
646 mdoc
->next
= MDOC_NEXT_SIBLING
;
648 mdoc
->last
= n
->parent
;
649 mdoc
->next
= MDOC_NEXT_CHILD
;
653 if (mdoc
&& mdoc
->first
== n
)
659 mdoc_node_delete(struct mdoc
*mdoc
, struct mdoc_node
*p
)
664 mdoc_node_delete(mdoc
, p
->child
);
666 assert(0 == p
->nchild
);
668 mdoc_node_unlink(mdoc
, p
);
673 mdoc_node_relink(struct mdoc
*mdoc
, struct mdoc_node
*p
)
676 mdoc_node_unlink(mdoc
, p
);
677 return(node_append(mdoc
, p
));
682 * Pre-treat a text line.
683 * Text lines can consist of equations, which must be handled apart from
685 * Thus, use this function to step through a line checking if it has any
686 * equations embedded in it.
687 * This must handle multiple equations AND equations that do not end at
688 * the end-of-line, i.e., will re-enter in the next roff parse.
691 mdoc_preptext(struct mdoc
*mdoc
, int line
, char *buf
, int offs
)
696 while ('\0' != buf
[offs
]) {
697 /* Mark starting position if eqn is set. */
699 if ('\0' != (delim
= roff_eqndelim(mdoc
->roff
)))
700 if (NULL
!= (start
= strchr(buf
+ offs
, delim
)))
703 /* Parse text as normal. */
704 if ( ! mdoc_ptext(mdoc
, line
, buf
, offs
))
707 /* Continue only if an equation exists. */
711 /* Read past the end of the equation. */
712 offs
+= start
- (buf
+ offs
);
713 assert(start
== &buf
[offs
]);
714 if (NULL
!= (end
= strchr(buf
+ offs
, delim
))) {
720 /* Parse the equation itself. */
721 roff_openeqn(mdoc
->roff
, NULL
, line
, offs
, buf
);
723 /* Process a finished equation? */
724 if (roff_closeeqn(mdoc
->roff
))
725 if ( ! mdoc_addeqn(mdoc
, roff_eqn(mdoc
->roff
)))
727 offs
+= (end
- (buf
+ offs
));
735 * Parse free-form text, that is, a line that does not begin with the
739 mdoc_ptext(struct mdoc
*mdoc
, int line
, char *buf
, int offs
)
744 /* No text before an initial macro. */
746 if (SEC_NONE
== mdoc
->lastnamed
) {
747 mdoc_pmsg(mdoc
, line
, offs
, MANDOCERR_NOTEXT
);
755 * Divert directly to list processing if we're encountering a
756 * columnar MDOC_BLOCK with or without a prior MDOC_BLOCK entry
757 * (a MDOC_BODY means it's already open, in which case we should
758 * process within its context in the normal way).
761 if (MDOC_Bl
== n
->tok
&& MDOC_BODY
== n
->type
&&
762 LIST_column
== n
->norm
->Bl
.type
) {
763 /* `Bl' is open without any children. */
764 mdoc
->flags
|= MDOC_FREECOL
;
765 return(mdoc_macro(mdoc
, MDOC_It
, line
, offs
, &offs
, buf
));
768 if (MDOC_It
== n
->tok
&& MDOC_BLOCK
== n
->type
&&
770 MDOC_Bl
== n
->parent
->tok
&&
771 LIST_column
== n
->parent
->norm
->Bl
.type
) {
772 /* `Bl' has block-level `It' children. */
773 mdoc
->flags
|= MDOC_FREECOL
;
774 return(mdoc_macro(mdoc
, MDOC_It
, line
, offs
, &offs
, buf
));
778 * Search for the beginning of unescaped trailing whitespace (ws)
779 * and for the first character not to be output (end).
782 /* FIXME: replace with strcspn(). */
784 for (c
= end
= buf
+ offs
; *c
; c
++) {
792 * Always warn about trailing tabs,
793 * even outside literal context,
794 * where they should be put on the next line.
799 * Strip trailing tabs in literal context only;
800 * outside, they affect the next line.
802 if (MDOC_LITERAL
& mdoc
->flags
)
806 /* Skip the escaped character, too, if any. */
819 mdoc_pmsg(mdoc
, line
, (int)(ws
-buf
), MANDOCERR_EOLNSPACE
);
821 if ('\0' == buf
[offs
] && ! (MDOC_LITERAL
& mdoc
->flags
)) {
822 mdoc_pmsg(mdoc
, line
, (int)(c
-buf
), MANDOCERR_NOBLANKLN
);
825 * Insert a `sp' in the case of a blank line. Technically,
826 * blank lines aren't allowed, but enough manuals assume this
827 * behaviour that we want to work around it.
829 if ( ! mdoc_elem_alloc(mdoc
, line
, offs
, MDOC_sp
, NULL
))
832 mdoc
->next
= MDOC_NEXT_SIBLING
;
834 return(mdoc_valid_post(mdoc
));
837 if ( ! mdoc_word_alloc(mdoc
, line
, offs
, buf
+offs
))
840 if (MDOC_LITERAL
& mdoc
->flags
)
844 * End-of-sentence check. If the last character is an unescaped
845 * EOS character, then flag the node as being the end of a
846 * sentence. The front-end will know how to interpret this.
851 if (mandoc_eos(buf
+offs
, (size_t)(end
-buf
-offs
)))
852 mdoc
->last
->flags
|= MDOC_EOS
;
859 * Parse a macro line, that is, a line beginning with the control
863 mdoc_pmacro(struct mdoc
*mdoc
, int ln
, char *buf
, int offs
)
870 /* Empty post-control lines are ignored. */
872 if ('"' == buf
[offs
]) {
873 mdoc_pmsg(mdoc
, ln
, offs
, MANDOCERR_BADCOMMENT
);
875 } else if ('\0' == buf
[offs
])
881 * Copy the first word into a nil-terminated buffer.
882 * Stop copying when a tab, space, or eoln is encountered.
886 while (i
< 4 && '\0' != buf
[offs
] &&
887 ' ' != buf
[offs
] && '\t' != buf
[offs
])
888 mac
[i
++] = buf
[offs
++];
892 tok
= (i
> 1 || i
< 4) ? mdoc_hash_find(mac
) : MDOC_MAX
;
894 if (MDOC_MAX
== tok
) {
895 mandoc_vmsg(MANDOCERR_MACRO
, mdoc
->parse
,
896 ln
, sv
, "%s", buf
+ sv
- 1);
900 /* Disregard the first trailing tab, if applicable. */
902 if ('\t' == buf
[offs
])
905 /* Jump to the next non-whitespace word. */
907 while (buf
[offs
] && ' ' == buf
[offs
])
911 * Trailing whitespace. Note that tabs are allowed to be passed
912 * into the parser as "text", so we only warn about spaces here.
915 if ('\0' == buf
[offs
] && ' ' == buf
[offs
- 1])
916 mdoc_pmsg(mdoc
, ln
, offs
- 1, MANDOCERR_EOLNSPACE
);
919 * If an initial macro or a list invocation, divert directly
920 * into macro processing.
923 if (NULL
== mdoc
->last
|| MDOC_It
== tok
|| MDOC_El
== tok
) {
924 if ( ! mdoc_macro(mdoc
, tok
, ln
, sv
, &offs
, buf
))
933 * If the first macro of a `Bl -column', open an `It' block
934 * context around the parsed macro.
937 if (MDOC_Bl
== n
->tok
&& MDOC_BODY
== n
->type
&&
938 LIST_column
== n
->norm
->Bl
.type
) {
939 mdoc
->flags
|= MDOC_FREECOL
;
940 if ( ! mdoc_macro(mdoc
, MDOC_It
, ln
, sv
, &sv
, buf
))
946 * If we're following a block-level `It' within a `Bl -column'
947 * context (perhaps opened in the above block or in ptext()),
948 * then open an `It' block context around the parsed macro.
951 if (MDOC_It
== n
->tok
&& MDOC_BLOCK
== n
->type
&&
953 MDOC_Bl
== n
->parent
->tok
&&
954 LIST_column
== n
->parent
->norm
->Bl
.type
) {
955 mdoc
->flags
|= MDOC_FREECOL
;
956 if ( ! mdoc_macro(mdoc
, MDOC_It
, ln
, sv
, &sv
, buf
))
961 /* Normal processing of a macro. */
963 if ( ! mdoc_macro(mdoc
, tok
, ln
, sv
, &offs
, buf
))
966 /* In quick mode (for mandocdb), abort after the NAME section. */
968 if (mdoc
->quick
&& MDOC_Sh
== tok
&&
969 SEC_NAME
!= mdoc
->last
->sec
)
974 err
: /* Error out. */
976 mdoc
->flags
|= MDOC_HALT
;
981 mdoc_isdelim(const char *p
)
994 return(DELIM_MIDDLE
);
1010 return(DELIM_CLOSE
);
1018 if (0 == strcmp(p
+ 1, "."))
1019 return(DELIM_CLOSE
);
1020 if (0 == strcmp(p
+ 1, "fR|\\fP"))
1021 return(DELIM_MIDDLE
);