-/* $Id: mdoc.c,v 1.247 2015/04/19 13:50:26 schwarze Exp $ */
+/* $Id: mdoc.c,v 1.249 2015/04/19 14:25:41 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012-2015 Ingo Schwarze <schwarze@openbsd.org>
#include "libmdoc.h"
const char *const __mdoc_macronames[MDOC_MAX + 1] = {
+ "text",
"Ap", "Dd", "Dt", "Os",
"Sh", "Ss", "Pp", "D1",
"Dl", "Bd", "Ed", "Bl",
"Lk", "Mt", "Brq", "Bro",
"Brc", "%C", "Es", "En",
"Dx", "%Q", "br", "sp",
- "%U", "Ta", "ll", "text",
- };
+ "%U", "Ta", "ll",
+};
const char *const __mdoc_argnames[MDOC_ARG_MAX] = {
"split", "nosplit", "ragged",
"symbolic", "nested", "centered"
};
-const char * const *mdoc_macronames = __mdoc_macronames;
+const char * const *mdoc_macronames = __mdoc_macronames + 1;
const char * const *mdoc_argnames = __mdoc_argnames;
static int mdoc_ptext(struct roff_man *, int, char *, int);
mdoc_macroend(mdoc);
}
-void
-mdoc_addeqn(struct roff_man *mdoc, const struct eqn *ep)
-{
- struct roff_node *n;
-
- n = roff_node_alloc(mdoc, ep->ln, ep->pos, ROFFT_EQN, MDOC_MAX);
- n->eqn = ep;
- if (ep->ln > mdoc->last->line)
- n->flags |= MDOC_LINE;
- roff_node_append(mdoc, n);
- mdoc->next = ROFF_NEXT_SIBLING;
-}
-
-void
-mdoc_addspan(struct roff_man *mdoc, const struct tbl_span *sp)
-{
- struct roff_node *n;
-
- n = roff_node_alloc(mdoc, sp->line, 0, ROFFT_TBL, MDOC_MAX);
- n->span = sp;
- roff_node_append(mdoc, n);
- mdoc_valid_post(mdoc);
- mdoc->next = ROFF_NEXT_SIBLING;
-}
-
/*
* Main parse routine. Parses a single line -- really just hands off to
* the macro (mdoc_pmacro()) or text parser (mdoc_ptext()).
void
mdoc_macro(MACRO_PROT_ARGS)
{
- assert(tok < MDOC_MAX);
+ assert(tok > TOKEN_NONE && tok < MDOC_MAX);
if (mdoc->flags & MDOC_PBODY) {
if (tok == MDOC_Dt) {
mdoc->next = ROFF_NEXT_CHILD;
}
-void
-mdoc_word_alloc(struct roff_man *mdoc, int line, int pos, const char *p)
-{
- struct roff_node *n;
-
- n = roff_node_alloc(mdoc, line, pos, ROFFT_TEXT, MDOC_MAX);
- n->string = roff_strdup(mdoc->roff, p);
- roff_node_append(mdoc, n);
- mdoc_valid_post(mdoc);
- mdoc->next = ROFF_NEXT_SIBLING;
-}
-
-void
-mdoc_word_append(struct roff_man *mdoc, const char *p)
-{
- struct roff_node *n;
- char *addstr, *newstr;
-
- n = mdoc->last;
- addstr = roff_strdup(mdoc->roff, p);
- mandoc_asprintf(&newstr, "%s %s", n->string, addstr);
- free(addstr);
- free(n->string);
- n->string = newstr;
- mdoc->next = ROFF_NEXT_SIBLING;
-}
-
void
mdoc_node_relink(struct roff_man *mdoc, struct roff_node *p)
{
return(1);
}
- mdoc_word_alloc(mdoc, line, offs, buf+offs);
+ roff_word_alloc(mdoc, line, offs, buf+offs);
if (mdoc->flags & MDOC_LITERAL)
return(1);
mac[i] = '\0';
- tok = (i > 1 && i < 4) ? mdoc_hash_find(mac) : MDOC_MAX;
+ tok = (i > 1 && i < 4) ? mdoc_hash_find(mac) : TOKEN_NONE;
- if (tok == MDOC_MAX) {
+ if (tok == TOKEN_NONE) {
mandoc_msg(MANDOCERR_MACRO, mdoc->parse,
ln, sv, buf + sv - 1);
return(1);