Annotation of mandoc/validate.c, Revision 1.55
1.55 ! kristaps 1: /* $Id: validate.c,v 1.54 2009/02/24 11:43:13 kristaps Exp $ */
1.1 kristaps 2: /*
3: * Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
4: *
5: * Permission to use, copy, modify, and distribute this software for any
6: * purpose with or without fee is hereby granted, provided that the
7: * above copyright notice and this permission notice appear in all
8: * copies.
9: *
10: * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11: * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12: * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13: * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14: * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15: * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16: * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17: * PERFORMANCE OF THIS SOFTWARE.
18: */
19: #include <assert.h>
1.8 kristaps 20: #include <stdlib.h>
1.1 kristaps 21:
22: #include "private.h"
23:
1.44 kristaps 24: /*
25: * Pre- and post-validate macros as they're parsed. Pre-validation
26: * occurs when the macro has been detected and its arguments parsed.
27: * Post-validation occurs when all child macros have also been parsed.
28: * In the ELEMENT case, this is simply the parameters of the macro; in
29: * the BLOCK case, this is the HEAD, BODY, TAIL and so on.
30: */
31:
1.55 ! kristaps 32: #define PRE_ARGS struct mdoc *mdoc, const struct mdoc_node *n
! 33: #define POST_ARGS struct mdoc *mdoc
! 34:
! 35: typedef int (*v_pre)(PRE_ARGS);
! 36: typedef int (*v_post)(POST_ARGS);
1.14 kristaps 37:
1.36 kristaps 38: /* FIXME: some sections should only occur in specific msecs. */
39: /* FIXME: ignoring Pp. */
40: /* FIXME: math symbols. */
1.51 kristaps 41: /* FIXME: .Fd only in synopsis section. */
1.36 kristaps 42:
1.14 kristaps 43: struct valids {
1.24 kristaps 44: v_pre *pre;
1.17 kristaps 45: v_post *post;
1.14 kristaps 46: };
1.1 kristaps 47:
1.37 kristaps 48: /* Utility checks. */
49:
1.55 ! kristaps 50: static int check_parent(PRE_ARGS, int, enum mdoc_type);
! 51: static int check_msec(PRE_ARGS, int, enum mdoc_msec *);
! 52: static int check_stdarg(PRE_ARGS);
! 53:
! 54: static int check_text(struct mdoc *,
! 55: size_t, size_t, const char *);
! 56:
1.51 kristaps 57: static int err_child_lt(struct mdoc *, const char *, int);
58: static int err_child_gt(struct mdoc *, const char *, int);
59: static int warn_child_gt(struct mdoc *, const char *, int);
60: static int err_child_eq(struct mdoc *, const char *, int);
61: static int warn_child_eq(struct mdoc *, const char *, int);
62:
63: /* Utility auxiliaries. */
64:
65: static inline int count_child(struct mdoc *);
66: static inline int warn_count(struct mdoc *, const char *,
67: int, const char *, int);
68: static inline int err_count(struct mdoc *, const char *,
69: int, const char *, int);
1.11 kristaps 70:
1.37 kristaps 71: /* Specific pre-child-parse routines. */
72:
1.55 ! kristaps 73: static int pre_display(PRE_ARGS);
! 74: static int pre_sh(PRE_ARGS);
! 75: static int pre_ss(PRE_ARGS);
! 76: static int pre_bd(PRE_ARGS);
! 77: static int pre_bl(PRE_ARGS);
! 78: static int pre_it(PRE_ARGS);
! 79: static int pre_cd(PRE_ARGS);
! 80: static int pre_er(PRE_ARGS);
! 81: static int pre_ex(PRE_ARGS);
! 82: static int pre_rv(PRE_ARGS);
! 83: static int pre_an(PRE_ARGS);
! 84: static int pre_st(PRE_ARGS);
! 85: static int pre_prologue(PRE_ARGS);
! 86: static int pre_prologue(PRE_ARGS);
! 87: static int pre_prologue(PRE_ARGS);
1.24 kristaps 88:
1.37 kristaps 89: /* Specific post-child-parse routines. */
90:
1.55 ! kristaps 91: static int herr_ge1(POST_ARGS);
! 92: static int herr_le1(POST_ARGS);
! 93: static int herr_eq0(POST_ARGS);
! 94: static int eerr_eq0(POST_ARGS);
! 95: static int eerr_le1(POST_ARGS);
! 96: static int eerr_le2(POST_ARGS);
! 97: static int eerr_eq1(POST_ARGS);
! 98: static int eerr_ge1(POST_ARGS);
! 99: static int ewarn_eq0(POST_ARGS);
! 100: static int ewarn_eq1(POST_ARGS);
! 101: static int bwarn_ge1(POST_ARGS);
! 102: static int ewarn_ge1(POST_ARGS);
! 103: static int ebool(POST_ARGS);
! 104:
! 105: static int post_sh(POST_ARGS);
! 106: static int post_sh_body(POST_ARGS);
! 107: static int post_sh_head(POST_ARGS);
! 108: static int post_bl(POST_ARGS);
! 109: static int post_it(POST_ARGS);
! 110: static int post_ex(POST_ARGS);
! 111: static int post_an(POST_ARGS);
! 112: static int post_at(POST_ARGS);
! 113: static int post_xr(POST_ARGS);
! 114: static int post_nm(POST_ARGS);
! 115: static int post_bf(POST_ARGS);
! 116: static int post_root(POST_ARGS);
1.37 kristaps 117:
118: /* Collections of pre-child-parse routines. */
1.17 kristaps 119:
1.24 kristaps 120: static v_pre pres_prologue[] = { pre_prologue, NULL };
121: static v_pre pres_d1[] = { pre_display, NULL };
122: static v_pre pres_bd[] = { pre_display, pre_bd, NULL };
123: static v_pre pres_bl[] = { pre_bl, NULL };
1.25 kristaps 124: static v_pre pres_it[] = { pre_it, NULL };
1.33 kristaps 125: static v_pre pres_ss[] = { pre_ss, NULL };
126: static v_pre pres_sh[] = { pre_sh, NULL };
127: static v_pre pres_cd[] = { pre_cd, NULL };
128: static v_pre pres_er[] = { pre_er, NULL };
129: static v_pre pres_ex[] = { pre_ex, NULL };
1.36 kristaps 130: static v_pre pres_rv[] = { pre_rv, NULL };
1.35 kristaps 131: static v_pre pres_an[] = { pre_an, NULL };
1.36 kristaps 132: static v_pre pres_st[] = { pre_st, NULL };
1.24 kristaps 133:
1.37 kristaps 134: /* Collections of post-child-parse routines. */
135:
136: static v_post posts_bool[] = { eerr_eq1, ebool, NULL };
137: static v_post posts_bd[] = { herr_eq0, bwarn_ge1, NULL };
138: static v_post posts_text[] = { eerr_ge1, NULL };
139: static v_post posts_wtext[] = { ewarn_ge1, NULL };
140: static v_post posts_notext[] = { eerr_eq0, NULL };
1.43 kristaps 141: static v_post posts_wline[] = { bwarn_ge1, herr_eq0, NULL };
1.37 kristaps 142: static v_post posts_sh[] = { herr_ge1, bwarn_ge1, post_sh, NULL };
143: static v_post posts_bl[] = { herr_eq0, bwarn_ge1, post_bl, NULL };
1.25 kristaps 144: static v_post posts_it[] = { post_it, NULL };
1.39 kristaps 145: static v_post posts_in[] = { ewarn_eq1, NULL };
1.37 kristaps 146: static v_post posts_ss[] = { herr_ge1, NULL };
1.52 kristaps 147: static v_post posts_pf[] = { eerr_eq1, NULL };
1.37 kristaps 148: static v_post posts_pp[] = { ewarn_eq0, NULL };
149: static v_post posts_ex[] = { eerr_le1, post_ex, NULL };
1.35 kristaps 150: static v_post posts_an[] = { post_an, NULL };
1.37 kristaps 151: static v_post posts_at[] = { post_at, NULL };
152: static v_post posts_xr[] = { eerr_ge1, eerr_le2, post_xr, NULL };
153: static v_post posts_nm[] = { post_nm, NULL };
1.41 kristaps 154: static v_post posts_bf[] = { herr_le1, post_bf, NULL };
1.45 kristaps 155: static v_post posts_rs[] = { herr_eq0, bwarn_ge1, NULL };
156: static v_post posts_fo[] = { bwarn_ge1, NULL };
157: static v_post posts_bk[] = { herr_eq0, bwarn_ge1, NULL };
1.9 kristaps 158:
1.37 kristaps 159: /* Per-macro pre- and post-child-check routine collections. */
1.12 kristaps 160:
1.9 kristaps 161: const struct valids mdoc_valids[MDOC_MAX] = {
1.51 kristaps 162: { NULL, NULL }, /* \" */
163: { pres_prologue, posts_text }, /* Dd */
164: { pres_prologue, NULL }, /* Dt */
165: { pres_prologue, NULL }, /* Os */
166: { pres_sh, posts_sh }, /* Sh */
167: { pres_ss, posts_ss }, /* Ss */
168: { NULL, posts_pp }, /* Pp */
169: { pres_d1, posts_wline }, /* D1 */
170: { pres_d1, posts_wline }, /* Dl */
171: { pres_bd, posts_bd }, /* Bd */
172: { NULL, NULL }, /* Ed */
173: { pres_bl, posts_bl }, /* Bl */
174: { NULL, NULL }, /* El */
175: { pres_it, posts_it }, /* It */
176: { NULL, posts_text }, /* Ad */
177: { pres_an, posts_an }, /* An */
178: { NULL, NULL }, /* Ar */
179: { pres_cd, posts_text }, /* Cd */
180: { NULL, NULL }, /* Cm */
181: { NULL, posts_text }, /* Dv */
182: { pres_er, posts_text }, /* Er */
183: { NULL, posts_text }, /* Ev */
184: { pres_ex, posts_ex }, /* Ex */
185: { NULL, posts_text }, /* Fa */
186: { NULL, posts_wtext }, /* Fd */
187: { NULL, NULL }, /* Fl */
188: { NULL, posts_text }, /* Fn */
189: { NULL, posts_wtext }, /* Ft */
190: { NULL, posts_text }, /* Ic */
191: { NULL, posts_in }, /* In */
192: { NULL, posts_text }, /* Li */
193: { NULL, posts_wtext }, /* Nd */
194: { NULL, posts_nm }, /* Nm */
195: { NULL, posts_wline }, /* Op */
196: { NULL, NULL }, /* Ot */
197: { NULL, NULL }, /* Pa */
198: { pres_rv, posts_notext }, /* Rv */
199: { pres_st, posts_notext }, /* St */
200: { NULL, posts_text }, /* Va */
201: { NULL, posts_text }, /* Vt */
202: { NULL, posts_xr }, /* Xr */
203: { NULL, posts_text }, /* %A */
204: { NULL, posts_text }, /* %B */
205: { NULL, posts_text }, /* %D */
206: { NULL, posts_text }, /* %I */
207: { NULL, posts_text }, /* %J */
208: { NULL, posts_text }, /* %N */
209: { NULL, posts_text }, /* %O */
210: { NULL, posts_text }, /* %P */
211: { NULL, posts_text }, /* %R */
212: { NULL, posts_text }, /* %T */
213: { NULL, posts_text }, /* %V */
214: { NULL, NULL }, /* Ac */
215: { NULL, NULL }, /* Ao */
216: { NULL, posts_wline }, /* Aq */
217: { NULL, posts_at }, /* At */
218: { NULL, NULL }, /* Bc */
219: { NULL, posts_bf }, /* Bf */
220: { NULL, NULL }, /* Bo */
221: { NULL, posts_wline }, /* Bq */
222: { NULL, NULL }, /* Bsx */
223: { NULL, NULL }, /* Bx */
224: { NULL, posts_bool }, /* Db */
225: { NULL, NULL }, /* Dc */
226: { NULL, NULL }, /* Do */
227: { NULL, posts_wline }, /* Dq */
228: { NULL, NULL }, /* Ec */
229: { NULL, NULL }, /* Ef */
230: { NULL, posts_text }, /* Em */
231: { NULL, NULL }, /* Eo */
232: { NULL, NULL }, /* Fx */
233: { NULL, posts_text }, /* Ms */
234: { NULL, posts_notext }, /* No */
235: { NULL, posts_notext }, /* Ns */
236: { NULL, NULL }, /* Nx */
237: { NULL, NULL }, /* Ox */
238: { NULL, NULL }, /* Pc */
1.52 kristaps 239: { NULL, posts_pf }, /* Pf */
1.51 kristaps 240: { NULL, NULL }, /* Po */
241: { NULL, posts_wline }, /* Pq */
242: { NULL, NULL }, /* Qc */
243: { NULL, posts_wline }, /* Ql */
244: { NULL, NULL }, /* Qo */
245: { NULL, posts_wline }, /* Qq */
246: { NULL, NULL }, /* Re */
247: { NULL, posts_rs }, /* Rs */
248: { NULL, NULL }, /* Sc */
249: { NULL, NULL }, /* So */
250: { NULL, posts_wline }, /* Sq */
251: { NULL, posts_bool }, /* Sm */
252: { NULL, posts_text }, /* Sx */
253: { NULL, posts_text }, /* Sy */
254: { NULL, posts_text }, /* Tn */
255: { NULL, NULL }, /* Ux */
256: { NULL, NULL }, /* Xc */
257: { NULL, NULL }, /* Xo */
258: { NULL, posts_fo }, /* Fo */
259: { NULL, NULL }, /* Fc */
260: { NULL, NULL }, /* Oo */
261: { NULL, NULL }, /* Oc */
262: { NULL, posts_bk }, /* Bk */
263: { NULL, NULL }, /* Ek */
264: { NULL, posts_notext }, /* Bt */
265: { NULL, NULL }, /* Hf */
266: { NULL, NULL }, /* Fr */
267: { NULL, posts_notext }, /* Ud */
1.9 kristaps 268: };
1.6 kristaps 269:
270:
1.51 kristaps 271: static inline int
272: warn_count(struct mdoc *m, const char *k,
273: int want, const char *v, int has)
274: {
275:
1.55 ! kristaps 276: return(mdoc_warn(m, WARN_SYNTAX,
! 277: "suggests %s %d %s (has %d)",
! 278: v, want, k, has));
1.51 kristaps 279: }
280:
281:
282: static inline int
283: err_count(struct mdoc *m, const char *k,
284: int want, const char *v, int has)
285: {
286:
287: return(mdoc_err(m, "requires %s %d %s (has %d)",
288: v, want, k, has));
289: }
290:
291:
292: static inline int
293: count_child(struct mdoc *mdoc)
1.36 kristaps 294: {
1.51 kristaps 295: int i;
1.36 kristaps 296: struct mdoc_node *n;
297:
298: for (i = 0, n = mdoc->last->child; n; n = n->next, i++)
299: /* Do nothing */ ;
1.53 kristaps 300:
1.36 kristaps 301: return(i);
302: }
303:
304:
1.53 kristaps 305: /*
306: * Build these up with macros because they're basically the same check
307: * for different inequalities. Yes, this could be done with functions,
308: * but this is reasonable for now.
309: */
1.36 kristaps 310:
1.53 kristaps 311: #define CHECK_CHILD_DEFN(lvl, name, ineq) \
312: static int \
313: lvl##_child_##name(struct mdoc *mdoc, const char *p, int sz) \
314: { \
315: int i; \
316: if ((i = count_child(mdoc)) ineq sz) \
317: return(1); \
318: return(lvl##_count(mdoc, #ineq, sz, p, i)); \
319: }
320:
321: #define CHECK_BODY_DEFN(name, lvl, func, num) \
322: static int \
1.55 ! kristaps 323: b##lvl##_##name(POST_ARGS) \
1.53 kristaps 324: { \
325: if (MDOC_BODY != mdoc->last->type) \
326: return(1); \
327: return(func(mdoc, "multiline parameters", (num))); \
328: }
329:
330: #define CHECK_ELEM_DEFN(name, lvl, func, num) \
331: static int \
1.55 ! kristaps 332: e##lvl##_##name(POST_ARGS) \
1.53 kristaps 333: { \
334: assert(MDOC_ELEM == mdoc->last->type); \
335: return(func(mdoc, "line parameters", (num))); \
336: }
337:
338: #define CHECK_HEAD_DEFN(name, lvl, func, num) \
339: static int \
1.55 ! kristaps 340: h##lvl##_##name(POST_ARGS) \
1.53 kristaps 341: { \
342: if (MDOC_HEAD != mdoc->last->type) \
343: return(1); \
344: return(func(mdoc, "multiline parameters", (num))); \
1.36 kristaps 345: }
346:
347:
1.53 kristaps 348: CHECK_CHILD_DEFN(warn, gt, >) /* warn_child_gt() */
349: CHECK_CHILD_DEFN(err, gt, >) /* err_child_gt() */
350: CHECK_CHILD_DEFN(warn, eq, ==) /* warn_child_eq() */
351: CHECK_CHILD_DEFN(err, eq, ==) /* err_child_eq() */
352: CHECK_CHILD_DEFN(err, lt, <) /* err_child_lt() */
353: CHECK_BODY_DEFN(ge1, warn, warn_child_gt, 0) /* bwarn_ge1() */
354: CHECK_ELEM_DEFN(eq1, warn, warn_child_eq, 1) /* ewarn_eq1() */
355: CHECK_ELEM_DEFN(eq0, warn, warn_child_eq, 0) /* ewarn_eq0() */
356: CHECK_ELEM_DEFN(ge1, warn, warn_child_gt, 0) /* ewarn_gt1() */
357: CHECK_ELEM_DEFN(eq1, err, err_child_eq, 1) /* eerr_eq1() */
358: CHECK_ELEM_DEFN(le2, err, err_child_lt, 3) /* eerr_le2() */
359: CHECK_ELEM_DEFN(le1, err, err_child_lt, 2) /* eerr_le1() */
360: CHECK_ELEM_DEFN(eq0, err, err_child_eq, 0) /* eerr_eq0() */
361: CHECK_ELEM_DEFN(ge1, err, err_child_gt, 0) /* eerr_ge1() */
362: CHECK_HEAD_DEFN(eq0, err, err_child_eq, 0) /* herr_eq0() */
363: CHECK_HEAD_DEFN(le1, err, err_child_lt, 2) /* herr_le1() */
364: CHECK_HEAD_DEFN(ge1, err, err_child_gt, 0) /* herr_ge1() */
1.36 kristaps 365:
366:
367: static int
1.55 ! kristaps 368: check_stdarg(PRE_ARGS)
1.36 kristaps 369: {
370:
1.55 ! kristaps 371: if (MDOC_Std == n->data.elem.argv[0].arg &&
! 372: 1 == n->data.elem.argc)
1.36 kristaps 373: return(1);
1.51 kristaps 374:
1.55 ! kristaps 375: return(mdoc_nwarn(mdoc, n, WARN_COMPAT,
1.53 kristaps 376: "one argument suggested"));
1.36 kristaps 377: }
378:
379:
380: static int
1.55 ! kristaps 381: check_msec(PRE_ARGS, int sz, enum mdoc_msec *msecs)
1.33 kristaps 382: {
383: int i;
384:
385: for (i = 0; i < sz; i++)
386: if (msecs[i] == mdoc->meta.msec)
387: return(1);
1.55 ! kristaps 388: return(mdoc_nwarn(mdoc, n, WARN_COMPAT,
! 389: "invalid manual section"));
! 390: }
! 391:
! 392:
! 393: static int
! 394: check_text(struct mdoc *mdoc, size_t line, size_t pos, const char *p)
! 395: {
! 396: size_t c;
! 397:
! 398: for ( ; *p; p++) {
! 399: if ('\\' != *p)
! 400: continue;
! 401: if ((c = mdoc_isescape(p))) {
! 402: p += (c - 1);
! 403: continue;
! 404: }
! 405: return(mdoc_perr(mdoc, line, pos,
! 406: "invalid escape sequence"));
! 407: }
! 408:
! 409: return(1);
1.14 kristaps 410: }
411:
412:
1.55 ! kristaps 413:
! 414:
1.14 kristaps 415: static int
1.55 ! kristaps 416: check_parent(PRE_ARGS, int tok, enum mdoc_type t)
1.54 kristaps 417: {
418:
419: assert(n->parent);
420: if ((MDOC_ROOT == t || tok == n->parent->tok) &&
421: (t == n->parent->type))
422: return(1);
423:
424: return(mdoc_nerr(mdoc, n, "require parent %s",
425: MDOC_ROOT == t ? "<root>" : mdoc_macronames[tok]));
426: }
427:
428:
429:
430: static int
1.55 ! kristaps 431: pre_display(PRE_ARGS)
1.23 kristaps 432: {
1.55 ! kristaps 433: struct mdoc_node *node;
1.23 kristaps 434:
1.53 kristaps 435: /* Display elements (`Bd', `D1'...) cannot be nested. */
436:
1.55 ! kristaps 437: if (MDOC_BLOCK != n->type)
1.24 kristaps 438: return(1);
439:
1.38 kristaps 440: /* LINTED */
1.55 ! kristaps 441: for (node = mdoc->last->parent; node; node = node->parent)
! 442: if (MDOC_BLOCK == node->type)
! 443: if (MDOC_Bd == node->tok)
1.23 kristaps 444: break;
1.55 ! kristaps 445: if (NULL == node)
1.23 kristaps 446: return(1);
1.53 kristaps 447:
1.55 ! kristaps 448: return(mdoc_nerr(mdoc, n, "displays may not be nested"));
1.23 kristaps 449: }
450:
451:
452: static int
1.55 ! kristaps 453: pre_bl(PRE_ARGS)
1.24 kristaps 454: {
1.53 kristaps 455: int type, err, i;
1.24 kristaps 456: struct mdoc_arg *argv;
1.53 kristaps 457: size_t argc;
1.24 kristaps 458:
1.55 ! kristaps 459: if (MDOC_BLOCK != n->type)
1.24 kristaps 460: return(1);
461:
1.55 ! kristaps 462: argc = n->data.block.argc;
1.24 kristaps 463:
1.53 kristaps 464: /* Make sure that only one type of list is specified. */
465:
1.38 kristaps 466: /* LINTED */
1.53 kristaps 467: for (i = 0, type = err = 0; i < (int)argc; i++) {
1.55 ! kristaps 468: argv = &n->data.block.argv[i];
1.53 kristaps 469:
1.24 kristaps 470: switch (argv->arg) {
471: case (MDOC_Bullet):
472: /* FALLTHROUGH */
473: case (MDOC_Dash):
474: /* FALLTHROUGH */
475: case (MDOC_Enum):
476: /* FALLTHROUGH */
477: case (MDOC_Hyphen):
478: /* FALLTHROUGH */
479: case (MDOC_Item):
480: /* FALLTHROUGH */
481: case (MDOC_Tag):
482: /* FALLTHROUGH */
483: case (MDOC_Diag):
484: /* FALLTHROUGH */
485: case (MDOC_Hang):
486: /* FALLTHROUGH */
487: case (MDOC_Ohang):
488: /* FALLTHROUGH */
489: case (MDOC_Inset):
1.26 kristaps 490: /* FALLTHROUGH */
491: case (MDOC_Column):
1.53 kristaps 492: if (0 == type++)
493: break;
494: return(mdoc_perr(mdoc, argv->line, argv->pos,
495: "multiple types specified"));
1.24 kristaps 496: default:
497: break;
498: }
499: }
1.53 kristaps 500:
501: if (type)
502: return(1);
503: return(mdoc_err(mdoc, "no type specified"));
1.24 kristaps 504: }
505:
506:
507: static int
1.55 ! kristaps 508: pre_bd(PRE_ARGS)
1.24 kristaps 509: {
1.53 kristaps 510: int type, err, i;
1.24 kristaps 511: struct mdoc_arg *argv;
1.53 kristaps 512: size_t argc;
1.24 kristaps 513:
1.55 ! kristaps 514: if (MDOC_BLOCK != n->type)
1.24 kristaps 515: return(1);
516:
1.55 ! kristaps 517: argc = n->data.block.argc;
1.24 kristaps 518:
1.53 kristaps 519: /* Make sure that only one type of display is specified. */
520:
1.38 kristaps 521: /* LINTED */
1.53 kristaps 522: for (i = 0, err = type = 0; ! err && i < (int)argc; i++) {
1.55 ! kristaps 523: argv = &n->data.block.argv[i];
1.53 kristaps 524:
1.24 kristaps 525: switch (argv->arg) {
526: case (MDOC_Ragged):
527: /* FALLTHROUGH */
528: case (MDOC_Unfilled):
529: /* FALLTHROUGH */
1.29 kristaps 530: case (MDOC_Filled):
531: /* FALLTHROUGH */
1.24 kristaps 532: case (MDOC_Literal):
533: /* FALLTHROUGH */
534: case (MDOC_File):
1.53 kristaps 535: if (0 == type++)
536: break;
537: return(mdoc_perr(mdoc, argv->line, argv->pos,
538: "multiple types specified"));
1.24 kristaps 539: default:
540: break;
541: }
542: }
1.53 kristaps 543:
544: if (type)
545: return(1);
546: return(mdoc_err(mdoc, "no type specified"));
1.24 kristaps 547: }
548:
549:
550: static int
1.55 ! kristaps 551: pre_ss(PRE_ARGS)
1.33 kristaps 552: {
553:
1.55 ! kristaps 554: if (MDOC_BLOCK != n->type)
1.33 kristaps 555: return(1);
1.55 ! kristaps 556: return(check_parent(mdoc, n, MDOC_Sh, MDOC_BODY));
1.33 kristaps 557: }
558:
559:
560: static int
1.55 ! kristaps 561: pre_sh(PRE_ARGS)
1.33 kristaps 562: {
563:
1.55 ! kristaps 564: if (MDOC_BLOCK != n->type)
1.33 kristaps 565: return(1);
1.55 ! kristaps 566: return(check_parent(mdoc, n, -1, MDOC_ROOT));
1.33 kristaps 567: }
568:
569:
570: static int
1.55 ! kristaps 571: pre_it(PRE_ARGS)
1.53 kristaps 572: {
573:
574: /* TODO: -width attribute must be specified for -tag. */
575: /* TODO: children too big for -width? */
576:
1.55 ! kristaps 577: if (MDOC_BLOCK != n->type)
1.53 kristaps 578: return(1);
1.55 ! kristaps 579: return(check_parent(mdoc, n, MDOC_Bl, MDOC_BODY));
1.53 kristaps 580: }
581:
582:
583: static int
1.55 ! kristaps 584: pre_st(PRE_ARGS)
1.36 kristaps 585: {
586:
1.55 ! kristaps 587: if (1 == n->data.elem.argc)
1.36 kristaps 588: return(1);
1.55 ! kristaps 589: return(mdoc_nerr(mdoc, n, "one argument required"));
1.36 kristaps 590: }
591:
592:
593: static int
1.55 ! kristaps 594: pre_an(PRE_ARGS)
1.35 kristaps 595: {
1.36 kristaps 596:
1.55 ! kristaps 597: if (1 >= n->data.elem.argc)
1.35 kristaps 598: return(1);
1.55 ! kristaps 599: return(mdoc_nerr(mdoc, n, "one argument allowed"));
1.35 kristaps 600: }
601:
602:
603: static int
1.55 ! kristaps 604: pre_rv(PRE_ARGS)
1.36 kristaps 605: {
1.53 kristaps 606: enum mdoc_msec msecs[] = { MSEC_2, MSEC_3 };
1.36 kristaps 607:
1.55 ! kristaps 608: if ( ! check_msec(mdoc, n, 2, msecs))
1.36 kristaps 609: return(0);
1.55 ! kristaps 610: return(check_stdarg(mdoc, n));
1.36 kristaps 611: }
612:
613:
614: static int
1.55 ! kristaps 615: pre_ex(PRE_ARGS)
1.33 kristaps 616: {
1.53 kristaps 617: enum mdoc_msec msecs[] = { MSEC_1, MSEC_6, MSEC_8 };
1.35 kristaps 618:
1.55 ! kristaps 619: if ( ! check_msec(mdoc, n, 3, msecs))
1.35 kristaps 620: return(0);
1.55 ! kristaps 621: return(check_stdarg(mdoc, n));
1.33 kristaps 622: }
623:
624:
625: static int
1.55 ! kristaps 626: pre_er(PRE_ARGS)
1.33 kristaps 627: {
1.53 kristaps 628: enum mdoc_msec msecs[] = { MSEC_2 };
1.33 kristaps 629:
1.55 ! kristaps 630: return(check_msec(mdoc, n, 1, msecs));
1.33 kristaps 631: }
632:
633:
634: static int
1.55 ! kristaps 635: pre_cd(PRE_ARGS)
1.33 kristaps 636: {
1.53 kristaps 637: enum mdoc_msec msecs[] = { MSEC_4 };
1.33 kristaps 638:
1.55 ! kristaps 639: return(check_msec(mdoc, n, 1, msecs));
1.33 kristaps 640: }
641:
642:
643: static int
1.55 ! kristaps 644: pre_prologue(PRE_ARGS)
1.20 kristaps 645: {
646:
1.46 kristaps 647: if (SEC_PROLOGUE != mdoc->lastnamed)
1.55 ! kristaps 648: return(mdoc_nerr(mdoc, n, "prologue only"));
1.20 kristaps 649:
650: /* Check for ordering. */
651:
1.55 ! kristaps 652: switch (n->tok) {
1.20 kristaps 653: case (MDOC_Os):
1.36 kristaps 654: if (mdoc->meta.title && mdoc->meta.date)
1.20 kristaps 655: break;
1.55 ! kristaps 656: return(mdoc_nerr(mdoc, n, "prologue out-of-order"));
1.20 kristaps 657: case (MDOC_Dt):
1.36 kristaps 658: if (NULL == mdoc->meta.title && mdoc->meta.date)
1.20 kristaps 659: break;
1.55 ! kristaps 660: return(mdoc_nerr(mdoc, n, "prologue out-of-order"));
1.20 kristaps 661: case (MDOC_Dd):
1.36 kristaps 662: if (NULL == mdoc->meta.title && 0 == mdoc->meta.date)
1.20 kristaps 663: break;
1.55 ! kristaps 664: return(mdoc_nerr(mdoc, n, "prologue out-of-order"));
1.20 kristaps 665: default:
666: abort();
667: /* NOTREACHED */
668: }
669:
670: /* Check for repetition. */
671:
1.55 ! kristaps 672: switch (n->tok) {
1.20 kristaps 673: case (MDOC_Os):
1.36 kristaps 674: if (NULL == mdoc->meta.os)
1.20 kristaps 675: return(1);
676: break;
677: case (MDOC_Dd):
678: if (0 == mdoc->meta.date)
679: return(1);
680: break;
681: case (MDOC_Dt):
1.36 kristaps 682: if (NULL == mdoc->meta.title)
1.20 kristaps 683: return(1);
684: break;
685: default:
686: abort();
687: /* NOTREACHED */
688: }
689:
1.55 ! kristaps 690: return(mdoc_nerr(mdoc, n, "prologue repetition"));
1.20 kristaps 691: }
692:
693:
1.35 kristaps 694: static int
1.55 ! kristaps 695: post_bf(POST_ARGS)
1.41 kristaps 696: {
697: char *p;
698: struct mdoc_node *head;
699:
700: if (MDOC_BLOCK != mdoc->last->type)
701: return(1);
1.53 kristaps 702:
1.41 kristaps 703: head = mdoc->last->data.block.head;
704:
705: if (0 == mdoc->last->data.block.argc) {
1.53 kristaps 706: if (NULL == head->child)
707: return(mdoc_err(mdoc, "argument expected"));
708:
709: p = head->child->data.text.string;
710: if (xstrcmp(p, "Em"))
711: return(1);
712: else if (xstrcmp(p, "Li"))
713: return(1);
714: else if (xstrcmp(p, "Sm"))
715: return(1);
716: return(mdoc_nerr(mdoc, head->child, "invalid font"));
1.41 kristaps 717: }
1.53 kristaps 718:
1.41 kristaps 719: if (head->child)
1.53 kristaps 720: return(mdoc_err(mdoc, "argument expected"));
721:
1.41 kristaps 722: if (1 == mdoc->last->data.block.argc)
723: return(1);
1.53 kristaps 724: return(mdoc_err(mdoc, "argument expected"));
1.41 kristaps 725: }
726:
727:
728: static int
1.55 ! kristaps 729: post_nm(POST_ARGS)
1.37 kristaps 730: {
731:
732: if (mdoc->last->child)
733: return(1);
734: if (mdoc->meta.name)
735: return(1);
1.53 kristaps 736: return(mdoc_err(mdoc, "not yet invoked with name"));
1.37 kristaps 737: }
738:
739:
740: static int
1.55 ! kristaps 741: post_xr(POST_ARGS)
1.36 kristaps 742: {
743: struct mdoc_node *n;
744:
745: if (NULL == (n = mdoc->last->child->next))
746: return(1);
747: if (MSEC_DEFAULT != mdoc_atomsec(n->data.text.string))
748: return(1);
749: return(mdoc_nerr(mdoc, n, "invalid manual section"));
750: }
751:
752:
753: static int
1.55 ! kristaps 754: post_at(POST_ARGS)
1.36 kristaps 755: {
756:
1.37 kristaps 757: if (NULL == mdoc->last->child)
758: return(1);
1.36 kristaps 759: if (ATT_DEFAULT != mdoc_atoatt(mdoc->last->child->data.text.string))
760: return(1);
1.53 kristaps 761: return(mdoc_err(mdoc, "require valid symbol"));
1.36 kristaps 762: }
763:
764:
765: static int
1.55 ! kristaps 766: post_an(POST_ARGS)
1.35 kristaps 767: {
768:
769: if (0 != mdoc->last->data.elem.argc) {
770: if (NULL == mdoc->last->child)
771: return(1);
1.53 kristaps 772: return(mdoc_err(mdoc, "argument(s) expected"));
1.35 kristaps 773: }
774:
775: if (mdoc->last->child)
776: return(1);
1.53 kristaps 777: return(mdoc_err(mdoc, "argument(s) expected"));
1.35 kristaps 778: }
779:
780:
781: static int
1.55 ! kristaps 782: post_ex(POST_ARGS)
1.35 kristaps 783: {
784:
785: if (0 == mdoc->last->data.elem.argc) {
786: if (mdoc->last->child)
787: return(1);
1.53 kristaps 788: return(mdoc_err(mdoc, "argument(s) expected"));
1.35 kristaps 789: }
790: if (mdoc->last->child)
1.53 kristaps 791: return(mdoc_err(mdoc, "argument(s) expected"));
1.35 kristaps 792: if (1 != mdoc->last->data.elem.argc)
1.53 kristaps 793: return(mdoc_err(mdoc, "argument(s) expected"));
1.35 kristaps 794: if (MDOC_Std != mdoc->last->data.elem.argv[0].arg)
1.53 kristaps 795: return(mdoc_err(mdoc, "argument(s) expected"));
796:
1.35 kristaps 797: return(1);
798: }
799:
800:
1.25 kristaps 801: static int
1.55 ! kristaps 802: post_it(POST_ARGS)
1.25 kristaps 803: {
1.53 kristaps 804: int type, sv, i;
1.25 kristaps 805: #define TYPE_NONE (0)
806: #define TYPE_BODY (1)
807: #define TYPE_HEAD (2)
1.47 kristaps 808: #define TYPE_OHEAD (3)
1.53 kristaps 809: size_t argc;
1.25 kristaps 810: struct mdoc_node *n;
811:
812: if (MDOC_BLOCK != mdoc->last->type)
813: return(1);
814:
1.53 kristaps 815: n = mdoc->last->parent->parent;
1.25 kristaps 816:
817: argc = n->data.block.argc;
818: type = TYPE_NONE;
1.38 kristaps 819: sv = -1;
1.26 kristaps 820:
821: /* Some types require block-head, some not. */
1.25 kristaps 822:
1.38 kristaps 823: /* LINTED */
1.53 kristaps 824: for (i = 0; TYPE_NONE == type && i < (int)argc; i++)
825: switch (n->data.block.argv[i].arg) {
1.25 kristaps 826: case (MDOC_Tag):
827: /* FALLTHROUGH */
828: case (MDOC_Diag):
829: /* FALLTHROUGH */
830: case (MDOC_Hang):
831: /* FALLTHROUGH */
832: case (MDOC_Ohang):
833: /* FALLTHROUGH */
834: case (MDOC_Inset):
835: type = TYPE_HEAD;
1.53 kristaps 836: sv = n->data.block.argv[i].arg;
1.25 kristaps 837: break;
838: case (MDOC_Bullet):
839: /* FALLTHROUGH */
840: case (MDOC_Dash):
841: /* FALLTHROUGH */
842: case (MDOC_Enum):
843: /* FALLTHROUGH */
844: case (MDOC_Hyphen):
845: /* FALLTHROUGH */
846: case (MDOC_Item):
1.47 kristaps 847: type = TYPE_BODY;
1.53 kristaps 848: sv = n->data.block.argv[i].arg;
1.47 kristaps 849: break;
1.25 kristaps 850: case (MDOC_Column):
1.47 kristaps 851: type = TYPE_OHEAD;
1.53 kristaps 852: sv = n->data.block.argv[i].arg;
1.25 kristaps 853: break;
854: default:
855: break;
856: }
857:
858: assert(TYPE_NONE != type);
859:
1.47 kristaps 860: n = mdoc->last->data.block.head;
861:
1.25 kristaps 862: if (TYPE_HEAD == type) {
1.33 kristaps 863: if (NULL == n->child)
1.53 kristaps 864: if ( ! mdoc_warn(mdoc, WARN_SYNTAX,
865: "argument(s) suggested"))
1.25 kristaps 866: return(0);
867:
1.33 kristaps 868: n = mdoc->last->data.block.body;
869: if (NULL == n->child)
1.53 kristaps 870: if ( ! mdoc_warn(mdoc, WARN_SYNTAX,
871: "multiline body suggested"))
1.25 kristaps 872: return(0);
873:
1.47 kristaps 874: } else if (TYPE_BODY == type) {
875: if (n->child)
1.53 kristaps 876: if ( ! mdoc_warn(mdoc, WARN_SYNTAX,
877: "no argument suggested"))
1.47 kristaps 878: return(0);
879:
880: n = mdoc->last->data.block.body;
881: if (NULL == n->child)
1.53 kristaps 882: if ( ! mdoc_warn(mdoc, WARN_SYNTAX,
883: "multiline body suggested"))
1.47 kristaps 884: return(0);
885: } else {
886: if (NULL == n->child)
1.53 kristaps 887: if ( ! mdoc_warn(mdoc, WARN_SYNTAX,
888: "argument(s) suggested"))
1.47 kristaps 889: return(0);
890:
891: n = mdoc->last->data.block.body;
892: if (n->child)
1.53 kristaps 893: if ( ! mdoc_warn(mdoc, WARN_SYNTAX,
894: "no multiline body suggested"))
1.47 kristaps 895: return(0);
1.25 kristaps 896: }
897:
1.47 kristaps 898: if (MDOC_Column != sv)
1.26 kristaps 899: return(1);
900:
1.38 kristaps 901: argc = mdoc->last->parent->parent->data.block.argv->sz;
1.26 kristaps 902: n = mdoc->last->data.block.head->child;
1.25 kristaps 903:
1.26 kristaps 904: for (i = 0; n; n = n->next)
905: i++;
906:
1.53 kristaps 907: if (i == (int)argc)
1.26 kristaps 908: return(1);
1.53 kristaps 909:
910: return(mdoc_err(mdoc, "need %zu columns (have %d)", argc, i));
1.25 kristaps 911: #undef TYPE_NONE
912: #undef TYPE_BODY
913: #undef TYPE_HEAD
1.47 kristaps 914: #undef TYPE_OHEAD
1.25 kristaps 915: }
916:
917:
1.24 kristaps 918: static int
1.55 ! kristaps 919: post_bl(POST_ARGS)
1.24 kristaps 920: {
1.53 kristaps 921: struct mdoc_node *n;
1.24 kristaps 922:
923: if (MDOC_BODY != mdoc->last->type)
924: return(1);
925:
1.38 kristaps 926: /* LINTED */
1.24 kristaps 927: for (n = mdoc->last->child; n; n = n->next) {
928: if (MDOC_BLOCK == n->type)
1.25 kristaps 929: if (MDOC_It == n->tok)
1.24 kristaps 930: continue;
931: break;
932: }
1.53 kristaps 933:
1.24 kristaps 934: if (NULL == n)
935: return(1);
1.53 kristaps 936:
937: return(mdoc_nerr(mdoc, n, "bad child of parent list"));
1.24 kristaps 938: }
939:
940:
1.34 kristaps 941: static int
1.37 kristaps 942: ebool(struct mdoc *mdoc)
1.34 kristaps 943: {
944: struct mdoc_node *n;
945:
1.38 kristaps 946: /* LINTED */
1.34 kristaps 947: for (n = mdoc->last->child; n; n = n->next) {
948: if (MDOC_TEXT != n->type)
949: break;
950: if (xstrcmp(n->data.text.string, "on"))
951: continue;
952: if (xstrcmp(n->data.text.string, "off"))
953: continue;
954: break;
955: }
1.53 kristaps 956:
1.34 kristaps 957: if (NULL == n)
958: return(1);
1.53 kristaps 959: return(mdoc_nerr(mdoc, n, "expected boolean"));
1.37 kristaps 960: }
961:
962:
963: static int
1.55 ! kristaps 964: post_root(POST_ARGS)
1.37 kristaps 965: {
966:
1.46 kristaps 967: if (NULL == mdoc->first->child)
1.53 kristaps 968: return(mdoc_err(mdoc, "document lacks data"));
1.46 kristaps 969: if (SEC_PROLOGUE == mdoc->lastnamed)
1.53 kristaps 970: return(mdoc_err(mdoc, "document lacks prologue"));
971:
1.46 kristaps 972: if (MDOC_BLOCK != mdoc->first->child->type)
1.54 kristaps 973: return(mdoc_err(mdoc, "lacking post-prologue %s",
1.53 kristaps 974: mdoc_macronames[MDOC_Sh]));
1.46 kristaps 975: if (MDOC_Sh != mdoc->first->child->tok)
1.54 kristaps 976: return(mdoc_err(mdoc, "lacking post-prologue %s",
1.53 kristaps 977: mdoc_macronames[MDOC_Sh]));
978:
1.37 kristaps 979: return(1);
1.34 kristaps 980: }
981:
982:
1.20 kristaps 983: static int
1.55 ! kristaps 984: post_sh(POST_ARGS)
1.14 kristaps 985: {
1.46 kristaps 986:
987: if (MDOC_HEAD == mdoc->last->type)
988: return(post_sh_head(mdoc));
989: if (MDOC_BODY == mdoc->last->type)
990: return(post_sh_body(mdoc));
1.53 kristaps 991:
1.46 kristaps 992: return(1);
993: }
994:
995:
996: static int
1.55 ! kristaps 997: post_sh_body(POST_ARGS)
1.46 kristaps 998: {
999: struct mdoc_node *n;
1000:
1001: if (SEC_NAME != mdoc->lastnamed)
1002: return(1);
1003:
1.51 kristaps 1004: /*
1005: * Warn if the NAME section doesn't contain the `Nm' and `Nd'
1006: * macros (can have multiple `Nm' and one `Nd'). Note that the
1007: * children of the BODY declaration can also be "text".
1008: */
1009:
1.46 kristaps 1010: if (NULL == (n = mdoc->last->child))
1.54 kristaps 1011: return(mdoc_warn(mdoc, WARN_SYNTAX,
1012: "section should have %s and %s",
1.51 kristaps 1013: mdoc_macronames[MDOC_Nm],
1014: mdoc_macronames[MDOC_Nd]));
1015:
1016: for ( ; n && n->next; n = n->next) {
1017: if (MDOC_ELEM == n->type && MDOC_Nm == n->tok)
1018: continue;
1019: if (MDOC_TEXT == n->type)
1020: continue;
1.54 kristaps 1021: if ( ! (mdoc_nwarn(mdoc, n, WARN_SYNTAX,
1022: "section should have %s first",
1.51 kristaps 1023: mdoc_macronames[MDOC_Nm])))
1024: return(0);
1025: }
1026:
1027: if (MDOC_ELEM == n->type && MDOC_Nd == n->tok)
1.46 kristaps 1028: return(1);
1029:
1.54 kristaps 1030: return(mdoc_warn(mdoc, WARN_SYNTAX,
1031: "section should have %s last",
1.51 kristaps 1032: mdoc_macronames[MDOC_Nd]));
1.46 kristaps 1033: }
1034:
1035:
1036: static int
1.55 ! kristaps 1037: post_sh_head(POST_ARGS)
1.46 kristaps 1038: {
1.36 kristaps 1039: char buf[64];
1.21 kristaps 1040: enum mdoc_sec sec;
1041:
1.25 kristaps 1042: assert(MDOC_Sh == mdoc->last->tok);
1.21 kristaps 1043:
1.54 kristaps 1044: if ( ! xstrlcats(buf, mdoc->last->child, sizeof(buf)))
1045: return(mdoc_err(mdoc, "argument too long"));
1.14 kristaps 1046:
1.46 kristaps 1047: sec = mdoc_atosec(buf);
1048:
1049: if (SEC_BODY == mdoc->lastnamed && SEC_NAME != sec)
1.54 kristaps 1050: return(mdoc_warn(mdoc, WARN_SYNTAX,
1051: "section NAME should be first"));
1.46 kristaps 1052: if (SEC_CUSTOM == sec)
1.21 kristaps 1053: return(1);
1.46 kristaps 1054: if (sec == mdoc->lastnamed)
1.54 kristaps 1055: return(mdoc_warn(mdoc, WARN_SYNTAX,
1056: "section repeated"));
1.46 kristaps 1057: if (sec < mdoc->lastnamed)
1.54 kristaps 1058: return(mdoc_warn(mdoc, WARN_SYNTAX,
1059: "section out of order"));
1.46 kristaps 1060:
1061: return(1);
1.11 kristaps 1062: }
1063:
1064:
1.17 kristaps 1065: int
1.55 ! kristaps 1066: mdoc_valid_pre(struct mdoc *mdoc,
! 1067: const struct mdoc_node *node)
1.11 kristaps 1068: {
1.24 kristaps 1069: v_pre *p;
1.55 ! kristaps 1070: struct mdoc_arg *argv;
! 1071: size_t argc, i, j, line, pos;
! 1072: const char *tp;
1.18 kristaps 1073:
1.55 ! kristaps 1074: if (MDOC_TEXT == node->type) {
! 1075: tp = node->data.text.string;
! 1076: line = node->line;
! 1077: pos = node->pos;
! 1078: return(check_text(mdoc, line, pos, tp));
! 1079: }
! 1080:
! 1081: if (MDOC_BLOCK == node->type || MDOC_ELEM == node->type) {
! 1082: argv = MDOC_BLOCK == node->type ?
! 1083: node->data.block.argv :
! 1084: node->data.elem.argv;
! 1085: argc = MDOC_BLOCK == node->type ?
! 1086: node->data.block.argc :
! 1087: node->data.elem.argc;
! 1088:
! 1089: for (i = 0; i < argc; i++) {
! 1090: if (0 == argv[i].sz)
! 1091: continue;
! 1092: for (j = 0; j < argv[i].sz; j++) {
! 1093: tp = argv[i].value[j];
! 1094: line = argv[i].line;
! 1095: pos = argv[i].pos;
! 1096: if ( ! check_text(mdoc, line, pos, tp))
! 1097: return(0);
! 1098: }
! 1099: }
! 1100: }
1.11 kristaps 1101:
1.25 kristaps 1102: if (NULL == mdoc_valids[node->tok].pre)
1.11 kristaps 1103: return(1);
1.25 kristaps 1104: for (p = mdoc_valids[node->tok].pre; *p; p++)
1.24 kristaps 1105: if ( ! (*p)(mdoc, node))
1106: return(0);
1107: return(1);
1.11 kristaps 1108: }
1109:
1110:
1.17 kristaps 1111: int
1.18 kristaps 1112: mdoc_valid_post(struct mdoc *mdoc)
1.11 kristaps 1113: {
1.17 kristaps 1114: v_post *p;
1.11 kristaps 1115:
1.54 kristaps 1116: /*
1117: * This check occurs after the macro's children have been filled
1118: * in: postfix validation. Since this happens when we're
1119: * rewinding the scope tree, it's possible to have multiple
1120: * invocations (as by design, for now), we set bit MDOC_VALID to
1121: * indicate that we've validated.
1122: */
1123:
1.39 kristaps 1124: if (MDOC_VALID & mdoc->last->flags)
1125: return(1);
1126: mdoc->last->flags |= MDOC_VALID;
1127:
1.25 kristaps 1128: if (MDOC_TEXT == mdoc->last->type)
1129: return(1);
1.37 kristaps 1130: if (MDOC_ROOT == mdoc->last->type)
1131: return(post_root(mdoc));
1.14 kristaps 1132:
1.25 kristaps 1133: if (NULL == mdoc_valids[mdoc->last->tok].post)
1.9 kristaps 1134: return(1);
1.25 kristaps 1135: for (p = mdoc_valids[mdoc->last->tok].post; *p; p++)
1.18 kristaps 1136: if ( ! (*p)(mdoc))
1.17 kristaps 1137: return(0);
1.11 kristaps 1138:
1.14 kristaps 1139: return(1);
1.11 kristaps 1140: }
1.14 kristaps 1141:
CVSweb