Annotation of mandoc/man.c, Revision 1.76
1.76 ! kristaps 1: /* $Id: man.c,v 1.75 2010/05/26 14:03:54 kristaps Exp $ */
1.1 kristaps 2: /*
1.76 ! kristaps 3: * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>
1.1 kristaps 4: *
5: * Permission to use, copy, modify, and distribute this software for any
1.18 kristaps 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.18 kristaps 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: */
1.47 kristaps 17: #ifdef HAVE_CONFIG_H
18: #include "config.h"
19: #endif
20:
1.41 kristaps 21: #include <sys/types.h>
22:
1.1 kristaps 23: #include <assert.h>
24: #include <ctype.h>
25: #include <stdarg.h>
26: #include <stdlib.h>
27: #include <stdio.h>
28: #include <string.h>
29:
1.74 kristaps 30: #include "mandoc.h"
1.1 kristaps 31: #include "libman.h"
1.45 kristaps 32: #include "libmandoc.h"
1.1 kristaps 33:
34: const char *const __man_macronames[MAN_MAX] = {
1.21 kristaps 35: "br", "TH", "SH", "SS",
1.1 kristaps 36: "TP", "LP", "PP", "P",
37: "IP", "HP", "SM", "SB",
38: "BI", "IB", "BR", "RB",
1.11 kristaps 39: "R", "B", "I", "IR",
1.29 kristaps 40: "RI", "na", "i", "sp",
1.30 kristaps 41: "nf", "fi", "r", "RE",
1.52 kristaps 42: "RS", "DT", "UC", "PD",
1.73 joerg 43: "Sp", "Vb", "Ve", "AT",
1.1 kristaps 44: };
45:
46: const char * const *man_macronames = __man_macronames;
47:
1.16 kristaps 48: static struct man_node *man_node_alloc(int, int,
1.53 kristaps 49: enum man_type, enum mant);
1.1 kristaps 50: static int man_node_append(struct man *,
51: struct man_node *);
1.54 kristaps 52: static void man_node_free(struct man_node *);
53: static void man_node_unlink(struct man *,
54: struct man_node *);
1.72 kristaps 55: static int man_ptext(struct man *, int, char *, int);
56: static int man_pmacro(struct man *, int, char *, int);
1.2 kristaps 57: static void man_free1(struct man *);
1.45 kristaps 58: static void man_alloc1(struct man *);
1.72 kristaps 59: static int macrowarn(struct man *, int, const char *, int);
1.1 kristaps 60:
61:
62: const struct man_node *
1.2 kristaps 63: man_node(const struct man *m)
1.1 kristaps 64: {
65:
1.2 kristaps 66: return(MAN_HALT & m->flags ? NULL : m->first);
1.1 kristaps 67: }
68:
69:
70: const struct man_meta *
1.2 kristaps 71: man_meta(const struct man *m)
1.1 kristaps 72: {
73:
1.2 kristaps 74: return(MAN_HALT & m->flags ? NULL : &m->meta);
1.1 kristaps 75: }
76:
77:
1.45 kristaps 78: void
1.1 kristaps 79: man_reset(struct man *man)
80: {
81:
1.2 kristaps 82: man_free1(man);
1.45 kristaps 83: man_alloc1(man);
1.1 kristaps 84: }
85:
86:
87: void
88: man_free(struct man *man)
89: {
90:
1.2 kristaps 91: man_free1(man);
1.1 kristaps 92: free(man);
93: }
94:
95:
96: struct man *
1.74 kristaps 97: man_alloc(void *data, int pflags, mandocmsg msg)
1.1 kristaps 98: {
99: struct man *p;
100:
1.45 kristaps 101: p = mandoc_calloc(1, sizeof(struct man));
1.2 kristaps 102:
1.40 kristaps 103: man_hash_init();
1.4 kristaps 104: p->data = data;
1.7 kristaps 105: p->pflags = pflags;
1.74 kristaps 106: p->msg = msg;
1.45 kristaps 107:
108: man_alloc1(p);
1.1 kristaps 109: return(p);
110: }
111:
112:
113: int
114: man_endparse(struct man *m)
115: {
116:
1.3 kristaps 117: if (MAN_HALT & m->flags)
118: return(0);
119: else if (man_macroend(m))
120: return(1);
121: m->flags |= MAN_HALT;
122: return(0);
1.1 kristaps 123: }
124:
125:
126: int
1.72 kristaps 127: man_parseln(struct man *m, int ln, char *buf, int offs)
1.1 kristaps 128: {
129:
1.72 kristaps 130: if (MAN_HALT & m->flags)
131: return(0);
132:
133: return(('.' == buf[offs] || '\'' == buf[offs]) ?
134: man_pmacro(m, ln, buf, offs) :
135: man_ptext(m, ln, buf, offs));
1.1 kristaps 136: }
137:
138:
1.2 kristaps 139: static void
140: man_free1(struct man *man)
141: {
142:
143: if (man->first)
1.54 kristaps 144: man_node_delete(man, man->first);
1.2 kristaps 145: if (man->meta.title)
146: free(man->meta.title);
1.6 kristaps 147: if (man->meta.source)
148: free(man->meta.source);
1.75 kristaps 149: if (man->meta.rawdate)
150: free(man->meta.rawdate);
1.2 kristaps 151: if (man->meta.vol)
152: free(man->meta.vol);
1.68 kristaps 153: if (man->meta.msec)
154: free(man->meta.msec);
1.2 kristaps 155: }
156:
157:
1.45 kristaps 158: static void
1.2 kristaps 159: man_alloc1(struct man *m)
160: {
161:
1.44 kristaps 162: memset(&m->meta, 0, sizeof(struct man_meta));
1.2 kristaps 163: m->flags = 0;
1.45 kristaps 164: m->last = mandoc_calloc(1, sizeof(struct man_node));
1.2 kristaps 165: m->first = m->last;
166: m->last->type = MAN_ROOT;
1.54 kristaps 167: m->last->tok = MAN_MAX;
1.2 kristaps 168: m->next = MAN_NEXT_CHILD;
169: }
170:
171:
1.1 kristaps 172: static int
173: man_node_append(struct man *man, struct man_node *p)
174: {
175:
176: assert(man->last);
177: assert(man->first);
178: assert(MAN_ROOT != p->type);
179:
180: switch (man->next) {
181: case (MAN_NEXT_SIBLING):
182: man->last->next = p;
183: p->prev = man->last;
184: p->parent = man->last->parent;
185: break;
186: case (MAN_NEXT_CHILD):
187: man->last->child = p;
188: p->parent = man->last;
189: break;
190: default:
191: abort();
192: /* NOTREACHED */
193: }
1.22 kristaps 194:
1.54 kristaps 195: assert(p->parent);
1.22 kristaps 196: p->parent->nchild++;
1.1 kristaps 197:
1.29 kristaps 198: if ( ! man_valid_pre(man, p))
199: return(0);
200:
201: switch (p->type) {
202: case (MAN_HEAD):
203: assert(MAN_BLOCK == p->parent->type);
204: p->parent->head = p;
205: break;
206: case (MAN_BODY):
207: assert(MAN_BLOCK == p->parent->type);
208: p->parent->body = p;
209: break;
210: default:
211: break;
212: }
213:
1.2 kristaps 214: man->last = p;
215:
1.1 kristaps 216: switch (p->type) {
1.2 kristaps 217: case (MAN_TEXT):
218: if ( ! man_valid_post(man))
219: return(0);
220: if ( ! man_action_post(man))
221: return(0);
1.1 kristaps 222: break;
223: default:
224: break;
225: }
226:
227: return(1);
228: }
229:
230:
231: static struct man_node *
1.53 kristaps 232: man_node_alloc(int line, int pos, enum man_type type, enum mant tok)
1.1 kristaps 233: {
234: struct man_node *p;
235:
1.45 kristaps 236: p = mandoc_calloc(1, sizeof(struct man_node));
1.1 kristaps 237: p->line = line;
238: p->pos = pos;
239: p->type = type;
1.16 kristaps 240: p->tok = tok;
1.1 kristaps 241: return(p);
242: }
243:
244:
245: int
1.53 kristaps 246: man_elem_alloc(struct man *m, int line, int pos, enum mant tok)
1.1 kristaps 247: {
248: struct man_node *p;
249:
1.16 kristaps 250: p = man_node_alloc(line, pos, MAN_ELEM, tok);
1.30 kristaps 251: if ( ! man_node_append(m, p))
252: return(0);
253: m->next = MAN_NEXT_CHILD;
254: return(1);
1.1 kristaps 255: }
256:
257:
258: int
1.53 kristaps 259: man_head_alloc(struct man *m, int line, int pos, enum mant tok)
1.29 kristaps 260: {
261: struct man_node *p;
262:
263: p = man_node_alloc(line, pos, MAN_HEAD, tok);
264: if ( ! man_node_append(m, p))
265: return(0);
266: m->next = MAN_NEXT_CHILD;
267: return(1);
268: }
269:
270:
271: int
1.53 kristaps 272: man_body_alloc(struct man *m, int line, int pos, enum mant tok)
1.29 kristaps 273: {
274: struct man_node *p;
275:
276: p = man_node_alloc(line, pos, MAN_BODY, tok);
277: if ( ! man_node_append(m, p))
278: return(0);
279: m->next = MAN_NEXT_CHILD;
280: return(1);
281: }
282:
283:
284: int
1.53 kristaps 285: man_block_alloc(struct man *m, int line, int pos, enum mant tok)
1.29 kristaps 286: {
287: struct man_node *p;
288:
289: p = man_node_alloc(line, pos, MAN_BLOCK, tok);
290: if ( ! man_node_append(m, p))
291: return(0);
292: m->next = MAN_NEXT_CHILD;
293: return(1);
294: }
295:
296:
1.61 kristaps 297: int
298: man_word_alloc(struct man *m, int line, int pos, const char *word)
1.1 kristaps 299: {
1.31 kristaps 300: struct man_node *n;
1.61 kristaps 301: size_t sv, len;
302:
303: len = strlen(word);
1.1 kristaps 304:
1.53 kristaps 305: n = man_node_alloc(line, pos, MAN_TEXT, MAN_MAX);
1.45 kristaps 306: n->string = mandoc_malloc(len + 1);
1.61 kristaps 307: sv = strlcpy(n->string, word, len + 1);
1.31 kristaps 308:
309: /* Prohibit truncation. */
310: assert(sv < len + 1);
311:
312: if ( ! man_node_append(m, n))
1.30 kristaps 313: return(0);
1.61 kristaps 314:
1.30 kristaps 315: m->next = MAN_NEXT_SIBLING;
316: return(1);
1.1 kristaps 317: }
318:
319:
1.54 kristaps 320: /*
321: * Free all of the resources held by a node. This does NOT unlink a
322: * node from its context; for that, see man_node_unlink().
323: */
324: static void
1.1 kristaps 325: man_node_free(struct man_node *p)
326: {
327:
328: if (p->string)
329: free(p->string);
330: free(p);
331: }
332:
333:
334: void
1.54 kristaps 335: man_node_delete(struct man *m, struct man_node *p)
1.1 kristaps 336: {
337:
1.54 kristaps 338: while (p->child)
339: man_node_delete(m, p->child);
340:
341: man_node_unlink(m, p);
1.1 kristaps 342: man_node_free(p);
343: }
344:
345:
346: static int
1.72 kristaps 347: man_ptext(struct man *m, int line, char *buf, int offs)
1.1 kristaps 348: {
1.61 kristaps 349: int i;
1.60 kristaps 350:
351: /* Ignore bogus comments. */
352:
1.72 kristaps 353: if ('\\' == buf[offs] &&
354: '.' == buf[offs + 1] &&
355: '"' == buf[offs + 2])
1.74 kristaps 356: return(man_pmsg(m, line, offs, MANDOCERR_BADCOMMENT));
1.31 kristaps 357:
1.35 kristaps 358: /* Literal free-form text whitespace is preserved. */
359:
360: if (MAN_LITERAL & m->flags) {
1.72 kristaps 361: if ( ! man_word_alloc(m, line, offs, buf + offs))
1.35 kristaps 362: return(0);
363: goto descope;
364: }
365:
1.61 kristaps 366: /* Pump blank lines directly into the backend. */
1.31 kristaps 367:
1.72 kristaps 368: for (i = offs; ' ' == buf[i]; i++)
1.31 kristaps 369: /* Skip leading whitespace. */ ;
1.48 kristaps 370:
1.49 kristaps 371: if ('\0' == buf[i]) {
1.61 kristaps 372: /* Allocate a blank entry. */
1.72 kristaps 373: if ( ! man_word_alloc(m, line, offs, ""))
1.31 kristaps 374: return(0);
375: goto descope;
376: }
377:
1.63 kristaps 378: /*
379: * Warn if the last un-escaped character is whitespace. Then
380: * strip away the remaining spaces (tabs stay!).
381: */
1.29 kristaps 382:
1.61 kristaps 383: i = (int)strlen(buf);
384: assert(i);
1.49 kristaps 385:
1.63 kristaps 386: if (' ' == buf[i - 1] || '\t' == buf[i - 1]) {
1.64 kristaps 387: if (i > 1 && '\\' != buf[i - 2])
1.74 kristaps 388: if ( ! man_pmsg(m, line, i - 1, MANDOCERR_EOLNSPACE))
1.49 kristaps 389: return(0);
1.63 kristaps 390:
391: for (--i; i && ' ' == buf[i]; i--)
392: /* Spin back to non-space. */ ;
393:
394: /* Jump ahead of escaped whitespace. */
395: i += '\\' == buf[i] ? 2 : 1;
396:
397: buf[i] = '\0';
398: }
1.49 kristaps 399:
1.72 kristaps 400: if ( ! man_word_alloc(m, line, offs, buf + offs))
1.1 kristaps 401: return(0);
1.65 kristaps 402:
403: /*
404: * End-of-sentence check. If the last character is an unescaped
405: * EOS character, then flag the node as being the end of a
406: * sentence. The front-end will know how to interpret this.
407: */
1.67 kristaps 408:
1.65 kristaps 409: assert(i);
1.66 kristaps 410: if (mandoc_eos(buf, (size_t)i))
1.65 kristaps 411: m->last->flags |= MAN_EOS;
1.31 kristaps 412:
413: descope:
1.11 kristaps 414: /*
1.29 kristaps 415: * Co-ordinate what happens with having a next-line scope open:
416: * first close out the element scope (if applicable), then close
417: * out the block scope (also if applicable).
1.11 kristaps 418: */
419:
1.29 kristaps 420: if (MAN_ELINE & m->flags) {
421: m->flags &= ~MAN_ELINE;
1.74 kristaps 422: if ( ! man_unscope(m, m->last->parent, MANDOCERR_MAX))
1.29 kristaps 423: return(0);
424: }
425:
426: if ( ! (MAN_BLINE & m->flags))
1.11 kristaps 427: return(1);
1.29 kristaps 428: m->flags &= ~MAN_BLINE;
1.11 kristaps 429:
1.74 kristaps 430: if ( ! man_unscope(m, m->last->parent, MANDOCERR_MAX))
1.11 kristaps 431: return(0);
1.72 kristaps 432: return(man_body_alloc(m, line, offs, m->last->tok));
1.1 kristaps 433: }
434:
435:
1.43 kristaps 436: static int
1.72 kristaps 437: macrowarn(struct man *m, int ln, const char *buf, int offs)
1.43 kristaps 438: {
1.74 kristaps 439: int rc;
440:
441: rc = man_vmsg(m, MANDOCERR_MACRO, ln, offs,
442: "unknown macro: %s%s",
443: buf, strlen(buf) > 3 ? "..." : "");
444:
445: return(MAN_IGN_MACRO & m->pflags ? rc : 0);
1.43 kristaps 446: }
447:
448:
1.1 kristaps 449: int
1.72 kristaps 450: man_pmacro(struct man *m, int ln, char *buf, int offs)
1.1 kristaps 451: {
1.58 kristaps 452: int i, j, ppos;
1.53 kristaps 453: enum mant tok;
1.34 kristaps 454: char mac[5];
455: struct man_node *n;
1.1 kristaps 456:
457: /* Comments and empties are quickly ignored. */
458:
1.72 kristaps 459: offs++;
460:
461: if ('\0' == buf[offs])
1.46 kristaps 462: return(1);
1.1 kristaps 463:
1.72 kristaps 464: i = offs;
1.9 kristaps 465:
1.56 kristaps 466: /*
467: * Skip whitespace between the control character and initial
468: * text. "Whitespace" is both spaces and tabs.
469: */
1.62 kristaps 470:
1.57 kristaps 471: if (' ' == buf[i] || '\t' == buf[i]) {
1.9 kristaps 472: i++;
1.56 kristaps 473: while (buf[i] && (' ' == buf[i] || '\t' == buf[i]))
1.1 kristaps 474: i++;
1.48 kristaps 475: if ('\0' == buf[i])
1.11 kristaps 476: goto out;
1.1 kristaps 477: }
478:
1.10 kristaps 479: ppos = i;
480:
1.1 kristaps 481: /* Copy the first word into a nil-terminated buffer. */
482:
1.10 kristaps 483: for (j = 0; j < 4; j++, i++) {
1.48 kristaps 484: if ('\0' == (mac[j] = buf[i]))
1.1 kristaps 485: break;
1.10 kristaps 486: else if (' ' == buf[i])
1.1 kristaps 487: break;
1.38 kristaps 488:
489: /* Check for invalid characters. */
490:
491: if (isgraph((u_char)buf[i]))
492: continue;
1.74 kristaps 493: if ( ! man_pmsg(m, ln, i, MANDOCERR_BADCHAR))
494: return(0);
495: i--;
1.1 kristaps 496: }
497:
1.46 kristaps 498: mac[j] = '\0';
1.1 kristaps 499:
1.9 kristaps 500: if (j == 4 || j < 1) {
1.74 kristaps 501: if ( ! macrowarn(m, ln, mac, ppos))
1.7 kristaps 502: goto err;
1.12 kristaps 503: return(1);
1.7 kristaps 504: }
1.1 kristaps 505:
1.53 kristaps 506: if (MAN_MAX == (tok = man_hash_find(mac))) {
1.72 kristaps 507: if ( ! macrowarn(m, ln, mac, ppos))
1.7 kristaps 508: goto err;
1.12 kristaps 509: return(1);
1.1 kristaps 510: }
511:
512: /* The macro is sane. Jump to the next word. */
513:
514: while (buf[i] && ' ' == buf[i])
515: i++;
516:
1.62 kristaps 517: /*
518: * Trailing whitespace. Note that tabs are allowed to be passed
519: * into the parser as "text", so we only warn about spaces here.
520: */
1.48 kristaps 521:
522: if ('\0' == buf[i] && ' ' == buf[i - 1])
1.74 kristaps 523: if ( ! man_pmsg(m, ln, i - 1, MANDOCERR_EOLNSPACE))
1.48 kristaps 524: goto err;
525:
1.50 kristaps 526: /*
1.51 kristaps 527: * Remove prior ELINE macro, as it's being clobbering by a new
528: * macro. Note that NSCOPED macros do not close out ELINE
529: * macros---they don't print text---so we let those slip by.
1.50 kristaps 530: */
1.34 kristaps 531:
1.53 kristaps 532: if ( ! (MAN_NSCOPED & man_macros[tok].flags) &&
1.51 kristaps 533: m->flags & MAN_ELINE) {
534: assert(MAN_TEXT != m->last->type);
535:
536: /*
537: * This occurs in the following construction:
538: * .B
539: * .br
540: * .B
541: * .br
542: * I hate man macros.
543: * Flat-out disallow this madness.
544: */
1.74 kristaps 545: if (MAN_NSCOPED & man_macros[m->last->tok].flags) {
546: man_pmsg(m, ln, ppos, MANDOCERR_SYNTLINESCOPE);
547: return(0);
548: }
1.51 kristaps 549:
1.34 kristaps 550: n = m->last;
1.51 kristaps 551:
552: assert(n);
1.34 kristaps 553: assert(NULL == n->child);
1.37 kristaps 554: assert(0 == n->nchild);
1.51 kristaps 555:
1.74 kristaps 556: if ( ! man_nmsg(m, n, MANDOCERR_LINESCOPE))
1.34 kristaps 557: return(0);
558:
1.54 kristaps 559: man_node_delete(m, n);
1.34 kristaps 560: m->flags &= ~MAN_ELINE;
561: }
562:
1.59 kristaps 563: /*
564: * Save the fact that we're in the next-line for a block. In
565: * this way, embedded roff instructions can "remember" state
566: * when they exit.
567: */
568:
569: if (MAN_BLINE & m->flags)
570: m->flags |= MAN_BPLINE;
571:
572: /* Call to handler... */
1.1 kristaps 573:
1.53 kristaps 574: assert(man_macros[tok].fp);
575: if ( ! (*man_macros[tok].fp)(m, tok, ln, ppos, &i, buf))
1.1 kristaps 576: goto err;
577:
1.11 kristaps 578: out:
1.50 kristaps 579: /*
580: * We weren't in a block-line scope when entering the
581: * above-parsed macro, so return.
582: */
583:
1.58 kristaps 584: if ( ! (MAN_BPLINE & m->flags)) {
1.50 kristaps 585: m->flags &= ~MAN_ILINE;
1.29 kristaps 586: return(1);
1.50 kristaps 587: }
1.58 kristaps 588: m->flags &= ~MAN_BPLINE;
1.50 kristaps 589:
590: /*
591: * If we're in a block scope, then allow this macro to slip by
592: * without closing scope around it.
593: */
594:
595: if (MAN_ILINE & m->flags) {
596: m->flags &= ~MAN_ILINE;
597: return(1);
598: }
1.29 kristaps 599:
600: /*
601: * If we've opened a new next-line element scope, then return
602: * now, as the next line will close out the block scope.
603: */
604:
605: if (MAN_ELINE & m->flags)
606: return(1);
607:
608: /* Close out the block scope opened in the prior line. */
1.11 kristaps 609:
1.29 kristaps 610: assert(MAN_BLINE & m->flags);
611: m->flags &= ~MAN_BLINE;
1.11 kristaps 612:
1.74 kristaps 613: if ( ! man_unscope(m, m->last->parent, MANDOCERR_MAX))
1.29 kristaps 614: return(0);
1.72 kristaps 615: return(man_body_alloc(m, ln, offs, m->last->tok));
1.1 kristaps 616:
617: err: /* Error out. */
618:
1.2 kristaps 619: m->flags |= MAN_HALT;
1.1 kristaps 620: return(0);
621: }
1.3 kristaps 622:
1.4 kristaps 623:
624: int
1.74 kristaps 625: man_vmsg(struct man *man, enum mandocerr t,
626: int ln, int pos, const char *fmt, ...)
1.4 kristaps 627: {
628: char buf[256];
629: va_list ap;
630:
631: va_start(ap, fmt);
1.74 kristaps 632: vsnprintf(buf, sizeof(buf) - 1, fmt, ap);
1.4 kristaps 633: va_end(ap);
1.74 kristaps 634: return((*man->msg)(t, man->data, ln, pos, buf));
1.51 kristaps 635: }
636:
637:
1.54 kristaps 638: /*
639: * Unlink a node from its context. If "m" is provided, the last parse
640: * point will also be adjusted accordingly.
641: */
642: static void
1.51 kristaps 643: man_node_unlink(struct man *m, struct man_node *n)
644: {
645:
1.54 kristaps 646: /* Adjust siblings. */
647:
648: if (n->prev)
1.51 kristaps 649: n->prev->next = n->next;
1.54 kristaps 650: if (n->next)
651: n->next->prev = n->prev;
652:
653: /* Adjust parent. */
654:
655: if (n->parent) {
656: n->parent->nchild--;
657: if (n->parent->child == n)
658: n->parent->child = n->prev ? n->prev : n->next;
659: }
660:
661: /* Adjust parse point, if applicable. */
662:
663: if (m && m->last == n) {
664: /*XXX: this can occur when bailing from validation. */
665: /*assert(NULL == n->next);*/
666: if (n->prev) {
1.51 kristaps 667: m->last = n->prev;
668: m->next = MAN_NEXT_SIBLING;
1.54 kristaps 669: } else {
1.51 kristaps 670: m->last = n->parent;
671: m->next = MAN_NEXT_CHILD;
672: }
673: }
674:
1.54 kristaps 675: if (m && m->first == n)
676: m->first = NULL;
1.23 kristaps 677: }
CVSweb