]>
git.cameronkatri.com Git - mandoc.git/blob - mdoc_action.c
1 /* $Id: mdoc_action.c,v 1.79 2010/11/29 12:22:28 kristaps Exp $ */
3 * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 #include <sys/utsname.h>
33 #include "libmandoc.h"
36 * FIXME: this file is deprecated. All future "actions" should be
37 * pushed into mdoc_validate.c.
40 #define POST_ARGS struct mdoc *m, struct mdoc_node *n
41 #define PRE_ARGS struct mdoc *m, struct mdoc_node *n
48 int (*post
)(POST_ARGS
);
51 static int concat(struct mdoc
*, char *,
52 const struct mdoc_node
*, size_t);
54 static int post_ar(POST_ARGS
);
55 static int post_at(POST_ARGS
);
56 static int post_bl(POST_ARGS
);
57 static int post_bl_head(POST_ARGS
);
58 static int post_bl_tagwidth(POST_ARGS
);
59 static int post_bl_width(POST_ARGS
);
60 static int post_dd(POST_ARGS
);
61 static int post_display(POST_ARGS
);
62 static int post_dt(POST_ARGS
);
63 static int post_lb(POST_ARGS
);
64 static int post_li(POST_ARGS
);
65 static int post_nm(POST_ARGS
);
66 static int post_os(POST_ARGS
);
67 static int post_pa(POST_ARGS
);
68 static int post_prol(POST_ARGS
);
69 static int post_sh(POST_ARGS
);
70 static int post_st(POST_ARGS
);
71 static int post_std(POST_ARGS
);
73 static int pre_bd(PRE_ARGS
);
74 static int pre_dl(PRE_ARGS
);
76 static const struct actions mdoc_actions
[MDOC_MAX
] = {
77 { NULL
, NULL
}, /* Ap */
78 { NULL
, post_dd
}, /* Dd */
79 { NULL
, post_dt
}, /* Dt */
80 { NULL
, post_os
}, /* Os */
81 { NULL
, post_sh
}, /* Sh */
82 { NULL
, NULL
}, /* Ss */
83 { NULL
, NULL
}, /* Pp */
84 { NULL
, NULL
}, /* D1 */
85 { pre_dl
, post_display
}, /* Dl */
86 { pre_bd
, post_display
}, /* Bd */
87 { NULL
, NULL
}, /* Ed */
88 { NULL
, post_bl
}, /* Bl */
89 { NULL
, NULL
}, /* El */
90 { NULL
, NULL
}, /* It */
91 { NULL
, NULL
}, /* Ad */
92 { NULL
, NULL
}, /* An */
93 { NULL
, post_ar
}, /* Ar */
94 { NULL
, NULL
}, /* Cd */
95 { NULL
, NULL
}, /* Cm */
96 { NULL
, NULL
}, /* Dv */
97 { NULL
, NULL
}, /* Er */
98 { NULL
, NULL
}, /* Ev */
99 { NULL
, post_std
}, /* Ex */
100 { NULL
, NULL
}, /* Fa */
101 { NULL
, NULL
}, /* Fd */
102 { NULL
, NULL
}, /* Fl */
103 { NULL
, NULL
}, /* Fn */
104 { NULL
, NULL
}, /* Ft */
105 { NULL
, NULL
}, /* Ic */
106 { NULL
, NULL
}, /* In */
107 { NULL
, post_li
}, /* Li */
108 { NULL
, NULL
}, /* Nd */
109 { NULL
, post_nm
}, /* Nm */
110 { NULL
, NULL
}, /* Op */
111 { NULL
, NULL
}, /* Ot */
112 { NULL
, post_pa
}, /* Pa */
113 { NULL
, post_std
}, /* Rv */
114 { NULL
, post_st
}, /* St */
115 { NULL
, NULL
}, /* Va */
116 { NULL
, NULL
}, /* Vt */
117 { NULL
, NULL
}, /* Xr */
118 { NULL
, NULL
}, /* %A */
119 { NULL
, NULL
}, /* %B */
120 { NULL
, NULL
}, /* %D */
121 { NULL
, NULL
}, /* %I */
122 { NULL
, NULL
}, /* %J */
123 { NULL
, NULL
}, /* %N */
124 { NULL
, NULL
}, /* %O */
125 { NULL
, NULL
}, /* %P */
126 { NULL
, NULL
}, /* %R */
127 { NULL
, NULL
}, /* %T */
128 { NULL
, NULL
}, /* %V */
129 { NULL
, NULL
}, /* Ac */
130 { NULL
, NULL
}, /* Ao */
131 { NULL
, NULL
}, /* Aq */
132 { NULL
, post_at
}, /* At */
133 { NULL
, NULL
}, /* Bc */
134 { NULL
, NULL
}, /* Bf */
135 { NULL
, NULL
}, /* Bo */
136 { NULL
, NULL
}, /* Bq */
137 { NULL
, NULL
}, /* Bsx */
138 { NULL
, NULL
}, /* Bx */
139 { NULL
, NULL
}, /* Db */
140 { NULL
, NULL
}, /* Dc */
141 { NULL
, NULL
}, /* Do */
142 { NULL
, NULL
}, /* Dq */
143 { NULL
, NULL
}, /* Ec */
144 { NULL
, NULL
}, /* Ef */
145 { NULL
, NULL
}, /* Em */
146 { NULL
, NULL
}, /* Eo */
147 { NULL
, NULL
}, /* Fx */
148 { NULL
, NULL
}, /* Ms */
149 { NULL
, NULL
}, /* No */
150 { NULL
, NULL
}, /* Ns */
151 { NULL
, NULL
}, /* Nx */
152 { NULL
, NULL
}, /* Ox */
153 { NULL
, NULL
}, /* Pc */
154 { NULL
, NULL
}, /* Pf */
155 { NULL
, NULL
}, /* Po */
156 { NULL
, NULL
}, /* Pq */
157 { NULL
, NULL
}, /* Qc */
158 { NULL
, NULL
}, /* Ql */
159 { NULL
, NULL
}, /* Qo */
160 { NULL
, NULL
}, /* Qq */
161 { NULL
, NULL
}, /* Re */
162 { NULL
, NULL
}, /* Rs */
163 { NULL
, NULL
}, /* Sc */
164 { NULL
, NULL
}, /* So */
165 { NULL
, NULL
}, /* Sq */
166 { NULL
, NULL
}, /* Sm */
167 { NULL
, NULL
}, /* Sx */
168 { NULL
, NULL
}, /* Sy */
169 { NULL
, NULL
}, /* Tn */
170 { NULL
, NULL
}, /* Ux */
171 { NULL
, NULL
}, /* Xc */
172 { NULL
, NULL
}, /* Xo */
173 { NULL
, NULL
}, /* Fo */
174 { NULL
, NULL
}, /* Fc */
175 { NULL
, NULL
}, /* Oo */
176 { NULL
, NULL
}, /* Oc */
177 { NULL
, NULL
}, /* Bk */
178 { NULL
, NULL
}, /* Ek */
179 { NULL
, NULL
}, /* Bt */
180 { NULL
, NULL
}, /* Hf */
181 { NULL
, NULL
}, /* Fr */
182 { NULL
, NULL
}, /* Ud */
183 { NULL
, post_lb
}, /* Lb */
184 { NULL
, NULL
}, /* Lp */
185 { NULL
, NULL
}, /* Lk */
186 { NULL
, NULL
}, /* Mt */
187 { NULL
, NULL
}, /* Brq */
188 { NULL
, NULL
}, /* Bro */
189 { NULL
, NULL
}, /* Brc */
190 { NULL
, NULL
}, /* %C */
191 { NULL
, NULL
}, /* Es */
192 { NULL
, NULL
}, /* En */
193 { NULL
, NULL
}, /* Dx */
194 { NULL
, NULL
}, /* %Q */
195 { NULL
, NULL
}, /* br */
196 { NULL
, NULL
}, /* sp */
197 { NULL
, NULL
}, /* %U */
198 { NULL
, NULL
}, /* Ta */
203 static const enum mdoct rsord
[RSORD_MAX
] = {
222 mdoc_action_pre(struct mdoc
*m
, struct mdoc_node
*n
)
234 if (NULL
== mdoc_actions
[n
->tok
].pre
)
236 return((*mdoc_actions
[n
->tok
].pre
)(m
, n
));
241 mdoc_action_post(struct mdoc
*m
)
244 if (MDOC_ACTED
& m
->last
->flags
)
246 m
->last
->flags
|= MDOC_ACTED
;
248 switch (m
->last
->type
) {
257 if (NULL
== mdoc_actions
[m
->last
->tok
].post
)
259 return((*mdoc_actions
[m
->last
->tok
].post
)(m
, m
->last
));
264 * Concatenate sibling nodes together. All siblings must be of type
265 * MDOC_TEXT or an assertion is raised. Concatenation is separated by a
269 concat(struct mdoc
*m
, char *p
, const struct mdoc_node
*n
, size_t sz
)
274 for ( ; n
; n
= n
->next
) {
275 assert(MDOC_TEXT
== n
->type
);
277 * XXX: yes, these can technically be resized, but it's
278 * highly unlikely that we're going to get here, so let
281 if (strlcat(p
, n
->string
, sz
) >= sz
) {
282 mdoc_nmsg(m
, n
, MANDOCERR_MEM
);
287 if (strlcat(p
, " ", sz
) >= sz
) {
288 mdoc_nmsg(m
, n
, MANDOCERR_MEM
);
298 * Macros accepting `-std' as an argument have the name of the current
299 * document (`Nm') filled in as the argument if it's not provided.
304 struct mdoc_node
*nn
;
308 if (NULL
== m
->meta
.name
)
312 m
->next
= MDOC_NEXT_CHILD
;
314 if ( ! mdoc_word_alloc(m
, n
->line
, n
->pos
, m
->meta
.name
))
322 * The `Nm' macro's first use sets the name of the document. See also
332 if ( ! concat(m
, buf
, n
->child
, BUFSIZ
))
334 m
->meta
.name
= mandoc_strdup(buf
);
340 * Look up the value of `Lb' for matching predefined strings. If it has
341 * one, then substitute the current value for the formatted value. Note
342 * that the lookup may fail (we can provide arbitrary strings).
352 assert(MDOC_TEXT
== n
->child
->type
);
353 p
= mdoc_a2lib(n
->child
->string
);
356 free(n
->child
->string
);
357 n
->child
->string
= mandoc_strdup(p
);
361 sz
= strlen(n
->child
->string
) +
362 2 + strlen("\\(lqlibrary\\(rq");
363 buf
= mandoc_malloc(sz
);
364 snprintf(buf
, sz
, "library \\(lq%s\\(rq", n
->child
->string
);
365 free(n
->child
->string
);
366 n
->child
->string
= buf
;
372 * Substitute the value of `St' for the corresponding formatted string.
373 * We're guaranteed that this exists (it's been verified during the
382 assert(MDOC_TEXT
== n
->child
->type
);
383 p
= mdoc_a2st(n
->child
->string
);
385 free(n
->child
->string
);
386 n
->child
->string
= mandoc_strdup(p
);
393 * Look up the standard string in a table. We know that it exists from
394 * the validation phase, so assert on failure. If a standard key wasn't
395 * supplied, supply the default ``AT&T UNIX''.
400 struct mdoc_node
*nn
;
406 assert(MDOC_TEXT
== n
->child
->type
);
407 p
= mdoc_a2att(n
->child
->string
);
409 free(n
->child
->string
);
410 n
->child
->string
= mandoc_strdup(p
);
413 q
= n
->child
->string
;
414 sz
= strlen(p
) + strlen(q
) + 1;
415 buf
= mandoc_malloc(sz
);
418 free(n
->child
->string
);
419 n
->child
->string
= buf
;
425 m
->next
= MDOC_NEXT_CHILD
;
426 if ( ! mdoc_word_alloc(m
, nn
->line
, nn
->pos
, "AT&T UNIX"))
434 * Mark the current section. The ``named'' section (lastnamed) is set
435 * whenever the current section isn't a custom section--we use this to
436 * keep track of section ordering. Also check that the section is
437 * allowed within the document's manual section.
445 if (MDOC_HEAD
!= n
->type
)
448 if ( ! concat(m
, buf
, n
->child
, BUFSIZ
))
450 sec
= mdoc_str2sec(buf
);
452 * The first section should always make us move into a non-new
455 if (SEC_NONE
== m
->lastnamed
|| SEC_CUSTOM
!= sec
)
459 * Switch the parser's SYNOPSIS mode, to be copied
460 * into individual nodes when creating them.
461 * Note that this mode can also be set and unset
462 * using the roff nS register.
464 if (SEC_SYNOPSIS
== sec
)
465 m
->flags
|= MDOC_SYNOPSIS
;
467 m
->flags
&= ~MDOC_SYNOPSIS
;
469 /* Some sections only live in certain manual sections. */
471 switch ((m
->lastsec
= sec
)) {
472 case (SEC_RETURN_VALUES
):
475 assert(m
->meta
.msec
);
476 if (*m
->meta
.msec
== '2')
478 if (*m
->meta
.msec
== '3')
480 if (*m
->meta
.msec
== '9')
482 return(mdoc_nmsg(m
, n
, MANDOCERR_SECMSEC
));
491 * Parse out the contents of `Dt'. See in-line documentation for how we
492 * handle the various fields of this macro.
497 struct mdoc_node
*nn
;
507 m
->meta
.title
= m
->meta
.vol
= m
->meta
.arch
= NULL
;
509 * --> title = unknown, volume = local, msec = 0, arch = NULL
512 if (NULL
== (nn
= n
->child
)) {
513 /* XXX: make these macro values. */
514 /* FIXME: warn about missing values. */
515 m
->meta
.title
= mandoc_strdup("UNKNOWN");
516 m
->meta
.vol
= mandoc_strdup("LOCAL");
517 m
->meta
.msec
= mandoc_strdup("1");
518 return(post_prol(m
, n
));
521 /* Handles: `.Dt TITLE'
522 * --> title = TITLE, volume = local, msec = 0, arch = NULL
525 m
->meta
.title
= mandoc_strdup
526 ('\0' == nn
->string
[0] ? "UNKNOWN" : nn
->string
);
528 if (NULL
== (nn
= nn
->next
)) {
529 /* FIXME: warn about missing msec. */
530 /* XXX: make this a macro value. */
531 m
->meta
.vol
= mandoc_strdup("LOCAL");
532 m
->meta
.msec
= mandoc_strdup("1");
533 return(post_prol(m
, n
));
536 /* Handles: `.Dt TITLE SEC'
537 * --> title = TITLE, volume = SEC is msec ?
538 * format(msec) : SEC,
539 * msec = SEC is msec ? atoi(msec) : 0,
543 cp
= mdoc_a2msec(nn
->string
);
545 m
->meta
.vol
= mandoc_strdup(cp
);
546 m
->meta
.msec
= mandoc_strdup(nn
->string
);
547 } else if (mdoc_nmsg(m
, n
, MANDOCERR_BADMSEC
)) {
548 m
->meta
.vol
= mandoc_strdup(nn
->string
);
549 m
->meta
.msec
= mandoc_strdup(nn
->string
);
553 if (NULL
== (nn
= nn
->next
))
554 return(post_prol(m
, n
));
556 /* Handles: `.Dt TITLE SEC VOL'
557 * --> title = TITLE, volume = VOL is vol ?
559 * VOL is arch ? format(arch) :
563 cp
= mdoc_a2vol(nn
->string
);
566 m
->meta
.vol
= mandoc_strdup(cp
);
568 /* FIXME: warn about bad arch. */
569 cp
= mdoc_a2arch(nn
->string
);
572 m
->meta
.vol
= mandoc_strdup(nn
->string
);
574 m
->meta
.arch
= mandoc_strdup(cp
);
577 /* Ignore any subsequent parameters... */
578 /* FIXME: warn about subsequent parameters. */
580 return(post_prol(m
, n
));
585 * Set the operating system by way of the `Os' macro. Note that if an
586 * argument isn't provided and -DOSNAME="\"foo\"" is provided during
587 * compilation, this value will be used instead of filling in "sysname
588 * release" from uname().
595 struct utsname utsname
;
601 if ( ! concat(m
, buf
, n
->child
, BUFSIZ
))
604 /* XXX: yes, these can all be dynamically-adjusted buffers, but
605 * it's really not worth the extra hackery.
608 if ('\0' == buf
[0]) {
610 if (strlcat(buf
, OSNAME
, BUFSIZ
) >= BUFSIZ
) {
611 mdoc_nmsg(m
, n
, MANDOCERR_MEM
);
615 if (-1 == uname(&utsname
))
616 return(mdoc_nmsg(m
, n
, MANDOCERR_UTSNAME
));
618 if (strlcat(buf
, utsname
.sysname
, BUFSIZ
) >= BUFSIZ
) {
619 mdoc_nmsg(m
, n
, MANDOCERR_MEM
);
622 if (strlcat(buf
, " ", 64) >= BUFSIZ
) {
623 mdoc_nmsg(m
, n
, MANDOCERR_MEM
);
626 if (strlcat(buf
, utsname
.release
, BUFSIZ
) >= BUFSIZ
) {
627 mdoc_nmsg(m
, n
, MANDOCERR_MEM
);
633 m
->meta
.os
= mandoc_strdup(buf
);
634 return(post_prol(m
, n
));
639 * Calculate the -width for a `Bl -tag' list if it hasn't been provided.
640 * Uses the first head macro. NOTE AGAIN: this is ONLY if the -width
641 * argument has NOT been provided. See post_bl_width() for converting
645 post_bl_tagwidth(POST_ARGS
)
647 struct mdoc_node
*nn
;
654 for (nn
= n
->body
->child
; nn
; nn
= nn
->next
) {
655 if (MDOC_It
!= nn
->tok
)
658 assert(MDOC_BLOCK
== nn
->type
);
659 nn
= nn
->head
->child
;
662 /* No -width for .Bl and first .It is emtpy */
663 if ( ! mdoc_nmsg(m
, n
, MANDOCERR_NOWIDTHARG
))
668 if (MDOC_TEXT
== nn
->type
) {
669 sz
= strlen(nn
->string
) + 1;
673 if (0 != (ssz
= mdoc_macro2len(nn
->tok
)))
675 else if ( ! mdoc_nmsg(m
, n
, MANDOCERR_NOWIDTHARG
))
681 /* Defaults to ten ens. */
683 snprintf(buf
, NUMSIZ
, "%zun", sz
);
686 * We have to dynamically add this to the macro's argument list.
687 * We're guaranteed that a MDOC_Width doesn't already exist.
691 i
= (int)(n
->args
->argc
)++;
693 n
->args
->argv
= mandoc_realloc(n
->args
->argv
,
694 n
->args
->argc
* sizeof(struct mdoc_argv
));
696 n
->args
->argv
[i
].arg
= MDOC_Width
;
697 n
->args
->argv
[i
].line
= n
->line
;
698 n
->args
->argv
[i
].pos
= n
->pos
;
699 n
->args
->argv
[i
].sz
= 1;
700 n
->args
->argv
[i
].value
= mandoc_malloc(sizeof(char *));
701 n
->args
->argv
[i
].value
[0] = mandoc_strdup(buf
);
704 n
->data
.Bl
->width
= n
->args
->argv
[i
].value
[0];
710 * Calculate the real width of a list from the -width string, which may
711 * contain a macro (with a known default width), a literal string, or a
715 post_bl_width(POST_ARGS
)
723 * If the value to -width is a macro, then we re-write it to be
724 * the macro's width as set in share/tmac/mdoc/doc-common.
727 if (0 == strcmp(n
->data
.Bl
->width
, "Ds"))
729 else if (MDOC_MAX
== (tok
= mdoc_hash_find(n
->data
.Bl
->width
)))
731 else if (0 == (width
= mdoc_macro2len(tok
)))
732 return(mdoc_nmsg(m
, n
, MANDOCERR_BADWIDTH
));
734 /* The value already exists: free and reallocate it. */
738 for (i
= 0; i
< (int)n
->args
->argc
; i
++)
739 if (MDOC_Width
== n
->args
->argv
[i
].arg
)
742 assert(i
< (int)n
->args
->argc
);
744 snprintf(buf
, NUMSIZ
, "%zun", width
);
745 free(n
->args
->argv
[i
].value
[0]);
746 n
->args
->argv
[i
].value
[0] = mandoc_strdup(buf
);
749 n
->data
.Bl
->width
= n
->args
->argv
[i
].value
[0];
755 * Do processing for -column lists, which can have two distinct styles
756 * of invocation. Merge this two styles into a consistent form.
760 post_bl_head(POST_ARGS
)
763 struct mdoc_node
*np
, *nn
, *nnp
;
765 if (LIST_column
!= n
->data
.Bl
->type
)
767 else if (NULL
== n
->child
)
773 for (c
= 0; c
< (int)np
->args
->argc
; c
++)
774 if (MDOC_Column
== np
->args
->argv
[c
].arg
)
777 assert(c
< (int)np
->args
->argc
);
778 assert(0 == np
->args
->argv
[c
].sz
);
781 * Accomodate for new-style groff column syntax. Shuffle the
782 * child nodes, all of which must be TEXT, as arguments for the
783 * column field. Then, delete the head children.
786 np
->args
->argv
[c
].sz
= (size_t)n
->nchild
;
787 np
->args
->argv
[c
].value
= mandoc_malloc
788 ((size_t)n
->nchild
* sizeof(char *));
790 n
->data
.Bl
->ncols
= np
->args
->argv
[c
].sz
;
791 n
->data
.Bl
->cols
= (const char **)np
->args
->argv
[c
].value
;
793 for (i
= 0, nn
= n
->child
; nn
; i
++) {
794 np
->args
->argv
[c
].value
[i
] = nn
->string
;
798 mdoc_node_delete(NULL
, nnp
);
811 if (MDOC_HEAD
== n
->type
)
812 return(post_bl_head(m
, n
));
813 if (MDOC_BLOCK
!= n
->type
)
817 * These are fairly complicated, so we've broken them into two
818 * functions. post_bl_tagwidth() is called when a -tag is
819 * specified, but no -width (it must be guessed). The second
820 * when a -width is specified (macro indicators must be
821 * rewritten into real lengths).
824 if (LIST_tag
== n
->data
.Bl
->type
&& NULL
== n
->data
.Bl
->width
) {
825 if ( ! post_bl_tagwidth(m
, n
))
827 } else if (NULL
!= n
->data
.Bl
->width
) {
828 if ( ! post_bl_width(m
, n
))
833 assert(n
->data
.Bl
->width
);
839 * The `Pa' macro defaults to a tilde if no value is provided as an
845 struct mdoc_node
*np
;
851 m
->next
= MDOC_NEXT_CHILD
;
852 if ( ! mdoc_word_alloc(m
, n
->line
, n
->pos
, "~"))
860 * Empty `Li' macros get an empty string to make front-ends add an extra
866 struct mdoc_node
*np
;
872 m
->next
= MDOC_NEXT_CHILD
;
873 if ( ! mdoc_word_alloc(m
, n
->line
, n
->pos
, ""))
881 * The `Ar' macro defaults to two strings "file ..." if no value is
882 * provided as an argument.
887 struct mdoc_node
*np
;
893 m
->next
= MDOC_NEXT_CHILD
;
894 /* XXX: make into macro values. */
895 if ( ! mdoc_word_alloc(m
, n
->line
, n
->pos
, "file"))
897 if ( ! mdoc_word_alloc(m
, n
->line
, n
->pos
, "..."))
905 * Parse the date field in `Dd'.
912 if (NULL
== n
->child
) {
913 m
->meta
.date
= time(NULL
);
914 return(post_prol(m
, n
));
917 if ( ! concat(m
, buf
, n
->child
, DATESIZ
))
920 m
->meta
.date
= mandoc_a2time
921 (MTIME_MDOCDATE
| MTIME_CANONICAL
, buf
);
923 if (0 == m
->meta
.date
) {
924 if ( ! mdoc_nmsg(m
, n
, MANDOCERR_BADDATE
))
926 m
->meta
.date
= time(NULL
);
929 return(post_prol(m
, n
));
934 * Remove prologue macros from the document after they're processed.
935 * The final document uses mdoc_meta for these values and discards the
942 mdoc_node_delete(m
, n
);
943 if (m
->meta
.title
&& m
->meta
.date
&& m
->meta
.os
)
944 m
->flags
|= MDOC_PBODY
;
950 * Trigger a literal context.
956 if (MDOC_BODY
== n
->type
)
957 m
->flags
|= MDOC_LITERAL
;
966 if (MDOC_BODY
!= n
->type
)
970 if (DISP_literal
== n
->data
.Bd
->type
)
971 m
->flags
|= MDOC_LITERAL
;
972 if (DISP_unfilled
== n
->data
.Bd
->type
)
973 m
->flags
|= MDOC_LITERAL
;
980 post_display(POST_ARGS
)
983 if (MDOC_BODY
== n
->type
)
984 m
->flags
&= ~MDOC_LITERAL
;