=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/mandoc/man.c,v retrieving revision 1.97 retrieving revision 1.98 diff -c -r1.97 -r1.98 *** src/usr.bin/mandoc/man.c 2015/01/30 21:28:21 1.97 --- src/usr.bin/mandoc/man.c 2015/04/02 21:03:18 1.98 *************** *** 1,4 **** ! /* $OpenBSD: man.c,v 1.97 2015/01/30 21:28:21 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2013, 2014, 2015 Ingo Schwarze --- 1,4 ---- ! /* $OpenBSD: man.c,v 1.98 2015/04/02 21:03:18 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2013, 2014, 2015 Ingo Schwarze *************** *** 8,16 **** * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * ! * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF ! * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF --- 8,16 ---- * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * ! * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF ! * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF *************** *** 25,35 **** #include #include - #include "man.h" - #include "mandoc.h" #include "mandoc_aux.h" ! #include "libman.h" #include "libmandoc.h" const char *const __man_macronames[MAN_MAX] = { "br", "TH", "SH", "SS", --- 25,36 ---- #include #include #include "mandoc_aux.h" ! #include "mandoc.h" ! #include "roff.h" ! #include "man.h" #include "libmandoc.h" + #include "libman.h" const char *const __man_macronames[MAN_MAX] = { "br", "TH", "SH", "SS", *************** *** 51,57 **** static void man_descope(struct man *, int, int); static void man_free1(struct man *); static struct man_node *man_node_alloc(struct man *, int, int, ! enum man_type, enum mant); static void man_node_append(struct man *, struct man_node *); static void man_node_free(struct man_node *); static void man_node_unlink(struct man *, --- 52,58 ---- static void man_descope(struct man *, int, int); static void man_free1(struct man *); static struct man_node *man_node_alloc(struct man *, int, int, ! enum roff_type, enum mant); static void man_node_append(struct man *, struct man_node *); static void man_node_free(struct man_node *); static void man_node_unlink(struct man *, *************** *** 119,125 **** man_parseln(struct man *man, int ln, char *buf, int offs) { ! if (man->last->type != MAN_EQN || ln > man->last->line) man->flags |= MAN_NEWLINE; return (roff_getcontrol(man->roff, buf, &offs) ? --- 120,126 ---- man_parseln(struct man *man, int ln, char *buf, int offs) { ! if (man->last->type != ROFFT_EQN || ln > man->last->line) man->flags |= MAN_NEWLINE; return (roff_getcontrol(man->roff, buf, &offs) ? *************** *** 148,154 **** man->flags = 0; man->last = mandoc_calloc(1, sizeof(struct man_node)); man->first = man->last; ! man->last->type = MAN_ROOT; man->last->tok = MAN_MAX; man->next = MAN_NEXT_CHILD; } --- 149,155 ---- man->flags = 0; man->last = mandoc_calloc(1, sizeof(struct man_node)); man->first = man->last; ! man->last->type = ROFFT_ROOT; man->last->tok = MAN_MAX; man->next = MAN_NEXT_CHILD; } *************** *** 160,166 **** assert(man->last); assert(man->first); ! assert(p->type != MAN_ROOT); switch (man->next) { case MAN_NEXT_SIBLING: --- 161,167 ---- assert(man->last); assert(man->first); ! assert(p->type != ROFFT_ROOT); switch (man->next) { case MAN_NEXT_SIBLING: *************** *** 181,196 **** p->parent->nchild++; switch (p->type) { ! case MAN_BLOCK: if (p->tok == MAN_SH || p->tok == MAN_SS) man->flags &= ~MAN_LITERAL; break; ! case MAN_HEAD: ! assert(p->parent->type == MAN_BLOCK); p->parent->head = p; break; ! case MAN_BODY: ! assert(p->parent->type == MAN_BLOCK); p->parent->body = p; break; default: --- 182,197 ---- p->parent->nchild++; switch (p->type) { ! case ROFFT_BLOCK: if (p->tok == MAN_SH || p->tok == MAN_SS) man->flags &= ~MAN_LITERAL; break; ! case ROFFT_HEAD: ! assert(p->parent->type == ROFFT_BLOCK); p->parent->head = p; break; ! case ROFFT_BODY: ! assert(p->parent->type == ROFFT_BLOCK); p->parent->body = p; break; default: *************** *** 200,208 **** man->last = p; switch (p->type) { ! case MAN_TBL: /* FALLTHROUGH */ ! case MAN_TEXT: man_valid_post(man); break; default: --- 201,209 ---- man->last = p; switch (p->type) { ! case ROFFT_TBL: /* FALLTHROUGH */ ! case ROFFT_TEXT: man_valid_post(man); break; default: *************** *** 212,218 **** static struct man_node * man_node_alloc(struct man *man, int line, int pos, ! enum man_type type, enum mant tok) { struct man_node *p; --- 213,219 ---- static struct man_node * man_node_alloc(struct man *man, int line, int pos, ! enum roff_type type, enum mant tok) { struct man_node *p; *************** *** 233,239 **** { struct man_node *p; ! p = man_node_alloc(man, line, pos, MAN_ELEM, tok); man_node_append(man, p); man->next = MAN_NEXT_CHILD; } --- 234,240 ---- { struct man_node *p; ! p = man_node_alloc(man, line, pos, ROFFT_ELEM, tok); man_node_append(man, p); man->next = MAN_NEXT_CHILD; } *************** *** 243,249 **** { struct man_node *p; ! p = man_node_alloc(man, line, pos, MAN_HEAD, tok); man_node_append(man, p); man->next = MAN_NEXT_CHILD; } --- 244,250 ---- { struct man_node *p; ! p = man_node_alloc(man, line, pos, ROFFT_HEAD, tok); man_node_append(man, p); man->next = MAN_NEXT_CHILD; } *************** *** 253,259 **** { struct man_node *p; ! p = man_node_alloc(man, line, pos, MAN_BODY, tok); man_node_append(man, p); man->next = MAN_NEXT_CHILD; } --- 254,260 ---- { struct man_node *p; ! p = man_node_alloc(man, line, pos, ROFFT_BODY, tok); man_node_append(man, p); man->next = MAN_NEXT_CHILD; } *************** *** 263,269 **** { struct man_node *p; ! p = man_node_alloc(man, line, pos, MAN_BLOCK, tok); man_node_append(man, p); man->next = MAN_NEXT_CHILD; } --- 264,270 ---- { struct man_node *p; ! p = man_node_alloc(man, line, pos, ROFFT_BLOCK, tok); man_node_append(man, p); man->next = MAN_NEXT_CHILD; } *************** *** 273,279 **** { struct man_node *n; ! n = man_node_alloc(man, line, pos, MAN_TEXT, MAN_MAX); n->string = roff_strdup(man->roff, word); man_node_append(man, n); man->next = MAN_NEXT_SIBLING; --- 274,280 ---- { struct man_node *n; ! n = man_node_alloc(man, line, pos, ROFFT_TEXT, MAN_MAX); n->string = roff_strdup(man->roff, word); man_node_append(man, n); man->next = MAN_NEXT_SIBLING; *************** *** 322,328 **** { struct man_node *n; ! n = man_node_alloc(man, ep->ln, ep->pos, MAN_EQN, MAN_MAX); n->eqn = ep; if (ep->ln > man->last->line) n->flags |= MAN_LINE; --- 323,329 ---- { struct man_node *n; ! n = man_node_alloc(man, ep->ln, ep->pos, ROFFT_EQN, MAN_MAX); n->eqn = ep; if (ep->ln > man->last->line) n->flags |= MAN_LINE; *************** *** 337,343 **** struct man_node *n; man_breakscope(man, MAN_MAX); ! n = man_node_alloc(man, sp->line, 0, MAN_TBL, MAN_MAX); n->span = sp; man_node_append(man, n); man->next = MAN_NEXT_SIBLING; --- 338,344 ---- struct man_node *n; man_breakscope(man, MAN_MAX); ! n = man_node_alloc(man, sp->line, 0, ROFFT_TBL, MAN_MAX); n->span = sp; man_node_append(man, n); man->next = MAN_NEXT_SIBLING; *************** *** 509,515 **** if (man->quick && tok == MAN_SH) { n = man->last; ! if (n->type == MAN_BODY && strcmp(n->prev->child->string, "NAME")) return(2); } --- 510,516 ---- if (man->quick && tok == MAN_SH) { n = man->last; ! if (n->type == ROFFT_BODY && strcmp(n->prev->child->string, "NAME")) return(2); } *************** *** 546,552 **** if (man->flags & MAN_ELINE && (tok == MAN_MAX || ! (man_macros[tok].flags & MAN_NSCOPED))) { n = man->last; ! assert(n->type != MAN_TEXT); if (man_macros[n->tok].flags & MAN_NSCOPED) n = n->parent; --- 547,553 ---- if (man->flags & MAN_ELINE && (tok == MAN_MAX || ! (man_macros[tok].flags & MAN_NSCOPED))) { n = man->last; ! assert(n->type != ROFFT_TEXT); if (man_macros[n->tok].flags & MAN_NSCOPED) n = n->parent; *************** *** 568,581 **** if (man->flags & MAN_BLINE && (tok == MAN_MAX || man_macros[tok].flags & MAN_BSCOPE)) { n = man->last; ! if (n->type == MAN_TEXT) n = n->parent; if ( ! (man_macros[n->tok].flags & MAN_BSCOPE)) n = n->parent; ! assert(n->type == MAN_HEAD); n = n->parent; ! assert(n->type == MAN_BLOCK); assert(man_macros[n->tok].flags & MAN_SCOPED); mandoc_vmsg(MANDOCERR_BLK_LINE, man->parse, --- 569,582 ---- if (man->flags & MAN_BLINE && (tok == MAN_MAX || man_macros[tok].flags & MAN_BSCOPE)) { n = man->last; ! if (n->type == ROFFT_TEXT) n = n->parent; if ( ! (man_macros[n->tok].flags & MAN_BSCOPE)) n = n->parent; ! assert(n->type == ROFFT_HEAD); n = n->parent; ! assert(n->type == ROFFT_BLOCK); assert(man_macros[n->tok].flags & MAN_SCOPED); mandoc_vmsg(MANDOCERR_BLK_LINE, man->parse, *************** *** 643,649 **** char *cp; size_t sz; ! if (n->type != MAN_TEXT) { for (n = n->child; n; n = n->next) man_deroff(dest, n); return; --- 644,650 ---- char *cp; size_t sz; ! if (n->type != ROFFT_TEXT) { for (n = n->child; n; n = n->next) man_deroff(dest, n); return;