-/* $Id: man_macro.c,v 1.104 2015/04/03 23:19:15 schwarze Exp $ */
+/* $Id: man_macro.c,v 1.111 2015/09/26 00:54:04 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2012, 2013, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
#include "roff.h"
#include "man.h"
#include "libmandoc.h"
+#include "roff_int.h"
#include "libman.h"
static void blk_close(MACRO_PROT_ARGS);
static void blk_exp(MACRO_PROT_ARGS);
static void blk_imp(MACRO_PROT_ARGS);
static void in_line_eoln(MACRO_PROT_ARGS);
-static int man_args(struct man *, int,
+static int man_args(struct roff_man *, int,
int *, char *, char **);
-static void rew_scope(struct man *, int);
+static void rew_scope(struct roff_man *, int);
const struct man_macro __man_macros[MAN_MAX] = {
{ in_line_eoln, MAN_NSCOPED }, /* br */
{ in_line_eoln, 0 }, /* IR */
{ in_line_eoln, 0 }, /* RI */
{ in_line_eoln, MAN_NSCOPED }, /* sp */
- { in_line_eoln, MAN_BSCOPE }, /* nf */
- { in_line_eoln, MAN_BSCOPE }, /* fi */
+ { in_line_eoln, MAN_NSCOPED }, /* nf */
+ { in_line_eoln, MAN_NSCOPED }, /* fi */
{ blk_close, MAN_BSCOPE }, /* RE */
{ blk_exp, MAN_BSCOPE }, /* RS */
{ in_line_eoln, 0 }, /* DT */
void
-man_unscope(struct man *man, const struct roff_node *to)
+man_unscope(struct roff_man *man, const struct roff_node *to)
{
struct roff_node *n;
}
man->last = n;
n = n->parent;
- man_node_delete(man, man->last);
+ roff_node_delete(man, man->last);
continue;
}
if (n->type == ROFFT_BLOCK &&
*/
man->next = (man->last == to) ?
- MAN_NEXT_CHILD : MAN_NEXT_SIBLING;
+ ROFF_NEXT_CHILD : ROFF_NEXT_SIBLING;
}
/*
* scopes. When a scope is closed, it must be validated and actioned.
*/
static void
-rew_scope(struct man *man, int tok)
+rew_scope(struct roff_man *man, int tok)
{
struct roff_node *n;
break;
default:
abort();
- /* NOTREACHED */
}
for (nn = man->last->parent; nn; nn = nn->parent)
int la;
rew_scope(man, tok);
- man_block_alloc(man, line, ppos, tok);
- man_head_alloc(man, line, ppos, tok);
- head = man->last;
+ roff_block_alloc(man, line, ppos, tok);
+ head = roff_head_alloc(man, line, ppos, tok);
la = *pos;
if (man_args(man, line, pos, buf, &p))
- man_word_alloc(man, line, la, p);
+ roff_word_alloc(man, line, la, p);
if (buf[*pos] != '\0')
mandoc_vmsg(MANDOCERR_ARG_EXCESS,
man_macronames[tok], buf + *pos);
man_unscope(man, head);
- man_body_alloc(man, line, ppos, tok);
+ roff_body_alloc(man, line, ppos, tok);
}
/*
struct roff_node *n;
rew_scope(man, tok);
- man_block_alloc(man, line, ppos, tok);
- man_head_alloc(man, line, ppos, tok);
- n = man->last;
+ n = roff_block_alloc(man, line, ppos, tok);
+ if (n->tok == MAN_SH || n->tok == MAN_SS)
+ man->flags &= ~MAN_LITERAL;
+ n = roff_head_alloc(man, line, ppos, tok);
/* Add line arguments. */
la = *pos;
if ( ! man_args(man, line, pos, buf, &p))
break;
- man_word_alloc(man, line, la, p);
+ roff_word_alloc(man, line, la, p);
}
/*
/* Close out the head and open the body. */
man_unscope(man, n);
- man_body_alloc(man, line, ppos, tok);
+ roff_body_alloc(man, line, ppos, tok);
}
void
char *p;
struct roff_node *n;
- man_elem_alloc(man, line, ppos, tok);
+ roff_elem_alloc(man, line, ppos, tok);
n = man->last;
for (;;) {
break;
if (man_macros[tok].flags & MAN_JOIN &&
man->last->type == ROFFT_TEXT)
- man_word_append(man, p);
+ roff_word_append(man, p);
else
- man_word_alloc(man, line, la, p);
+ roff_word_alloc(man, line, la, p);
}
/*
}
assert(man->last->type != ROFFT_ROOT);
- man->next = MAN_NEXT_SIBLING;
+ man->next = ROFF_NEXT_SIBLING;
/*
* Rewind our element scope. Note that when TH is pruned, we'll
man_valid_post(man);
}
-
void
-man_macroend(struct man *man)
+man_endparse(struct roff_man *man)
{
man_unscope(man, man->first);
}
static int
-man_args(struct man *man, int line, int *pos, char *buf, char **v)
+man_args(struct roff_man *man, int line, int *pos, char *buf, char **v)
{
char *start;