Annotation of mandoc/man.c, Revision 1.100
1.100 ! kristaps 1: /* $Id: man.c,v 1.99 2011/02/06 22:05:20 kristaps Exp $ */
1.1 kristaps 2: /*
1.82 schwarze 3: * Copyright (c) 2008, 2009, 2010 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 <stdarg.h>
25: #include <stdlib.h>
26: #include <stdio.h>
27: #include <string.h>
28:
1.74 kristaps 29: #include "mandoc.h"
1.1 kristaps 30: #include "libman.h"
1.45 kristaps 31: #include "libmandoc.h"
1.1 kristaps 32:
33: const char *const __man_macronames[MAN_MAX] = {
1.21 kristaps 34: "br", "TH", "SH", "SS",
1.1 kristaps 35: "TP", "LP", "PP", "P",
36: "IP", "HP", "SM", "SB",
37: "BI", "IB", "BR", "RB",
1.11 kristaps 38: "R", "B", "I", "IR",
1.92 kristaps 39: "RI", "na", "sp", "nf",
40: "fi", "RE", "RS", "DT",
41: "UC", "PD", "AT", "in",
42: "ft"
1.1 kristaps 43: };
44:
45: const char * const *man_macronames = __man_macronames;
46:
1.97 kristaps 47: static struct man_node *man_node_alloc(struct man *, int, int,
1.53 kristaps 48: enum man_type, enum mant);
1.1 kristaps 49: static int man_node_append(struct man *,
50: struct man_node *);
1.54 kristaps 51: static void man_node_free(struct man_node *);
52: static void man_node_unlink(struct man *,
53: struct man_node *);
1.72 kristaps 54: static int man_ptext(struct man *, int, char *, int);
1.79 kristaps 55: static int man_pmacro(struct man *, int, char *, int);
1.2 kristaps 56: static void man_free1(struct man *);
1.45 kristaps 57: static void man_alloc1(struct man *);
1.94 kristaps 58: static int man_descope(struct man *, int, int);
1.1 kristaps 59:
60:
61: const struct man_node *
1.2 kristaps 62: man_node(const struct man *m)
1.1 kristaps 63: {
64:
1.96 kristaps 65: assert( ! (MAN_HALT & m->flags));
66: return(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.96 kristaps 74: assert( ! (MAN_HALT & m->flags));
75: return(&m->meta);
1.1 kristaps 76: }
77:
78:
1.45 kristaps 79: void
1.1 kristaps 80: man_reset(struct man *man)
81: {
82:
1.2 kristaps 83: man_free1(man);
1.45 kristaps 84: man_alloc1(man);
1.1 kristaps 85: }
86:
87:
88: void
89: man_free(struct man *man)
90: {
91:
1.2 kristaps 92: man_free1(man);
1.1 kristaps 93: free(man);
94: }
95:
96:
97: struct man *
1.87 schwarze 98: man_alloc(struct regset *regs, void *data, mandocmsg msg)
1.1 kristaps 99: {
100: struct man *p;
101:
1.45 kristaps 102: p = mandoc_calloc(1, sizeof(struct man));
1.2 kristaps 103:
1.40 kristaps 104: man_hash_init();
1.4 kristaps 105: p->data = data;
1.74 kristaps 106: p->msg = msg;
1.79 kristaps 107: p->regs = regs;
1.45 kristaps 108:
109: man_alloc1(p);
1.1 kristaps 110: return(p);
111: }
112:
113:
114: int
115: man_endparse(struct man *m)
116: {
117:
1.96 kristaps 118: assert( ! (MAN_HALT & m->flags));
119: if (man_macroend(m))
1.3 kristaps 120: return(1);
121: m->flags |= MAN_HALT;
122: return(0);
1.1 kristaps 123: }
124:
125:
126: int
1.79 kristaps 127: man_parseln(struct man *m, int ln, char *buf, int offs)
1.1 kristaps 128: {
129:
1.97 kristaps 130: m->flags |= MAN_NEWLINE;
131:
1.96 kristaps 132: assert( ! (MAN_HALT & m->flags));
1.72 kristaps 133: return(('.' == buf[offs] || '\'' == buf[offs]) ?
1.79 kristaps 134: man_pmacro(m, ln, buf, offs) :
1.72 kristaps 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.94 kristaps 217: case (MAN_TBL):
218: /* FALLTHROUGH */
1.2 kristaps 219: case (MAN_TEXT):
220: if ( ! man_valid_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.97 kristaps 232: man_node_alloc(struct man *m, int line, int pos,
233: enum man_type type, enum mant tok)
1.1 kristaps 234: {
235: struct man_node *p;
236:
1.45 kristaps 237: p = mandoc_calloc(1, sizeof(struct man_node));
1.1 kristaps 238: p->line = line;
239: p->pos = pos;
240: p->type = type;
1.16 kristaps 241: p->tok = tok;
1.97 kristaps 242:
243: if (MAN_NEWLINE & m->flags)
244: p->flags |= MAN_LINE;
245: m->flags &= ~MAN_NEWLINE;
1.1 kristaps 246: return(p);
247: }
248:
249:
250: int
1.53 kristaps 251: man_elem_alloc(struct man *m, int line, int pos, enum mant tok)
1.1 kristaps 252: {
253: struct man_node *p;
254:
1.97 kristaps 255: p = man_node_alloc(m, line, pos, MAN_ELEM, tok);
1.30 kristaps 256: if ( ! man_node_append(m, p))
257: return(0);
258: m->next = MAN_NEXT_CHILD;
259: return(1);
1.1 kristaps 260: }
261:
262:
263: int
1.53 kristaps 264: man_head_alloc(struct man *m, int line, int pos, enum mant tok)
1.29 kristaps 265: {
266: struct man_node *p;
267:
1.97 kristaps 268: p = man_node_alloc(m, line, pos, MAN_HEAD, tok);
1.29 kristaps 269: if ( ! man_node_append(m, p))
270: return(0);
271: m->next = MAN_NEXT_CHILD;
272: return(1);
273: }
274:
275:
276: int
1.53 kristaps 277: man_body_alloc(struct man *m, int line, int pos, enum mant tok)
1.29 kristaps 278: {
279: struct man_node *p;
280:
1.97 kristaps 281: p = man_node_alloc(m, line, pos, MAN_BODY, tok);
1.29 kristaps 282: if ( ! man_node_append(m, p))
283: return(0);
284: m->next = MAN_NEXT_CHILD;
285: return(1);
286: }
287:
288:
289: int
1.53 kristaps 290: man_block_alloc(struct man *m, int line, int pos, enum mant tok)
1.29 kristaps 291: {
292: struct man_node *p;
293:
1.97 kristaps 294: p = man_node_alloc(m, line, pos, MAN_BLOCK, tok);
1.29 kristaps 295: if ( ! man_node_append(m, p))
296: return(0);
297: m->next = MAN_NEXT_CHILD;
298: return(1);
299: }
300:
1.61 kristaps 301: int
302: man_word_alloc(struct man *m, int line, int pos, const char *word)
1.1 kristaps 303: {
1.31 kristaps 304: struct man_node *n;
1.61 kristaps 305: size_t sv, len;
306:
307: len = strlen(word);
1.1 kristaps 308:
1.97 kristaps 309: n = man_node_alloc(m, line, pos, MAN_TEXT, MAN_MAX);
1.45 kristaps 310: n->string = mandoc_malloc(len + 1);
1.61 kristaps 311: sv = strlcpy(n->string, word, len + 1);
1.31 kristaps 312:
313: /* Prohibit truncation. */
314: assert(sv < len + 1);
315:
316: if ( ! man_node_append(m, n))
1.30 kristaps 317: return(0);
1.61 kristaps 318:
1.30 kristaps 319: m->next = MAN_NEXT_SIBLING;
320: return(1);
1.1 kristaps 321: }
322:
323:
1.54 kristaps 324: /*
325: * Free all of the resources held by a node. This does NOT unlink a
326: * node from its context; for that, see man_node_unlink().
327: */
328: static void
1.1 kristaps 329: man_node_free(struct man_node *p)
330: {
331:
332: if (p->string)
333: free(p->string);
334: free(p);
335: }
336:
337:
338: void
1.54 kristaps 339: man_node_delete(struct man *m, struct man_node *p)
1.1 kristaps 340: {
341:
1.54 kristaps 342: while (p->child)
343: man_node_delete(m, p->child);
344:
345: man_node_unlink(m, p);
1.1 kristaps 346: man_node_free(p);
347: }
348:
349:
1.94 kristaps 350: int
351: man_addspan(struct man *m, const struct tbl_span *sp)
352: {
1.100 ! kristaps 353: struct man_node *n;
1.94 kristaps 354:
1.96 kristaps 355: assert( ! (MAN_HALT & m->flags));
1.100 ! kristaps 356:
! 357: n = man_node_alloc(m, sp->line, 0, MAN_TBL, MAN_MAX);
! 358: n->span = sp;
! 359:
! 360: if ( ! man_node_append(m, n))
1.94 kristaps 361: return(0);
1.100 ! kristaps 362:
! 363: m->next = MAN_NEXT_SIBLING;
1.99 kristaps 364: return(man_descope(m, sp->line, 0));
1.94 kristaps 365: }
366:
367: static int
368: man_descope(struct man *m, int line, int offs)
369: {
370: /*
371: * Co-ordinate what happens with having a next-line scope open:
372: * first close out the element scope (if applicable), then close
373: * out the block scope (also if applicable).
374: */
375:
376: if (MAN_ELINE & m->flags) {
377: m->flags &= ~MAN_ELINE;
378: if ( ! man_unscope(m, m->last->parent, MANDOCERR_MAX))
379: return(0);
380: }
381:
382: if ( ! (MAN_BLINE & m->flags))
383: return(1);
384: m->flags &= ~MAN_BLINE;
385:
386: if ( ! man_unscope(m, m->last->parent, MANDOCERR_MAX))
387: return(0);
388: return(man_body_alloc(m, line, offs, m->last->tok));
389: }
390:
391:
1.1 kristaps 392: static int
1.72 kristaps 393: man_ptext(struct man *m, int line, char *buf, int offs)
1.1 kristaps 394: {
1.61 kristaps 395: int i;
1.60 kristaps 396:
397: /* Ignore bogus comments. */
398:
1.72 kristaps 399: if ('\\' == buf[offs] &&
400: '.' == buf[offs + 1] &&
1.93 kristaps 401: '"' == buf[offs + 2]) {
402: man_pmsg(m, line, offs, MANDOCERR_BADCOMMENT);
403: return(1);
404: }
1.31 kristaps 405:
1.35 kristaps 406: /* Literal free-form text whitespace is preserved. */
407:
408: if (MAN_LITERAL & m->flags) {
1.72 kristaps 409: if ( ! man_word_alloc(m, line, offs, buf + offs))
1.35 kristaps 410: return(0);
1.94 kristaps 411: return(man_descope(m, line, offs));
1.35 kristaps 412: }
413:
1.61 kristaps 414: /* Pump blank lines directly into the backend. */
1.31 kristaps 415:
1.72 kristaps 416: for (i = offs; ' ' == buf[i]; i++)
1.31 kristaps 417: /* Skip leading whitespace. */ ;
1.48 kristaps 418:
1.49 kristaps 419: if ('\0' == buf[i]) {
1.61 kristaps 420: /* Allocate a blank entry. */
1.72 kristaps 421: if ( ! man_word_alloc(m, line, offs, ""))
1.31 kristaps 422: return(0);
1.94 kristaps 423: return(man_descope(m, line, offs));
1.31 kristaps 424: }
425:
1.63 kristaps 426: /*
427: * Warn if the last un-escaped character is whitespace. Then
428: * strip away the remaining spaces (tabs stay!).
429: */
1.29 kristaps 430:
1.61 kristaps 431: i = (int)strlen(buf);
432: assert(i);
1.49 kristaps 433:
1.63 kristaps 434: if (' ' == buf[i - 1] || '\t' == buf[i - 1]) {
1.64 kristaps 435: if (i > 1 && '\\' != buf[i - 2])
1.93 kristaps 436: man_pmsg(m, line, i - 1, MANDOCERR_EOLNSPACE);
1.63 kristaps 437:
438: for (--i; i && ' ' == buf[i]; i--)
439: /* Spin back to non-space. */ ;
440:
441: /* Jump ahead of escaped whitespace. */
442: i += '\\' == buf[i] ? 2 : 1;
443:
444: buf[i] = '\0';
445: }
1.49 kristaps 446:
1.72 kristaps 447: if ( ! man_word_alloc(m, line, offs, buf + offs))
1.1 kristaps 448: return(0);
1.65 kristaps 449:
450: /*
451: * End-of-sentence check. If the last character is an unescaped
452: * EOS character, then flag the node as being the end of a
453: * sentence. The front-end will know how to interpret this.
454: */
1.67 kristaps 455:
1.65 kristaps 456: assert(i);
1.83 schwarze 457: if (mandoc_eos(buf, (size_t)i, 0))
1.65 kristaps 458: m->last->flags |= MAN_EOS;
1.31 kristaps 459:
1.94 kristaps 460: return(man_descope(m, line, offs));
1.1 kristaps 461: }
462:
463:
1.96 kristaps 464: static int
1.79 kristaps 465: man_pmacro(struct man *m, int ln, char *buf, int offs)
1.1 kristaps 466: {
1.58 kristaps 467: int i, j, ppos;
1.53 kristaps 468: enum mant tok;
1.34 kristaps 469: char mac[5];
470: struct man_node *n;
1.1 kristaps 471:
472: /* Comments and empties are quickly ignored. */
473:
1.72 kristaps 474: offs++;
475:
476: if ('\0' == buf[offs])
1.46 kristaps 477: return(1);
1.1 kristaps 478:
1.72 kristaps 479: i = offs;
1.9 kristaps 480:
1.56 kristaps 481: /*
482: * Skip whitespace between the control character and initial
483: * text. "Whitespace" is both spaces and tabs.
484: */
1.62 kristaps 485:
1.57 kristaps 486: if (' ' == buf[i] || '\t' == buf[i]) {
1.9 kristaps 487: i++;
1.56 kristaps 488: while (buf[i] && (' ' == buf[i] || '\t' == buf[i]))
1.1 kristaps 489: i++;
1.48 kristaps 490: if ('\0' == buf[i])
1.11 kristaps 491: goto out;
1.1 kristaps 492: }
493:
1.10 kristaps 494: ppos = i;
495:
1.86 schwarze 496: /*
497: * Copy the first word into a nil-terminated buffer.
498: * Stop copying when a tab, space, or eoln is encountered.
499: */
1.1 kristaps 500:
1.86 schwarze 501: j = 0;
502: while (j < 4 && '\0' != buf[i] && ' ' != buf[i] && '\t' != buf[i])
503: mac[j++] = buf[i++];
1.46 kristaps 504: mac[j] = '\0';
1.1 kristaps 505:
1.87 schwarze 506: tok = (j > 0 && j < 4) ? man_hash_find(mac) : MAN_MAX;
507: if (MAN_MAX == tok) {
1.90 kristaps 508: man_vmsg(m, MANDOCERR_MACRO, ln, ppos, "%s", buf + ppos - 1);
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.93 kristaps 523: man_pmsg(m, ln, i - 1, MANDOCERR_EOLNSPACE);
1.48 kristaps 524:
1.50 kristaps 525: /*
1.90 kristaps 526: * Remove prior ELINE macro, as it's being clobbered by a new
1.51 kristaps 527: * macro. Note that NSCOPED macros do not close out ELINE
528: * macros---they don't print text---so we let those slip by.
1.50 kristaps 529: */
1.34 kristaps 530:
1.53 kristaps 531: if ( ! (MAN_NSCOPED & man_macros[tok].flags) &&
1.51 kristaps 532: m->flags & MAN_ELINE) {
1.90 kristaps 533: n = m->last;
534: assert(MAN_TEXT != n->type);
1.51 kristaps 535:
1.90 kristaps 536: /* Remove repeated NSCOPED macros causing ELINE. */
1.51 kristaps 537:
1.90 kristaps 538: if (MAN_NSCOPED & man_macros[n->tok].flags)
539: n = n->parent;
1.51 kristaps 540:
1.90 kristaps 541: man_vmsg(m, MANDOCERR_LINESCOPE, n->line, n->pos,
542: "%s", man_macronames[n->tok]);
1.34 kristaps 543:
1.54 kristaps 544: man_node_delete(m, n);
1.34 kristaps 545: m->flags &= ~MAN_ELINE;
546: }
547:
1.59 kristaps 548: /*
549: * Save the fact that we're in the next-line for a block. In
550: * this way, embedded roff instructions can "remember" state
551: * when they exit.
552: */
553:
554: if (MAN_BLINE & m->flags)
555: m->flags |= MAN_BPLINE;
556:
557: /* Call to handler... */
1.1 kristaps 558:
1.53 kristaps 559: assert(man_macros[tok].fp);
1.79 kristaps 560: if ( ! (*man_macros[tok].fp)(m, tok, ln, ppos, &i, buf))
1.1 kristaps 561: goto err;
562:
1.11 kristaps 563: out:
1.50 kristaps 564: /*
565: * We weren't in a block-line scope when entering the
566: * above-parsed macro, so return.
567: */
568:
1.58 kristaps 569: if ( ! (MAN_BPLINE & m->flags)) {
1.50 kristaps 570: m->flags &= ~MAN_ILINE;
1.29 kristaps 571: return(1);
1.50 kristaps 572: }
1.58 kristaps 573: m->flags &= ~MAN_BPLINE;
1.50 kristaps 574:
575: /*
576: * If we're in a block scope, then allow this macro to slip by
577: * without closing scope around it.
578: */
579:
580: if (MAN_ILINE & m->flags) {
581: m->flags &= ~MAN_ILINE;
582: return(1);
583: }
1.29 kristaps 584:
585: /*
586: * If we've opened a new next-line element scope, then return
587: * now, as the next line will close out the block scope.
588: */
589:
590: if (MAN_ELINE & m->flags)
591: return(1);
592:
593: /* Close out the block scope opened in the prior line. */
1.11 kristaps 594:
1.29 kristaps 595: assert(MAN_BLINE & m->flags);
596: m->flags &= ~MAN_BLINE;
1.11 kristaps 597:
1.74 kristaps 598: if ( ! man_unscope(m, m->last->parent, MANDOCERR_MAX))
1.29 kristaps 599: return(0);
1.72 kristaps 600: return(man_body_alloc(m, ln, offs, m->last->tok));
1.1 kristaps 601:
602: err: /* Error out. */
603:
1.2 kristaps 604: m->flags |= MAN_HALT;
1.1 kristaps 605: return(0);
606: }
1.3 kristaps 607:
1.4 kristaps 608:
609: int
1.74 kristaps 610: man_vmsg(struct man *man, enum mandocerr t,
611: int ln, int pos, const char *fmt, ...)
1.4 kristaps 612: {
613: char buf[256];
614: va_list ap;
615:
616: va_start(ap, fmt);
1.74 kristaps 617: vsnprintf(buf, sizeof(buf) - 1, fmt, ap);
1.4 kristaps 618: va_end(ap);
1.74 kristaps 619: return((*man->msg)(t, man->data, ln, pos, buf));
1.51 kristaps 620: }
621:
622:
1.54 kristaps 623: /*
624: * Unlink a node from its context. If "m" is provided, the last parse
625: * point will also be adjusted accordingly.
626: */
627: static void
1.51 kristaps 628: man_node_unlink(struct man *m, struct man_node *n)
629: {
630:
1.54 kristaps 631: /* Adjust siblings. */
632:
633: if (n->prev)
1.51 kristaps 634: n->prev->next = n->next;
1.54 kristaps 635: if (n->next)
636: n->next->prev = n->prev;
637:
638: /* Adjust parent. */
639:
640: if (n->parent) {
641: n->parent->nchild--;
642: if (n->parent->child == n)
643: n->parent->child = n->prev ? n->prev : n->next;
644: }
645:
646: /* Adjust parse point, if applicable. */
647:
648: if (m && m->last == n) {
649: /*XXX: this can occur when bailing from validation. */
650: /*assert(NULL == n->next);*/
651: if (n->prev) {
1.51 kristaps 652: m->last = n->prev;
653: m->next = MAN_NEXT_SIBLING;
1.54 kristaps 654: } else {
1.51 kristaps 655: m->last = n->parent;
656: m->next = MAN_NEXT_CHILD;
657: }
658: }
659:
1.54 kristaps 660: if (m && m->first == n)
661: m->first = NULL;
1.23 kristaps 662: }
CVSweb