Annotation of mandoc/man_validate.c, Revision 1.99
1.99 ! schwarze 1: /* $Id: man_validate.c,v 1.98 2014/07/05 12:34:17 schwarze Exp $ */
1.1 kristaps 2: /*
1.63 schwarze 3: * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
1.88 schwarze 4: * Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
1.1 kristaps 5: *
6: * Permission to use, copy, modify, and distribute this software for any
1.8 kristaps 7: * purpose with or without fee is hereby granted, provided that the above
8: * copyright notice and this permission notice appear in all copies.
1.1 kristaps 9: *
1.8 kristaps 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.
1.1 kristaps 17: */
1.28 kristaps 18: #ifdef HAVE_CONFIG_H
19: #include "config.h"
20: #endif
21:
1.1 kristaps 22: #include <sys/types.h>
23:
24: #include <assert.h>
25: #include <ctype.h>
1.16 kristaps 26: #include <errno.h>
27: #include <limits.h>
1.1 kristaps 28: #include <stdarg.h>
29: #include <stdlib.h>
1.46 kristaps 30: #include <string.h>
1.50 kristaps 31: #include <time.h>
1.1 kristaps 32:
1.66 kristaps 33: #include "man.h"
1.41 kristaps 34: #include "mandoc.h"
1.89 schwarze 35: #include "mandoc_aux.h"
1.1 kristaps 36: #include "libman.h"
1.15 kristaps 37: #include "libmandoc.h"
1.1 kristaps 38:
1.85 schwarze 39: #define CHKARGS struct man *man, struct man_node *n
1.1 kristaps 40:
1.17 kristaps 41: typedef int (*v_check)(CHKARGS);
1.1 kristaps 42:
43: struct man_valid {
1.17 kristaps 44: v_check *pres;
45: v_check *posts;
1.1 kristaps 46: };
47:
1.17 kristaps 48: static int check_eq0(CHKARGS);
1.80 kristaps 49: static int check_eq2(CHKARGS);
1.25 kristaps 50: static int check_le1(CHKARGS);
1.17 kristaps 51: static int check_ge2(CHKARGS);
52: static int check_le5(CHKARGS);
1.86 schwarze 53: static int check_head1(CHKARGS);
1.17 kristaps 54: static int check_par(CHKARGS);
1.23 kristaps 55: static int check_part(CHKARGS);
1.17 kristaps 56: static int check_root(CHKARGS);
1.75 kristaps 57: static void check_text(CHKARGS);
1.17 kristaps 58:
1.51 kristaps 59: static int post_AT(CHKARGS);
1.83 schwarze 60: static int post_IP(CHKARGS);
1.70 kristaps 61: static int post_vs(CHKARGS);
1.51 kristaps 62: static int post_fi(CHKARGS);
1.73 kristaps 63: static int post_ft(CHKARGS);
1.51 kristaps 64: static int post_nf(CHKARGS);
1.73 kristaps 65: static int post_sec(CHKARGS);
1.51 kristaps 66: static int post_TH(CHKARGS);
67: static int post_UC(CHKARGS);
1.73 kristaps 68: static int pre_sec(CHKARGS);
1.51 kristaps 69:
70: static v_check posts_at[] = { post_AT, NULL };
1.70 kristaps 71: static v_check posts_br[] = { post_vs, check_eq0, NULL };
1.17 kristaps 72: static v_check posts_eq0[] = { check_eq0, NULL };
1.80 kristaps 73: static v_check posts_eq2[] = { check_eq2, NULL };
1.51 kristaps 74: static v_check posts_fi[] = { check_eq0, post_fi, NULL };
1.73 kristaps 75: static v_check posts_ft[] = { post_ft, NULL };
1.83 schwarze 76: static v_check posts_ip[] = { post_IP, NULL };
1.84 schwarze 77: static v_check posts_le1[] = { check_le1, NULL };
1.51 kristaps 78: static v_check posts_nf[] = { check_eq0, post_nf, NULL };
1.17 kristaps 79: static v_check posts_par[] = { check_par, NULL };
1.23 kristaps 80: static v_check posts_part[] = { check_part, NULL };
1.73 kristaps 81: static v_check posts_sec[] = { post_sec, NULL };
1.70 kristaps 82: static v_check posts_sp[] = { post_vs, check_le1, NULL };
1.60 schwarze 83: static v_check posts_th[] = { check_ge2, check_le5, post_TH, NULL };
1.51 kristaps 84: static v_check posts_uc[] = { post_UC, NULL };
1.86 schwarze 85: static v_check posts_ur[] = { check_head1, check_part, NULL };
1.78 schwarze 86: static v_check pres_sec[] = { pre_sec, NULL };
1.1 kristaps 87:
88: static const struct man_valid man_valids[MAN_MAX] = {
1.70 kristaps 89: { NULL, posts_br }, /* br */
1.78 schwarze 90: { NULL, posts_th }, /* TH */
1.73 kristaps 91: { pres_sec, posts_sec }, /* SH */
92: { pres_sec, posts_sec }, /* SS */
1.78 schwarze 93: { NULL, NULL }, /* TP */
94: { NULL, posts_par }, /* LP */
95: { NULL, posts_par }, /* PP */
96: { NULL, posts_par }, /* P */
1.83 schwarze 97: { NULL, posts_ip }, /* IP */
1.78 schwarze 98: { NULL, NULL }, /* HP */
1.22 kristaps 99: { NULL, NULL }, /* SM */
100: { NULL, NULL }, /* SB */
1.17 kristaps 101: { NULL, NULL }, /* BI */
102: { NULL, NULL }, /* IB */
103: { NULL, NULL }, /* BR */
104: { NULL, NULL }, /* RB */
1.22 kristaps 105: { NULL, NULL }, /* R */
106: { NULL, NULL }, /* B */
107: { NULL, NULL }, /* I */
1.17 kristaps 108: { NULL, NULL }, /* IR */
109: { NULL, NULL }, /* RI */
1.80 kristaps 110: { NULL, posts_eq0 }, /* na */
111: { NULL, posts_sp }, /* sp */
1.78 schwarze 112: { NULL, posts_nf }, /* nf */
113: { NULL, posts_fi }, /* fi */
1.19 kristaps 114: { NULL, NULL }, /* RE */
1.23 kristaps 115: { NULL, posts_part }, /* RS */
1.21 kristaps 116: { NULL, NULL }, /* DT */
1.51 kristaps 117: { NULL, posts_uc }, /* UC */
1.84 schwarze 118: { NULL, posts_le1 }, /* PD */
1.51 kristaps 119: { NULL, posts_at }, /* AT */
1.47 kristaps 120: { NULL, NULL }, /* in */
1.55 kristaps 121: { NULL, posts_ft }, /* ft */
1.80 kristaps 122: { NULL, posts_eq2 }, /* OP */
1.81 schwarze 123: { NULL, posts_nf }, /* EX */
124: { NULL, posts_fi }, /* EE */
1.86 schwarze 125: { NULL, posts_ur }, /* UR */
126: { NULL, NULL }, /* UE */
1.90 schwarze 127: { NULL, NULL }, /* ll */
1.1 kristaps 128: };
129:
130:
131: int
1.85 schwarze 132: man_valid_pre(struct man *man, struct man_node *n)
1.17 kristaps 133: {
134: v_check *cp;
135:
1.57 kristaps 136: switch (n->type) {
1.91 schwarze 137: case MAN_TEXT:
1.57 kristaps 138: /* FALLTHROUGH */
1.91 schwarze 139: case MAN_ROOT:
1.61 kristaps 140: /* FALLTHROUGH */
1.91 schwarze 141: case MAN_EQN:
1.57 kristaps 142: /* FALLTHROUGH */
1.91 schwarze 143: case MAN_TBL:
1.17 kristaps 144: return(1);
1.57 kristaps 145: default:
146: break;
147: }
1.17 kristaps 148:
149: if (NULL == (cp = man_valids[n->tok].pres))
150: return(1);
151: for ( ; *cp; cp++)
1.91 schwarze 152: if ( ! (*cp)(man, n))
1.17 kristaps 153: return(0);
154: return(1);
155: }
156:
157: int
1.85 schwarze 158: man_valid_post(struct man *man)
1.1 kristaps 159: {
1.17 kristaps 160: v_check *cp;
1.1 kristaps 161:
1.85 schwarze 162: if (MAN_VALID & man->last->flags)
1.1 kristaps 163: return(1);
1.85 schwarze 164: man->last->flags |= MAN_VALID;
1.1 kristaps 165:
1.85 schwarze 166: switch (man->last->type) {
1.91 schwarze 167: case MAN_TEXT:
1.85 schwarze 168: check_text(man, man->last);
1.75 kristaps 169: return(1);
1.91 schwarze 170: case MAN_ROOT:
1.85 schwarze 171: return(check_root(man, man->last));
1.91 schwarze 172: case MAN_EQN:
1.62 kristaps 173: /* FALLTHROUGH */
1.91 schwarze 174: case MAN_TBL:
1.57 kristaps 175: return(1);
1.1 kristaps 176: default:
177: break;
178: }
179:
1.85 schwarze 180: if (NULL == (cp = man_valids[man->last->tok].posts))
1.1 kristaps 181: return(1);
182: for ( ; *cp; cp++)
1.85 schwarze 183: if ( ! (*cp)(man, man->last))
1.1 kristaps 184: return(0);
185:
186: return(1);
187: }
188:
1.11 kristaps 189: static int
1.91 schwarze 190: check_root(CHKARGS)
1.14 kristaps 191: {
1.17 kristaps 192:
1.85 schwarze 193: if (MAN_BLINE & man->flags)
194: man_nmsg(man, n, MANDOCERR_SCOPEEXIT);
195: else if (MAN_ELINE & man->flags)
196: man_nmsg(man, n, MANDOCERR_SCOPEEXIT);
1.22 kristaps 197:
1.85 schwarze 198: man->flags &= ~MAN_BLINE;
199: man->flags &= ~MAN_ELINE;
1.17 kristaps 200:
1.93 schwarze 201: if (NULL == man->first->child)
202: man_nmsg(man, n, MANDOCERR_DOC_EMPTY);
203: else
204: man->meta.hasbody = 1;
205:
206: if (NULL == man->meta.title) {
1.92 schwarze 207: man_nmsg(man, n, MANDOCERR_TH_MISSING);
1.54 kristaps 208:
1.34 kristaps 209: /*
210: * If a title hasn't been set, do so now (by
211: * implication, date and section also aren't set).
212: */
1.54 kristaps 213:
1.91 schwarze 214: man->meta.title = mandoc_strdup("unknown");
1.85 schwarze 215: man->meta.msec = mandoc_strdup("1");
1.88 schwarze 216: man->meta.date = man->quick ? mandoc_strdup("") :
217: mandoc_normdate(man->parse, NULL, n->line, n->pos);
1.34 kristaps 218: }
1.32 kristaps 219:
220: return(1);
1.75 kristaps 221: }
222:
223: static void
224: check_text(CHKARGS)
225: {
226: char *cp, *p;
227:
1.85 schwarze 228: if (MAN_LITERAL & man->flags)
1.76 schwarze 229: return;
230:
231: cp = n->string;
232: for (p = cp; NULL != (p = strchr(p, '\t')); p++)
1.99 ! schwarze 233: mandoc_msg(MANDOCERR_FI_TAB, man->parse,
! 234: n->line, n->pos + (p - cp), NULL);
1.1 kristaps 235: }
236:
237: #define INEQ_DEFINE(x, ineq, name) \
238: static int \
1.17 kristaps 239: check_##name(CHKARGS) \
1.1 kristaps 240: { \
1.11 kristaps 241: if (n->nchild ineq (x)) \
1.1 kristaps 242: return(1); \
1.85 schwarze 243: mandoc_vmsg(MANDOCERR_ARGCOUNT, man->parse, n->line, n->pos, \
1.91 schwarze 244: "line arguments %s %d (have %d)", \
245: #ineq, (x), n->nchild); \
1.60 schwarze 246: return(1); \
1.1 kristaps 247: }
248:
249: INEQ_DEFINE(0, ==, eq0)
1.80 kristaps 250: INEQ_DEFINE(2, ==, eq2)
1.25 kristaps 251: INEQ_DEFINE(1, <=, le1)
1.1 kristaps 252: INEQ_DEFINE(2, >=, ge2)
253: INEQ_DEFINE(5, <=, le5)
1.86 schwarze 254:
255: static int
256: check_head1(CHKARGS)
257: {
258:
259: if (MAN_HEAD == n->type && 1 != n->nchild)
260: mandoc_vmsg(MANDOCERR_ARGCOUNT, man->parse, n->line,
261: n->pos, "line arguments eq 1 (have %d)", n->nchild);
262:
263: return(1);
264: }
1.1 kristaps 265:
1.55 kristaps 266: static int
1.73 kristaps 267: post_ft(CHKARGS)
1.55 kristaps 268: {
269: char *cp;
270: int ok;
271:
272: if (0 == n->nchild)
273: return(1);
274:
275: ok = 0;
276: cp = n->child->string;
277: switch (*cp) {
1.91 schwarze 278: case '1':
1.55 kristaps 279: /* FALLTHROUGH */
1.91 schwarze 280: case '2':
1.55 kristaps 281: /* FALLTHROUGH */
1.91 schwarze 282: case '3':
1.55 kristaps 283: /* FALLTHROUGH */
1.91 schwarze 284: case '4':
1.55 kristaps 285: /* FALLTHROUGH */
1.91 schwarze 286: case 'I':
1.55 kristaps 287: /* FALLTHROUGH */
1.91 schwarze 288: case 'P':
1.55 kristaps 289: /* FALLTHROUGH */
1.91 schwarze 290: case 'R':
1.55 kristaps 291: if ('\0' == cp[1])
292: ok = 1;
293: break;
1.91 schwarze 294: case 'B':
1.55 kristaps 295: if ('\0' == cp[1] || ('I' == cp[1] && '\0' == cp[2]))
296: ok = 1;
297: break;
1.91 schwarze 298: case 'C':
1.55 kristaps 299: if ('W' == cp[1] && '\0' == cp[2])
300: ok = 1;
301: break;
302: default:
303: break;
304: }
305:
306: if (0 == ok) {
1.98 schwarze 307: mandoc_vmsg(MANDOCERR_FT_BAD, man->parse,
308: n->line, n->pos, "ft %s", cp);
1.55 kristaps 309: *cp = '\0';
310: }
311:
312: if (1 < n->nchild)
1.91 schwarze 313: mandoc_vmsg(MANDOCERR_ARGCOUNT, man->parse, n->line,
314: n->pos, "want one child (have %d)", n->nchild);
1.55 kristaps 315:
316: return(1);
317: }
1.16 kristaps 318:
319: static int
1.73 kristaps 320: pre_sec(CHKARGS)
321: {
322:
323: if (MAN_BLOCK == n->type)
1.85 schwarze 324: man->flags &= ~MAN_LITERAL;
1.73 kristaps 325: return(1);
326: }
327:
328: static int
329: post_sec(CHKARGS)
1.17 kristaps 330: {
1.16 kristaps 331:
1.91 schwarze 332: if ( ! (MAN_HEAD == n->type && 0 == n->nchild))
1.69 kristaps 333: return(1);
1.41 kristaps 334:
1.85 schwarze 335: man_nmsg(man, n, MANDOCERR_SYNTARGCOUNT);
1.69 kristaps 336: return(0);
1.16 kristaps 337: }
1.17 kristaps 338:
339: static int
1.23 kristaps 340: check_part(CHKARGS)
341: {
342:
343: if (MAN_BODY == n->type && 0 == n->nchild)
1.91 schwarze 344: mandoc_msg(MANDOCERR_ARGCWARN, man->parse, n->line,
345: n->pos, "want children (have none)");
1.54 kristaps 346:
1.23 kristaps 347: return(1);
348: }
349:
350: static int
1.17 kristaps 351: check_par(CHKARGS)
352: {
353:
1.59 kristaps 354: switch (n->type) {
1.91 schwarze 355: case MAN_BLOCK:
1.59 kristaps 356: if (0 == n->body->nchild)
1.85 schwarze 357: man_node_delete(man, n);
1.59 kristaps 358: break;
1.91 schwarze 359: case MAN_BODY:
1.59 kristaps 360: if (0 == n->nchild)
1.95 schwarze 361: mandoc_vmsg(MANDOCERR_PAR_SKIP,
362: man->parse, n->line, n->pos,
363: "%s empty", man_macronames[n->tok]);
1.59 kristaps 364: break;
1.91 schwarze 365: case MAN_HEAD:
1.59 kristaps 366: if (n->nchild)
1.97 schwarze 367: mandoc_vmsg(MANDOCERR_ARG_SKIP,
368: man->parse, n->line, n->pos,
369: "%s %s%s", man_macronames[n->tok],
370: n->child->string,
371: n->nchild > 1 ? " ..." : "");
1.59 kristaps 372: break;
373: default:
374: break;
375: }
1.17 kristaps 376:
377: return(1);
378: }
379:
1.83 schwarze 380: static int
381: post_IP(CHKARGS)
382: {
383:
384: switch (n->type) {
1.91 schwarze 385: case MAN_BLOCK:
1.83 schwarze 386: if (0 == n->head->nchild && 0 == n->body->nchild)
1.85 schwarze 387: man_node_delete(man, n);
1.83 schwarze 388: break;
1.91 schwarze 389: case MAN_BODY:
1.83 schwarze 390: if (0 == n->parent->head->nchild && 0 == n->nchild)
1.95 schwarze 391: mandoc_vmsg(MANDOCERR_PAR_SKIP,
392: man->parse, n->line, n->pos,
393: "%s empty", man_macronames[n->tok]);
1.83 schwarze 394: break;
395: default:
396: break;
397: }
398: return(1);
399: }
1.17 kristaps 400:
1.51 kristaps 401: static int
402: post_TH(CHKARGS)
403: {
1.92 schwarze 404: struct man_node *nb;
1.60 schwarze 405: const char *p;
1.51 kristaps 406:
1.85 schwarze 407: free(man->meta.title);
408: free(man->meta.vol);
409: free(man->meta.source);
410: free(man->meta.msec);
411: free(man->meta.date);
1.51 kristaps 412:
1.85 schwarze 413: man->meta.title = man->meta.vol = man->meta.date =
1.91 schwarze 414: man->meta.msec = man->meta.source = NULL;
1.51 kristaps 415:
1.92 schwarze 416: nb = n;
417:
1.51 kristaps 418: /* ->TITLE<- MSEC DATE SOURCE VOL */
419:
420: n = n->child;
1.60 schwarze 421: if (n && n->string) {
422: for (p = n->string; '\0' != *p; p++) {
423: /* Only warn about this once... */
1.91 schwarze 424: if (isalpha((unsigned char)*p) &&
425: ! isupper((unsigned char)*p)) {
1.94 schwarze 426: mandoc_msg(MANDOCERR_TITLE_CASE,
427: man->parse, n->line,
428: n->pos + (p - n->string),
429: n->string);
1.60 schwarze 430: break;
431: }
432: }
1.85 schwarze 433: man->meta.title = mandoc_strdup(n->string);
1.60 schwarze 434: } else
1.85 schwarze 435: man->meta.title = mandoc_strdup("");
1.51 kristaps 436:
437: /* TITLE ->MSEC<- DATE SOURCE VOL */
438:
1.60 schwarze 439: if (n)
440: n = n->next;
441: if (n && n->string)
1.85 schwarze 442: man->meta.msec = mandoc_strdup(n->string);
1.60 schwarze 443: else
1.85 schwarze 444: man->meta.msec = mandoc_strdup("");
1.51 kristaps 445:
446: /* TITLE MSEC ->DATE<- SOURCE VOL */
447:
1.60 schwarze 448: if (n)
449: n = n->next;
1.77 schwarze 450: if (n && n->string && '\0' != n->string[0]) {
1.88 schwarze 451: man->meta.date = man->quick ?
452: mandoc_strdup(n->string) :
453: mandoc_normdate(man->parse, n->string,
454: n->line, n->pos);
1.92 schwarze 455: } else {
1.85 schwarze 456: man->meta.date = mandoc_strdup("");
1.92 schwarze 457: man_nmsg(man, n ? n : nb, MANDOCERR_DATE_MISSING);
458: }
1.51 kristaps 459:
460: /* TITLE MSEC DATE ->SOURCE<- VOL */
461:
462: if (n && (n = n->next))
1.85 schwarze 463: man->meta.source = mandoc_strdup(n->string);
1.51 kristaps 464:
465: /* TITLE MSEC DATE SOURCE ->VOL<- */
1.79 schwarze 466: /* If missing, use the default VOL name for MSEC. */
1.51 kristaps 467:
468: if (n && (n = n->next))
1.85 schwarze 469: man->meta.vol = mandoc_strdup(n->string);
470: else if ('\0' != man->meta.msec[0] &&
471: (NULL != (p = mandoc_a2msec(man->meta.msec))))
472: man->meta.vol = mandoc_strdup(p);
1.51 kristaps 473:
474: /*
475: * Remove the `TH' node after we've processed it for our
476: * meta-data.
477: */
1.85 schwarze 478: man_node_delete(man, man->last);
1.51 kristaps 479: return(1);
480: }
481:
482: static int
483: post_nf(CHKARGS)
484: {
485:
1.85 schwarze 486: if (MAN_LITERAL & man->flags)
1.96 schwarze 487: man_nmsg(man, n, MANDOCERR_NF_SKIP);
1.51 kristaps 488:
1.85 schwarze 489: man->flags |= MAN_LITERAL;
1.51 kristaps 490: return(1);
491: }
492:
493: static int
494: post_fi(CHKARGS)
495: {
496:
1.85 schwarze 497: if ( ! (MAN_LITERAL & man->flags))
1.96 schwarze 498: man_nmsg(man, n, MANDOCERR_FI_SKIP);
1.51 kristaps 499:
1.85 schwarze 500: man->flags &= ~MAN_LITERAL;
1.51 kristaps 501: return(1);
502: }
503:
504: static int
505: post_UC(CHKARGS)
506: {
507: static const char * const bsd_versions[] = {
508: "3rd Berkeley Distribution",
509: "4th Berkeley Distribution",
510: "4.2 Berkeley Distribution",
511: "4.3 Berkeley Distribution",
512: "4.4 Berkeley Distribution",
513: };
514:
515: const char *p, *s;
516:
517: n = n->child;
518:
519: if (NULL == n || MAN_TEXT != n->type)
520: p = bsd_versions[0];
521: else {
522: s = n->string;
523: if (0 == strcmp(s, "3"))
524: p = bsd_versions[0];
525: else if (0 == strcmp(s, "4"))
526: p = bsd_versions[1];
527: else if (0 == strcmp(s, "5"))
528: p = bsd_versions[2];
529: else if (0 == strcmp(s, "6"))
530: p = bsd_versions[3];
531: else if (0 == strcmp(s, "7"))
532: p = bsd_versions[4];
533: else
534: p = bsd_versions[0];
535: }
536:
1.85 schwarze 537: free(man->meta.source);
538: man->meta.source = mandoc_strdup(p);
1.51 kristaps 539: return(1);
540: }
541:
542: static int
543: post_AT(CHKARGS)
544: {
545: static const char * const unix_versions[] = {
546: "7th Edition",
547: "System III",
548: "System V",
549: "System V Release 2",
550: };
551:
552: const char *p, *s;
553: struct man_node *nn;
554:
555: n = n->child;
556:
557: if (NULL == n || MAN_TEXT != n->type)
558: p = unix_versions[0];
559: else {
560: s = n->string;
561: if (0 == strcmp(s, "3"))
562: p = unix_versions[0];
563: else if (0 == strcmp(s, "4"))
564: p = unix_versions[1];
565: else if (0 == strcmp(s, "5")) {
566: nn = n->next;
567: if (nn && MAN_TEXT == nn->type && nn->string[0])
568: p = unix_versions[3];
569: else
570: p = unix_versions[2];
571: } else
572: p = unix_versions[0];
573: }
574:
1.85 schwarze 575: free(man->meta.source);
576: man->meta.source = mandoc_strdup(p);
1.70 kristaps 577: return(1);
578: }
579:
580: static int
581: post_vs(CHKARGS)
582: {
583:
1.82 schwarze 584: if (NULL != n->prev)
585: return(1);
586:
587: switch (n->parent->tok) {
1.91 schwarze 588: case MAN_SH:
1.82 schwarze 589: /* FALLTHROUGH */
1.91 schwarze 590: case MAN_SS:
1.95 schwarze 591: mandoc_vmsg(MANDOCERR_PAR_SKIP, man->parse, n->line, n->pos,
592: "%s after %s", man_macronames[n->tok],
593: man_macronames[n->parent->tok]);
1.82 schwarze 594: /* FALLTHROUGH */
1.91 schwarze 595: case MAN_MAX:
596: /*
1.82 schwarze 597: * Don't warn about this because it occurs in pod2man
598: * and would cause considerable (unfixable) warnage.
599: */
1.85 schwarze 600: man_node_delete(man, n);
1.82 schwarze 601: break;
602: default:
603: break;
604: }
1.70 kristaps 605:
1.51 kristaps 606: return(1);
607: }
CVSweb