aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--demandoc.c10
-rw-r--r--libman.h26
-rw-r--r--libmdoc.h48
-rw-r--r--man.c69
-rw-r--r--man.h117
-rw-r--r--man_hash.c8
-rw-r--r--man_html.c18
-rw-r--r--man_macro.c35
-rw-r--r--man_term.c18
-rw-r--r--man_validate.c8
-rw-r--r--mandoc_headers.331
-rw-r--r--mandocdb.c58
-rw-r--r--mdoc.c84
-rw-r--r--mdoc.h340
-rw-r--r--mdoc_argv.c8
-rw-r--r--mdoc_hash.c6
-rw-r--r--mdoc_html.c14
-rw-r--r--mdoc_macro.c78
-rw-r--r--mdoc_man.c22
-rw-r--r--mdoc_term.c28
-rw-r--r--mdoc_validate.c112
-rw-r--r--roff.h77
-rw-r--r--tree.c10
23 files changed, 597 insertions, 628 deletions
diff --git a/demandoc.c b/demandoc.c
index 6403191e..8cfe5777 100644
--- a/demandoc.c
+++ b/demandoc.c
@@ -1,4 +1,4 @@
-/* $Id: demandoc.c,v 1.16 2015/04/02 21:36:49 schwarze Exp $ */
+/* $Id: demandoc.c,v 1.17 2015/04/02 22:48:17 schwarze Exp $ */
/*
* Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -32,9 +32,9 @@
#include "mandoc.h"
static void pline(int, int *, int *, int);
-static void pman(const struct man_node *, int *, int *, int);
+static void pman(const struct roff_node *, int *, int *, int);
static void pmandoc(struct mparse *, int, const char *, int);
-static void pmdoc(const struct mdoc_node *, int *, int *, int);
+static void pmdoc(const struct roff_node *, int *, int *, int);
static void pstring(const char *, int, int *, int);
static void usage(void);
@@ -234,7 +234,7 @@ pline(int line, int *linep, int *col, int list)
}
static void
-pmdoc(const struct mdoc_node *p, int *line, int *col, int list)
+pmdoc(const struct roff_node *p, int *line, int *col, int list)
{
for ( ; p; p = p->next) {
@@ -248,7 +248,7 @@ pmdoc(const struct mdoc_node *p, int *line, int *col, int list)
}
static void
-pman(const struct man_node *p, int *line, int *col, int list)
+pman(const struct roff_node *p, int *line, int *col, int list)
{
for ( ; p; p = p->next) {
diff --git a/libman.h b/libman.h
index e55bc89a..62c7f294 100644
--- a/libman.h
+++ b/libman.h
@@ -1,4 +1,4 @@
-/* $Id: libman.h,v 1.68 2015/03/20 12:54:22 schwarze Exp $ */
+/* $Id: libman.h,v 1.69 2015/04/02 22:48:17 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -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
@@ -31,14 +31,14 @@ struct man {
#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 man_node *last; /* the last parsed node */
- struct man_node *first; /* the first parsed node */
+ struct roff_node *last; /* the last parsed node */
+ struct roff_node *first; /* the first parsed node */
struct man_meta meta; /* document meta-data */
struct roff *roff;
};
#define MACRO_PROT_ARGS struct man *man, \
- enum mant tok, \
+ int tok, \
int line, \
int ppos, \
int *pos, \
@@ -59,15 +59,15 @@ __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, enum mant);
-void man_head_alloc(struct man *, int, int, enum mant);
-void man_body_alloc(struct man *, int, int, enum mant);
-void man_elem_alloc(struct man *, int, int, enum mant);
-void man_node_delete(struct man *, struct man_node *);
+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_hash_init(void);
-enum mant man_hash_find(const char *);
+int man_hash_find(const char *);
void man_macroend(struct man *);
void man_valid_post(struct man *);
-void man_unscope(struct man *, const struct man_node *);
+void man_unscope(struct man *, const struct roff_node *);
__END_DECLS
diff --git a/libmdoc.h b/libmdoc.h
index 527fe027..ceaf217e 100644
--- a/libmdoc.h
+++ b/libmdoc.h
@@ -1,15 +1,15 @@
-/* $Id: libmdoc.h,v 1.97 2015/02/02 04:26:44 schwarze Exp $ */
+/* $Id: libmdoc.h,v 1.98 2015/04/02 22:48:17 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 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
@@ -37,17 +37,17 @@ struct mdoc {
#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 mdoc_node *last; /* the last node parsed */
- struct mdoc_node *first; /* the first node parsed */
- struct mdoc_node *last_es; /* the most recent Es 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 mdoc_meta meta; /* document meta-data */
- enum mdoc_sec lastnamed;
- enum mdoc_sec lastsec;
+ enum roff_sec lastnamed;
+ enum roff_sec lastsec;
struct roff *roff;
};
#define MACRO_PROT_ARGS struct mdoc *mdoc, \
- enum mdoct tok, \
+ int tok, \
int line, \
int ppos, \
int *pos, \
@@ -100,29 +100,29 @@ 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,
- enum mdoct, struct mdoc_arg *);
-struct mdoc_node *mdoc_block_alloc(struct mdoc *, int, int,
- enum mdoct, struct mdoc_arg *);
-struct mdoc_node *mdoc_head_alloc(struct mdoc *, int, int, enum mdoct);
-void mdoc_tail_alloc(struct mdoc *, int, int, enum mdoct);
-struct mdoc_node *mdoc_body_alloc(struct mdoc *, int, int, enum mdoct);
-struct mdoc_node *mdoc_endbody_alloc(struct mdoc *, int, int, enum mdoct,
- struct mdoc_node *, enum mdoc_endbody);
-void mdoc_node_delete(struct mdoc *, struct mdoc_node *);
-void mdoc_node_relink(struct mdoc *, struct mdoc_node *);
+ int, struct mdoc_arg *);
+struct roff_node *mdoc_block_alloc(struct mdoc *, 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 *, enum mdoc_endbody);
+void mdoc_node_delete(struct mdoc *, struct roff_node *);
+void mdoc_node_relink(struct mdoc *, struct roff_node *);
void mdoc_hash_init(void);
-enum mdoct mdoc_hash_find(const char *);
+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 mdoc_node *);
+void mdoc_valid_pre(struct mdoc *, struct roff_node *);
void mdoc_valid_post(struct mdoc *);
-void mdoc_argv(struct mdoc *, int, enum mdoct,
+void mdoc_argv(struct mdoc *, int, int,
struct mdoc_arg **, int *, char *);
void mdoc_argv_free(struct mdoc_arg *);
enum margserr mdoc_args(struct mdoc *, int,
- int *, char *, enum mdoct, char **);
+ int *, char *, int, char **);
void mdoc_macroend(struct mdoc *);
enum mdelim mdoc_isdelim(const char *);
diff --git a/man.c b/man.c
index 39aff548..aa1e4ac1 100644
--- a/man.c
+++ b/man.c
@@ -1,4 +1,4 @@
-/* $Id: man.c,v 1.150 2015/04/02 21:36:49 schwarze Exp $ */
+/* $Id: man.c,v 1.151 2015/04/02 22:48:17 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -50,20 +50,19 @@ const char *const __man_macronames[MAN_MAX] = {
const char * const *man_macronames = __man_macronames;
static void man_alloc1(struct man *);
-static void man_breakscope(struct man *, enum mant);
+static void man_breakscope(struct man *, int);
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 *,
- struct man_node *);
+static struct roff_node *man_node_alloc(struct man *, int, int,
+ enum roff_type, int);
+static void man_node_append(struct 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);
-const struct man_node *
+const struct roff_node *
man_node(const struct man *man)
{
@@ -149,7 +148,7 @@ man_alloc1(struct man *man)
memset(&man->meta, 0, sizeof(struct man_meta));
man->flags = 0;
- man->last = mandoc_calloc(1, sizeof(struct man_node));
+ man->last = mandoc_calloc(1, sizeof(*man->last));
man->first = man->last;
man->last->type = ROFFT_ROOT;
man->last->tok = MAN_MAX;
@@ -158,7 +157,7 @@ man_alloc1(struct man *man)
static void
-man_node_append(struct man *man, struct man_node *p)
+man_node_append(struct man *man, struct roff_node *p)
{
assert(man->last);
@@ -213,13 +212,13 @@ man_node_append(struct man *man, struct man_node *p)
}
}
-static struct man_node *
+static struct roff_node *
man_node_alloc(struct man *man, int line, int pos,
- enum roff_type type, enum mant tok)
+ enum roff_type type, int tok)
{
- struct man_node *p;
+ struct roff_node *p;
- p = mandoc_calloc(1, sizeof(struct man_node));
+ p = mandoc_calloc(1, sizeof(*p));
p->line = line;
p->pos = pos;
p->type = type;
@@ -232,9 +231,9 @@ man_node_alloc(struct man *man, int line, int pos,
}
void
-man_elem_alloc(struct man *man, int line, int pos, enum mant tok)
+man_elem_alloc(struct man *man, int line, int pos, int tok)
{
- struct man_node *p;
+ struct roff_node *p;
p = man_node_alloc(man, line, pos, ROFFT_ELEM, tok);
man_node_append(man, p);
@@ -242,9 +241,9 @@ man_elem_alloc(struct man *man, int line, int pos, enum mant tok)
}
void
-man_head_alloc(struct man *man, int line, int pos, enum mant tok)
+man_head_alloc(struct man *man, int line, int pos, int tok)
{
- struct man_node *p;
+ struct roff_node *p;
p = man_node_alloc(man, line, pos, ROFFT_HEAD, tok);
man_node_append(man, p);
@@ -252,9 +251,9 @@ man_head_alloc(struct man *man, int line, int pos, enum mant tok)
}
void
-man_body_alloc(struct man *man, int line, int pos, enum mant tok)
+man_body_alloc(struct man *man, int line, int pos, int tok)
{
- struct man_node *p;
+ struct roff_node *p;
p = man_node_alloc(man, line, pos, ROFFT_BODY, tok);
man_node_append(man, p);
@@ -262,9 +261,9 @@ man_body_alloc(struct man *man, int line, int pos, enum mant tok)
}
void
-man_block_alloc(struct man *man, int line, int pos, enum mant tok)
+man_block_alloc(struct man *man, int line, int pos, int tok)
{
- struct man_node *p;
+ struct roff_node *p;
p = man_node_alloc(man, line, pos, ROFFT_BLOCK, tok);
man_node_append(man, p);
@@ -274,7 +273,7 @@ man_block_alloc(struct man *man, int line, int pos, enum mant tok)
void
man_word_alloc(struct man *man, int line, int pos, const char *word)
{
- struct man_node *n;
+ struct roff_node *n;
n = man_node_alloc(man, line, pos, ROFFT_TEXT, MAN_MAX);
n->string = roff_strdup(man->roff, word);
@@ -285,7 +284,7 @@ man_word_alloc(struct man *man, int line, int pos, const char *word)
void
man_word_append(struct man *man, const char *word)
{
- struct man_node *n;
+ struct roff_node *n;
char *addstr, *newstr;
n = man->last;
@@ -302,7 +301,7 @@ man_word_append(struct man *man, const char *word)
* node from its context; for that, see man_node_unlink().
*/
static void
-man_node_free(struct man_node *p)
+man_node_free(struct roff_node *p)
{
free(p->string);
@@ -310,7 +309,7 @@ man_node_free(struct man_node *p)
}
void
-man_node_delete(struct man *man, struct man_node *p)
+man_node_delete(struct man *man, struct roff_node *p)
{
while (p->child)
@@ -323,7 +322,7 @@ man_node_delete(struct man *man, struct man_node *p)
void
man_addeqn(struct man *man, const struct eqn *ep)
{
- struct man_node *n;
+ struct roff_node *n;
n = man_node_alloc(man, ep->ln, ep->pos, ROFFT_EQN, MAN_MAX);
n->eqn = ep;
@@ -337,7 +336,7 @@ man_addeqn(struct man *man, const struct eqn *ep)
void
man_addspan(struct man *man, const struct tbl_span *sp)
{
- struct man_node *n;
+ struct roff_node *n;
man_breakscope(man, MAN_MAX);
n = man_node_alloc(man, sp->line, 0, ROFFT_TBL, MAN_MAX);
@@ -438,9 +437,9 @@ man_ptext(struct man *man, int line, char *buf, int offs)
static int
man_pmacro(struct man *man, int ln, char *buf, int offs)
{
- struct man_node *n;
+ struct roff_node *n;
const char *cp;
- enum mant tok;
+ int tok;
int i, ppos;
int bline;
char mac[5];
@@ -536,9 +535,9 @@ man_pmacro(struct man *man, int ln, char *buf, int offs)
}
void
-man_breakscope(struct man *man, enum mant tok)
+man_breakscope(struct man *man, int tok)
{
- struct man_node *n;
+ struct roff_node *n;
/*
* An element next line scope is open,
@@ -596,7 +595,7 @@ man_breakscope(struct man *man, enum mant tok)
* point will also be adjusted accordingly.
*/
static void
-man_node_unlink(struct man *man, struct man_node *n)
+man_node_unlink(struct man *man, struct roff_node *n)
{
/* Adjust siblings. */
@@ -641,7 +640,7 @@ man_mparse(const struct man *man)
}
void
-man_deroff(char **dest, const struct man_node *n)
+man_deroff(char **dest, const struct roff_node *n)
{
char *cp;
size_t sz;
diff --git a/man.h b/man.h
index ae53a359..66f75813 100644
--- a/man.h
+++ b/man.h
@@ -1,62 +1,60 @@
-/* $Id: man.h,v 1.70 2015/04/02 21:36:49 schwarze Exp $ */
+/* $Id: man.h,v 1.71 2015/04/02 22:48:17 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 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
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-enum mant {
- MAN_br = 0,
- MAN_TH,
- MAN_SH,
- MAN_SS,
- MAN_TP,
- MAN_LP,
- MAN_PP,
- MAN_P,
- MAN_IP,
- MAN_HP,
- MAN_SM,
- MAN_SB,
- MAN_BI,
- MAN_IB,
- MAN_BR,
- MAN_RB,
- MAN_R,
- MAN_B,
- MAN_I,
- MAN_IR,
- MAN_RI,
- MAN_sp,
- MAN_nf,
- MAN_fi,
- MAN_RE,
- MAN_RS,
- MAN_DT,
- MAN_UC,
- MAN_PD,
- MAN_AT,
- MAN_in,
- MAN_ft,
- MAN_OP,
- MAN_EX,
- MAN_EE,
- MAN_UR,
- MAN_UE,
- MAN_ll,
- MAN_MAX
-};
+#define MAN_br 0
+#define MAN_TH 1
+#define MAN_SH 2
+#define MAN_SS 3
+#define MAN_TP 4
+#define MAN_LP 5
+#define MAN_PP 6
+#define MAN_P 7
+#define MAN_IP 8
+#define MAN_HP 9
+#define MAN_SM 10
+#define MAN_SB 11
+#define MAN_BI 12
+#define MAN_IB 13
+#define MAN_BR 14
+#define MAN_RB 15
+#define MAN_R 16
+#define MAN_B 17
+#define MAN_I 18
+#define MAN_IR 19
+#define MAN_RI 20
+#define MAN_sp 21
+#define MAN_nf 22
+#define MAN_fi 23
+#define MAN_RE 24
+#define MAN_RS 25
+#define MAN_DT 26
+#define MAN_UC 27
+#define MAN_PD 28
+#define MAN_AT 29
+#define MAN_in 30
+#define MAN_ft 31
+#define MAN_OP 32
+#define MAN_EX 33
+#define MAN_EE 34
+#define MAN_UR 35
+#define MAN_UE 36
+#define MAN_ll 37
+#define MAN_MAX 38
struct man_meta {
char *msec; /* `TH' section (1, 3p, etc.) */
@@ -67,39 +65,16 @@ struct man_meta {
int hasbody; /* document is not empty */
};
-struct man_node {
- struct man_node *parent; /* parent AST node */
- struct man_node *child; /* first child AST node */
- struct man_node *next; /* sibling AST node */
- struct man_node *prev; /* prior sibling AST node */
- int nchild; /* number children */
- int line;
- int pos;
- enum mant tok; /* tok or MAN__MAX if none */
- int flags;
-#define MAN_VALID (1 << 0) /* has been validated */
-#define MAN_EOS (1 << 2) /* at sentence boundary */
-#define MAN_LINE (1 << 3) /* first macro/text on line */
- enum roff_type type; /* AST node type */
- char *string; /* TEXT node argument */
- struct man_node *head; /* BLOCK node HEAD ptr */
- struct man_node *tail; /* BLOCK node TAIL ptr */
- struct man_node *body; /* BLOCK node BODY ptr */
- const struct tbl_span *span; /* TBL */
- const struct eqn *eqn; /* EQN */
- int aux; /* decoded node data, type-dependent */
-};
-
-/* Names of macros. Index is enum mant. */
+/* Names of macros. */
extern const char *const *man_macronames;
__BEGIN_DECLS
struct man;
-const struct man_node *man_node(const struct man *);
+const struct roff_node *man_node(const struct man *);
const struct man_meta *man_meta(const struct man *);
const struct mparse *man_mparse(const struct man *);
-void man_deroff(char **, const struct man_node *);
+void man_deroff(char **, const struct roff_node *);
__END_DECLS
diff --git a/man_hash.c b/man_hash.c
index d24d9ecf..8726614a 100644
--- a/man_hash.c
+++ b/man_hash.c
@@ -1,4 +1,4 @@
-/* $Id: man_hash.c,v 1.30 2015/04/02 21:36:49 schwarze Exp $ */
+/* $Id: man_hash.c,v 1.31 2015/04/02 22:48:17 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -77,11 +77,11 @@ man_hash_init(void)
}
}
-enum mant
+int
man_hash_find(const char *tmp)
{
int x, y, i;
- enum mant tok;
+ int tok;
if ('\0' == (x = tmp[0]))
return(MAN_MAX);
@@ -94,7 +94,7 @@ man_hash_find(const char *tmp)
if (UCHAR_MAX == (y = table[x + i]))
return(MAN_MAX);
- tok = (enum mant)y;
+ tok = y;
if (0 == strcmp(tmp, man_macronames[tok]))
return(tok);
}
diff --git a/man_html.c b/man_html.c
index 0967b3bb..7533e979 100644
--- a/man_html.c
+++ b/man_html.c
@@ -1,4 +1,4 @@
-/* $Id: man_html.c,v 1.113 2015/04/02 21:36:49 schwarze Exp $ */
+/* $Id: man_html.c,v 1.114 2015/04/02 22:48:17 schwarze Exp $ */
/*
* Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -38,7 +38,7 @@
#define INDENT 5
#define MAN_ARGS const struct man_meta *man, \
- const struct man_node *n, \
+ const struct roff_node *n, \
struct mhtml *mh, \
struct html *h
@@ -53,12 +53,12 @@ struct htmlman {
};
static void print_bvspace(struct html *,
- const struct man_node *);
+ const struct roff_node *);
static void print_man(MAN_ARGS);
static void print_man_head(MAN_ARGS);
static void print_man_nodelist(MAN_ARGS);
static void print_man_node(MAN_ARGS);
-static int a2width(const struct man_node *,
+static int a2width(const struct roff_node *,
struct roffsu *);
static int man_B_pre(MAN_ARGS);
static int man_HP_pre(MAN_ARGS);
@@ -130,7 +130,7 @@ static const struct htmlman mans[MAN_MAX] = {
* first, print it.
*/
static void
-print_bvspace(struct html *h, const struct man_node *n)
+print_bvspace(struct html *h, const struct roff_node *n)
{
if (n->body && n->body->child)
@@ -280,7 +280,7 @@ print_man_node(MAN_ARGS)
}
static int
-a2width(const struct man_node *n, struct roffsu *su)
+a2width(const struct roff_node *n, struct roffsu *su)
{
if (n->type != ROFFT_TEXT)
@@ -400,7 +400,7 @@ man_SH_pre(MAN_ARGS)
static int
man_alt_pre(MAN_ARGS)
{
- const struct man_node *nn;
+ const struct roff_node *nn;
int i, savelit;
enum htmltag fp;
struct tag *t;
@@ -496,7 +496,7 @@ man_PP_pre(MAN_ARGS)
static int
man_IP_pre(MAN_ARGS)
{
- const struct man_node *nn;
+ const struct roff_node *nn;
if (n->type == ROFFT_BODY) {
print_otag(h, TAG_DD, 0, NULL);
@@ -535,7 +535,7 @@ man_HP_pre(MAN_ARGS)
{
struct htmlpair tag[2];
struct roffsu su;
- const struct man_node *np;
+ const struct roff_node *np;
if (n->type == ROFFT_HEAD)
return(0);
diff --git a/man_macro.c b/man_macro.c
index bf891c05..0de6f7ee 100644
--- a/man_macro.c
+++ b/man_macro.c
@@ -1,4 +1,4 @@
-/* $Id: man_macro.c,v 1.101 2015/04/02 21:36:50 schwarze Exp $ */
+/* $Id: man_macro.c,v 1.102 2015/04/02 22:48:17 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2012, 2013, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -44,12 +44,11 @@ static void in_line_eoln(MACRO_PROT_ARGS);
static int man_args(struct man *, int,
int *, char *, char **);
-static void rew_scope(enum roff_type,
- struct man *, enum mant);
-static enum rew rew_dohalt(enum mant, enum roff_type,
- const struct man_node *);
-static enum rew rew_block(enum mant, enum roff_type,
- const struct man_node *);
+static void rew_scope(enum roff_type, struct man *, int);
+static enum rew rew_dohalt(int, enum roff_type,
+ const struct roff_node *);
+static enum rew rew_block(int, enum roff_type,
+ const struct roff_node *);
const struct man_macro __man_macros[MAN_MAX] = {
{ in_line_eoln, MAN_NSCOPED }, /* br */
@@ -96,9 +95,9 @@ const struct man_macro * const man_macros = __man_macros;
void
-man_unscope(struct man *man, const struct man_node *to)
+man_unscope(struct man *man, const struct roff_node *to)
{
- struct man_node *n;
+ struct roff_node *n;
to = to->parent;
n = man->last;
@@ -156,7 +155,7 @@ man_unscope(struct man *man, const struct man_node *to)
}
static enum rew
-rew_block(enum mant ntok, enum roff_type type, const struct man_node *n)
+rew_block(int ntok, enum roff_type type, const struct roff_node *n)
{
if (type == ROFFT_BLOCK && n->parent->tok == ntok &&
@@ -171,7 +170,7 @@ rew_block(enum mant ntok, enum roff_type type, const struct man_node *n)
* sections and subsections).
*/
static enum rew
-rew_dohalt(enum mant tok, enum roff_type type, const struct man_node *n)
+rew_dohalt(int tok, enum roff_type type, const struct roff_node *n)
{
enum rew c;
@@ -244,9 +243,9 @@ rew_dohalt(enum mant tok, enum roff_type type, const struct man_node *n)
* scopes. When a scope is closed, it must be validated and actioned.
*/
static void
-rew_scope(enum roff_type type, struct man *man, enum mant tok)
+rew_scope(enum roff_type type, struct man *man, int tok)
{
- struct man_node *n;
+ struct roff_node *n;
enum rew c;
for (n = man->last; n; n = n->parent) {
@@ -277,8 +276,8 @@ rew_scope(enum roff_type type, struct man *man, enum mant tok)
void
blk_close(MACRO_PROT_ARGS)
{
- enum mant ntok;
- const struct man_node *nn;
+ int ntok;
+ const struct roff_node *nn;
char *p;
int nrew, target;
@@ -338,7 +337,7 @@ blk_close(MACRO_PROT_ARGS)
void
blk_exp(MACRO_PROT_ARGS)
{
- struct man_node *head;
+ struct roff_node *head;
char *p;
int la;
@@ -371,7 +370,7 @@ blk_imp(MACRO_PROT_ARGS)
{
int la;
char *p;
- struct man_node *n;
+ struct roff_node *n;
rew_scope(ROFFT_BODY, man, tok);
rew_scope(ROFFT_BLOCK, man, tok);
@@ -411,7 +410,7 @@ in_line_eoln(MACRO_PROT_ARGS)
{
int la;
char *p;
- struct man_node *n;
+ struct roff_node *n;
man_elem_alloc(man, line, ppos, tok);
n = man->last;
diff --git a/man_term.c b/man_term.c
index 416824ed..cd1a2099 100644
--- a/man_term.c
+++ b/man_term.c
@@ -1,4 +1,4 @@
-/* $Id: man_term.c,v 1.171 2015/04/02 21:36:50 schwarze Exp $ */
+/* $Id: man_term.c,v 1.172 2015/04/02 22:48:17 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -48,7 +48,7 @@ struct mtermp {
#define DECL_ARGS struct termp *p, \
struct mtermp *mt, \
- struct man_node *n, \
+ struct roff_node *n, \
const struct man_meta *meta
struct termact {
@@ -63,7 +63,7 @@ static void print_man_node(DECL_ARGS);
static void print_man_head(struct termp *, const void *);
static void print_man_foot(struct termp *, const void *);
static void print_bvspace(struct termp *,
- const struct man_node *, int);
+ const struct roff_node *, int);
static int pre_B(DECL_ARGS);
static int pre_HP(DECL_ARGS);
@@ -140,7 +140,7 @@ terminal_man(void *arg, const struct man *man)
{
struct termp *p;
const struct man_meta *meta;
- struct man_node *n;
+ struct roff_node *n;
struct mtermp mt;
p = (struct termp *)arg;
@@ -191,7 +191,7 @@ terminal_man(void *arg, const struct man *man)
* first, print it.
*/
static void
-print_bvspace(struct termp *p, const struct man_node *n, int pardist)
+print_bvspace(struct termp *p, const struct roff_node *n, int pardist)
{
int i;
@@ -280,7 +280,7 @@ static int
pre_alternate(DECL_ARGS)
{
enum termfont font[2];
- struct man_node *nn;
+ struct roff_node *nn;
int savelit, i;
switch (n->tok) {
@@ -488,7 +488,7 @@ static int
pre_HP(DECL_ARGS)
{
struct roffsu su;
- const struct man_node *nn;
+ const struct roff_node *nn;
int len;
switch (n->type) {
@@ -562,7 +562,7 @@ static int
pre_IP(DECL_ARGS)
{
struct roffsu su;
- const struct man_node *nn;
+ const struct roff_node *nn;
int len, savelit;
switch (n->type) {
@@ -643,7 +643,7 @@ static int
pre_TP(DECL_ARGS)
{
struct roffsu su;
- struct man_node *nn;
+ struct roff_node *nn;
int len, savelit;
switch (n->type) {
diff --git a/man_validate.c b/man_validate.c
index 8614708b..a73be7ca 100644
--- a/man_validate.c
+++ b/man_validate.c
@@ -35,7 +35,7 @@
#include "libmandoc.h"
#include "libman.h"
-#define CHKARGS struct man *man, struct man_node *n
+#define CHKARGS struct man *man, struct roff_node *n
typedef void (*v_check)(CHKARGS);
@@ -100,7 +100,7 @@ static v_check man_valids[MAN_MAX] = {
void
man_valid_post(struct man *man)
{
- struct man_node *n;
+ struct roff_node *n;
v_check *cp;
n = man->last;
@@ -300,7 +300,7 @@ post_IP(CHKARGS)
static void
post_TH(CHKARGS)
{
- struct man_node *nb;
+ struct roff_node *nb;
const char *p;
free(man->meta.title);
@@ -460,8 +460,8 @@ post_AT(CHKARGS)
"System V Release 2",
};
+ struct roff_node *nn;
const char *p, *s;
- struct man_node *nn;
n = n->child;
diff --git a/mandoc_headers.3 b/mandoc_headers.3
index 52ac2890..d3400876 100644
--- a/mandoc_headers.3
+++ b/mandoc_headers.3
@@ -118,7 +118,19 @@ from
as opaque types for function prototypes.
.It Qq Pa roff.h
Provides
-.Vt enum roff_type .
+.Vt enum mdoc_endbody ,
+.Vt enum roff_sec ,
+.Vt enum roff_type ,
+and
+.Vt struct roff_node .
+.Pp
+Uses pointers to the types
+.Vt struct mdoc_arg
+and
+.Vt union mdoc_data
+from
+.Qq Pa mdoc.h
+as opaque struct members.
.El
.Pp
The following two require
@@ -137,10 +149,7 @@ for
.Vt enum roff_type .
.Pp
Provides
-.Vt enum mdoct ,
.Vt enum mdocargt ,
-.Vt enum mdoc_sec ,
-.Vt enum mdoc_endbody ,
.Vt enum mdoc_disp ,
.Vt enum mdoc_list ,
.Vt enum mdoc_auth ,
@@ -153,7 +162,6 @@ Provides
.Vt struct mdoc_an ,
.Vt struct mdoc_bf ,
.Vt struct mdoc_rs ,
-.Vt struct mdoc_node ,
and the functions
.Fn mdoc_*
described in
@@ -181,9 +189,7 @@ for
.Vt enum roff_type .
.Pp
Provides
-.Vt enum mant ,
-.Vt struct man_meta ,
-.Vt struct man_node ,
+.Vt struct man_meta
and the functions
.Fn man_*
described in
@@ -259,8 +265,7 @@ as opaque types for function prototypes.
Requires
.Qq Pa mdoc.h
for
-.Vt enum mdoct ,
-.Vt enum mdoc_* ,
+.Vt enum mdoc_*
and
.Vt struct mdoc_* .
.Pp
@@ -290,11 +295,9 @@ or
.Pa libroff.h .
.It Qq Pa libman.h
Requires
-.Qq Pa man.h
+.Qq Pa roff.h
for
-.Vt enum mant
-and
-.Vt struct man_node.
+.Vt struct roff_node.
.Pp
Provides
.Vt enum man_next ,
diff --git a/mandocdb.c b/mandocdb.c
index 84e2d5bb..73d7b108 100644
--- a/mandocdb.c
+++ b/mandocdb.c
@@ -1,4 +1,4 @@
-/* $Id: mandocdb.c,v 1.188 2015/04/02 21:36:50 schwarze Exp $ */
+/* $Id: mandocdb.c,v 1.189 2015/04/02 22:48:17 schwarze Exp $ */
/*
* Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -131,7 +131,7 @@ enum stmt {
};
typedef int (*mdoc_fp)(struct mpage *, const struct mdoc_meta *,
- const struct mdoc_node *);
+ const struct roff_node *);
struct mdoc_handler {
mdoc_fp fp; /* optional handler */
@@ -157,32 +157,32 @@ static void mpages_merge(struct mparse *);
static void names_check(void);
static void parse_cat(struct mpage *, int);
static void parse_man(struct mpage *, const struct man_meta *,
- const struct man_node *);
+ const struct roff_node *);
static void parse_mdoc(struct mpage *, const struct mdoc_meta *,
- const struct mdoc_node *);
+ const struct roff_node *);
static int parse_mdoc_body(struct mpage *, const struct mdoc_meta *,
- const struct mdoc_node *);
+ const struct roff_node *);
static int parse_mdoc_head(struct mpage *, const struct mdoc_meta *,
- const struct mdoc_node *);
+ const struct roff_node *);
static int parse_mdoc_Fd(struct mpage *, const struct mdoc_meta *,
- const struct mdoc_node *);
-static void parse_mdoc_fname(struct mpage *, const struct mdoc_node *);
+ const struct roff_node *);
+static void parse_mdoc_fname(struct mpage *, const struct roff_node *);
static int parse_mdoc_Fn(struct mpage *, const struct mdoc_meta *,
- const struct mdoc_node *);
+ const struct roff_node *);
static int parse_mdoc_Fo(struct mpage *, const struct mdoc_meta *,
- const struct mdoc_node *);
+ const struct roff_node *);
static int parse_mdoc_Nd(struct mpage *, const struct mdoc_meta *,
- const struct mdoc_node *);
+ const struct roff_node *);
static int parse_mdoc_Nm(struct mpage *, const struct mdoc_meta *,
- const struct mdoc_node *);
+ const struct roff_node *);
static int parse_mdoc_Sh(struct mpage *, const struct mdoc_meta *,
- const struct mdoc_node *);
+ const struct roff_node *);
static int parse_mdoc_Xr(struct mpage *, const struct mdoc_meta *,
- const struct mdoc_node *);
+ const struct roff_node *);
static void putkey(const struct mpage *, char *, uint64_t);
static void putkeys(const struct mpage *, char *, size_t, uint64_t);
static void putmdockey(const struct mpage *,
- const struct mdoc_node *, uint64_t);
+ const struct roff_node *, uint64_t);
static int render_string(char **, size_t *);
static void say(const char *, const char *, ...);
static int set_basedir(const char *, int);
@@ -1431,7 +1431,7 @@ putkey(const struct mpage *mpage, char *value, uint64_t type)
*/
static void
putmdockey(const struct mpage *mpage,
- const struct mdoc_node *n, uint64_t m)
+ const struct roff_node *n, uint64_t m)
{
for ( ; NULL != n; n = n->next) {
@@ -1444,9 +1444,9 @@ putmdockey(const struct mpage *mpage,
static void
parse_man(struct mpage *mpage, const struct man_meta *meta,
- const struct man_node *n)
+ const struct roff_node *n)
{
- const struct man_node *head, *body;
+ const struct roff_node *head, *body;
char *start, *title;
char byte;
size_t sz;
@@ -1570,7 +1570,7 @@ parse_man(struct mpage *mpage, const struct man_meta *meta,
static void
parse_mdoc(struct mpage *mpage, const struct mdoc_meta *meta,
- const struct mdoc_node *n)
+ const struct roff_node *n)
{
assert(NULL != n);
@@ -1603,7 +1603,7 @@ parse_mdoc(struct mpage *mpage, const struct mdoc_meta *meta,
static int
parse_mdoc_Fd(struct mpage *mpage, const struct mdoc_meta *meta,
- const struct mdoc_node *n)
+ const struct roff_node *n)
{
char *start, *end;
size_t sz;
@@ -1646,7 +1646,7 @@ parse_mdoc_Fd(struct mpage *mpage, const struct mdoc_meta *meta,
}
static void
-parse_mdoc_fname(struct mpage *mpage, const struct mdoc_node *n)
+parse_mdoc_fname(struct mpage *mpage, const struct roff_node *n)
{
char *cp;
size_t sz;
@@ -1668,7 +1668,7 @@ parse_mdoc_fname(struct mpage *mpage, const struct mdoc_node *n)
static int
parse_mdoc_Fn(struct mpage *mpage, const struct mdoc_meta *meta,
- const struct mdoc_node *n)
+ const struct roff_node *n)
{
if (n->child == NULL)
@@ -1685,7 +1685,7 @@ parse_mdoc_Fn(struct mpage *mpage, const struct mdoc_meta *meta,
static int
parse_mdoc_Fo(struct mpage *mpage, const struct mdoc_meta *meta,
- const struct mdoc_node *n)
+ const struct roff_node *n)
{
if (n->type != ROFFT_HEAD)
@@ -1699,7 +1699,7 @@ parse_mdoc_Fo(struct mpage *mpage, const struct mdoc_meta *meta,
static int
parse_mdoc_Xr(struct mpage *mpage, const struct mdoc_meta *meta,
- const struct mdoc_node *n)
+ const struct roff_node *n)
{
char *cp;
@@ -1719,7 +1719,7 @@ parse_mdoc_Xr(struct mpage *mpage, const struct mdoc_meta *meta,
static int
parse_mdoc_Nd(struct mpage *mpage, const struct mdoc_meta *meta,
- const struct mdoc_node *n)
+ const struct roff_node *n)
{
if (n->type == ROFFT_BODY)
@@ -1729,7 +1729,7 @@ parse_mdoc_Nd(struct mpage *mpage, const struct mdoc_meta *meta,
static int
parse_mdoc_Nm(struct mpage *mpage, const struct mdoc_meta *meta,
- const struct mdoc_node *n)
+ const struct roff_node *n)
{
if (SEC_NAME == n->sec)
@@ -1751,7 +1751,7 @@ parse_mdoc_Nm(struct mpage *mpage, const struct mdoc_meta *meta,
static int
parse_mdoc_Sh(struct mpage *mpage, const struct mdoc_meta *meta,
- const struct mdoc_node *n)
+ const struct roff_node *n)
{
return(n->sec == SEC_CUSTOM && n->type == ROFFT_HEAD);
@@ -1759,7 +1759,7 @@ parse_mdoc_Sh(struct mpage *mpage, const struct mdoc_meta *meta,
static int
parse_mdoc_head(struct mpage *mpage, const struct mdoc_meta *meta,
- const struct mdoc_node *n)
+ const struct roff_node *n)
{
return(n->type == ROFFT_HEAD);
@@ -1767,7 +1767,7 @@ parse_mdoc_head(struct mpage *mpage, const struct mdoc_meta *meta,
static int
parse_mdoc_body(struct mpage *mpage, const struct mdoc_meta *meta,
- const struct mdoc_node *n)
+ const struct roff_node *n)
{
return(n->type == ROFFT_BODY);
diff --git a/mdoc.c b/mdoc.c
index 6bf8dc3f..9890b79b 100644
--- a/mdoc.c
+++ b/mdoc.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc.c,v 1.239 2015/04/02 21:36:50 schwarze Exp $ */
+/* $Id: mdoc.c,v 1.240 2015/04/02 22:48:17 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -83,19 +83,19 @@ const char *const __mdoc_argnames[MDOC_ARG_MAX] = {
const char * const *mdoc_macronames = __mdoc_macronames;
const char * const *mdoc_argnames = __mdoc_argnames;
-static void mdoc_node_free(struct mdoc_node *);
+static void mdoc_node_free(struct roff_node *);
static void mdoc_node_unlink(struct mdoc *,
- struct mdoc_node *);
+ struct roff_node *);
static void mdoc_free1(struct mdoc *);
static void mdoc_alloc1(struct mdoc *);
-static struct mdoc_node *node_alloc(struct mdoc *, int, int,
- enum mdoct, enum roff_type);
-static void node_append(struct mdoc *, struct mdoc_node *);
+static struct roff_node *node_alloc(struct mdoc *, 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);
-const struct mdoc_node *
+const struct roff_node *
mdoc_node(const struct mdoc *mdoc)
{
@@ -137,7 +137,7 @@ mdoc_alloc1(struct mdoc *mdoc)
memset(&mdoc->meta, 0, sizeof(struct mdoc_meta));
mdoc->flags = 0;
mdoc->lastnamed = mdoc->lastsec = SEC_NONE;
- mdoc->last = mandoc_calloc(1, sizeof(struct mdoc_node));
+ mdoc->last = mandoc_calloc(1, sizeof(*mdoc->last));
mdoc->first = mdoc->last;
mdoc->last->type = ROFFT_ROOT;
mdoc->last->tok = MDOC_MAX;
@@ -201,7 +201,7 @@ mdoc_endparse(struct mdoc *mdoc)
void
mdoc_addeqn(struct mdoc *mdoc, const struct eqn *ep)
{
- struct mdoc_node *n;
+ struct roff_node *n;
n = node_alloc(mdoc, ep->ln, ep->pos, MDOC_MAX, ROFFT_EQN);
n->eqn = ep;
@@ -214,7 +214,7 @@ mdoc_addeqn(struct mdoc *mdoc, const struct eqn *ep)
void
mdoc_addspan(struct mdoc *mdoc, const struct tbl_span *sp)
{
- struct mdoc_node *n;
+ struct roff_node *n;
n = node_alloc(mdoc, sp->line, 0, MDOC_MAX, ROFFT_TBL);
n->span = sp;
@@ -277,7 +277,7 @@ mdoc_macro(MACRO_PROT_ARGS)
static void
-node_append(struct mdoc *mdoc, struct mdoc_node *p)
+node_append(struct mdoc *mdoc, struct roff_node *p)
{
assert(mdoc->last);
@@ -354,13 +354,13 @@ node_append(struct mdoc *mdoc, struct mdoc_node *p)
}
}
-static struct mdoc_node *
+static struct roff_node *
node_alloc(struct mdoc *mdoc, int line, int pos,
- enum mdoct tok, enum roff_type type)
+ int tok, enum roff_type type)
{
- struct mdoc_node *p;
+ struct roff_node *p;
- p = mandoc_calloc(1, sizeof(struct mdoc_node));
+ p = mandoc_calloc(1, sizeof(*p));
p->sec = mdoc->lastsec;
p->line = line;
p->pos = pos;
@@ -381,19 +381,19 @@ node_alloc(struct mdoc *mdoc, int line, int pos,
}
void
-mdoc_tail_alloc(struct mdoc *mdoc, int line, int pos, enum mdoct tok)
+mdoc_tail_alloc(struct mdoc *mdoc, int line, int pos, int tok)
{
- struct mdoc_node *p;
+ struct roff_node *p;
p = node_alloc(mdoc, line, pos, tok, ROFFT_TAIL);
node_append(mdoc, p);
mdoc->next = MDOC_NEXT_CHILD;
}
-struct mdoc_node *
-mdoc_head_alloc(struct mdoc *mdoc, int line, int pos, enum mdoct tok)
+struct roff_node *
+mdoc_head_alloc(struct mdoc *mdoc, int line, int pos, int tok)
{
- struct mdoc_node *p;
+ struct roff_node *p;
assert(mdoc->first);
assert(mdoc->last);
@@ -403,10 +403,10 @@ mdoc_head_alloc(struct mdoc *mdoc, int line, int pos, enum mdoct tok)
return(p);
}
-struct mdoc_node *
-mdoc_body_alloc(struct mdoc *mdoc, int line, int pos, enum mdoct tok)
+struct roff_node *
+mdoc_body_alloc(struct mdoc *mdoc, int line, int pos, int tok)
{
- struct mdoc_node *p;
+ struct roff_node *p;
p = node_alloc(mdoc, line, pos, tok, ROFFT_BODY);
node_append(mdoc, p);
@@ -414,11 +414,11 @@ mdoc_body_alloc(struct mdoc *mdoc, int line, int pos, enum mdoct tok)
return(p);
}
-struct mdoc_node *
-mdoc_endbody_alloc(struct mdoc *mdoc, int line, int pos, enum mdoct tok,
- struct mdoc_node *body, enum mdoc_endbody end)
+struct roff_node *
+mdoc_endbody_alloc(struct mdoc *mdoc, int line, int pos, int tok,
+ struct roff_node *body, enum mdoc_endbody end)
{
- struct mdoc_node *p;
+ struct roff_node *p;
body->flags |= MDOC_ENDED;
body->parent->flags |= MDOC_ENDED;
@@ -431,11 +431,11 @@ mdoc_endbody_alloc(struct mdoc *mdoc, int line, int pos, enum mdoct tok,
return(p);
}
-struct mdoc_node *
+struct roff_node *
mdoc_block_alloc(struct mdoc *mdoc, int line, int pos,
- enum mdoct tok, struct mdoc_arg *args)
+ int tok, struct mdoc_arg *args)
{
- struct mdoc_node *p;
+ struct roff_node *p;
p = node_alloc(mdoc, line, pos, tok, ROFFT_BLOCK);
p->args = args;
@@ -464,9 +464,9 @@ mdoc_block_alloc(struct mdoc *mdoc, int line, int pos,
void
mdoc_elem_alloc(struct mdoc *mdoc, int line, int pos,
- enum mdoct tok, struct mdoc_arg *args)
+ int tok, struct mdoc_arg *args)
{
- struct mdoc_node *p;
+ struct roff_node *p;
p = node_alloc(mdoc, line, pos, tok, ROFFT_ELEM);
p->args = args;
@@ -487,7 +487,7 @@ mdoc_elem_alloc(struct mdoc *mdoc, int line, int pos,
void
mdoc_word_alloc(struct mdoc *mdoc, int line, int pos, const char *p)
{
- struct mdoc_node *n;
+ struct roff_node *n;
n = node_alloc(mdoc, line, pos, MDOC_MAX, ROFFT_TEXT);
n->string = roff_strdup(mdoc->roff, p);
@@ -498,7 +498,7 @@ mdoc_word_alloc(struct mdoc *mdoc, int line, int pos, const char *p)
void
mdoc_word_append(struct mdoc *mdoc, const char *p)
{
- struct mdoc_node *n;
+ struct roff_node *n;
char *addstr, *newstr;
n = mdoc->last;
@@ -511,7 +511,7 @@ mdoc_word_append(struct mdoc *mdoc, const char *p)
}
static void
-mdoc_node_free(struct mdoc_node *p)
+mdoc_node_free(struct roff_node *p)
{
if (p->type == ROFFT_BLOCK || p->type == ROFFT_ELEM)
@@ -524,7 +524,7 @@ mdoc_node_free(struct mdoc_node *p)
}
static void
-mdoc_node_unlink(struct mdoc *mdoc, struct mdoc_node *n)
+mdoc_node_unlink(struct mdoc *mdoc, struct roff_node *n)
{
/* Adjust siblings. */
@@ -561,7 +561,7 @@ mdoc_node_unlink(struct mdoc *mdoc, struct mdoc_node *n)
}
void
-mdoc_node_delete(struct mdoc *mdoc, struct mdoc_node *p)
+mdoc_node_delete(struct mdoc *mdoc, struct roff_node *p)
{
while (p->child) {
@@ -575,7 +575,7 @@ mdoc_node_delete(struct mdoc *mdoc, struct mdoc_node *p)
}
void
-mdoc_node_relink(struct mdoc *mdoc, struct mdoc_node *p)
+mdoc_node_relink(struct mdoc *mdoc, struct roff_node *p)
{
mdoc_node_unlink(mdoc, p);
@@ -589,8 +589,8 @@ mdoc_node_relink(struct mdoc *mdoc, struct mdoc_node *p)
static int
mdoc_ptext(struct mdoc *mdoc, int line, char *buf, int offs)
{
+ struct roff_node *n;
char *c, *ws, *end;
- struct mdoc_node *n;
assert(mdoc->last);
n = mdoc->last;
@@ -705,9 +705,9 @@ mdoc_ptext(struct mdoc *mdoc, int line, char *buf, int offs)
static int
mdoc_pmacro(struct mdoc *mdoc, int ln, char *buf, int offs)
{
- struct mdoc_node *n;
+ struct roff_node *n;
const char *cp;
- enum mdoct tok;
+ int tok;
int i, sv;
char mac[5];
@@ -861,7 +861,7 @@ mdoc_isdelim(const char *p)
}
void
-mdoc_deroff(char **dest, const struct mdoc_node *n)
+mdoc_deroff(char **dest, const struct roff_node *n)
{
char *cp;
size_t sz;
diff --git a/mdoc.h b/mdoc.h
index 6a428c3f..ad2ef3ac 100644
--- a/mdoc.h
+++ b/mdoc.h
@@ -1,4 +1,4 @@
-/* $Id: mdoc.h,v 1.137 2015/04/02 21:36:50 schwarze Exp $ */
+/* $Id: mdoc.h,v 1.138 2015/04/02 22:48:17 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -16,132 +16,130 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-enum mdoct {
- MDOC_Ap = 0,
- MDOC_Dd,
- MDOC_Dt,
- MDOC_Os,
- MDOC_Sh,
- MDOC_Ss,
- MDOC_Pp,
- MDOC_D1,
- MDOC_Dl,
- MDOC_Bd,
- MDOC_Ed,
- MDOC_Bl,
- MDOC_El,
- MDOC_It,
- MDOC_Ad,
- MDOC_An,
- MDOC_Ar,
- MDOC_Cd,
- MDOC_Cm,
- MDOC_Dv,
- MDOC_Er,
- MDOC_Ev,
- MDOC_Ex,
- MDOC_Fa,
- MDOC_Fd,
- MDOC_Fl,
- MDOC_Fn,
- MDOC_Ft,
- MDOC_Ic,
- MDOC_In,
- MDOC_Li,
- MDOC_Nd,
- MDOC_Nm,
- MDOC_Op,
- MDOC_Ot,
- MDOC_Pa,
- MDOC_Rv,
- MDOC_St,
- MDOC_Va,
- MDOC_Vt,
- MDOC_Xr,
- MDOC__A,
- MDOC__B,
- MDOC__D,
- MDOC__I,
- MDOC__J,
- MDOC__N,
- MDOC__O,
- MDOC__P,
- MDOC__R,
- MDOC__T,
- MDOC__V,
- MDOC_Ac,
- MDOC_Ao,
- MDOC_Aq,
- MDOC_At,
- MDOC_Bc,
- MDOC_Bf,
- MDOC_Bo,
- MDOC_Bq,
- MDOC_Bsx,
- MDOC_Bx,
- MDOC_Db,
- MDOC_Dc,
- MDOC_Do,
- MDOC_Dq,
- MDOC_Ec,
- MDOC_Ef,
- MDOC_Em,
- MDOC_Eo,
- MDOC_Fx,
- MDOC_Ms,
- MDOC_No,
- MDOC_Ns,
- MDOC_Nx,
- MDOC_Ox,
- MDOC_Pc,
- MDOC_Pf,
- MDOC_Po,
- MDOC_Pq,
- MDOC_Qc,
- MDOC_Ql,
- MDOC_Qo,
- MDOC_Qq,
- MDOC_Re,
- MDOC_Rs,
- MDOC_Sc,
- MDOC_So,
- MDOC_Sq,
- MDOC_Sm,
- MDOC_Sx,
- MDOC_Sy,
- MDOC_Tn,
- MDOC_Ux,
- MDOC_Xc,
- MDOC_Xo,
- MDOC_Fo,
- MDOC_Fc,
- MDOC_Oo,
- MDOC_Oc,
- MDOC_Bk,
- MDOC_Ek,
- MDOC_Bt,
- MDOC_Hf,
- MDOC_Fr,
- MDOC_Ud,
- MDOC_Lb,
- MDOC_Lp,
- MDOC_Lk,
- MDOC_Mt,
- MDOC_Brq,
- MDOC_Bro,
- MDOC_Brc,
- MDOC__C,
- MDOC_Es,
- MDOC_En,
- MDOC_Dx,
- MDOC__Q,
- MDOC_br,
- MDOC_sp,
- MDOC__U,
- MDOC_Ta,
- MDOC_ll,
- MDOC_MAX
-};
+#define MDOC_Ap 0
+#define MDOC_Dd 1
+#define MDOC_Dt 2
+#define MDOC_Os 3
+#define MDOC_Sh 4
+#define MDOC_Ss 5
+#define MDOC_Pp 6
+#define MDOC_D1 7
+#define MDOC_Dl 8
+#define MDOC_Bd 9
+#define MDOC_Ed 10
+#define MDOC_Bl 11
+#define MDOC_El 12
+#define MDOC_It 13
+#define MDOC_Ad 14
+#define MDOC_An 15
+#define MDOC_Ar 16
+#define MDOC_Cd 17
+#define MDOC_Cm 18
+#define MDOC_Dv 19
+#define MDOC_Er 20
+#define MDOC_Ev 21
+#define MDOC_Ex 22
+#define MDOC_Fa 23
+#define MDOC_Fd 24
+#define MDOC_Fl 25
+#define MDOC_Fn 26
+#define MDOC_Ft 27
+#define MDOC_Ic 28
+#define MDOC_In 29
+#define MDOC_Li 30
+#define MDOC_Nd 31
+#define MDOC_Nm 32
+#define MDOC_Op 33
+#define MDOC_Ot 34
+#define MDOC_Pa 35
+#define MDOC_Rv 36
+#define MDOC_St 37
+#define MDOC_Va 38
+#define MDOC_Vt 39
+#define MDOC_Xr 40
+#define MDOC__A 41
+#define MDOC__B 42
+#define MDOC__D 43
+#define MDOC__I 44
+#define MDOC__J 45
+#define MDOC__N 46
+#define MDOC__O 47
+#define MDOC__P 48
+#define MDOC__R 49
+#define MDOC__T 50
+#define MDOC__V 51
+#define MDOC_Ac 52
+#define MDOC_Ao 53
+#define MDOC_Aq 54
+#define MDOC_At 55
+#define MDOC_Bc 56
+#define MDOC_Bf 57
+#define MDOC_Bo 58
+#define MDOC_Bq 59
+#define MDOC_Bsx 60
+#define MDOC_Bx 61
+#define MDOC_Db 62
+#define MDOC_Dc 63
+#define MDOC_Do 64
+#define MDOC_Dq 65
+#define MDOC_Ec 66
+#define MDOC_Ef 67
+#define MDOC_Em 68
+#define MDOC_Eo 69
+#define MDOC_Fx 70
+#define MDOC_Ms 71
+#define MDOC_No 72
+#define MDOC_Ns 73
+#define MDOC_Nx 74
+#define MDOC_Ox 75
+#define MDOC_Pc 76
+#define MDOC_Pf 77
+#define MDOC_Po 78
+#define MDOC_Pq 79
+#define MDOC_Qc 80
+#define MDOC_Ql 81
+#define MDOC_Qo 82
+#define MDOC_Qq 83
+#define MDOC_Re 84
+#define MDOC_Rs 85
+#define MDOC_Sc 86
+#define MDOC_So 87
+#define MDOC_Sq 88
+#define MDOC_Sm 89
+#define MDOC_Sx 90
+#define MDOC_Sy 91
+#define MDOC_Tn 92
+#define MDOC_Ux 93
+#define MDOC_Xc 94
+#define MDOC_Xo 95
+#define MDOC_Fo 96
+#define MDOC_Fc 97
+#define MDOC_Oo 98
+#define MDOC_Oc 99
+#define MDOC_Bk 100
+#define MDOC_Ek 101
+#define MDOC_Bt 102
+#define MDOC_Hf 103
+#define MDOC_Fr 104
+#define MDOC_Ud 105
+#define MDOC_Lb 106
+#define MDOC_Lp 107
+#define MDOC_Lk 108
+#define MDOC_Mt 109
+#define MDOC_Brq 110
+#define MDOC_Bro 111
+#define MDOC_Brc 112
+#define MDOC__C 113
+#define MDOC_Es 114
+#define MDOC_En 115
+#define MDOC_Dx 116
+#define MDOC__Q 117
+#define MDOC_br 118
+#define MDOC_sp 119
+#define MDOC__U 120
+#define MDOC_Ta 121
+#define MDOC_ll 122
+#define MDOC_MAX 123
enum mdocargt {
MDOC_Split, /* -split */
@@ -174,39 +172,6 @@ enum mdocargt {
MDOC_ARG_MAX
};
-/*
- * Section (named/unnamed) of `Sh'. Note that these appear in the
- * conventional order imposed by mdoc.7. In the case of SEC_NONE, no
- * section has been invoked (this shouldn't happen). SEC_CUSTOM refers
- * to other sections.
- */
-enum mdoc_sec {
- SEC_NONE = 0,
- SEC_NAME, /* NAME */
- SEC_LIBRARY, /* LIBRARY */
- SEC_SYNOPSIS, /* SYNOPSIS */
- SEC_DESCRIPTION, /* DESCRIPTION */
- SEC_CONTEXT, /* CONTEXT */
- SEC_IMPLEMENTATION, /* IMPLEMENTATION NOTES */
- SEC_RETURN_VALUES, /* RETURN VALUES */
- SEC_ENVIRONMENT, /* ENVIRONMENT */
- SEC_FILES, /* FILES */
- SEC_EXIT_STATUS, /* EXIT STATUS */
- SEC_EXAMPLES, /* EXAMPLES */
- SEC_DIAGNOSTICS, /* DIAGNOSTICS */
- SEC_COMPATIBILITY, /* COMPATIBILITY */
- SEC_ERRORS, /* ERRORS */
- SEC_SEE_ALSO, /* SEE ALSO */
- SEC_STANDARDS, /* STANDARDS */
- SEC_HISTORY, /* HISTORY */
- SEC_AUTHORS, /* AUTHORS */
- SEC_CAVEATS, /* CAVEATS */
- SEC_BUGS, /* BUGS */
- SEC_SECURITY, /* SECURITY */
- SEC_CUSTOM,
- SEC__MAX
-};
-
struct mdoc_meta {
char *msec; /* `Dt' section (1, 3p, etc.) */
char *vol; /* `Dt' volume (implied) */
@@ -239,16 +204,6 @@ struct mdoc_arg {
unsigned int refcnt;
};
-/*
- * Indicates that a BODY's formatting has ended, but the scope is still
- * open. Used for syntax-broken blocks.
- */
-enum mdoc_endbody {
- ENDBODY_NOT = 0,
- ENDBODY_SPACE, /* is broken: append a space */
- ENDBODY_NOSPACE /* is broken: don't append a space */
-};
-
enum mdoc_list {
LIST__NONE = 0,
LIST_bullet, /* -bullet */
@@ -325,48 +280,11 @@ union mdoc_data {
struct mdoc_bd Bd;
struct mdoc_bf Bf;
struct mdoc_bl Bl;
- struct mdoc_node *Es;
+ struct roff_node *Es;
struct mdoc_rs Rs;
};
-/*
- * Single node in tree-linked AST.
- */
-struct mdoc_node {
- struct mdoc_node *parent; /* parent AST node */
- struct mdoc_node *child; /* first child AST node */
- struct mdoc_node *last; /* last child AST node */
- struct mdoc_node *next; /* sibling AST node */
- struct mdoc_node *prev; /* prior sibling AST node */
- int nchild; /* number children */
- int line; /* parse line */
- int pos; /* parse column */
- enum mdoct tok; /* tok or MDOC__MAX if none */
- int flags;
-#define MDOC_VALID (1 << 0) /* has been validated */
-#define MDOC_ENDED (1 << 1) /* gone past body end mark */
-#define MDOC_EOS (1 << 2) /* at sentence boundary */
-#define MDOC_LINE (1 << 3) /* first macro/text on line */
-#define MDOC_SYNPRETTY (1 << 4) /* SYNOPSIS-style formatting */
-#define MDOC_BROKEN (1 << 5) /* must validate parent when ending */
-#define MDOC_DELIMO (1 << 6)
-#define MDOC_DELIMC (1 << 7)
- enum roff_type type; /* AST node type */
- enum mdoc_sec sec; /* current named section */
- union mdoc_data *norm; /* normalised args */
- int prev_font; /* before entering this node */
- /* FIXME: these can be union'd to shave a few bytes. */
- struct mdoc_arg *args; /* BLOCK/ELEM */
- struct mdoc_node *head; /* BLOCK */
- struct mdoc_node *body; /* BLOCK/ENDBODY */
- struct mdoc_node *tail; /* BLOCK */
- char *string; /* TEXT */
- const struct tbl_span *span; /* TBL */
- const struct eqn *eqn; /* EQN */
- enum mdoc_endbody end; /* BODY */
-};
-
-/* Names of macros. Index is enum mdoct. */
+/* Names of macros. */
extern const char *const *mdoc_macronames;
/* Names of macro args. Index is enum mdocargt. */
@@ -376,8 +294,8 @@ __BEGIN_DECLS
struct mdoc;
-const struct mdoc_node *mdoc_node(const struct mdoc *);
+const struct roff_node *mdoc_node(const struct mdoc *);
const struct mdoc_meta *mdoc_meta(const struct mdoc *);
-void mdoc_deroff(char **, const struct mdoc_node *);
+void mdoc_deroff(char **, const struct roff_node *);
__END_DECLS
diff --git a/mdoc_argv.c b/mdoc_argv.c
index 9db3344c..3b917bf2 100644
--- a/mdoc_argv.c
+++ b/mdoc_argv.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_argv.c,v 1.101 2015/04/02 21:36:50 schwarze Exp $ */
+/* $Id: mdoc_argv.c,v 1.102 2015/04/02 22:48:17 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2012, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -276,7 +276,7 @@ static const struct mdocarg mdocargs[MDOC_MAX] = {
* Some flags take no argument, some one, some multiple.
*/
void
-mdoc_argv(struct mdoc *mdoc, int line, enum mdoct tok,
+mdoc_argv(struct mdoc *mdoc, int line, int tok,
struct mdoc_arg **reta, int *pos, char *buf)
{
struct mdoc_argv tmpv;
@@ -414,9 +414,9 @@ argn_free(struct mdoc_arg *p, int iarg)
enum margserr
mdoc_args(struct mdoc *mdoc, int line, int *pos,
- char *buf, enum mdoct tok, char **v)
+ char *buf, int tok, char **v)
{
- struct mdoc_node *n;
+ struct roff_node *n;
char *v_local;
enum argsflag fl;
diff --git a/mdoc_hash.c b/mdoc_hash.c
index 4513b026..cd576511 100644
--- a/mdoc_hash.c
+++ b/mdoc_hash.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_hash.c,v 1.22 2015/04/02 21:36:50 schwarze Exp $ */
+/* $Id: mdoc_hash.c,v 1.23 2015/04/02 22:48:17 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -62,7 +62,7 @@ mdoc_hash_init(void)
}
}
-enum mdoct
+int
mdoc_hash_find(const char *p)
{
int major, i, j;
@@ -86,7 +86,7 @@ mdoc_hash_find(const char *p)
if (UCHAR_MAX == (i = table[major + j]))
break;
if (0 == strcmp(p, mdoc_macronames[i]))
- return((enum mdoct)i);
+ return(i);
}
return(MDOC_MAX);
diff --git a/mdoc_html.c b/mdoc_html.c
index c1f0ba74..654a37bb 100644
--- a/mdoc_html.c
+++ b/mdoc_html.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_html.c,v 1.227 2015/04/02 21:36:50 schwarze Exp $ */
+/* $Id: mdoc_html.c,v 1.228 2015/04/02 22:48:17 schwarze Exp $ */
/*
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -36,7 +36,7 @@
#define INDENT 5
#define MDOC_ARGS const struct mdoc_meta *meta, \
- struct mdoc_node *n, \
+ struct roff_node *n, \
struct html *h
#ifndef MIN
@@ -53,7 +53,7 @@ static void print_mdoc_head(MDOC_ARGS);
static void print_mdoc_node(MDOC_ARGS);
static void print_mdoc_nodelist(MDOC_ARGS);
static void synopsis_pre(struct html *,
- const struct mdoc_node *);
+ const struct roff_node *);
static void a2width(const char *, struct roffsu *);
@@ -293,7 +293,7 @@ a2width(const char *p, struct roffsu *su)
* See the same function in mdoc_term.c for documentation.
*/
static void
-synopsis_pre(struct html *h, const struct mdoc_node *n)
+synopsis_pre(struct html *h, const struct roff_node *n)
{
if (NULL == n->prev || ! (MDOC_SYNPRETTY & n->flags))
@@ -822,7 +822,7 @@ mdoc_it_pre(MDOC_ARGS)
struct roffsu su;
enum mdoc_list type;
struct htmlpair tag[2];
- const struct mdoc_node *bl;
+ const struct roff_node *bl;
bl = n->parent;
while (bl && MDOC_Bl != bl->tok)
@@ -1126,7 +1126,7 @@ mdoc_bd_pre(MDOC_ARGS)
{
struct htmlpair tag[2];
int comp, sv;
- struct mdoc_node *nn;
+ struct roff_node *nn;
struct roffsu su;
if (n->type == ROFFT_HEAD)
@@ -1312,7 +1312,7 @@ mdoc_er_pre(MDOC_ARGS)
static int
mdoc_fa_pre(MDOC_ARGS)
{
- const struct mdoc_node *nn;
+ const struct roff_node *nn;
struct htmlpair tag;
struct tag *t;
diff --git a/mdoc_macro.c b/mdoc_macro.c
index 55ff5ed1..bd3bf3e2 100644
--- a/mdoc_macro.c
+++ b/mdoc_macro.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_macro.c,v 1.184 2015/04/02 21:36:50 schwarze Exp $ */
+/* $Id: mdoc_macro.c,v 1.185 2015/04/02 22:48:17 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -45,15 +45,13 @@ static void phrase_ta(MACRO_PROT_ARGS);
static void dword(struct mdoc *, int, int, const char *,
enum mdelim, int);
static void append_delims(struct mdoc *, int, int *, char *);
-static enum mdoct lookup(struct mdoc *, enum mdoct,
- int, int, const char *);
+static int lookup(struct mdoc *, int, int, int, const char *);
static int macro_or_word(MACRO_PROT_ARGS, int);
-static int parse_rest(struct mdoc *, enum mdoct,
- int, int *, char *);
-static enum mdoct rew_alt(enum mdoct);
-static void rew_elem(struct mdoc *, enum mdoct);
-static void rew_last(struct mdoc *, const struct mdoc_node *);
-static void rew_pending(struct mdoc *, const struct mdoc_node *);
+static int parse_rest(struct mdoc *, 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 *);
const struct mdoc_macro __mdoc_macros[MDOC_MAX] = {
{ in_line_argn, MDOC_CALLABLE | MDOC_PARSED | MDOC_JOIN }, /* Ap */
@@ -210,7 +208,7 @@ const struct mdoc_macro * const mdoc_macros = __mdoc_macros;
void
mdoc_macroend(struct mdoc *mdoc)
{
- struct mdoc_node *n;
+ struct roff_node *n;
/* Scan for open explicit scopes. */
@@ -232,10 +230,10 @@ mdoc_macroend(struct mdoc *mdoc)
* Look up the macro at *p called by "from",
* or as a line macro if from == MDOC_MAX.
*/
-static enum mdoct
-lookup(struct mdoc *mdoc, enum mdoct from, int line, int ppos, const char *p)
+static int
+lookup(struct mdoc *mdoc, int from, int line, int ppos, const char *p)
{
- enum mdoct res;
+ int res;
if (from == MDOC_MAX || mdoc_macros[from].flags & MDOC_PARSED) {
res = mdoc_hash_find(p);
@@ -254,9 +252,9 @@ lookup(struct mdoc *mdoc, enum mdoct from, int line, int ppos, const char *p)
* Rewind up to and including a specific node.
*/
static void
-rew_last(struct mdoc *mdoc, const struct mdoc_node *to)
+rew_last(struct mdoc *mdoc, const struct roff_node *to)
{
- struct mdoc_node *n, *np;
+ struct roff_node *n, *np;
assert(to);
mdoc->next = MDOC_NEXT_SIBLING;
@@ -281,7 +279,7 @@ rew_last(struct mdoc *mdoc, const struct mdoc_node *to)
* Rewind up to a specific block, including all blocks that broke it.
*/
static void
-rew_pending(struct mdoc *mdoc, const struct mdoc_node *n)
+rew_pending(struct mdoc *mdoc, const struct roff_node *n)
{
for (;;) {
@@ -319,8 +317,8 @@ rew_pending(struct mdoc *mdoc, const struct mdoc_node *n)
* For a block closing macro, return the corresponding opening one.
* Otherwise, return the macro itself.
*/
-static enum mdoct
-rew_alt(enum mdoct tok)
+static int
+rew_alt(int tok)
{
switch (tok) {
case MDOC_Ac:
@@ -362,9 +360,9 @@ rew_alt(enum mdoct tok)
}
static void
-rew_elem(struct mdoc *mdoc, enum mdoct tok)
+rew_elem(struct mdoc *mdoc, int tok)
{
- struct mdoc_node *n;
+ struct roff_node *n;
n = mdoc->last;
if (n->type != ROFFT_ELEM)
@@ -453,7 +451,7 @@ static int
macro_or_word(MACRO_PROT_ARGS, int parsed)
{
char *p;
- enum mdoct ntok;
+ int ntok;
p = buf + ppos;
ntok = MDOC_MAX;
@@ -482,15 +480,15 @@ macro_or_word(MACRO_PROT_ARGS, int parsed)
static void
blk_exp_close(MACRO_PROT_ARGS)
{
- struct mdoc_node *body; /* Our own body. */
- struct mdoc_node *endbody; /* Our own end marker. */
- struct mdoc_node *itblk; /* An It block starting later. */
- struct mdoc_node *later; /* A sub-block starting later. */
- struct mdoc_node *n; /* Search back to our block. */
+ struct roff_node *body; /* Our own body. */
+ struct roff_node *endbody; /* Our own end marker. */
+ struct roff_node *itblk; /* An It block starting later. */
+ struct roff_node *later; /* A sub-block starting later. */
+ struct roff_node *n; /* Search back to our block. */
int j, lastarg, maxargs, nl;
enum margserr ac;
- enum mdoct atok, ntok;
+ int atok, ntok;
char *p;
nl = MDOC_NEWLINE & mdoc->flags;
@@ -664,7 +662,7 @@ static void
in_line(MACRO_PROT_ARGS)
{
int la, scope, cnt, firstarg, mayopen, nc, nl;
- enum mdoct ntok;
+ int ntok;
enum margserr ac;
enum mdelim d;
struct mdoc_arg *arg;
@@ -848,10 +846,10 @@ blk_full(MACRO_PROT_ARGS)
{
int la, nl, parsed;
struct mdoc_arg *arg;
- struct mdoc_node *blk; /* Our own or a broken block. */
- struct mdoc_node *head; /* Our own head. */
- struct mdoc_node *body; /* Our own body. */
- struct mdoc_node *n;
+ struct roff_node *blk; /* Our own or a broken block. */
+ struct roff_node *head; /* Our own head. */
+ struct roff_node *body; /* Our own body. */
+ struct roff_node *n;
enum margserr ac, lac;
char *p;
@@ -1114,9 +1112,9 @@ blk_part_imp(MACRO_PROT_ARGS)
int la, nl;
enum margserr ac;
char *p;
- struct mdoc_node *blk; /* saved block context */
- struct mdoc_node *body; /* saved body context */
- struct mdoc_node *n;
+ struct roff_node *blk; /* saved block context */
+ struct roff_node *body; /* saved body context */
+ struct roff_node *n;
nl = MDOC_NEWLINE & mdoc->flags;
@@ -1207,7 +1205,7 @@ blk_part_exp(MACRO_PROT_ARGS)
{
int la, nl;
enum margserr ac;
- struct mdoc_node *head; /* keep track of head */
+ struct roff_node *head; /* keep track of head */
char *p;
nl = MDOC_NEWLINE & mdoc->flags;
@@ -1264,7 +1262,7 @@ in_line_argn(MACRO_PROT_ARGS)
struct mdoc_arg *arg;
char *p;
enum margserr ac;
- enum mdoct ntok;
+ int ntok;
int state; /* arg#; -1: not yet open; -2: closed */
int la, maxargs, nl;
@@ -1378,7 +1376,7 @@ in_line_argn(MACRO_PROT_ARGS)
static void
in_line_eoln(MACRO_PROT_ARGS)
{
- struct mdoc_node *n;
+ struct roff_node *n;
struct mdoc_arg *arg;
if ((tok == MDOC_Pp || tok == MDOC_Lp) &&
@@ -1410,7 +1408,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, enum mdoct tok, int line, int *pos, char *buf)
+parse_rest(struct mdoc *mdoc, int tok, int line, int *pos, char *buf)
{
int la;
@@ -1445,7 +1443,7 @@ ctx_synopsis(MACRO_PROT_ARGS)
static void
phrase_ta(MACRO_PROT_ARGS)
{
- struct mdoc_node *body, *n;
+ struct roff_node *body, *n;
/* Make sure we are in a column list or ignore this macro. */
diff --git a/mdoc_man.c b/mdoc_man.c
index 484268ac..e1068ace 100644
--- a/mdoc_man.c
+++ b/mdoc_man.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_man.c,v 1.89 2015/04/02 21:36:50 schwarze Exp $ */
+/* $Id: mdoc_man.c,v 1.90 2015/04/02 22:48:17 schwarze Exp $ */
/*
* Copyright (c) 2011-2015 Ingo Schwarze <schwarze@openbsd.org>
*
@@ -30,7 +30,7 @@
#include "out.h"
#include "main.h"
-#define DECL_ARGS const struct mdoc_meta *meta, struct mdoc_node *n
+#define DECL_ARGS const struct mdoc_meta *meta, struct roff_node *n
struct manact {
int (*cond)(DECL_ARGS); /* DON'T run actions */
@@ -108,7 +108,7 @@ static int pre_sm(DECL_ARGS);
static int pre_sp(DECL_ARGS);
static int pre_sect(DECL_ARGS);
static int pre_sy(DECL_ARGS);
-static void pre_syn(const struct mdoc_node *);
+static void pre_syn(const struct roff_node *);
static int pre_vt(DECL_ARGS);
static int pre_ux(DECL_ARGS);
static int pre_xr(DECL_ARGS);
@@ -117,7 +117,7 @@ static void print_line(const char *, int);
static void print_block(const char *, int);
static void print_offs(const char *, int);
static void print_width(const struct mdoc_bl *,
- const struct mdoc_node *);
+ const struct roff_node *);
static void print_count(int *);
static void print_node(DECL_ARGS);
@@ -468,7 +468,7 @@ print_offs(const char *v, int keywords)
* Set up the indentation for a list item; used from pre_it().
*/
static void
-print_width(const struct mdoc_bl *bl, const struct mdoc_node *child)
+print_width(const struct mdoc_bl *bl, const struct roff_node *child)
{
char buf[24];
struct roffsu su;
@@ -548,7 +548,7 @@ void
man_mdoc(void *arg, const struct mdoc *mdoc)
{
const struct mdoc_meta *meta;
- struct mdoc_node *n;
+ struct roff_node *n;
meta = mdoc_meta(mdoc);
n = mdoc_node(mdoc)->child;
@@ -578,7 +578,7 @@ static void
print_node(DECL_ARGS)
{
const struct manact *act;
- struct mdoc_node *sub;
+ struct roff_node *sub;
int cond, do_sub;
/*
@@ -808,7 +808,7 @@ post_sect(DECL_ARGS)
/* See mdoc_term.c, synopsis_pre() for comments. */
static void
-pre_syn(const struct mdoc_node *n)
+pre_syn(const struct roff_node *n)
{
if (NULL == n->prev || ! (MDOC_SYNPRETTY & n->flags))
@@ -1366,7 +1366,7 @@ post_in(DECL_ARGS)
static int
pre_it(DECL_ARGS)
{
- const struct mdoc_node *bln;
+ const struct roff_node *bln;
switch (n->type) {
case ROFFT_HEAD:
@@ -1463,7 +1463,7 @@ mid_it(void)
static void
post_it(DECL_ARGS)
{
- const struct mdoc_node *bln;
+ const struct roff_node *bln;
bln = n->parent->parent;
@@ -1533,7 +1533,7 @@ post_lb(DECL_ARGS)
static int
pre_lk(DECL_ARGS)
{
- const struct mdoc_node *link, *descr;
+ const struct roff_node *link, *descr;
if (NULL == (link = n->child))
return(0);
diff --git a/mdoc_term.c b/mdoc_term.c
index 342ca5aa..410f941e 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_term.c,v 1.314 2015/04/02 21:36:50 schwarze Exp $ */
+/* $Id: mdoc_term.c,v 1.315 2015/04/02 22:48:17 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -44,7 +44,7 @@ struct termpair {
#define DECL_ARGS struct termp *p, \
struct termpair *pair, \
const struct mdoc_meta *meta, \
- struct mdoc_node *n
+ struct roff_node *n
struct termact {
int (*pre)(DECL_ARGS);
@@ -54,14 +54,14 @@ struct termact {
static int a2width(const struct termp *, const char *);
static void print_bvspace(struct termp *,
- const struct mdoc_node *,
- const struct mdoc_node *);
+ const struct roff_node *,
+ const struct roff_node *);
static void print_mdoc_node(DECL_ARGS);
static void print_mdoc_nodelist(DECL_ARGS);
static void print_mdoc_head(struct termp *, const void *);
static void print_mdoc_foot(struct termp *, const void *);
static void synopsis_pre(struct termp *,
- const struct mdoc_node *);
+ const struct roff_node *);
static void termp____post(DECL_ARGS);
static void termp__t_post(DECL_ARGS);
@@ -254,7 +254,7 @@ void
terminal_mdoc(void *arg, const struct mdoc *mdoc)
{
const struct mdoc_meta *meta;
- struct mdoc_node *n;
+ struct roff_node *n;
struct termp *p;
p = (struct termp *)arg;
@@ -549,10 +549,10 @@ a2width(const struct termp *p, const char *v)
*/
static void
print_bvspace(struct termp *p,
- const struct mdoc_node *bl,
- const struct mdoc_node *n)
+ const struct roff_node *bl,
+ const struct roff_node *n)
{
- const struct mdoc_node *nn;
+ const struct roff_node *nn;
assert(n);
@@ -610,7 +610,7 @@ static int
termp_it_pre(DECL_ARGS)
{
char buf[24];
- const struct mdoc_node *bl, *nn;
+ const struct roff_node *bl, *nn;
size_t ncols, dcol;
int i, offset, width;
enum mdoc_list type;
@@ -1267,7 +1267,7 @@ termp_xr_pre(DECL_ARGS)
* macro combos).
*/
static void
-synopsis_pre(struct termp *p, const struct mdoc_node *n)
+synopsis_pre(struct termp *p, const struct roff_node *n)
{
/*
* Obviously, if we're not in a SYNOPSIS or no prior macros
@@ -1515,7 +1515,7 @@ termp_fn_pre(DECL_ARGS)
static int
termp_fa_pre(DECL_ARGS)
{
- const struct mdoc_node *nn;
+ const struct roff_node *nn;
if (n->parent->tok != MDOC_Fo) {
term_fontpush(p, TERMFONT_UNDER);
@@ -1541,7 +1541,7 @@ static int
termp_bd_pre(DECL_ARGS)
{
size_t tabwidth, lm, len, rm, rmax;
- struct mdoc_node *nn;
+ struct roff_node *nn;
int offset;
if (n->type == ROFFT_BLOCK) {
@@ -2170,7 +2170,7 @@ termp_li_pre(DECL_ARGS)
static int
termp_lk_pre(DECL_ARGS)
{
- const struct mdoc_node *link, *descr;
+ const struct roff_node *link, *descr;
if (NULL == (link = n->child))
return(0);
diff --git a/mdoc_validate.c b/mdoc_validate.c
index 6b89abc9..d090ff7a 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_validate.c,v 1.284 2015/04/02 21:36:50 schwarze Exp $ */
+/* $Id: mdoc_validate.c,v 1.285 2015/04/02 22:48:17 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -40,7 +40,7 @@
/* FIXME: .Bl -diag can't have non-text children in HEAD. */
-#define PRE_ARGS struct mdoc *mdoc, struct mdoc_node *n
+#define PRE_ARGS struct mdoc *mdoc, struct roff_node *n
#define POST_ARGS struct mdoc *mdoc
enum check_ineq {
@@ -59,11 +59,11 @@ struct valids {
static void check_text(struct mdoc *, int, int, char *);
static void check_argv(struct mdoc *,
- struct mdoc_node *, struct mdoc_argv *);
-static void check_args(struct mdoc *, struct mdoc_node *);
-static int child_an(const struct mdoc_node *);
-static enum mdoc_sec a2sec(const char *);
-static size_t macro2len(enum mdoct);
+ struct roff_node *, struct mdoc_argv *);
+static void check_args(struct mdoc *, struct roff_node *);
+static int child_an(const struct roff_node *);
+static enum roff_sec a2sec(const char *);
+static size_t macro2len(int);
static void rewrite_macro2len(char **);
static void post_an(POST_ARGS);
@@ -248,7 +248,7 @@ static const struct valids mdoc_valids[MDOC_MAX] = {
#define RSORD_MAX 14 /* Number of `Rs' blocks. */
-static const enum mdoct rsord[RSORD_MAX] = {
+static const int rsord[RSORD_MAX] = {
MDOC__A,
MDOC__T,
MDOC__B,
@@ -293,7 +293,7 @@ static const char * const secnames[SEC__MAX] = {
void
-mdoc_valid_pre(struct mdoc *mdoc, struct mdoc_node *n)
+mdoc_valid_pre(struct mdoc *mdoc, struct roff_node *n)
{
v_pre p;
@@ -321,7 +321,7 @@ mdoc_valid_pre(struct mdoc *mdoc, struct mdoc_node *n)
void
mdoc_valid_post(struct mdoc *mdoc)
{
- struct mdoc_node *n;
+ struct roff_node *n;
v_post p;
n = mdoc->last;
@@ -362,7 +362,7 @@ mdoc_valid_post(struct mdoc *mdoc)
}
static void
-check_args(struct mdoc *mdoc, struct mdoc_node *n)
+check_args(struct mdoc *mdoc, struct roff_node *n)
{
int i;
@@ -375,7 +375,7 @@ check_args(struct mdoc *mdoc, struct mdoc_node *n)
}
static void
-check_argv(struct mdoc *mdoc, struct mdoc_node *n, struct mdoc_argv *v)
+check_argv(struct mdoc *mdoc, struct roff_node *n, struct mdoc_argv *v)
{
int i;
@@ -399,7 +399,7 @@ check_text(struct mdoc *mdoc, int ln, int pos, char *p)
static void
pre_display(PRE_ARGS)
{
- struct mdoc_node *node;
+ struct roff_node *node;
if (n->type != ROFFT_BLOCK)
return;
@@ -769,7 +769,7 @@ pre_dd(PRE_ARGS)
static void
post_bf(POST_ARGS)
{
- struct mdoc_node *np, *nch;
+ struct roff_node *np, *nch;
enum mdocargt arg;
/*
@@ -831,7 +831,7 @@ post_bf(POST_ARGS)
static void
post_lb(POST_ARGS)
{
- struct mdoc_node *n;
+ struct roff_node *n;
const char *stdlibname;
char *libname;
@@ -851,7 +851,7 @@ post_lb(POST_ARGS)
static void
post_eoln(POST_ARGS)
{
- const struct mdoc_node *n;
+ const struct roff_node *n;
n = mdoc->last;
if (n->child)
@@ -864,7 +864,7 @@ post_eoln(POST_ARGS)
static void
post_fname(POST_ARGS)
{
- const struct mdoc_node *n;
+ const struct roff_node *n;
const char *cp;
size_t pos;
@@ -887,7 +887,7 @@ post_fn(POST_ARGS)
static void
post_fo(POST_ARGS)
{
- const struct mdoc_node *n;
+ const struct roff_node *n;
n = mdoc->last;
@@ -913,7 +913,7 @@ post_fo(POST_ARGS)
static void
post_fa(POST_ARGS)
{
- const struct mdoc_node *n;
+ const struct roff_node *n;
const char *cp;
for (n = mdoc->last->child; n != NULL; n = n->next) {
@@ -934,7 +934,7 @@ post_fa(POST_ARGS)
static void
post_vt(POST_ARGS)
{
- const struct mdoc_node *n;
+ const struct roff_node *n;
/*
* The Vt macro comes in both ELEM and BLOCK form, both of which
@@ -956,7 +956,7 @@ post_vt(POST_ARGS)
static void
post_nm(POST_ARGS)
{
- struct mdoc_node *n;
+ struct roff_node *n;
n = mdoc->last;
@@ -978,7 +978,7 @@ post_nm(POST_ARGS)
static void
post_nd(POST_ARGS)
{
- struct mdoc_node *n;
+ struct roff_node *n;
n = mdoc->last;
@@ -995,7 +995,7 @@ post_nd(POST_ARGS)
static void
post_d1(POST_ARGS)
{
- struct mdoc_node *n;
+ struct roff_node *n;
n = mdoc->last;
@@ -1012,7 +1012,7 @@ post_d1(POST_ARGS)
static void
post_literal(POST_ARGS)
{
- struct mdoc_node *n;
+ struct roff_node *n;
n = mdoc->last;
@@ -1034,7 +1034,7 @@ post_literal(POST_ARGS)
static void
post_defaults(POST_ARGS)
{
- struct mdoc_node *nn;
+ struct roff_node *nn;
/*
* The `Ar' defaults to "file ..." if no value is provided as an
@@ -1068,7 +1068,7 @@ post_defaults(POST_ARGS)
static void
post_at(POST_ARGS)
{
- struct mdoc_node *n;
+ struct roff_node *n;
const char *std_att;
char *att;
@@ -1102,7 +1102,7 @@ post_at(POST_ARGS)
static void
post_an(POST_ARGS)
{
- struct mdoc_node *np, *nch;
+ struct roff_node *np, *nch;
np = mdoc->last;
nch = np->child;
@@ -1133,9 +1133,9 @@ post_es(POST_ARGS)
static void
post_it(POST_ARGS)
{
+ struct roff_node *nbl, *nit, *nch;
int i, cols;
enum mdoc_list lt;
- struct mdoc_node *nbl, *nit, *nch;
nit = mdoc->last;
if (nit->type != ROFFT_BLOCK)
@@ -1201,7 +1201,7 @@ post_it(POST_ARGS)
static void
post_bl_block(POST_ARGS)
{
- struct mdoc_node *n, *ni, *nc;
+ struct roff_node *n, *ni, *nc;
/*
* These are fairly complicated, so we've broken them into two
@@ -1262,7 +1262,7 @@ void
rewrite_macro2len(char **arg)
{
size_t width;
- enum mdoct tok;
+ int tok;
if (*arg == NULL)
return;
@@ -1280,7 +1280,7 @@ rewrite_macro2len(char **arg)
static void
post_bl_block_tag(POST_ARGS)
{
- struct mdoc_node *n, *nn;
+ struct roff_node *n, *nn;
size_t sz, ssz;
int i;
char buf[24];
@@ -1345,7 +1345,7 @@ post_bl_block_tag(POST_ARGS)
static void
post_bl_head(POST_ARGS)
{
- struct mdoc_node *nbl, *nh, *nch, *nnext;
+ struct roff_node *nbl, *nh, *nch, *nnext;
struct mdoc_argv *argv;
int i, j;
@@ -1407,9 +1407,9 @@ post_bl_head(POST_ARGS)
static void
post_bl(POST_ARGS)
{
- struct mdoc_node *nparent, *nprev; /* of the Bl block */
- struct mdoc_node *nblock, *nbody; /* of the Bl */
- struct mdoc_node *nchild, *nnext; /* of the Bl body */
+ struct roff_node *nparent, *nprev; /* of the Bl block */
+ struct roff_node *nblock, *nbody; /* of the Bl */
+ struct roff_node *nchild, *nnext; /* of the Bl body */
nbody = mdoc->last;
switch (nbody->type) {
@@ -1490,7 +1490,7 @@ post_bl(POST_ARGS)
static void
post_bk(POST_ARGS)
{
- struct mdoc_node *n;
+ struct roff_node *n;
n = mdoc->last;
@@ -1504,7 +1504,7 @@ post_bk(POST_ARGS)
static void
post_sm(struct mdoc *mdoc)
{
- struct mdoc_node *nch;
+ struct roff_node *nch;
nch = mdoc->last->child;
@@ -1534,7 +1534,7 @@ post_sm(struct mdoc *mdoc)
static void
post_root(POST_ARGS)
{
- struct mdoc_node *n;
+ struct roff_node *n;
/* Add missing prologue data. */
@@ -1574,7 +1574,7 @@ post_root(POST_ARGS)
static void
post_st(POST_ARGS)
{
- struct mdoc_node *n, *nch;
+ struct roff_node *n, *nch;
const char *p;
n = mdoc->last;
@@ -1595,7 +1595,7 @@ post_st(POST_ARGS)
static void
post_rs(POST_ARGS)
{
- struct mdoc_node *np, *nch, *next, *prev;
+ struct roff_node *np, *nch, *next, *prev;
int i, j;
np = mdoc->last;
@@ -1689,7 +1689,7 @@ post_rs(POST_ARGS)
static void
post_hyph(POST_ARGS)
{
- struct mdoc_node *nch;
+ struct roff_node *nch;
char *cp;
for (nch = mdoc->last->child; nch != NULL; nch = nch->next) {
@@ -1748,7 +1748,7 @@ post_sh(POST_ARGS)
static void
post_sh_name(POST_ARGS)
{
- struct mdoc_node *n;
+ struct roff_node *n;
int hasnm, hasnd;
hasnm = hasnd = 0;
@@ -1786,7 +1786,7 @@ post_sh_name(POST_ARGS)
static void
post_sh_see_also(POST_ARGS)
{
- const struct mdoc_node *n;
+ const struct roff_node *n;
const char *name, *sec;
const char *lastname, *lastsec, *lastpunct;
int cmp;
@@ -1846,7 +1846,7 @@ post_sh_see_also(POST_ARGS)
}
static int
-child_an(const struct mdoc_node *n)
+child_an(const struct roff_node *n)
{
for (n = n->child; n != NULL; n = n->next)
@@ -1867,10 +1867,10 @@ post_sh_authors(POST_ARGS)
static void
post_sh_head(POST_ARGS)
{
- struct mdoc_node *n;
+ struct roff_node *n;
const char *goodsec;
char *secname;
- enum mdoc_sec sec;
+ enum roff_sec sec;
/*
* Process a new section. Sections are either "named" or
@@ -1987,7 +1987,7 @@ post_sh_head(POST_ARGS)
static void
post_ignpar(POST_ARGS)
{
- struct mdoc_node *np;
+ struct roff_node *np;
switch (mdoc->last->type) {
case ROFFT_HEAD:
@@ -2053,7 +2053,7 @@ pre_par(PRE_ARGS)
static void
post_par(POST_ARGS)
{
- struct mdoc_node *np;
+ struct roff_node *np;
np = mdoc->last;
@@ -2116,7 +2116,7 @@ pre_literal(PRE_ARGS)
static void
post_dd(POST_ARGS)
{
- struct mdoc_node *n;
+ struct roff_node *n;
char *datestr;
if (mdoc->meta.date)
@@ -2145,7 +2145,7 @@ out:
static void
post_dt(POST_ARGS)
{
- struct mdoc_node *nn, *n;
+ struct roff_node *nn, *n;
const char *cp;
char *p;
@@ -2230,7 +2230,7 @@ out:
static void
post_bx(POST_ARGS)
{
- struct mdoc_node *n;
+ struct roff_node *n;
/*
* Make `Bx's second argument always start with an uppercase
@@ -2250,7 +2250,7 @@ post_os(POST_ARGS)
struct utsname utsname;
static char *defbuf;
#endif
- struct mdoc_node *n;
+ struct roff_node *n;
n = mdoc->last;
@@ -2300,7 +2300,7 @@ out:
static void
post_ex(POST_ARGS)
{
- struct mdoc_node *n;
+ struct roff_node *n;
n = mdoc->last;
@@ -2318,20 +2318,20 @@ post_ex(POST_ARGS)
mdoc->last = n;
}
-static enum mdoc_sec
+static enum roff_sec
a2sec(const char *p)
{
int i;
for (i = 0; i < (int)SEC__MAX; i++)
if (secnames[i] && 0 == strcmp(p, secnames[i]))
- return((enum mdoc_sec)i);
+ return((enum roff_sec)i);
return(SEC_CUSTOM);
}
static size_t
-macro2len(enum mdoct macro)
+macro2len(int macro)
{
switch (macro) {
diff --git a/roff.h b/roff.h
index e9566c1a..232100c8 100644
--- a/roff.h
+++ b/roff.h
@@ -16,6 +16,36 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+struct mdoc_arg;
+union mdoc_data;
+
+enum roff_sec {
+ SEC_NONE = 0,
+ SEC_NAME,
+ SEC_LIBRARY,
+ SEC_SYNOPSIS,
+ SEC_DESCRIPTION,
+ SEC_CONTEXT,
+ SEC_IMPLEMENTATION, /* IMPLEMENTATION NOTES */
+ SEC_RETURN_VALUES,
+ SEC_ENVIRONMENT,
+ SEC_FILES,
+ SEC_EXIT_STATUS,
+ SEC_EXAMPLES,
+ SEC_DIAGNOSTICS,
+ SEC_COMPATIBILITY,
+ SEC_ERRORS,
+ SEC_SEE_ALSO,
+ SEC_STANDARDS,
+ SEC_HISTORY,
+ SEC_AUTHORS,
+ SEC_CAVEATS,
+ SEC_BUGS,
+ SEC_SECURITY,
+ SEC_CUSTOM,
+ SEC__MAX
+};
+
enum roff_type {
ROFFT_ROOT,
ROFFT_BLOCK,
@@ -27,3 +57,50 @@ enum roff_type {
ROFFT_TBL,
ROFFT_EQN
};
+
+/*
+ * Indicates that a BODY's formatting has ended, but
+ * the scope is still open. Used for badly nested blocks.
+ */
+enum mdoc_endbody {
+ ENDBODY_NOT = 0,
+ ENDBODY_SPACE, /* Is broken: append a space. */
+ ENDBODY_NOSPACE /* Is broken: don't append a space. */
+};
+
+struct roff_node {
+ struct roff_node *parent; /* Parent AST node. */
+ struct roff_node *child; /* First child AST node. */
+ struct roff_node *last; /* Last child AST node. */
+ struct roff_node *next; /* Sibling AST node. */
+ struct roff_node *prev; /* Prior sibling AST node. */
+ struct roff_node *head; /* BLOCK */
+ struct roff_node *body; /* BLOCK/ENDBODY */
+ struct roff_node *tail; /* BLOCK */
+ struct mdoc_arg *args; /* BLOCK/ELEM */
+ union mdoc_data *norm; /* Normalized arguments. */
+ char *string; /* TEXT */
+ const struct tbl_span *span; /* TBL */
+ const struct eqn *eqn; /* EQN */
+ int nchild; /* Number of child nodes. */
+ int line; /* Input file line number. */
+ int pos; /* Input file column number. */
+ int tok; /* Request or macro ID. */
+ int flags;
+#define MDOC_VALID (1 << 0) /* Has been validated. */
+#define MDOC_ENDED (1 << 1) /* Gone past body end mark. */
+#define MDOC_EOS (1 << 2) /* At sentence boundary. */
+#define MDOC_LINE (1 << 3) /* First macro/text on line. */
+#define MDOC_SYNPRETTY (1 << 4) /* SYNOPSIS-style formatting. */
+#define MDOC_BROKEN (1 << 5) /* Must validate parent when ending. */
+#define MDOC_DELIMO (1 << 6)
+#define MDOC_DELIMC (1 << 7)
+#define MAN_VALID MDOC_VALID
+#define MAN_EOS MDOC_EOS
+#define MAN_LINE MDOC_LINE
+ int prev_font; /* Before entering this node. */
+ int aux; /* Decoded node data, type-dependent. */
+ enum roff_type type; /* AST node type. */
+ enum roff_sec sec; /* Current named section. */
+ enum mdoc_endbody end; /* BODY */
+};
diff --git a/tree.c b/tree.c
index 70537cb5..d7cd037b 100644
--- a/tree.c
+++ b/tree.c
@@ -1,4 +1,4 @@
-/* $Id: tree.c,v 1.63 2015/04/02 21:36:51 schwarze Exp $ */
+/* $Id: tree.c,v 1.64 2015/04/02 22:48:18 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -32,8 +32,8 @@
#include "main.h"
static void print_box(const struct eqn_box *, int);
-static void print_man(const struct man_node *, int);
-static void print_mdoc(const struct mdoc_node *, int);
+static void print_man(const struct roff_node *, int);
+static void print_mdoc(const struct roff_node *, int);
static void print_span(const struct tbl_span *, int);
@@ -52,7 +52,7 @@ tree_man(void *arg, const struct man *man)
}
static void
-print_mdoc(const struct mdoc_node *n, int indent)
+print_mdoc(const struct roff_node *n, int indent)
{
const char *p, *t;
int i, j;
@@ -176,7 +176,7 @@ print_mdoc(const struct mdoc_node *n, int indent)
}
static void
-print_man(const struct man_node *n, int indent)
+print_man(const struct roff_node *n, int indent)
{
const char *p, *t;
int i;