* mdocml: Replace the structs mdoc and man by a unified struct roff_man.
@ 2015-04-18 16:07 schwarze
0 siblings, 0 replies; only message in thread
From: schwarze @ 2015-04-18 16:07 UTC (permalink / raw)
To: source
Log Message:
-----------
Replace the structs mdoc and man by a unified struct roff_man.
Almost completely mechanical, no functional change.
Written on the train from Exeter to London returning from p2k15.
Modified Files:
--------------
mdocml:
cgi.c
demandoc.c
libman.h
libmandoc.h
libmdoc.h
main.c
main.h
man.c
man.h
man_html.c
man_macro.c
man_term.c
man_validate.c
mandoc.h
mandocdb.c
mdoc.c
mdoc.h
mdoc_argv.c
mdoc_html.c
mdoc_macro.c
mdoc_man.c
mdoc_term.c
mdoc_validate.c
read.c
roff.h
tree.c
Revision Data
-------------
Index: man.h
===================================================================
RCS file: /home/cvs/mdocml/mdocml/man.h,v
retrieving revision 1.72
retrieving revision 1.73
diff -Lman.h -Lman.h -u -p -r1.72 -r1.73
--- man.h
+++ man.h
@@ -61,11 +61,11 @@ extern const char *const *man_macronames
__BEGIN_DECLS
-struct man;
+struct roff_man;
-const struct roff_node *man_node(const struct man *);
-const struct roff_meta *man_meta(const struct man *);
-const struct mparse *man_mparse(const struct man *);
+const struct roff_node *man_node(const struct roff_man *);
+const struct roff_meta *man_meta(const struct roff_man *);
+const struct mparse *man_mparse(const struct roff_man *);
void man_deroff(char **, const struct roff_node *);
__END_DECLS
Index: read.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/read.c,v
retrieving revision 1.133
retrieving revision 1.134
diff -Lread.c -Lread.c -u -p -r1.133 -r1.134
--- read.c
+++ read.c
@@ -47,10 +47,10 @@
#define REPARSE_LIMIT 1000
struct mparse {
- struct man *pman; /* persistent man parser */
- struct mdoc *pmdoc; /* persistent mdoc parser */
- struct man *man; /* man parser */
- struct mdoc *mdoc; /* mdoc parser */
+ struct roff_man *pman; /* persistent man parser */
+ struct roff_man *pmdoc; /* persistent mdoc parser */
+ struct roff_man *man; /* man parser */
+ struct roff_man *mdoc; /* mdoc parser */
struct roff *roff; /* roff parser (!NULL) */
const struct mchars *mchars; /* character table */
char *sodest; /* filename pointed to by .so */
@@ -952,8 +952,8 @@ mparse_free(struct mparse *curp)
}
void
-mparse_result(struct mparse *curp,
- struct mdoc **mdoc, struct man **man, char **sodest)
+mparse_result(struct mparse *curp, struct roff_man **mdoc,
+ struct roff_man **man, char **sodest)
{
if (sodest && NULL != (*sodest = curp->sodest)) {
Index: man_html.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/man_html.c,v
retrieving revision 1.115
retrieving revision 1.116
diff -Lman_html.c -Lman_html.c -u -p -r1.115 -r1.116
--- man_html.c
+++ man_html.c
@@ -145,7 +145,7 @@ print_bvspace(struct html *h, const stru
}
void
-html_man(void *arg, const struct man *man)
+html_man(void *arg, const struct roff_man *man)
{
struct mhtml mh;
Index: mdoc_macro.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mdoc_macro.c,v
retrieving revision 1.188
retrieving revision 1.189
diff -Lmdoc_macro.c -Lmdoc_macro.c -u -p -r1.188 -r1.189
--- mdoc_macro.c
+++ mdoc_macro.c
@@ -42,18 +42,19 @@ static void in_line_argn(MACRO_PROT_ARG
static void in_line(MACRO_PROT_ARGS);
static void phrase_ta(MACRO_PROT_ARGS);
-static void append_delims(struct mdoc *, int, int *, char *);
-static void dword(struct mdoc *, int, int, const char *,
+static void append_delims(struct roff_man *, int, int *, char *);
+static void dword(struct roff_man *, int, int, const char *,
enum mdelim, int);
-static int find_pending(struct mdoc *, int, int, int,
+static int find_pending(struct roff_man *, int, int, int,
struct roff_node *);
-static int lookup(struct mdoc *, int, int, int, const char *);
+static int lookup(struct roff_man *, int, int, int, const char *);
static int macro_or_word(MACRO_PROT_ARGS, int);
-static int parse_rest(struct mdoc *, int, int, int *, char *);
+static int parse_rest(struct roff_man *, int, int, int *, char *);
static int rew_alt(int);
-static void rew_elem(struct mdoc *, int);
-static void rew_last(struct mdoc *, const struct roff_node *);
-static void rew_pending(struct mdoc *, const struct roff_node *);
+static void rew_elem(struct roff_man *, int);
+static void rew_last(struct roff_man *, const struct roff_node *);
+static void rew_pending(struct roff_man *,
+ const struct roff_node *);
const struct mdoc_macro __mdoc_macros[MDOC_MAX] = {
{ in_line_argn, MDOC_CALLABLE | MDOC_PARSED | MDOC_JOIN }, /* Ap */
@@ -208,7 +209,7 @@ const struct mdoc_macro * const mdoc_mac
* are errors.
*/
void
-mdoc_macroend(struct mdoc *mdoc)
+mdoc_macroend(struct roff_man *mdoc)
{
struct roff_node *n;
@@ -233,7 +234,7 @@ mdoc_macroend(struct mdoc *mdoc)
* or as a line macro if from == MDOC_MAX.
*/
static int
-lookup(struct mdoc *mdoc, int from, int line, int ppos, const char *p)
+lookup(struct roff_man *mdoc, int from, int line, int ppos, const char *p)
{
int res;
@@ -254,14 +255,14 @@ lookup(struct mdoc *mdoc, int from, int
* Rewind up to and including a specific node.
*/
static void
-rew_last(struct mdoc *mdoc, const struct roff_node *to)
+rew_last(struct roff_man *mdoc, const struct roff_node *to)
{
struct roff_node *n, *np;
if (to->flags & MDOC_VALID)
return;
- mdoc->next = MDOC_NEXT_SIBLING;
+ mdoc->next = ROFF_NEXT_SIBLING;
while (mdoc->last != to) {
/*
* Save the parent here, because we may delete the
@@ -283,7 +284,7 @@ rew_last(struct mdoc *mdoc, const struct
* Rewind up to a specific block, including all blocks that broke it.
*/
static void
-rew_pending(struct mdoc *mdoc, const struct roff_node *n)
+rew_pending(struct roff_man *mdoc, const struct roff_node *n)
{
for (;;) {
@@ -364,7 +365,7 @@ rew_alt(int tok)
}
static void
-rew_elem(struct mdoc *mdoc, int tok)
+rew_elem(struct roff_man *mdoc, int tok)
{
struct roff_node *n;
@@ -382,7 +383,7 @@ rew_elem(struct mdoc *mdoc, int tok)
* the rew_pending() call closing out the sub-block.
*/
static int
-find_pending(struct mdoc *mdoc, int tok, int line, int ppos,
+find_pending(struct roff_man *mdoc, int tok, int line, int ppos,
struct roff_node *target)
{
struct roff_node *n;
@@ -419,7 +420,7 @@ find_pending(struct mdoc *mdoc, int tok,
* Punctuation consists of those tokens found in mdoc_isdelim().
*/
static void
-dword(struct mdoc *mdoc, int line, int col, const char *p,
+dword(struct roff_man *mdoc, int line, int col, const char *p,
enum mdelim d, int may_append)
{
@@ -453,7 +454,7 @@ dword(struct mdoc *mdoc, int line, int c
}
static void
-append_delims(struct mdoc *mdoc, int line, int *pos, char *buf)
+append_delims(struct roff_man *mdoc, int line, int *pos, char *buf)
{
char *p;
int la;
@@ -617,7 +618,7 @@ blk_exp_close(MACRO_PROT_ARGS)
*/
if (maxargs)
- mdoc->next = MDOC_NEXT_CHILD;
+ mdoc->next = ROFF_NEXT_CHILD;
break;
}
@@ -1386,7 +1387,7 @@ in_line_eoln(MACRO_PROT_ARGS)
if ((tok == MDOC_Pp || tok == MDOC_Lp) &&
! (mdoc->flags & MDOC_SYNOPSIS)) {
n = mdoc->last;
- if (mdoc->next == MDOC_NEXT_SIBLING)
+ if (mdoc->next == ROFF_NEXT_SIBLING)
n = n->parent;
if (n->tok == MDOC_Nm)
rew_last(mdoc, mdoc->last->parent);
@@ -1412,7 +1413,7 @@ in_line_eoln(MACRO_PROT_ARGS)
* or until the next macro, call that macro, and return 1.
*/
static int
-parse_rest(struct mdoc *mdoc, int tok, int line, int *pos, char *buf)
+parse_rest(struct roff_man *mdoc, int tok, int line, int *pos, char *buf)
{
int la;
Index: mdoc_html.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mdoc_html.c,v
retrieving revision 1.230
retrieving revision 1.231
diff -Lmdoc_html.c -Lmdoc_html.c -u -p -r1.230 -r1.231
--- mdoc_html.c
+++ mdoc_html.c
@@ -265,7 +265,7 @@ static const char * const lists[LIST_MAX
void
-html_mdoc(void *arg, const struct mdoc *mdoc)
+html_mdoc(void *arg, const struct roff_man *mdoc)
{
print_mdoc(mdoc_meta(mdoc), mdoc_node(mdoc)->child,
Index: cgi.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/cgi.c,v
retrieving revision 1.106
retrieving revision 1.107
diff -Lcgi.c -Lcgi.c -u -p -r1.106 -r1.107
--- cgi.c
+++ cgi.c
@@ -819,8 +819,8 @@ format(const struct req *req, const char
struct manoutput conf;
struct mparse *mp;
struct mchars *mchars;
- struct mdoc *mdoc;
- struct man *man;
+ struct roff_man *mdoc;
+ struct roff_man *man;
void *vp;
int fd;
int usepath;
Index: mdoc.h
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mdoc.h,v
retrieving revision 1.139
retrieving revision 1.140
diff -Lmdoc.h -Lmdoc.h -u -p -r1.139 -r1.140
--- mdoc.h
+++ mdoc.h
@@ -282,10 +282,10 @@ extern const char *const *mdoc_argnames;
__BEGIN_DECLS
-struct mdoc;
+struct roff_man;
-const struct roff_node *mdoc_node(const struct mdoc *);
-const struct roff_meta *mdoc_meta(const struct mdoc *);
+const struct roff_node *mdoc_node(const struct roff_man *);
+const struct roff_meta *mdoc_meta(const struct roff_man *);
void mdoc_deroff(char **, const struct roff_node *);
__END_DECLS
Index: mdoc_term.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mdoc_term.c,v
retrieving revision 1.317
retrieving revision 1.318
diff -Lmdoc_term.c -Lmdoc_term.c -u -p -r1.317 -r1.318
--- mdoc_term.c
+++ mdoc_term.c
@@ -251,7 +251,7 @@ static const struct termact termacts[MDO
void
-terminal_mdoc(void *arg, const struct mdoc *mdoc)
+terminal_mdoc(void *arg, const struct roff_man *mdoc)
{
const struct roff_meta *meta;
struct roff_node *n;
Index: man.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/man.c,v
retrieving revision 1.152
retrieving revision 1.153
diff -Lman.c -Lman.c -u -p -r1.152 -r1.153
--- man.c
+++ man.c
@@ -49,35 +49,37 @@ const char *const __man_macronames[MAN_M
const char * const *man_macronames = __man_macronames;
-static void man_alloc1(struct man *);
-static void man_breakscope(struct man *, int);
-static void man_descope(struct man *, int, int);
-static void man_free1(struct man *);
-static struct roff_node *man_node_alloc(struct man *, int, int,
+static void man_alloc1(struct roff_man *);
+static void man_breakscope(struct roff_man *, int);
+static void man_descope(struct roff_man *, int, int);
+static void man_free1(struct roff_man *);
+static struct roff_node *man_node_alloc(struct roff_man *, int, int,
enum roff_type, int);
-static void man_node_append(struct man *, struct roff_node *);
+static void man_node_append(struct roff_man *,
+ struct roff_node *);
static void man_node_free(struct roff_node *);
-static void man_node_unlink(struct man *, struct roff_node *);
-static int man_ptext(struct man *, int, char *, int);
-static int man_pmacro(struct man *, int, char *, int);
+static void man_node_unlink(struct roff_man *,
+ struct roff_node *);
+static int man_ptext(struct roff_man *, int, char *, int);
+static int man_pmacro(struct roff_man *, int, char *, int);
const struct roff_node *
-man_node(const struct man *man)
+man_node(const struct roff_man *man)
{
return(man->first);
}
const struct roff_meta *
-man_meta(const struct man *man)
+man_meta(const struct roff_man *man)
{
return(&man->meta);
}
void
-man_reset(struct man *man)
+man_reset(struct roff_man *man)
{
man_free1(man);
@@ -85,20 +87,20 @@ man_reset(struct man *man)
}
void
-man_free(struct man *man)
+man_free(struct roff_man *man)
{
man_free1(man);
free(man);
}
-struct man *
+struct roff_man *
man_alloc(struct roff *roff, struct mparse *parse,
const char *defos, int quick)
{
- struct man *p;
+ struct roff_man *p;
- p = mandoc_calloc(1, sizeof(struct man));
+ p = mandoc_calloc(1, sizeof(*p));
man_hash_init();
p->parse = parse;
@@ -111,14 +113,14 @@ man_alloc(struct roff *roff, struct mpar
}
void
-man_endparse(struct man *man)
+man_endparse(struct roff_man *man)
{
man_macroend(man);
}
int
-man_parseln(struct man *man, int ln, char *buf, int offs)
+man_parseln(struct roff_man *man, int ln, char *buf, int offs)
{
if (man->last->type != ROFFT_EQN || ln > man->last->line)
@@ -130,7 +132,7 @@ man_parseln(struct man *man, int ln, cha
}
static void
-man_free1(struct man *man)
+man_free1(struct roff_man *man)
{
if (man->first)
@@ -143,7 +145,7 @@ man_free1(struct man *man)
}
static void
-man_alloc1(struct man *man)
+man_alloc1(struct roff_man *man)
{
memset(&man->meta, 0, sizeof(man->meta));
@@ -152,12 +154,12 @@ man_alloc1(struct man *man)
man->first = man->last;
man->last->type = ROFFT_ROOT;
man->last->tok = MAN_MAX;
- man->next = MAN_NEXT_CHILD;
+ man->next = ROFF_NEXT_CHILD;
}
static void
-man_node_append(struct man *man, struct roff_node *p)
+man_node_append(struct roff_man *man, struct roff_node *p)
{
assert(man->last);
@@ -165,12 +167,12 @@ man_node_append(struct man *man, struct
assert(p->type != ROFFT_ROOT);
switch (man->next) {
- case MAN_NEXT_SIBLING:
+ case ROFF_NEXT_SIBLING:
man->last->next = p;
p->prev = man->last;
p->parent = man->last->parent;
break;
- case MAN_NEXT_CHILD:
+ case ROFF_NEXT_CHILD:
man->last->child = p;
p->parent = man->last;
break;
@@ -213,7 +215,7 @@ man_node_append(struct man *man, struct
}
static struct roff_node *
-man_node_alloc(struct man *man, int line, int pos,
+man_node_alloc(struct roff_man *man, int line, int pos,
enum roff_type type, int tok)
{
struct roff_node *p;
@@ -231,58 +233,58 @@ man_node_alloc(struct man *man, int line
}
void
-man_elem_alloc(struct man *man, int line, int pos, int tok)
+man_elem_alloc(struct roff_man *man, int line, int pos, int tok)
{
struct roff_node *p;
p = man_node_alloc(man, line, pos, ROFFT_ELEM, tok);
man_node_append(man, p);
- man->next = MAN_NEXT_CHILD;
+ man->next = ROFF_NEXT_CHILD;
}
void
-man_head_alloc(struct man *man, int line, int pos, int tok)
+man_head_alloc(struct roff_man *man, int line, int pos, int tok)
{
struct roff_node *p;
p = man_node_alloc(man, line, pos, ROFFT_HEAD, tok);
man_node_append(man, p);
- man->next = MAN_NEXT_CHILD;
+ man->next = ROFF_NEXT_CHILD;
}
void
-man_body_alloc(struct man *man, int line, int pos, int tok)
+man_body_alloc(struct roff_man *man, int line, int pos, int tok)
{
struct roff_node *p;
p = man_node_alloc(man, line, pos, ROFFT_BODY, tok);
man_node_append(man, p);
- man->next = MAN_NEXT_CHILD;
+ man->next = ROFF_NEXT_CHILD;
}
void
-man_block_alloc(struct man *man, int line, int pos, int tok)
+man_block_alloc(struct roff_man *man, int line, int pos, int tok)
{
struct roff_node *p;
p = man_node_alloc(man, line, pos, ROFFT_BLOCK, tok);
man_node_append(man, p);
- man->next = MAN_NEXT_CHILD;
+ man->next = ROFF_NEXT_CHILD;
}
void
-man_word_alloc(struct man *man, int line, int pos, const char *word)
+man_word_alloc(struct roff_man *man, int line, int pos, const char *word)
{
struct roff_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;
+ man->next = ROFF_NEXT_SIBLING;
}
void
-man_word_append(struct man *man, const char *word)
+man_word_append(struct roff_man *man, const char *word)
{
struct roff_node *n;
char *addstr, *newstr;
@@ -293,7 +295,7 @@ man_word_append(struct man *man, const c
free(addstr);
free(n->string);
n->string = newstr;
- man->next = MAN_NEXT_SIBLING;
+ man->next = ROFF_NEXT_SIBLING;
}
/*
@@ -309,7 +311,7 @@ man_node_free(struct roff_node *p)
}
void
-man_node_delete(struct man *man, struct roff_node *p)
+man_node_delete(struct roff_man *man, struct roff_node *p)
{
while (p->child)
@@ -320,7 +322,7 @@ man_node_delete(struct man *man, struct
}
void
-man_addeqn(struct man *man, const struct eqn *ep)
+man_addeqn(struct roff_man *man, const struct eqn *ep)
{
struct roff_node *n;
@@ -329,12 +331,12 @@ man_addeqn(struct man *man, const struct
if (ep->ln > man->last->line)
n->flags |= MAN_LINE;
man_node_append(man, n);
- man->next = MAN_NEXT_SIBLING;
+ man->next = ROFF_NEXT_SIBLING;
man_descope(man, ep->ln, ep->pos);
}
void
-man_addspan(struct man *man, const struct tbl_span *sp)
+man_addspan(struct roff_man *man, const struct tbl_span *sp)
{
struct roff_node *n;
@@ -342,12 +344,12 @@ man_addspan(struct man *man, const struc
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;
+ man->next = ROFF_NEXT_SIBLING;
man_descope(man, sp->line, 0);
}
static void
-man_descope(struct man *man, int line, int offs)
+man_descope(struct roff_man *man, int line, int offs)
{
/*
* Co-ordinate what happens with having a next-line scope open:
@@ -367,7 +369,7 @@ man_descope(struct man *man, int line, i
}
static int
-man_ptext(struct man *man, int line, char *buf, int offs)
+man_ptext(struct roff_man *man, int line, char *buf, int offs)
{
int i;
@@ -392,7 +394,7 @@ man_ptext(struct man *man, int line, cha
if (man->last->tok != MAN_SH &&
man->last->tok != MAN_SS) {
man_elem_alloc(man, line, offs, MAN_sp);
- man->next = MAN_NEXT_SIBLING;
+ man->next = ROFF_NEXT_SIBLING;
}
return(1);
}
@@ -435,7 +437,7 @@ man_ptext(struct man *man, int line, cha
}
static int
-man_pmacro(struct man *man, int ln, char *buf, int offs)
+man_pmacro(struct roff_man *man, int ln, char *buf, int offs)
{
struct roff_node *n;
const char *cp;
@@ -535,7 +537,7 @@ man_pmacro(struct man *man, int ln, char
}
void
-man_breakscope(struct man *man, int tok)
+man_breakscope(struct roff_man *man, int tok)
{
struct roff_node *n;
@@ -595,7 +597,7 @@ man_breakscope(struct man *man, int tok)
* point will also be adjusted accordingly.
*/
static void
-man_node_unlink(struct man *man, struct roff_node *n)
+man_node_unlink(struct roff_man *man, struct roff_node *n)
{
/* Adjust siblings. */
@@ -620,10 +622,10 @@ man_node_unlink(struct man *man, struct
/*assert(NULL == n->next);*/
if (n->prev) {
man->last = n->prev;
- man->next = MAN_NEXT_SIBLING;
+ man->next = ROFF_NEXT_SIBLING;
} else {
man->last = n->parent;
- man->next = MAN_NEXT_CHILD;
+ man->next = ROFF_NEXT_CHILD;
}
}
@@ -632,7 +634,7 @@ man_node_unlink(struct man *man, struct
}
const struct mparse *
-man_mparse(const struct man *man)
+man_mparse(const struct roff_man *man)
{
assert(man && man->parse);
Index: mdoc_validate.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mdoc_validate.c,v
retrieving revision 1.285
retrieving revision 1.286
diff -Lmdoc_validate.c -Lmdoc_validate.c -u -p -r1.285 -r1.286
--- mdoc_validate.c
+++ mdoc_validate.c
@@ -40,8 +40,8 @@
/* FIXME: .Bl -diag can't have non-text children in HEAD. */
-#define PRE_ARGS struct mdoc *mdoc, struct roff_node *n
-#define POST_ARGS struct mdoc *mdoc
+#define PRE_ARGS struct roff_man *mdoc, struct roff_node *n
+#define POST_ARGS struct roff_man *mdoc
enum check_ineq {
CHECK_LT,
@@ -57,10 +57,10 @@ struct valids {
v_post post;
};
-static void check_text(struct mdoc *, int, int, char *);
-static void check_argv(struct mdoc *,
+static void check_text(struct roff_man *, int, int, char *);
+static void check_argv(struct roff_man *,
struct roff_node *, struct mdoc_argv *);
-static void check_args(struct mdoc *, struct roff_node *);
+static void check_args(struct roff_man *, struct roff_node *);
static int child_an(const struct roff_node *);
static enum roff_sec a2sec(const char *);
static size_t macro2len(int);
@@ -293,7 +293,7 @@ static const char * const secnames[SEC__
void
-mdoc_valid_pre(struct mdoc *mdoc, struct roff_node *n)
+mdoc_valid_pre(struct roff_man *mdoc, struct roff_node *n)
{
v_pre p;
@@ -319,7 +319,7 @@ mdoc_valid_pre(struct mdoc *mdoc, struct
}
void
-mdoc_valid_post(struct mdoc *mdoc)
+mdoc_valid_post(struct roff_man *mdoc)
{
struct roff_node *n;
v_post p;
@@ -362,7 +362,7 @@ mdoc_valid_post(struct mdoc *mdoc)
}
static void
-check_args(struct mdoc *mdoc, struct roff_node *n)
+check_args(struct roff_man *mdoc, struct roff_node *n)
{
int i;
@@ -375,7 +375,7 @@ check_args(struct mdoc *mdoc, struct rof
}
static void
-check_argv(struct mdoc *mdoc, struct roff_node *n, struct mdoc_argv *v)
+check_argv(struct roff_man *mdoc, struct roff_node *n, struct mdoc_argv *v)
{
int i;
@@ -384,7 +384,7 @@ check_argv(struct mdoc *mdoc, struct rof
}
static void
-check_text(struct mdoc *mdoc, int ln, int pos, char *p)
+check_text(struct roff_man *mdoc, int ln, int pos, char *p)
{
char *cp;
@@ -1046,7 +1046,7 @@ post_defaults(POST_ARGS)
return;
nn = mdoc->last;
- mdoc->next = MDOC_NEXT_CHILD;
+ mdoc->next = ROFF_NEXT_CHILD;
switch (nn->tok) {
case MDOC_Ar:
@@ -1074,7 +1074,7 @@ post_at(POST_ARGS)
n = mdoc->last;
if (n->child == NULL) {
- mdoc->next = MDOC_NEXT_CHILD;
+ mdoc->next = ROFF_NEXT_CHILD;
mdoc_word_alloc(mdoc, n->line, n->pos, "AT&T UNIX");
mdoc->last = n;
return;
@@ -1502,7 +1502,7 @@ post_bk(POST_ARGS)
}
static void
-post_sm(struct mdoc *mdoc)
+post_sm(struct roff_man *mdoc)
{
struct roff_node *nch;
@@ -2313,7 +2313,7 @@ post_ex(POST_ARGS)
return;
}
- mdoc->next = MDOC_NEXT_CHILD;
+ mdoc->next = ROFF_NEXT_CHILD;
mdoc_word_alloc(mdoc, n->line, n->pos, mdoc->meta.name);
mdoc->last = n;
}
Index: mandoc.h
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mandoc.h,v
retrieving revision 1.201
retrieving revision 1.202
diff -Lmandoc.h -Lmandoc.h -u -p -r1.201 -r1.202
--- mandoc.h
+++ mandoc.h
@@ -7,9 +7,9 @@
* 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
+ * 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 AUTHOR BE LIABLE FOR
+ * 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
@@ -412,8 +412,7 @@ __BEGIN_DECLS
struct mparse;
struct mchars;
-struct mdoc;
-struct man;
+struct roff_man;
enum mandoc_esc mandoc_escape(const char **, const char **, int *);
struct mchars *mchars_alloc(void);
@@ -434,8 +433,8 @@ enum mandoclevel mparse_readfd(struct m
enum mandoclevel mparse_readmem(struct mparse *, void *, size_t,
const char *);
void mparse_reset(struct mparse *);
-void mparse_result(struct mparse *,
- struct mdoc **, struct man **, char **);
+void mparse_result(struct mparse *, struct roff_man **,
+ struct roff_man **, char **);
const char *mparse_getkeep(const struct mparse *);
const char *mparse_strerror(enum mandocerr);
const char *mparse_strlevel(enum mandoclevel);
Index: mandocdb.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mandocdb.c,v
retrieving revision 1.190
retrieving revision 1.191
diff -Lmandocdb.c -Lmandocdb.c -u -p -r1.190 -r1.191
--- mandocdb.c
+++ mandocdb.c
@@ -1107,8 +1107,8 @@ mpages_merge(struct mparse *mp)
struct ohash_info str_info;
struct mpage *mpage, *mpage_dest;
struct mlink *mlink, *mlink_dest;
- struct mdoc *mdoc;
- struct man *man;
+ struct roff_man *mdoc;
+ struct roff_man *man;
char *sodest;
char *cp;
int fd;
Index: mdoc_argv.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mdoc_argv.c,v
retrieving revision 1.102
retrieving revision 1.103
diff -Lmdoc_argv.c -Lmdoc_argv.c -u -p -r1.102 -r1.103
--- mdoc_argv.c
+++ mdoc_argv.c
@@ -1,7 +1,7 @@
/* $Id$ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2012, 2014 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2012, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -52,12 +52,12 @@ struct mdocarg {
};
static void argn_free(struct mdoc_arg *, int);
-static enum margserr args(struct mdoc *, int, int *,
+static enum margserr args(struct roff_man *, int, int *,
char *, enum argsflag, char **);
static int args_checkpunct(const char *, int);
-static void argv_multi(struct mdoc *, int,
+static void argv_multi(struct roff_man *, int,
struct mdoc_argv *, int *, char *);
-static void argv_single(struct mdoc *, int,
+static void argv_single(struct roff_man *, int,
struct mdoc_argv *, int *, char *);
static const enum argvflag argvflags[MDOC_ARG_MAX] = {
@@ -276,7 +276,7 @@ static const struct mdocarg mdocargs[MDO
* Some flags take no argument, some one, some multiple.
*/
void
-mdoc_argv(struct mdoc *mdoc, int line, int tok,
+mdoc_argv(struct roff_man *mdoc, int line, int tok,
struct mdoc_arg **reta, int *pos, char *buf)
{
struct mdoc_argv tmpv;
@@ -413,7 +413,7 @@ argn_free(struct mdoc_arg *p, int iarg)
}
enum margserr
-mdoc_args(struct mdoc *mdoc, int line, int *pos,
+mdoc_args(struct roff_man *mdoc, int line, int *pos,
char *buf, int tok, char **v)
{
struct roff_node *n;
@@ -444,7 +444,7 @@ mdoc_args(struct mdoc *mdoc, int line, i
}
static enum margserr
-args(struct mdoc *mdoc, int line, int *pos,
+args(struct roff_man *mdoc, int line, int *pos,
char *buf, enum argsflag fl, char **v)
{
char *p, *pp;
@@ -654,7 +654,7 @@ args_checkpunct(const char *buf, int i)
}
static void
-argv_multi(struct mdoc *mdoc, int line,
+argv_multi(struct roff_man *mdoc, int line,
struct mdoc_argv *v, int *pos, char *buf)
{
enum margserr ac;
@@ -676,7 +676,7 @@ argv_multi(struct mdoc *mdoc, int line,
}
static void
-argv_single(struct mdoc *mdoc, int line,
+argv_single(struct roff_man *mdoc, int line,
struct mdoc_argv *v, int *pos, char *buf)
{
enum margserr ac;
Index: libmdoc.h
===================================================================
RCS file: /home/cvs/mdocml/mdocml/libmdoc.h,v
retrieving revision 1.99
retrieving revision 1.100
diff -Llibmdoc.h -Llibmdoc.h -u -p -r1.99 -r1.100
--- libmdoc.h
+++ libmdoc.h
@@ -16,37 +16,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-enum mdoc_next {
- MDOC_NEXT_SIBLING = 0,
- MDOC_NEXT_CHILD
-};
-
-struct mdoc {
- struct mparse *parse; /* parse pointer */
- const char *defos; /* default argument for .Os */
- int quick; /* abort parse early */
- int flags; /* parse flags */
-#define MDOC_LITERAL (1 << 1) /* in a literal scope */
-#define MDOC_PBODY (1 << 2) /* in the document body */
-#define MDOC_NEWLINE (1 << 3) /* first macro/text in a line */
-#define MDOC_PHRASELIT (1 << 4) /* literal within a partila phrase */
-#define MDOC_PPHRASE (1 << 5) /* within a partial phrase */
-#define MDOC_FREECOL (1 << 6) /* `It' invocation should close */
-#define MDOC_SYNOPSIS (1 << 7) /* SYNOPSIS-style formatting */
-#define MDOC_KEEP (1 << 8) /* in a word keep */
-#define MDOC_SMOFF (1 << 9) /* spacing is off */
-#define MDOC_NODELIMC (1 << 10) /* disable closing delimiter handling */
- enum mdoc_next next; /* where to put the next node */
- struct roff_node *last; /* the last node parsed */
- struct roff_node *first; /* the first node parsed */
- struct roff_node *last_es; /* the most recent Es node */
- struct roff_meta meta; /* document meta-data */
- enum roff_sec lastnamed;
- enum roff_sec lastsec;
- struct roff *roff;
-};
-
-#define MACRO_PROT_ARGS struct mdoc *mdoc, \
+#define MACRO_PROT_ARGS struct roff_man *mdoc, \
int tok, \
int line, \
int ppos, \
@@ -97,33 +67,33 @@ extern const struct mdoc_macro *const md
__BEGIN_DECLS
void mdoc_macro(MACRO_PROT_ARGS);
-void mdoc_word_alloc(struct mdoc *, int, int, const char *);
-void mdoc_word_append(struct mdoc *, const char *);
-void mdoc_elem_alloc(struct mdoc *, int, int,
+void mdoc_word_alloc(struct roff_man *, int, int, const char *);
+void mdoc_word_append(struct roff_man *, const char *);
+void mdoc_elem_alloc(struct roff_man *, int, int,
int, struct mdoc_arg *);
-struct roff_node *mdoc_block_alloc(struct mdoc *, int, int,
+struct roff_node *mdoc_block_alloc(struct roff_man *, int, int,
int, struct mdoc_arg *);
-struct roff_node *mdoc_head_alloc(struct mdoc *, int, int, int);
-void mdoc_tail_alloc(struct mdoc *, int, int, int);
-struct roff_node *mdoc_body_alloc(struct mdoc *, int, int, int);
-struct roff_node *mdoc_endbody_alloc(struct mdoc *, int, int, int,
+struct roff_node *mdoc_head_alloc(struct roff_man *, int, int, int);
+void mdoc_tail_alloc(struct roff_man *, int, int, int);
+struct roff_node *mdoc_body_alloc(struct roff_man *, int, int, int);
+struct roff_node *mdoc_endbody_alloc(struct roff_man *, int, int, int,
struct roff_node *, enum mdoc_endbody);
-void mdoc_node_delete(struct mdoc *, struct roff_node *);
-void mdoc_node_relink(struct mdoc *, struct roff_node *);
+void mdoc_node_delete(struct roff_man *, struct roff_node *);
+void mdoc_node_relink(struct roff_man *, struct roff_node *);
void mdoc_hash_init(void);
int mdoc_hash_find(const char *);
const char *mdoc_a2att(const char *);
const char *mdoc_a2lib(const char *);
const char *mdoc_a2st(const char *);
const char *mdoc_a2arch(const char *);
-void mdoc_valid_pre(struct mdoc *, struct roff_node *);
-void mdoc_valid_post(struct mdoc *);
-void mdoc_argv(struct mdoc *, int, int,
+void mdoc_valid_pre(struct roff_man *, struct roff_node *);
+void mdoc_valid_post(struct roff_man *);
+void mdoc_argv(struct roff_man *, int, int,
struct mdoc_arg **, int *, char *);
void mdoc_argv_free(struct mdoc_arg *);
-enum margserr mdoc_args(struct mdoc *, int,
+enum margserr mdoc_args(struct roff_man *, int,
int *, char *, int, char **);
-void mdoc_macroend(struct mdoc *);
+void mdoc_macroend(struct roff_man *);
enum mdelim mdoc_isdelim(const char *);
__END_DECLS
Index: mdoc_man.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mdoc_man.c,v
retrieving revision 1.91
retrieving revision 1.92
diff -Lmdoc_man.c -Lmdoc_man.c -u -p -r1.91 -r1.92
--- mdoc_man.c
+++ mdoc_man.c
@@ -532,7 +532,7 @@ print_count(int *count)
}
void
-man_man(void *arg, const struct man *man)
+man_man(void *arg, const struct roff_man *man)
{
/*
@@ -545,7 +545,7 @@ man_man(void *arg, const struct man *man
}
void
-man_mdoc(void *arg, const struct mdoc *mdoc)
+man_mdoc(void *arg, const struct roff_man *mdoc)
{
const struct roff_meta *meta;
struct roff_node *n;
Index: tree.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/tree.c,v
retrieving revision 1.64
retrieving revision 1.65
diff -Ltree.c -Ltree.c -u -p -r1.64 -r1.65
--- tree.c
+++ tree.c
@@ -38,14 +38,14 @@ static void print_span(const struct tbl_
void
-tree_mdoc(void *arg, const struct mdoc *mdoc)
+tree_mdoc(void *arg, const struct roff_man *mdoc)
{
print_mdoc(mdoc_node(mdoc)->child, 0);
}
void
-tree_man(void *arg, const struct man *man)
+tree_man(void *arg, const struct roff_man *man)
{
print_man(man_node(man)->child, 0);
Index: roff.h
===================================================================
RCS file: /home/cvs/mdocml/mdocml/roff.h,v
retrieving revision 1.30
retrieving revision 1.31
diff -Lroff.h -Lroff.h -u -p -r1.30 -r1.31
--- roff.h
+++ roff.h
@@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2013, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -58,6 +58,11 @@ enum roff_type {
ROFFT_EQN
};
+enum roff_next {
+ ROFF_NEXT_SIBLING = 0,
+ ROFF_NEXT_CHILD
+};
+
/*
* Indicates that a BODY's formatting has ended, but
* the scope is still open. Used for badly nested blocks.
@@ -114,4 +119,33 @@ struct roff_meta {
char *name; /* Leading manual name. */
char *date; /* Normalized date. */
int hasbody; /* Document is not empty. */
+};
+
+struct roff_man {
+ struct roff_meta meta; /* Document meta-data. */
+ struct mparse *parse; /* Parse pointer. */
+ struct roff *roff; /* Roff parser state data. */
+ const char *defos; /* Default operating system. */
+ struct roff_node *first; /* The first node parsed. */
+ struct roff_node *last; /* The last node parsed. */
+ struct roff_node *last_es; /* The most recent Es node. */
+ int quick; /* Abort parse early. */
+ int flags; /* Parse flags. */
+#define MDOC_LITERAL (1 << 1) /* In a literal scope. */
+#define MDOC_PBODY (1 << 2) /* In the document body. */
+#define MDOC_NEWLINE (1 << 3) /* First macro/text in a line. */
+#define MDOC_PHRASELIT (1 << 4) /* Literal within a partial phrase. */
+#define MDOC_PPHRASE (1 << 5) /* Within a partial phrase. */
+#define MDOC_FREECOL (1 << 6) /* `It' invocation should close. */
+#define MDOC_SYNOPSIS (1 << 7) /* SYNOPSIS-style formatting. */
+#define MDOC_KEEP (1 << 8) /* In a word keep. */
+#define MDOC_SMOFF (1 << 9) /* Spacing is off. */
+#define MDOC_NODELIMC (1 << 10) /* Disable closing delimiter handling. */
+#define MAN_ELINE (1 << 11) /* Next-line element scope. */
+#define MAN_BLINE (1 << 12) /* Next-line block scope. */
+#define MAN_LITERAL MDOC_LITERAL
+#define MAN_NEWLINE MDOC_NEWLINE
+ enum roff_sec lastsec; /* Last section seen. */
+ enum roff_sec lastnamed; /* Last standard section seen. */
+ enum roff_next next; /* Where to put the next node. */
};
Index: man_macro.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/man_macro.c,v
retrieving revision 1.104
retrieving revision 1.105
diff -Lman_macro.c -Lman_macro.c -u -p -r1.104 -r1.105
--- man_macro.c
+++ man_macro.c
@@ -35,9 +35,9 @@ 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 */
@@ -84,7 +84,7 @@ const struct man_macro * const man_macro
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;
@@ -140,7 +140,7 @@ man_unscope(struct man *man, const struc
*/
man->next = (man->last == to) ?
- MAN_NEXT_CHILD : MAN_NEXT_SIBLING;
+ ROFF_NEXT_CHILD : ROFF_NEXT_SIBLING;
}
/*
@@ -149,7 +149,7 @@ man_unscope(struct man *man, const struc
* 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;
@@ -377,7 +377,7 @@ in_line_eoln(MACRO_PROT_ARGS)
}
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
@@ -405,14 +405,14 @@ in_line_eoln(MACRO_PROT_ARGS)
void
-man_macroend(struct man *man)
+man_macroend(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;
Index: man_validate.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/man_validate.c,v
retrieving revision 1.116
retrieving revision 1.117
diff -Lman_validate.c -Lman_validate.c -u -p -r1.116 -r1.117
--- man_validate.c
+++ man_validate.c
@@ -35,7 +35,7 @@
#include "libmandoc.h"
#include "libman.h"
-#define CHKARGS struct man *man, struct roff_node *n
+#define CHKARGS struct roff_man *man, struct roff_node *n
typedef void (*v_check)(CHKARGS);
@@ -98,7 +98,7 @@ static v_check man_valids[MAN_MAX] = {
void
-man_valid_post(struct man *man)
+man_valid_post(struct roff_man *man)
{
struct roff_node *n;
v_check *cp;
Index: main.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/main.c,v
retrieving revision 1.233
retrieving revision 1.234
diff -Lmain.c -Lmain.c -u -p -r1.233 -r1.234
--- main.c
+++ main.c
@@ -58,8 +58,8 @@ enum outmode {
OUTMODE_ONE
};
-typedef void (*out_mdoc)(void *, const struct mdoc *);
-typedef void (*out_man)(void *, const struct man *);
+typedef void (*out_mdoc)(void *, const struct roff_man *);
+typedef void (*out_man)(void *, const struct roff_man *);
typedef void (*out_free)(void *);
enum outt {
@@ -632,8 +632,8 @@ static void
parse(struct curparse *curp, int fd, const char *file)
{
enum mandoclevel rctmp;
- struct mdoc *mdoc;
- struct man *man;
+ struct roff_man *mdoc;
+ struct roff_man *man;
/* Begin by parsing the file itself. */
Index: libmandoc.h
===================================================================
RCS file: /home/cvs/mdocml/mdocml/libmandoc.h,v
retrieving revision 1.55
retrieving revision 1.56
diff -Llibmandoc.h -Llibmandoc.h -u -p -r1.55 -r1.56
--- libmandoc.h
+++ libmandoc.h
@@ -1,15 +1,15 @@
/* $Id$ */
/*
* Copyright (c) 2009, 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2013, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* 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
+ * 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 AUTHOR BE LIABLE FOR
+ * 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
@@ -39,8 +39,7 @@ struct mchars;
struct tbl_span;
struct eqn;
struct roff;
-struct mdoc;
-struct man;
+struct roff_man;
void mandoc_msg(enum mandocerr, struct mparse *,
int, int, const char *);
@@ -55,23 +54,23 @@ int mandoc_eos(const char *, size_t);
int mandoc_strntoi(const char *, size_t, int);
const char *mandoc_a2msec(const char*);
-void mdoc_free(struct mdoc *);
-struct mdoc *mdoc_alloc(struct roff *, struct mparse *,
+void mdoc_free(struct roff_man *);
+struct roff_man *mdoc_alloc(struct roff *, struct mparse *,
const char *, int);
-void mdoc_reset(struct mdoc *);
-int mdoc_parseln(struct mdoc *, int, char *, int);
-void mdoc_endparse(struct mdoc *);
-void mdoc_addspan(struct mdoc *, const struct tbl_span *);
-void mdoc_addeqn(struct mdoc *, const struct eqn *);
+void mdoc_reset(struct roff_man *);
+int mdoc_parseln(struct roff_man *, int, char *, int);
+void mdoc_endparse(struct roff_man *);
+void mdoc_addspan(struct roff_man *, const struct tbl_span *);
+void mdoc_addeqn(struct roff_man *, const struct eqn *);
-void man_free(struct man *);
-struct man *man_alloc(struct roff *, struct mparse *,
+void man_free(struct roff_man *);
+struct roff_man *man_alloc(struct roff *, struct mparse *,
const char *, int);
-void man_reset(struct man *);
-int man_parseln(struct man *, int, char *, int);
-void man_endparse(struct man *);
-void man_addspan(struct man *, const struct tbl_span *);
-void man_addeqn(struct man *, const struct eqn *);
+void man_reset(struct roff_man *);
+int man_parseln(struct roff_man *, int, char *, int);
+void man_endparse(struct roff_man *);
+void man_addspan(struct roff_man *, const struct tbl_span *);
+void man_addeqn(struct roff_man *, const struct eqn *);
int preconv_cue(const struct buf *, size_t);
int preconv_encode(struct buf *, size_t *,
Index: mdoc.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mdoc.c,v
retrieving revision 1.241
retrieving revision 1.242
diff -Lmdoc.c -Lmdoc.c -u -p -r1.241 -r1.242
--- mdoc.c
+++ mdoc.c
@@ -84,26 +84,26 @@ const char * const *mdoc_macronames = __
const char * const *mdoc_argnames = __mdoc_argnames;
static void mdoc_node_free(struct roff_node *);
-static void mdoc_node_unlink(struct mdoc *,
+static void mdoc_node_unlink(struct roff_man *,
struct roff_node *);
-static void mdoc_free1(struct mdoc *);
-static void mdoc_alloc1(struct mdoc *);
-static struct roff_node *node_alloc(struct mdoc *, int, int,
+static void mdoc_free1(struct roff_man *);
+static void mdoc_alloc1(struct roff_man *);
+static struct roff_node *node_alloc(struct roff_man *, int, int,
int, enum roff_type);
-static void node_append(struct mdoc *, struct roff_node *);
-static int mdoc_ptext(struct mdoc *, int, char *, int);
-static int mdoc_pmacro(struct mdoc *, int, char *, int);
+static void node_append(struct roff_man *, struct roff_node *);
+static int mdoc_ptext(struct roff_man *, int, char *, int);
+static int mdoc_pmacro(struct roff_man *, int, char *, int);
const struct roff_node *
-mdoc_node(const struct mdoc *mdoc)
+mdoc_node(const struct roff_man *mdoc)
{
return(mdoc->first);
}
const struct roff_meta *
-mdoc_meta(const struct mdoc *mdoc)
+mdoc_meta(const struct roff_man *mdoc)
{
return(&mdoc->meta);
@@ -113,7 +113,7 @@ mdoc_meta(const struct mdoc *mdoc)
* Frees volatile resources (parse tree, meta-data, fields).
*/
static void
-mdoc_free1(struct mdoc *mdoc)
+mdoc_free1(struct roff_man *mdoc)
{
if (mdoc->first)
@@ -131,7 +131,7 @@ mdoc_free1(struct mdoc *mdoc)
* Allocate all volatile resources (parse tree, meta-data, fields).
*/
static void
-mdoc_alloc1(struct mdoc *mdoc)
+mdoc_alloc1(struct roff_man *mdoc)
{
memset(&mdoc->meta, 0, sizeof(mdoc->meta));
@@ -141,7 +141,7 @@ mdoc_alloc1(struct mdoc *mdoc)
mdoc->first = mdoc->last;
mdoc->last->type = ROFFT_ROOT;
mdoc->last->tok = MDOC_MAX;
- mdoc->next = MDOC_NEXT_CHILD;
+ mdoc->next = ROFF_NEXT_CHILD;
}
/*
@@ -151,7 +151,7 @@ mdoc_alloc1(struct mdoc *mdoc)
* cross-parse non-volatile data is kept intact.
*/
void
-mdoc_reset(struct mdoc *mdoc)
+mdoc_reset(struct roff_man *mdoc)
{
mdoc_free1(mdoc);
@@ -163,7 +163,7 @@ mdoc_reset(struct mdoc *mdoc)
* After invocation, the pointer is no longer usable.
*/
void
-mdoc_free(struct mdoc *mdoc)
+mdoc_free(struct roff_man *mdoc)
{
mdoc_free1(mdoc);
@@ -173,13 +173,13 @@ mdoc_free(struct mdoc *mdoc)
/*
* Allocate volatile and non-volatile parse resources.
*/
-struct mdoc *
+struct roff_man *
mdoc_alloc(struct roff *roff, struct mparse *parse,
const char *defos, int quick)
{
- struct mdoc *p;
+ struct roff_man *p;
- p = mandoc_calloc(1, sizeof(struct mdoc));
+ p = mandoc_calloc(1, sizeof(*p));
p->parse = parse;
p->defos = defos;
@@ -192,14 +192,14 @@ mdoc_alloc(struct roff *roff, struct mpa
}
void
-mdoc_endparse(struct mdoc *mdoc)
+mdoc_endparse(struct roff_man *mdoc)
{
mdoc_macroend(mdoc);
}
void
-mdoc_addeqn(struct mdoc *mdoc, const struct eqn *ep)
+mdoc_addeqn(struct roff_man *mdoc, const struct eqn *ep)
{
struct roff_node *n;
@@ -208,18 +208,18 @@ mdoc_addeqn(struct mdoc *mdoc, const str
if (ep->ln > mdoc->last->line)
n->flags |= MDOC_LINE;
node_append(mdoc, n);
- mdoc->next = MDOC_NEXT_SIBLING;
+ mdoc->next = ROFF_NEXT_SIBLING;
}
void
-mdoc_addspan(struct mdoc *mdoc, const struct tbl_span *sp)
+mdoc_addspan(struct roff_man *mdoc, const struct tbl_span *sp)
{
struct roff_node *n;
n = node_alloc(mdoc, sp->line, 0, MDOC_MAX, ROFFT_TBL);
n->span = sp;
node_append(mdoc, n);
- mdoc->next = MDOC_NEXT_SIBLING;
+ mdoc->next = ROFF_NEXT_SIBLING;
}
/*
@@ -227,7 +227,7 @@ mdoc_addspan(struct mdoc *mdoc, const st
* the macro (mdoc_pmacro()) or text parser (mdoc_ptext()).
*/
int
-mdoc_parseln(struct mdoc *mdoc, int ln, char *buf, int offs)
+mdoc_parseln(struct roff_man *mdoc, int ln, char *buf, int offs)
{
if (mdoc->last->type != ROFFT_EQN || ln > mdoc->last->line)
@@ -277,7 +277,7 @@ mdoc_macro(MACRO_PROT_ARGS)
static void
-node_append(struct mdoc *mdoc, struct roff_node *p)
+node_append(struct roff_man *mdoc, struct roff_node *p)
{
assert(mdoc->last);
@@ -285,12 +285,12 @@ node_append(struct mdoc *mdoc, struct ro
assert(p->type != ROFFT_ROOT);
switch (mdoc->next) {
- case MDOC_NEXT_SIBLING:
+ case ROFF_NEXT_SIBLING:
mdoc->last->next = p;
p->prev = mdoc->last;
p->parent = mdoc->last->parent;
break;
- case MDOC_NEXT_CHILD:
+ case ROFF_NEXT_CHILD:
mdoc->last->child = p;
p->parent = mdoc->last;
break;
@@ -355,7 +355,7 @@ node_append(struct mdoc *mdoc, struct ro
}
static struct roff_node *
-node_alloc(struct mdoc *mdoc, int line, int pos,
+node_alloc(struct roff_man *mdoc, int line, int pos,
int tok, enum roff_type type)
{
struct roff_node *p;
@@ -381,17 +381,17 @@ node_alloc(struct mdoc *mdoc, int line,
}
void
-mdoc_tail_alloc(struct mdoc *mdoc, int line, int pos, int tok)
+mdoc_tail_alloc(struct roff_man *mdoc, int line, int pos, int tok)
{
struct roff_node *p;
p = node_alloc(mdoc, line, pos, tok, ROFFT_TAIL);
node_append(mdoc, p);
- mdoc->next = MDOC_NEXT_CHILD;
+ mdoc->next = ROFF_NEXT_CHILD;
}
struct roff_node *
-mdoc_head_alloc(struct mdoc *mdoc, int line, int pos, int tok)
+mdoc_head_alloc(struct roff_man *mdoc, int line, int pos, int tok)
{
struct roff_node *p;
@@ -399,23 +399,23 @@ mdoc_head_alloc(struct mdoc *mdoc, int l
assert(mdoc->last);
p = node_alloc(mdoc, line, pos, tok, ROFFT_HEAD);
node_append(mdoc, p);
- mdoc->next = MDOC_NEXT_CHILD;
+ mdoc->next = ROFF_NEXT_CHILD;
return(p);
}
struct roff_node *
-mdoc_body_alloc(struct mdoc *mdoc, int line, int pos, int tok)
+mdoc_body_alloc(struct roff_man *mdoc, int line, int pos, int tok)
{
struct roff_node *p;
p = node_alloc(mdoc, line, pos, tok, ROFFT_BODY);
node_append(mdoc, p);
- mdoc->next = MDOC_NEXT_CHILD;
+ mdoc->next = ROFF_NEXT_CHILD;
return(p);
}
struct roff_node *
-mdoc_endbody_alloc(struct mdoc *mdoc, int line, int pos, int tok,
+mdoc_endbody_alloc(struct roff_man *mdoc, int line, int pos, int tok,
struct roff_node *body, enum mdoc_endbody end)
{
struct roff_node *p;
@@ -427,12 +427,12 @@ mdoc_endbody_alloc(struct mdoc *mdoc, in
p->norm = body->norm;
p->end = end;
node_append(mdoc, p);
- mdoc->next = MDOC_NEXT_SIBLING;
+ mdoc->next = ROFF_NEXT_SIBLING;
return(p);
}
struct roff_node *
-mdoc_block_alloc(struct mdoc *mdoc, int line, int pos,
+mdoc_block_alloc(struct roff_man *mdoc, int line, int pos,
int tok, struct mdoc_arg *args)
{
struct roff_node *p;
@@ -458,12 +458,12 @@ mdoc_block_alloc(struct mdoc *mdoc, int
break;
}
node_append(mdoc, p);
- mdoc->next = MDOC_NEXT_CHILD;
+ mdoc->next = ROFF_NEXT_CHILD;
return(p);
}
void
-mdoc_elem_alloc(struct mdoc *mdoc, int line, int pos,
+mdoc_elem_alloc(struct roff_man *mdoc, int line, int pos,
int tok, struct mdoc_arg *args)
{
struct roff_node *p;
@@ -481,22 +481,22 @@ mdoc_elem_alloc(struct mdoc *mdoc, int l
break;
}
node_append(mdoc, p);
- mdoc->next = MDOC_NEXT_CHILD;
+ mdoc->next = ROFF_NEXT_CHILD;
}
void
-mdoc_word_alloc(struct mdoc *mdoc, int line, int pos, const char *p)
+mdoc_word_alloc(struct roff_man *mdoc, int line, int pos, const char *p)
{
struct roff_node *n;
n = node_alloc(mdoc, line, pos, MDOC_MAX, ROFFT_TEXT);
n->string = roff_strdup(mdoc->roff, p);
node_append(mdoc, n);
- mdoc->next = MDOC_NEXT_SIBLING;
+ mdoc->next = ROFF_NEXT_SIBLING;
}
void
-mdoc_word_append(struct mdoc *mdoc, const char *p)
+mdoc_word_append(struct roff_man *mdoc, const char *p)
{
struct roff_node *n;
char *addstr, *newstr;
@@ -507,7 +507,7 @@ mdoc_word_append(struct mdoc *mdoc, cons
free(addstr);
free(n->string);
n->string = newstr;
- mdoc->next = MDOC_NEXT_SIBLING;
+ mdoc->next = ROFF_NEXT_SIBLING;
}
static void
@@ -524,7 +524,7 @@ mdoc_node_free(struct roff_node *p)
}
static void
-mdoc_node_unlink(struct mdoc *mdoc, struct roff_node *n)
+mdoc_node_unlink(struct roff_man *mdoc, struct roff_node *n)
{
/* Adjust siblings. */
@@ -549,10 +549,10 @@ mdoc_node_unlink(struct mdoc *mdoc, stru
if (mdoc && mdoc->last == n) {
if (n->prev) {
mdoc->last = n->prev;
- mdoc->next = MDOC_NEXT_SIBLING;
+ mdoc->next = ROFF_NEXT_SIBLING;
} else {
mdoc->last = n->parent;
- mdoc->next = MDOC_NEXT_CHILD;
+ mdoc->next = ROFF_NEXT_CHILD;
}
}
@@ -561,7 +561,7 @@ mdoc_node_unlink(struct mdoc *mdoc, stru
}
void
-mdoc_node_delete(struct mdoc *mdoc, struct roff_node *p)
+mdoc_node_delete(struct roff_man *mdoc, struct roff_node *p)
{
while (p->child) {
@@ -575,7 +575,7 @@ mdoc_node_delete(struct mdoc *mdoc, stru
}
void
-mdoc_node_relink(struct mdoc *mdoc, struct roff_node *p)
+mdoc_node_relink(struct roff_man *mdoc, struct roff_node *p)
{
mdoc_node_unlink(mdoc, p);
@@ -587,7 +587,7 @@ mdoc_node_relink(struct mdoc *mdoc, stru
* control character.
*/
static int
-mdoc_ptext(struct mdoc *mdoc, int line, char *buf, int offs)
+mdoc_ptext(struct roff_man *mdoc, int line, char *buf, int offs)
{
struct roff_node *n;
char *c, *ws, *end;
@@ -675,7 +675,7 @@ mdoc_ptext(struct mdoc *mdoc, int line,
* behaviour that we want to work around it.
*/
mdoc_elem_alloc(mdoc, line, offs, MDOC_sp, NULL);
- mdoc->next = MDOC_NEXT_SIBLING;
+ mdoc->next = ROFF_NEXT_SIBLING;
mdoc_valid_post(mdoc);
return(1);
}
@@ -703,7 +703,7 @@ mdoc_ptext(struct mdoc *mdoc, int line,
* character.
*/
static int
-mdoc_pmacro(struct mdoc *mdoc, int ln, char *buf, int offs)
+mdoc_pmacro(struct roff_man *mdoc, int ln, char *buf, int offs)
{
struct roff_node *n;
const char *cp;
Index: main.h
===================================================================
RCS file: /home/cvs/mdocml/mdocml/main.h,v
retrieving revision 1.21
retrieving revision 1.22
diff -Lmain.h -Lmain.h -u -p -r1.21 -r1.22
--- main.h
+++ main.h
@@ -21,8 +21,7 @@
__BEGIN_DECLS
struct mchars;
-struct mdoc;
-struct man;
+struct roff_man;
struct manoutput;
/*
@@ -34,15 +33,15 @@ struct manoutput;
void *html_alloc(const struct mchars *,
const struct manoutput *);
-void html_mdoc(void *, const struct mdoc *);
-void html_man(void *, const struct man *);
+void html_mdoc(void *, const struct roff_man *);
+void html_man(void *, const struct roff_man *);
void html_free(void *);
-void tree_mdoc(void *, const struct mdoc *);
-void tree_man(void *, const struct man *);
+void tree_mdoc(void *, const struct roff_man *);
+void tree_man(void *, const struct roff_man *);
-void man_mdoc(void *, const struct mdoc *);
-void man_man(void *, const struct man *);
+void man_mdoc(void *, const struct roff_man *);
+void man_man(void *, const struct roff_man *);
void *locale_alloc(const struct mchars *,
const struct manoutput *);
@@ -59,7 +58,7 @@ void *ps_alloc(const struct mchars *,
const struct manoutput *);
void pspdf_free(void *);
-void terminal_mdoc(void *, const struct mdoc *);
-void terminal_man(void *, const struct man *);
+void terminal_mdoc(void *, const struct roff_man *);
+void terminal_man(void *, const struct roff_man *);
__END_DECLS
Index: demandoc.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/demandoc.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -Ldemandoc.c -Ldemandoc.c -u -p -r1.17 -r1.18
--- demandoc.c
+++ demandoc.c
@@ -110,8 +110,8 @@ usage(void)
static void
pmandoc(struct mparse *mp, int fd, const char *fn, int list)
{
- struct mdoc *mdoc;
- struct man *man;
+ struct roff_man *mdoc;
+ struct roff_man *man;
int line, col;
mparse_readfd(mp, fd, fn);
Index: man_term.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/man_term.c,v
retrieving revision 1.179
retrieving revision 1.180
diff -Lman_term.c -Lman_term.c -u -p -r1.179 -r1.180
--- man_term.c
+++ man_term.c
@@ -138,7 +138,7 @@ static const struct termact termacts[MAN
void
-terminal_man(void *arg, const struct man *man)
+terminal_man(void *arg, const struct roff_man *man)
{
struct termp *p;
const struct roff_meta *meta;
Index: libman.h
===================================================================
RCS file: /home/cvs/mdocml/mdocml/libman.h,v
retrieving revision 1.70
retrieving revision 1.71
diff -Llibman.h -Llibman.h -u -p -r1.70 -r1.71
--- libman.h
+++ libman.h
@@ -16,28 +16,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-enum man_next {
- MAN_NEXT_SIBLING = 0,
- MAN_NEXT_CHILD
-};
-
-struct man {
- struct mparse *parse; /* parse pointer */
- const char *defos; /* default OS argument for .TH */
- int quick; /* abort parse early */
- int flags; /* parse flags */
-#define MAN_ELINE (1 << 1) /* Next-line element scope. */
-#define MAN_BLINE (1 << 2) /* Next-line block scope. */
-#define MAN_LITERAL (1 << 4) /* Literal input. */
-#define MAN_NEWLINE (1 << 6) /* first macro/text in a line */
- enum man_next next; /* where to put the next node */
- struct roff_node *last; /* the last parsed node */
- struct roff_node *first; /* the first parsed node */
- struct roff_meta meta; /* document meta-data */
- struct roff *roff;
-};
-
-#define MACRO_PROT_ARGS struct man *man, \
+#define MACRO_PROT_ARGS struct roff_man *man, \
int tok, \
int line, \
int ppos, \
@@ -57,17 +36,17 @@ extern const struct man_macro *const man
__BEGIN_DECLS
-void man_word_alloc(struct man *, int, int, const char *);
-void man_word_append(struct man *, const char *);
-void man_block_alloc(struct man *, int, int, int);
-void man_head_alloc(struct man *, int, int, int);
-void man_body_alloc(struct man *, int, int, int);
-void man_elem_alloc(struct man *, int, int, int);
-void man_node_delete(struct man *, struct roff_node *);
+void man_word_alloc(struct roff_man *, int, int, const char *);
+void man_word_append(struct roff_man *, const char *);
+void man_block_alloc(struct roff_man *, int, int, int);
+void man_head_alloc(struct roff_man *, int, int, int);
+void man_body_alloc(struct roff_man *, int, int, int);
+void man_elem_alloc(struct roff_man *, int, int, int);
+void man_node_delete(struct roff_man *, struct roff_node *);
void man_hash_init(void);
int man_hash_find(const char *);
-void man_macroend(struct man *);
-void man_valid_post(struct man *);
-void man_unscope(struct man *, const struct roff_node *);
+void man_macroend(struct roff_man *);
+void man_valid_post(struct roff_man *);
+void man_unscope(struct roff_man *, const struct roff_node *);
__END_DECLS
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2015-04-18 16:07 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-18 16:07 mdocml: Replace the structs mdoc and man by a unified struct roff_man schwarze
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).