aboutsummaryrefslogtreecommitdiffstatshomepage
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
commit28e0682df89260767e1ad5a3af0b93e504ae5290 (patch)
treee1bd4cc5ee13a989fdaa752597ae30a9a5710491
parentacfef3c388fe4c84eaad68e8f398c7873f1bb732 (diff)
downloadmandoc-28e0682df89260767e1ad5a3af0b93e504ae5290.tar.gz
mandoc-28e0682df89260767e1ad5a3af0b93e504ae5290.tar.zst
mandoc-28e0682df89260767e1ad5a3af0b93e504ae5290.zip
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.c6
-rw-r--r--man.c16
-rw-r--r--man.h4
-rw-r--r--man_html.c22
-rw-r--r--man_term.c16
-rw-r--r--mandocdb.c17
-rw-r--r--mdoc.c16
-rw-r--r--mdoc.h4
-rw-r--r--mdoc_html.c29
-rw-r--r--mdoc_man.c18
-rw-r--r--mdoc_term.c16
-rw-r--r--tree.c6
12 files changed, 56 insertions, 114 deletions
diff --git a/demandoc.c b/demandoc.c
index d4667c48..a51c8cca 100644
--- a/demandoc.c
+++ b/demandoc.c
@@ -1,4 +1,4 @@
-/* $Id: demandoc.c,v 1.19 2015/04/18 16:34:25 schwarze Exp $ */
+/* $Id: demandoc.c,v 1.20 2015/04/18 17:53:21 schwarze Exp $ */
/*
* Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -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 608ef6cf..b4463170 100644
--- a/man.c
+++ b/man.c
@@ -1,4 +1,4 @@
-/* $Id: man.c,v 1.156 2015/04/18 17:28:36 schwarze Exp $ */
+/* $Id: man.c,v 1.157 2015/04/18 17:53:21 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -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 28f9abcd..9e77eee4 100644
--- a/man.h
+++ b/man.h
@@ -1,4 +1,4 @@
-/* $Id: man.h,v 1.73 2015/04/18 16:06:40 schwarze Exp $ */
+/* $Id: man.h,v 1.74 2015/04/18 17:53:21 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -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 35da21d4..12266acb 100644
--- a/man_html.c
+++ b/man_html.c
@@ -1,4 +1,4 @@
-/* $Id: man_html.c,v 1.116 2015/04/18 16:06:40 schwarze Exp $ */
+/* $Id: man_html.c,v 1.117 2015/04/18 17:53:21 schwarze Exp $ */
/*
* Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -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 dc424128..08a87f0f 100644
--- a/man_term.c
+++ b/man_term.c
@@ -1,4 +1,4 @@
-/* $Id: man_term.c,v 1.180 2015/04/18 16:06:40 schwarze Exp $ */
+/* $Id: man_term.c,v 1.181 2015/04/18 17:53:21 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -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 398f1666..46bd4dfa 100644
--- a/mandocdb.c
+++ b/mandocdb.c
@@ -1,4 +1,4 @@
-/* $Id: mandocdb.c,v 1.192 2015/04/18 16:34:25 schwarze Exp $ */
+/* $Id: mandocdb.c,v 1.193 2015/04/18 17:53:21 schwarze Exp $ */
/*
* Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -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 c3c36421..d0ccaa73 100644
--- a/mdoc.c
+++ b/mdoc.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc.c,v 1.245 2015/04/18 17:28:36 schwarze Exp $ */
+/* $Id: mdoc.c,v 1.246 2015/04/18 17:53:21 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -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 d8814575..ddfd4e1e 100644
--- a/mdoc.h
+++ b/mdoc.h
@@ -1,4 +1,4 @@
-/* $Id: mdoc.h,v 1.140 2015/04/18 16:06:40 schwarze Exp $ */
+/* $Id: mdoc.h,v 1.141 2015/04/18 17:53:21 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -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 62d70993..85be95b6 100644
--- a/mdoc_html.c
+++ b/mdoc_html.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_html.c,v 1.231 2015/04/18 16:06:40 schwarze Exp $ */
+/* $Id: mdoc_html.c,v 1.232 2015/04/18 17:53:21 schwarze Exp $ */
/*
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -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 10daa697..4ea0fa24 100644
--- a/mdoc_man.c
+++ b/mdoc_man.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_man.c,v 1.92 2015/04/18 16:06:40 schwarze Exp $ */
+/* $Id: mdoc_man.c,v 1.93 2015/04/18 17:53:21 schwarze Exp $ */
/*
* Copyright (c) 2011-2015 Ingo Schwarze <schwarze@openbsd.org>
*
@@ -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 f2b081a6..be170bf5 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_term.c,v 1.318 2015/04/18 16:06:41 schwarze Exp $ */
+/* $Id: mdoc_term.c,v 1.319 2015/04/18 17:53:21 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -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 8a5ba452..8673f45b 100644
--- a/tree.c
+++ b/tree.c
@@ -1,4 +1,4 @@
-/* $Id: tree.c,v 1.65 2015/04/18 16:06:41 schwarze Exp $ */
+/* $Id: tree.c,v 1.66 2015/04/18 17:53:21 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -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