Annotation of src/usr.bin/mandoc/mdoc_action.c, Revision 1.2
1.2 ! schwarze 1: /* $Id: mdoc_action.c,v 1.11 2009/06/12 12:52:51 kristaps Exp $ */
1.1 kristaps 2: /*
1.2 ! schwarze 3: * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
1.1 kristaps 4: *
5: * Permission to use, copy, modify, and distribute this software for any
1.2 ! schwarze 6: * purpose with or without fee is hereby granted, provided that the above
! 7: * copyright notice and this permission notice appear in all copies.
1.1 kristaps 8: *
1.2 ! schwarze 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.
1.1 kristaps 16: */
17: #include <sys/utsname.h>
18:
19: #include <assert.h>
20: #include <errno.h>
21: #include <stdio.h>
22: #include <stdlib.h>
23: #include <string.h>
24:
25: #include "libmdoc.h"
26:
27: enum mwarn {
28: WBADSEC,
29: WNOWIDTH,
30: WBADDATE
31: };
32:
33: enum merr {
34: ETOOLONG,
35: EMALLOC,
36: ENUMFMT
37: };
38:
39: #define PRE_ARGS struct mdoc *m, const struct mdoc_node *n
40: #define POST_ARGS struct mdoc *m
41:
42: struct actions {
43: int (*pre)(PRE_ARGS);
44: int (*post)(POST_ARGS);
45: };
46:
47: static int pwarn(struct mdoc *, int, int, enum mwarn);
48: static int perr(struct mdoc *, int, int, enum merr);
49: static int concat(struct mdoc *, const struct mdoc_node *,
50: char *, size_t);
51:
52: static int post_ar(POST_ARGS);
53: static int post_bl(POST_ARGS);
54: static int post_bl_width(POST_ARGS);
55: static int post_bl_tagwidth(POST_ARGS);
56: static int post_dd(POST_ARGS);
57: static int post_display(POST_ARGS);
58: static int post_dt(POST_ARGS);
59: static int post_nm(POST_ARGS);
60: static int post_os(POST_ARGS);
61: static int post_prol(POST_ARGS);
62: static int post_sh(POST_ARGS);
63: static int post_std(POST_ARGS);
64:
65: static int pre_bd(PRE_ARGS);
66: static int pre_dl(PRE_ARGS);
67:
68: #define vwarn(m, t) pwarn((m), (m)->last->line, (m)->last->pos, (t))
69: #define verr(m, t) perr((m), (m)->last->line, (m)->last->pos, (t))
70: #define nerr(m, n, t) perr((m), (n)->line, (n)->pos, (t))
71:
72: const struct actions mdoc_actions[MDOC_MAX] = {
73: { NULL, NULL }, /* \" */
74: { NULL, post_dd }, /* Dd */
75: { NULL, post_dt }, /* Dt */
76: { NULL, post_os }, /* Os */
77: { NULL, post_sh }, /* Sh */
78: { NULL, NULL }, /* Ss */
79: { NULL, NULL }, /* Pp */
80: { NULL, NULL }, /* D1 */
81: { pre_dl, post_display }, /* Dl */
82: { pre_bd, post_display }, /* Bd */
83: { NULL, NULL }, /* Ed */
84: { NULL, post_bl }, /* Bl */
85: { NULL, NULL }, /* El */
86: { NULL, NULL }, /* It */
87: { NULL, NULL }, /* Ad */
88: { NULL, NULL }, /* An */
89: { NULL, post_ar }, /* Ar */
90: { NULL, NULL }, /* Cd */
91: { NULL, NULL }, /* Cm */
92: { NULL, NULL }, /* Dv */
93: { NULL, NULL }, /* Er */
94: { NULL, NULL }, /* Ev */
95: { NULL, post_std }, /* Ex */
96: { NULL, NULL }, /* Fa */
97: { NULL, NULL }, /* Fd */
98: { NULL, NULL }, /* Fl */
99: { NULL, NULL }, /* Fn */
100: { NULL, NULL }, /* Ft */
101: { NULL, NULL }, /* Ic */
102: { NULL, NULL }, /* In */
103: { NULL, NULL }, /* Li */
104: { NULL, NULL }, /* Nd */
105: { NULL, post_nm }, /* Nm */
106: { NULL, NULL }, /* Op */
107: { NULL, NULL }, /* Ot */
108: { NULL, NULL }, /* Pa */
109: { NULL, post_std }, /* Rv */
110: { NULL, NULL }, /* St */
111: { NULL, NULL }, /* Va */
112: { NULL, NULL }, /* Vt */
113: { NULL, NULL }, /* Xr */
114: { NULL, NULL }, /* %A */
115: { NULL, NULL }, /* %B */
116: { NULL, NULL }, /* %D */
117: { NULL, NULL }, /* %I */
118: { NULL, NULL }, /* %J */
119: { NULL, NULL }, /* %N */
120: { NULL, NULL }, /* %O */
121: { NULL, NULL }, /* %P */
122: { NULL, NULL }, /* %R */
123: { NULL, NULL }, /* %T */
124: { NULL, NULL }, /* %V */
125: { NULL, NULL }, /* Ac */
126: { NULL, NULL }, /* Ao */
127: { NULL, NULL }, /* Aq */
128: { NULL, NULL }, /* At */
129: { NULL, NULL }, /* Bc */
130: { NULL, NULL }, /* Bf */
131: { NULL, NULL }, /* Bo */
132: { NULL, NULL }, /* Bq */
133: { NULL, NULL }, /* Bsx */
134: { NULL, NULL }, /* Bx */
135: { NULL, NULL }, /* Db */
136: { NULL, NULL }, /* Dc */
137: { NULL, NULL }, /* Do */
138: { NULL, NULL }, /* Dq */
139: { NULL, NULL }, /* Ec */
140: { NULL, NULL }, /* Ef */
141: { NULL, NULL }, /* Em */
142: { NULL, NULL }, /* Eo */
143: { NULL, NULL }, /* Fx */
144: { NULL, NULL }, /* Ms */
145: { NULL, NULL }, /* No */
146: { NULL, NULL }, /* Ns */
147: { NULL, NULL }, /* Nx */
148: { NULL, NULL }, /* Ox */
149: { NULL, NULL }, /* Pc */
150: { NULL, NULL }, /* Pf */
151: { NULL, NULL }, /* Po */
152: { NULL, NULL }, /* Pq */
153: { NULL, NULL }, /* Qc */
154: { NULL, NULL }, /* Ql */
155: { NULL, NULL }, /* Qo */
156: { NULL, NULL }, /* Qq */
157: { NULL, NULL }, /* Re */
158: { NULL, NULL }, /* Rs */
159: { NULL, NULL }, /* Sc */
160: { NULL, NULL }, /* So */
161: { NULL, NULL }, /* Sq */
162: { NULL, NULL }, /* Sm */
163: { NULL, NULL }, /* Sx */
164: { NULL, NULL }, /* Sy */
165: { NULL, NULL }, /* Tn */
166: { NULL, NULL }, /* Ux */
167: { NULL, NULL }, /* Xc */
168: { NULL, NULL }, /* Xo */
169: { NULL, NULL }, /* Fo */
170: { NULL, NULL }, /* Fc */
171: { NULL, NULL }, /* Oo */
172: { NULL, NULL }, /* Oc */
173: { NULL, NULL }, /* Bk */
174: { NULL, NULL }, /* Ek */
175: { NULL, NULL }, /* Bt */
176: { NULL, NULL }, /* Hf */
177: { NULL, NULL }, /* Fr */
178: { NULL, NULL }, /* Ud */
179: { NULL, NULL }, /* Lb */
180: { NULL, NULL }, /* Ap */
181: { NULL, NULL }, /* Lp */
182: { NULL, NULL }, /* Lk */
183: { NULL, NULL }, /* Mt */
184: { NULL, NULL }, /* Brq */
185: { NULL, NULL }, /* Bro */
186: { NULL, NULL }, /* Brc */
187: { NULL, NULL }, /* %C */
188: { NULL, NULL }, /* Es */
189: { NULL, NULL }, /* En */
190: { NULL, NULL }, /* Dx */
191: { NULL, NULL }, /* %Q */
192: };
193:
194:
195: int
196: mdoc_action_pre(struct mdoc *m, const struct mdoc_node *n)
197: {
198:
199: switch (n->type) {
200: case (MDOC_ROOT):
201: /* FALLTHROUGH */
202: case (MDOC_TEXT):
203: return(1);
204: default:
205: break;
206: }
207:
208: if (NULL == mdoc_actions[n->tok].pre)
209: return(1);
210: return((*mdoc_actions[n->tok].pre)(m, n));
211: }
212:
213:
214: int
215: mdoc_action_post(struct mdoc *m)
216: {
217:
218: if (MDOC_ACTED & m->last->flags)
219: return(1);
220: m->last->flags |= MDOC_ACTED;
221:
222: switch (m->last->type) {
223: case (MDOC_TEXT):
224: /* FALLTHROUGH */
225: case (MDOC_ROOT):
226: return(1);
227: default:
228: break;
229: }
230:
231: if (NULL == mdoc_actions[m->last->tok].post)
232: return(1);
233: return((*mdoc_actions[m->last->tok].post)(m));
234: }
235:
236:
237: static int
238: concat(struct mdoc *m, const struct mdoc_node *n,
239: char *buf, size_t sz)
240: {
241:
242: for ( ; n; n = n->next) {
243: assert(MDOC_TEXT == n->type);
244: if (strlcat(buf, n->string, sz) >= sz)
245: return(nerr(m, n, ETOOLONG));
246: if (NULL == n->next)
247: continue;
248: if (strlcat(buf, " ", sz) >= sz)
249: return(nerr(m, n, ETOOLONG));
250: }
251:
252: return(1);
253: }
254:
255:
256: static int
257: perr(struct mdoc *m, int line, int pos, enum merr type)
258: {
259: char *p;
260:
261: p = NULL;
262: switch (type) {
263: case (ENUMFMT):
264: p = "bad number format";
265: break;
266: case (ETOOLONG):
267: p = "argument text too long";
268: break;
269: case (EMALLOC):
270: p = "memory exhausted";
271: break;
272: }
273: assert(p);
274: return(mdoc_perr(m, line, pos, p));
275: }
276:
277:
278: static int
279: pwarn(struct mdoc *m, int line, int pos, enum mwarn type)
280: {
281: char *p;
282: int c;
283:
284: p = NULL;
285: c = WARN_SYNTAX;
286: switch (type) {
287: case (WBADSEC):
288: p = "inappropriate document section in manual section";
289: c = WARN_COMPAT;
290: break;
291: case (WNOWIDTH):
292: p = "cannot determine default width";
293: break;
294: case (WBADDATE):
295: p = "malformed date syntax";
296: break;
297: }
298: assert(p);
299: return(mdoc_pwarn(m, line, pos, c, p));
300: }
301:
302:
303: static int
304: post_std(POST_ARGS)
305: {
306:
307: /*
308: * If '-std' is invoked without an argument, fill it in with our
309: * name (if it's been set).
310: */
311:
312: if (NULL == m->last->args)
313: return(1);
314: if (m->last->args->argv[0].sz)
315: return(1);
316:
317: assert(m->meta.name);
318:
319: m->last->args->argv[0].value = calloc(1, sizeof(char *));
320: if (NULL == m->last->args->argv[0].value)
321: return(verr(m, EMALLOC));
322:
323: m->last->args->argv[0].sz = 1;
324: m->last->args->argv[0].value[0] = strdup(m->meta.name);
325: if (NULL == m->last->args->argv[0].value[0])
326: return(verr(m, EMALLOC));
327:
328: return(1);
329: }
330:
331:
332: static int
333: post_nm(POST_ARGS)
334: {
335: char buf[64];
336:
337: if (m->meta.name)
338: return(1);
339:
340: buf[0] = 0;
341: if ( ! concat(m, m->last->child, buf, sizeof(buf)))
342: return(0);
1.2 ! schwarze 343:
1.1 kristaps 344: if (NULL == (m->meta.name = strdup(buf)))
345: return(verr(m, EMALLOC));
1.2 ! schwarze 346:
1.1 kristaps 347: return(1);
348: }
349:
350:
351: static int
352: post_sh(POST_ARGS)
353: {
354: enum mdoc_sec sec;
355: char buf[64];
356:
357: /*
358: * We keep track of the current section /and/ the "named"
359: * section, which is one of the conventional ones, in order to
360: * check ordering.
361: */
362:
363: if (MDOC_HEAD != m->last->type)
364: return(1);
365:
366: buf[0] = 0;
367: if ( ! concat(m, m->last->child, buf, sizeof(buf)))
368: return(0);
369: if (SEC_CUSTOM != (sec = mdoc_atosec(buf)))
370: m->lastnamed = sec;
371:
372: switch ((m->lastsec = sec)) {
373: case (SEC_RETURN_VALUES):
374: /* FALLTHROUGH */
375: case (SEC_ERRORS):
376: switch (m->meta.msec) {
377: case (2):
378: /* FALLTHROUGH */
379: case (3):
380: /* FALLTHROUGH */
381: case (9):
382: break;
383: default:
384: return(vwarn(m, WBADSEC));
385: }
386: break;
387: default:
388: break;
389: }
390: return(1);
391: }
392:
393:
394: static int
395: post_dt(POST_ARGS)
396: {
397: struct mdoc_node *n;
398: const char *cp;
399: char *ep;
400: long lval;
401:
402: if (m->meta.title)
403: free(m->meta.title);
404: if (m->meta.vol)
405: free(m->meta.vol);
406: if (m->meta.arch)
407: free(m->meta.arch);
408:
409: m->meta.title = m->meta.vol = m->meta.arch = NULL;
410: m->meta.msec = 0;
411:
412: /* Handles: `.Dt'
413: * --> title = unknown, volume = local, msec = 0, arch = NULL
414: */
415:
416: if (NULL == (n = m->last->child)) {
417: if (NULL == (m->meta.title = strdup("unknown")))
418: return(verr(m, EMALLOC));
419: if (NULL == (m->meta.vol = strdup("local")))
420: return(verr(m, EMALLOC));
421: return(post_prol(m));
422: }
423:
424: /* Handles: `.Dt TITLE'
425: * --> title = TITLE, volume = local, msec = 0, arch = NULL
426: */
427:
428: if (NULL == (m->meta.title = strdup(n->string)))
429: return(verr(m, EMALLOC));
430:
431: if (NULL == (n = n->next)) {
432: if (NULL == (m->meta.vol = strdup("local")))
433: return(verr(m, EMALLOC));
434: return(post_prol(m));
435: }
436:
437: /* Handles: `.Dt TITLE SEC'
438: * --> title = TITLE, volume = SEC is msec ?
439: * format(msec) : SEC,
440: * msec = SEC is msec ? atoi(msec) : 0,
441: * arch = NULL
442: */
443:
444: cp = mdoc_a2msec(n->string);
445: if (cp) {
446: if (NULL == (m->meta.vol = strdup(cp)))
447: return(verr(m, EMALLOC));
448: errno = 0;
449: lval = strtol(n->string, &ep, 10);
450: if (n->string[0] != '\0' && *ep == '\0')
451: m->meta.msec = (int)lval;
452: } else if (NULL == (m->meta.vol = strdup(n->string)))
453: return(verr(m, EMALLOC));
454:
455: if (NULL == (n = n->next))
456: return(post_prol(m));
457:
458: /* Handles: `.Dt TITLE SEC VOL'
459: * --> title = TITLE, volume = VOL is vol ?
460: * format(VOL) :
461: * VOL is arch ? format(arch) :
462: * VOL
463: */
464:
465: cp = mdoc_a2vol(n->string);
466: if (cp) {
467: free(m->meta.vol);
468: if (NULL == (m->meta.vol = strdup(cp)))
469: return(verr(m, EMALLOC));
470: n = n->next;
471: } else {
472: cp = mdoc_a2arch(n->string);
473: if (NULL == cp) {
474: free(m->meta.vol);
475: if (NULL == (m->meta.vol = strdup(n->string)))
476: return(verr(m, EMALLOC));
477: } else if (NULL == (m->meta.arch = strdup(cp)))
478: return(verr(m, EMALLOC));
479: }
480:
481: /* Ignore any subsequent parameters... */
482:
483: return(post_prol(m));
484: }
485:
486:
487: static int
488: post_os(POST_ARGS)
489: {
490: char buf[64];
491: struct utsname utsname;
492:
493: if (m->meta.os)
494: free(m->meta.os);
495:
496: buf[0] = 0;
497: if ( ! concat(m, m->last->child, buf, sizeof(buf)))
498: return(0);
499:
500: if (0 == buf[0]) {
501: if (-1 == uname(&utsname))
502: return(mdoc_err(m, "utsname"));
503: if (strlcat(buf, utsname.sysname, 64) >= 64)
504: return(verr(m, ETOOLONG));
505: if (strlcat(buf, " ", 64) >= 64)
506: return(verr(m, ETOOLONG));
507: if (strlcat(buf, utsname.release, 64) >= 64)
508: return(verr(m, ETOOLONG));
509: }
510:
511: if (NULL == (m->meta.os = strdup(buf)))
512: return(verr(m, EMALLOC));
513: m->lastnamed = m->lastsec = SEC_BODY;
514:
515: return(post_prol(m));
516: }
517:
518:
519: /*
520: * Calculate the -width for a `Bl -tag' list if it hasn't been provided.
521: * Uses the first head macro.
522: */
523: static int
524: post_bl_tagwidth(struct mdoc *m)
525: {
526: struct mdoc_node *n;
527: int sz;
528: char buf[32];
529:
530: /*
531: * Use the text width, if a text node, or the default macro
532: * width if a macro.
533: */
534:
535: if ((n = m->last->body->child)) {
536: assert(MDOC_BLOCK == n->type);
537: assert(MDOC_It == n->tok);
538: n = n->head->child;
539: }
540:
541: sz = 10; /* Default size. */
542:
543: if (n) {
544: if (MDOC_TEXT != n->type) {
545: if (0 == (sz = (int)mdoc_macro2len(n->tok)))
546: if ( ! vwarn(m, WNOWIDTH))
547: return(0);
548: } else
549: sz = (int)strlen(n->string) + 1;
550: }
551:
552: if (-1 == snprintf(buf, sizeof(buf), "%dn", sz))
553: return(verr(m, ENUMFMT));
554:
555: /*
556: * We have to dynamically add this to the macro's argument list.
557: * We're guaranteed that a MDOC_Width doesn't already exist.
558: */
559:
560: n = m->last;
561: assert(n->args);
562: sz = (int)(n->args->argc)++;
563:
564: n->args->argv = realloc(n->args->argv,
565: n->args->argc * sizeof(struct mdoc_argv));
566:
567: if (NULL == n->args->argv)
568: return(verr(m, EMALLOC));
569:
570: n->args->argv[sz].arg = MDOC_Width;
571: n->args->argv[sz].line = m->last->line;
572: n->args->argv[sz].pos = m->last->pos;
573: n->args->argv[sz].sz = 1;
574: n->args->argv[sz].value = calloc(1, sizeof(char *));
575:
576: if (NULL == n->args->argv[sz].value)
577: return(verr(m, EMALLOC));
578: if (NULL == (n->args->argv[sz].value[0] = strdup(buf)))
579: return(verr(m, EMALLOC));
580:
581: return(1);
582: }
583:
584:
585: static int
586: post_bl_width(struct mdoc *m)
587: {
588: size_t width;
589: int i, tok;
590: char buf[32];
591: char *p;
592:
593: if (NULL == m->last->args)
594: return(1);
595:
596: for (i = 0; i < (int)m->last->args->argc; i++)
597: if (MDOC_Width == m->last->args->argv[i].arg)
598: break;
599:
600: if (i == (int)m->last->args->argc)
601: return(1);
602: p = m->last->args->argv[i].value[0];
603:
604: /*
605: * If the value to -width is a macro, then we re-write it to be
606: * the macro's width as set in share/tmac/mdoc/doc-common.
607: */
608:
609: if (0 == strcmp(p, "Ds"))
610: width = 8;
611: else if (MDOC_MAX == (tok = mdoc_hash_find(m->htab, p)))
612: return(1);
613: else if (0 == (width = mdoc_macro2len(tok)))
614: return(vwarn(m, WNOWIDTH));
615:
616: /* The value already exists: free and reallocate it. */
617:
618: if (-1 == snprintf(buf, sizeof(buf), "%zun", width))
619: return(verr(m, ENUMFMT));
620:
621: free(m->last->args->argv[i].value[0]);
622: m->last->args->argv[i].value[0] = strdup(buf);
623: if (NULL == m->last->args->argv[i].value[0])
624: return(verr(m, EMALLOC));
625:
626: return(1);
627: }
628:
629:
630: static int
631: post_bl(POST_ARGS)
632: {
633: int i, r, len;
634:
635: if (MDOC_BLOCK != m->last->type)
636: return(1);
637:
638: /*
639: * These are fairly complicated, so we've broken them into two
640: * functions. post_bl_tagwidth() is called when a -tag is
641: * specified, but no -width (it must be guessed). The second
642: * when a -width is specified (macro indicators must be
643: * rewritten into real lengths).
644: */
645:
646: len = (int)(m->last->args ? m->last->args->argc : 0);
647:
648: for (r = i = 0; i < len; i++) {
649: if (MDOC_Tag == m->last->args->argv[i].arg)
650: r |= 1 << 0;
651: if (MDOC_Width == m->last->args->argv[i].arg)
652: r |= 1 << 1;
653: }
654:
655: if (r & (1 << 0) && ! (r & (1 << 1))) {
656: if ( ! post_bl_tagwidth(m))
657: return(0);
658: } else if (r & (1 << 1))
659: if ( ! post_bl_width(m))
660: return(0);
661:
662: return(1);
663: }
664:
665:
666: static int
667: post_ar(POST_ARGS)
668: {
669: struct mdoc_node *n;
670:
671: if (m->last->child)
672: return(1);
673:
674: n = m->last;
675: m->next = MDOC_NEXT_CHILD;
676: if ( ! mdoc_word_alloc(m, m->last->line,
677: m->last->pos, "file"))
678: return(0);
679: m->next = MDOC_NEXT_SIBLING;
680: if ( ! mdoc_word_alloc(m, m->last->line,
681: m->last->pos, "..."))
682: return(0);
683:
684: m->last = n;
685: m->next = MDOC_NEXT_SIBLING;
686: return(1);
687: }
688:
689:
690: static int
691: post_dd(POST_ARGS)
692: {
693: char buf[64];
694:
695: buf[0] = 0;
696: if ( ! concat(m, m->last->child, buf, sizeof(buf)))
697: return(0);
698:
699: if (0 == (m->meta.date = mdoc_atotime(buf))) {
700: if ( ! vwarn(m, WBADDATE))
701: return(0);
702: m->meta.date = time(NULL);
703: }
704:
705: return(post_prol(m));
706: }
707:
708:
709: static int
710: post_prol(POST_ARGS)
711: {
712: struct mdoc_node *n;
713:
714: /*
715: * The end document shouldn't have the prologue macros as part
716: * of the syntax tree (they encompass only meta-data).
717: */
718:
719: if (m->last->parent->child == m->last)
720: m->last->parent->child = m->last->prev;
721: if (m->last->prev)
722: m->last->prev->next = NULL;
723:
724: n = m->last;
725: assert(NULL == m->last->next);
726:
727: if (m->last->prev) {
728: m->last = m->last->prev;
729: m->next = MDOC_NEXT_SIBLING;
730: } else {
731: m->last = m->last->parent;
732: m->next = MDOC_NEXT_CHILD;
733: }
734:
735: mdoc_node_freelist(n);
736: return(1);
737: }
738:
739:
740: static int
741: pre_dl(PRE_ARGS)
742: {
743:
744: if (MDOC_BODY != n->type)
745: return(1);
746: m->flags |= MDOC_LITERAL;
747: return(1);
748: }
749:
750:
751: static int
752: pre_bd(PRE_ARGS)
753: {
754: int i;
755:
756: if (MDOC_BODY != n->type)
757: return(1);
758:
759: /* Enter literal context if `Bd -literal' or * -unfilled'. */
760:
761: for (n = n->parent, i = 0; i < (int)n->args->argc; i++)
762: if (MDOC_Literal == n->args->argv[i].arg)
763: break;
764: else if (MDOC_Unfilled == n->args->argv[i].arg)
765: break;
766:
767: if (i < (int)n->args->argc)
768: m->flags |= MDOC_LITERAL;
769:
770: return(1);
771: }
772:
773:
774: static int
775: post_display(POST_ARGS)
776: {
777:
778: if (MDOC_BODY == m->last->type)
779: m->flags &= ~MDOC_LITERAL;
780: return(1);
781: }
782:
783: