summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2015-04-18 17:53:21 +0000
committerIngo Schwarze <schwarze@openbsd.org>2015-04-18 17:53:21 +0000
commitd4d5d006d52687c2882e89b913c70967626da0e1 (patch)
treebc16a6725a85bb2b430e2ac2de6f2a83721bb6a8
parentafd3f3a3f381e6bd5e6803a730f57302dd9234d2 (diff)
downloadmandoc-d4d5d006d52687c2882e89b913c70967626da0e1.tar.gz
Delete the wrapper functions mdoc_meta(), man_meta(), mdoc_node(),
man_node() from the mandoc(3) semi-public interface and the internal wrapper functions print_mdoc() and print_man() from the HTML formatters. Minus 60 lines of code, no functional change.
-rw-r--r--demandoc.c4
-rw-r--r--man.c14
-rw-r--r--man.h2
-rw-r--r--man_html.c20
-rw-r--r--man_term.c14
-rw-r--r--mandocdb.c15
-rw-r--r--mdoc.c14
-rw-r--r--mdoc.h2
-rw-r--r--mdoc_html.c27
-rw-r--r--mdoc_man.c16
-rw-r--r--mdoc_term.c14
-rw-r--r--tree.c4
12 files changed, 44 insertions, 102 deletions
diff --git a/demandoc.c b/demandoc.c
index 937145de..7a4e303a 100644
--- a/demandoc.c
+++ b/demandoc.c
@@ -121,9 +121,9 @@ pmandoc(struct mparse *mp, int fd, const char *fn, int list)
if (man == NULL)
return;
if (man->macroset == MACROSET_MDOC)
- pmdoc(mdoc_node(man), &line, &col, list);
+ pmdoc(man->first->child, &line, &col, list);
else
- pman(man_node(man), &line, &col, list);
+ pman(man->first->child, &line, &col, list);
if ( ! list)
putchar('\n');
diff --git a/man.c b/man.c
index ba0af269..601e8348 100644
--- a/man.c
+++ b/man.c
@@ -62,20 +62,6 @@ 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 roff_man *man)
-{
-
- return(man->first);
-}
-
-const struct roff_meta *
-man_meta(const struct roff_man *man)
-{
-
- return(&man->meta);
-}
-
void
man_endparse(struct roff_man *man)
{
diff --git a/man.h b/man.h
index 790c9a6e..8e29f2f8 100644
--- a/man.h
+++ b/man.h
@@ -63,8 +63,6 @@ __BEGIN_DECLS
struct roff_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 *);
diff --git a/man_html.c b/man_html.c
index 15194d1f..ffb265e1 100644
--- a/man_html.c
+++ b/man_html.c
@@ -54,7 +54,6 @@ struct htmlman {
static void print_bvspace(struct html *,
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);
@@ -148,33 +147,28 @@ void
html_man(void *arg, const struct roff_man *man)
{
struct mhtml mh;
-
- memset(&mh, 0, sizeof(struct mhtml));
- print_man(man_meta(man), man_node(man), &mh, (struct html *)arg);
- putchar('\n');
-}
-
-static void
-print_man(MAN_ARGS)
-{
- struct tag *t, *tt;
struct htmlpair tag;
+ struct html *h;
+ struct tag *t, *tt;
+ memset(&mh, 0, sizeof(mh));
PAIR_CLASS_INIT(&tag, "mandoc");
+ h = (struct html *)arg;
if ( ! (HTML_FRAGMENT & h->oflags)) {
print_gen_decls(h);
t = print_otag(h, TAG_HTML, 0, NULL);
tt = print_otag(h, TAG_HEAD, 0, NULL);
- print_man_head(man, n, mh, h);
+ print_man_head(&man->meta, man->first, &mh, h);
print_tagq(h, tt);
print_otag(h, TAG_BODY, 0, NULL);
print_otag(h, TAG_DIV, 1, &tag);
} else
t = print_otag(h, TAG_DIV, 1, &tag);
- print_man_nodelist(man, n, mh, h);
+ print_man_nodelist(&man->meta, man->first, &mh, h);
print_tagq(h, t);
+ putchar('\n');
}
static void
diff --git a/man_term.c b/man_term.c
index d488e063..5067d0ce 100644
--- a/man_term.c
+++ b/man_term.c
@@ -141,25 +141,20 @@ void
terminal_man(void *arg, const struct roff_man *man)
{
struct termp *p;
- const struct roff_meta *meta;
struct roff_node *n;
struct mtermp mt;
p = (struct termp *)arg;
-
p->overstep = 0;
p->rmargin = p->maxrmargin = p->defrmargin;
p->tabwidth = term_len(p, 5);
- n = man_node(man)->child;
- meta = man_meta(man);
-
memset(&mt, 0, sizeof(struct mtermp));
-
mt.lmargin[mt.lmargincur] = term_len(p, p->defindent);
mt.offset = term_len(p, p->defindent);
mt.pardist = 1;
+ n = man->first->child;
if (p->synopsisonly) {
while (n != NULL) {
if (n->tok == MAN_SH &&
@@ -167,7 +162,8 @@ terminal_man(void *arg, const struct roff_man *man)
!strcmp(n->child->child->string, "SYNOPSIS")) {
if (n->child->next->child != NULL)
print_man_nodelist(p, &mt,
- n->child->next->child, meta);
+ n->child->next->child,
+ &man->meta);
term_newln(p);
break;
}
@@ -176,10 +172,10 @@ terminal_man(void *arg, const struct roff_man *man)
} else {
if (p->defindent == 0)
p->defindent = 7;
- term_begin(p, print_man_head, print_man_foot, meta);
+ term_begin(p, print_man_head, print_man_foot, &man->meta);
p->flags |= TERMP_NOSPACE;
if (n != NULL)
- print_man_nodelist(p, &mt, n, meta);
+ print_man_nodelist(p, &mt, n, &man->meta);
term_end(p);
}
}
diff --git a/mandocdb.c b/mandocdb.c
index 161e2d5f..c367f443 100644
--- a/mandocdb.c
+++ b/mandocdb.c
@@ -1195,19 +1195,18 @@ mpages_merge(struct mparse *mp)
goto nextpage;
} else if (man != NULL && man->macroset == MACROSET_MDOC) {
mpage->form = FORM_SRC;
- mpage->sec = mdoc_meta(man)->msec;
+ mpage->sec = man->meta.msec;
mpage->sec = mandoc_strdup(
mpage->sec == NULL ? "" : mpage->sec);
- mpage->arch = mdoc_meta(man)->arch;
+ mpage->arch = man->meta.arch;
mpage->arch = mandoc_strdup(
mpage->arch == NULL ? "" : mpage->arch);
- mpage->title =
- mandoc_strdup(mdoc_meta(man)->title);
+ mpage->title = mandoc_strdup(man->meta.title);
} else if (man != NULL && man->macroset == MACROSET_MAN) {
mpage->form = FORM_SRC;
- mpage->sec = mandoc_strdup(man_meta(man)->msec);
+ mpage->sec = mandoc_strdup(man->meta.msec);
mpage->arch = mandoc_strdup(mlink->arch);
- mpage->title = mandoc_strdup(man_meta(man)->title);
+ mpage->title = mandoc_strdup(man->meta.title);
} else {
mpage->form = FORM_CAT;
mpage->sec = mandoc_strdup(mlink->dsec);
@@ -1230,9 +1229,9 @@ mpages_merge(struct mparse *mp)
assert(mpage->desc == NULL);
if (man != NULL && man->macroset == MACROSET_MDOC)
- parse_mdoc(mpage, mdoc_meta(man), mdoc_node(man));
+ parse_mdoc(mpage, &man->meta, man->first);
else if (man != NULL)
- parse_man(mpage, man_meta(man), man_node(man));
+ parse_man(mpage, &man->meta, man->first);
else
parse_cat(mpage, fd);
if (mpage->desc == NULL)
diff --git a/mdoc.c b/mdoc.c
index 3fec9748..78f1e424 100644
--- a/mdoc.c
+++ b/mdoc.c
@@ -93,20 +93,6 @@ 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 roff_man *mdoc)
-{
-
- return(mdoc->first);
-}
-
-const struct roff_meta *
-mdoc_meta(const struct roff_man *mdoc)
-{
-
- return(&mdoc->meta);
-}
-
void
mdoc_endparse(struct roff_man *mdoc)
{
diff --git a/mdoc.h b/mdoc.h
index 536d4002..b73b99a6 100644
--- a/mdoc.h
+++ b/mdoc.h
@@ -284,8 +284,6 @@ __BEGIN_DECLS
struct roff_man;
-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
diff --git a/mdoc_html.c b/mdoc_html.c
index eec5361f..42fe218b 100644
--- a/mdoc_html.c
+++ b/mdoc_html.c
@@ -48,7 +48,6 @@ struct htmlmdoc {
void (*post)(MDOC_ARGS);
};
-static void print_mdoc(MDOC_ARGS);
static void print_mdoc_head(MDOC_ARGS);
static void print_mdoc_node(MDOC_ARGS);
static void print_mdoc_nodelist(MDOC_ARGS);
@@ -264,15 +263,6 @@ static const char * const lists[LIST_MAX] = {
};
-void
-html_mdoc(void *arg, const struct roff_man *mdoc)
-{
-
- print_mdoc(mdoc_meta(mdoc), mdoc_node(mdoc)->child,
- (struct html *)arg);
- putchar('\n');
-}
-
/*
* Calculate the scaling unit passed in a `-width' argument. This uses
* either a native scaling unit (e.g., 1i, 2m) or the string length of
@@ -331,29 +321,32 @@ synopsis_pre(struct html *h, const struct roff_node *n)
}
}
-static void
-print_mdoc(MDOC_ARGS)
+void
+html_mdoc(void *arg, const struct roff_man *mdoc)
{
- struct tag *t, *tt;
struct htmlpair tag;
+ struct html *h;
+ struct tag *t, *tt;
PAIR_CLASS_INIT(&tag, "mandoc");
+ h = (struct html *)arg;
if ( ! (HTML_FRAGMENT & h->oflags)) {
print_gen_decls(h);
t = print_otag(h, TAG_HTML, 0, NULL);
tt = print_otag(h, TAG_HEAD, 0, NULL);
- print_mdoc_head(meta, n, h);
+ print_mdoc_head(&mdoc->meta, mdoc->first->child, h);
print_tagq(h, tt);
print_otag(h, TAG_BODY, 0, NULL);
print_otag(h, TAG_DIV, 1, &tag);
} else
t = print_otag(h, TAG_DIV, 1, &tag);
- mdoc_root_pre(meta, n, h);
- print_mdoc_nodelist(meta, n, h);
- mdoc_root_post(meta, n, h);
+ mdoc_root_pre(&mdoc->meta, mdoc->first->child, h);
+ print_mdoc_nodelist(&mdoc->meta, mdoc->first->child, h);
+ mdoc_root_post(&mdoc->meta, mdoc->first->child, h);
print_tagq(h, t);
+ putchar('\n');
}
static void
diff --git a/mdoc_man.c b/mdoc_man.c
index 66f4d1bd..5fdd495a 100644
--- a/mdoc_man.c
+++ b/mdoc_man.c
@@ -547,16 +547,12 @@ man_man(void *arg, const struct roff_man *man)
void
man_mdoc(void *arg, const struct roff_man *mdoc)
{
- const struct roff_meta *meta;
struct roff_node *n;
- meta = mdoc_meta(mdoc);
- n = mdoc_node(mdoc)->child;
-
printf(".TH \"%s\" \"%s\" \"%s\" \"%s\" \"%s\"\n",
- meta->title,
- (meta->msec == NULL ? "" : meta->msec),
- meta->date, meta->os, meta->vol);
+ mdoc->meta.title,
+ (mdoc->meta.msec == NULL ? "" : mdoc->meta.msec),
+ mdoc->meta.date, mdoc->meta.os, mdoc->meta.vol);
/* Disable hyphenation and if nroff, disable justification. */
printf(".nh\n.if n .ad l");
@@ -567,10 +563,8 @@ man_mdoc(void *arg, const struct roff_man *mdoc)
fontqueue.head = fontqueue.tail = mandoc_malloc(8);
*fontqueue.tail = 'R';
}
- while (n != NULL) {
- print_node(meta, n);
- n = n->next;
- }
+ for (n = mdoc->first->child; n != NULL; n = n->next)
+ print_node(&mdoc->meta, n);
putchar('\n');
}
diff --git a/mdoc_term.c b/mdoc_term.c
index 68338ebd..a2ce71fc 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -253,25 +253,22 @@ static const struct termact termacts[MDOC_MAX] = {
void
terminal_mdoc(void *arg, const struct roff_man *mdoc)
{
- const struct roff_meta *meta;
struct roff_node *n;
struct termp *p;
p = (struct termp *)arg;
-
p->overstep = 0;
p->rmargin = p->maxrmargin = p->defrmargin;
p->tabwidth = term_len(p, 5);
- n = mdoc_node(mdoc)->child;
- meta = mdoc_meta(mdoc);
-
+ n = mdoc->first->child;
if (p->synopsisonly) {
while (n != NULL) {
if (n->tok == MDOC_Sh && n->sec == SEC_SYNOPSIS) {
if (n->child->next->child != NULL)
print_mdoc_nodelist(p, NULL,
- meta, n->child->next->child);
+ &mdoc->meta,
+ n->child->next->child);
term_newln(p);
break;
}
@@ -280,11 +277,12 @@ terminal_mdoc(void *arg, const struct roff_man *mdoc)
} else {
if (p->defindent == 0)
p->defindent = 5;
- term_begin(p, print_mdoc_head, print_mdoc_foot, meta);
+ term_begin(p, print_mdoc_head, print_mdoc_foot,
+ &mdoc->meta);
if (n != NULL) {
if (n->tok != MDOC_Sh)
term_vspace(p);
- print_mdoc_nodelist(p, NULL, meta, n);
+ print_mdoc_nodelist(p, NULL, &mdoc->meta, n);
}
term_end(p);
}
diff --git a/tree.c b/tree.c
index 43753149..4b20d048 100644
--- a/tree.c
+++ b/tree.c
@@ -41,14 +41,14 @@ void
tree_mdoc(void *arg, const struct roff_man *mdoc)
{
- print_mdoc(mdoc_node(mdoc)->child, 0);
+ print_mdoc(mdoc->first->child, 0);
}
void
tree_man(void *arg, const struct roff_man *man)
{
- print_man(man_node(man)->child, 0);
+ print_man(man->first->child, 0);
}
static void