aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mandocdb.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2015-04-02 21:36:49 +0000
committerIngo Schwarze <schwarze@openbsd.org>2015-04-02 21:36:49 +0000
commit483afc5a7a52b601da9e854d5645cd4b0a140184 (patch)
tree159f32df48c5d133f76368d6fb95ad45656bccc4 /mandocdb.c
parent0fa412f32faf6969057d9e796beabcbf0413f279 (diff)
downloadmandoc-483afc5a7a52b601da9e854d5645cd4b0a140184.tar.gz
mandoc-483afc5a7a52b601da9e854d5645cd4b0a140184.tar.zst
mandoc-483afc5a7a52b601da9e854d5645cd4b0a140184.zip
First step towards parser unification:
Replace enum mdoc_type and enum man_type by a unified enum roff_type. Almost mechanical, no functional change. Written on the ICE train from Frankfurt to Bruxelles on the way to p2k15.
Diffstat (limited to 'mandocdb.c')
-rw-r--r--mandocdb.c47
1 files changed, 24 insertions, 23 deletions
diff --git a/mandocdb.c b/mandocdb.c
index a0b87750..84e2d5bb 100644
--- a/mandocdb.c
+++ b/mandocdb.c
@@ -1,4 +1,4 @@
-/* $Id: mandocdb.c,v 1.187 2015/03/27 17:37:25 schwarze Exp $ */
+/* $Id: mandocdb.c,v 1.188 2015/04/02 21:36:50 schwarze Exp $ */
/*
* Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -46,10 +46,11 @@
#endif
#include <sqlite3.h>
+#include "mandoc_aux.h"
+#include "mandoc.h"
+#include "roff.h"
#include "mdoc.h"
#include "man.h"
-#include "mandoc.h"
-#include "mandoc_aux.h"
#include "manconf.h"
#include "mansearch.h"
@@ -1436,7 +1437,7 @@ putmdockey(const struct mpage *mpage,
for ( ; NULL != n; n = n->next) {
if (NULL != n->child)
putmdockey(mpage, n->child, m);
- if (MDOC_TEXT == n->type)
+ if (n->type == ROFFT_TEXT)
putkey(mpage, n->string, m);
}
}
@@ -1460,13 +1461,13 @@ parse_man(struct mpage *mpage, const struct man_meta *meta,
* the correct section or not.
*/
- if (MAN_BODY == n->type && MAN_SH == n->tok) {
+ if (n->type == ROFFT_BODY && n->tok == MAN_SH) {
body = n;
assert(body->parent);
if (NULL != (head = body->parent->head) &&
1 == head->nchild &&
NULL != (head = (head->child)) &&
- MAN_TEXT == head->type &&
+ head->type == ROFFT_TEXT &&
0 == strcmp(head->string, "NAME") &&
NULL != body->child) {
@@ -1575,15 +1576,15 @@ parse_mdoc(struct mpage *mpage, const struct mdoc_meta *meta,
assert(NULL != n);
for (n = n->child; NULL != n; n = n->next) {
switch (n->type) {
- case MDOC_ELEM:
+ case ROFFT_ELEM:
/* FALLTHROUGH */
- case MDOC_BLOCK:
+ case ROFFT_BLOCK:
/* FALLTHROUGH */
- case MDOC_HEAD:
+ case ROFFT_HEAD:
/* FALLTHROUGH */
- case MDOC_BODY:
+ case ROFFT_BODY:
/* FALLTHROUGH */
- case MDOC_TAIL:
+ case ROFFT_TAIL:
if (NULL != mdocs[n->tok].fp)
if (0 == (*mdocs[n->tok].fp)(mpage, meta, n))
break;
@@ -1592,7 +1593,7 @@ parse_mdoc(struct mpage *mpage, const struct mdoc_meta *meta,
mdocs[n->tok].mask);
break;
default:
- assert(MDOC_ROOT != n->type);
+ assert(n->type != ROFFT_ROOT);
continue;
}
if (NULL != n->child)
@@ -1609,7 +1610,7 @@ parse_mdoc_Fd(struct mpage *mpage, const struct mdoc_meta *meta,
if (SEC_SYNOPSIS != n->sec ||
NULL == (n = n->child) ||
- MDOC_TEXT != n->type)
+ n->type != ROFFT_TEXT)
return(0);
/*
@@ -1620,7 +1621,7 @@ parse_mdoc_Fd(struct mpage *mpage, const struct mdoc_meta *meta,
if (strcmp("#include", n->string))
return(0);
- if (NULL == (n = n->next) || MDOC_TEXT != n->type)
+ if ((n = n->next) == NULL || n->type != ROFFT_TEXT)
return(0);
/*
@@ -1650,7 +1651,7 @@ parse_mdoc_fname(struct mpage *mpage, const struct mdoc_node *n)
char *cp;
size_t sz;
- if (n->type != MDOC_TEXT)
+ if (n->type != ROFFT_TEXT)
return;
/* Skip function pointer punctuation. */
@@ -1676,7 +1677,7 @@ parse_mdoc_Fn(struct mpage *mpage, const struct mdoc_meta *meta,
parse_mdoc_fname(mpage, n->child);
for (n = n->child->next; n != NULL; n = n->next)
- if (n->type == MDOC_TEXT)
+ if (n->type == ROFFT_TEXT)
putkey(mpage, n->string, TYPE_Fa);
return(0);
@@ -1687,7 +1688,7 @@ parse_mdoc_Fo(struct mpage *mpage, const struct mdoc_meta *meta,
const struct mdoc_node *n)
{
- if (n->type != MDOC_HEAD)
+ if (n->type != ROFFT_HEAD)
return(1);
if (n->child != NULL)
@@ -1721,7 +1722,7 @@ parse_mdoc_Nd(struct mpage *mpage, const struct mdoc_meta *meta,
const struct mdoc_node *n)
{
- if (MDOC_BODY == n->type)
+ if (n->type == ROFFT_BODY)
mdoc_deroff(&mpage->desc, n);
return(0);
}
@@ -1733,7 +1734,7 @@ parse_mdoc_Nm(struct mpage *mpage, const struct mdoc_meta *meta,
if (SEC_NAME == n->sec)
putmdockey(mpage, n->child, NAME_TITLE);
- else if (SEC_SYNOPSIS == n->sec && MDOC_HEAD == n->type) {
+ else if (n->sec == SEC_SYNOPSIS && n->type == ROFFT_HEAD) {
if (n->child == NULL)
putkey(mpage, meta->name, NAME_SYN);
else
@@ -1742,7 +1743,7 @@ parse_mdoc_Nm(struct mpage *mpage, const struct mdoc_meta *meta,
if ( ! (mpage->name_head_done ||
n->child == NULL || n->child->string == NULL ||
strcasecmp(n->child->string, meta->title))) {
- putkey(mpage, n->child->string, NAME_HEAD);
+ putkey(mpage, n->child->string, ROFFT_HEAD);
mpage->name_head_done = 1;
}
return(0);
@@ -1753,7 +1754,7 @@ parse_mdoc_Sh(struct mpage *mpage, const struct mdoc_meta *meta,
const struct mdoc_node *n)
{
- return(SEC_CUSTOM == n->sec && MDOC_HEAD == n->type);
+ return(n->sec == SEC_CUSTOM && n->type == ROFFT_HEAD);
}
static int
@@ -1761,7 +1762,7 @@ parse_mdoc_head(struct mpage *mpage, const struct mdoc_meta *meta,
const struct mdoc_node *n)
{
- return(MDOC_HEAD == n->type);
+ return(n->type == ROFFT_HEAD);
}
static int
@@ -1769,7 +1770,7 @@ parse_mdoc_body(struct mpage *mpage, const struct mdoc_meta *meta,
const struct mdoc_node *n)
{
- return(MDOC_BODY == n->type);
+ return(n->type == ROFFT_BODY);
}
/*