summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2015-04-18 17:50:03 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2015-04-18 17:50:03 +0000
commita15dfcc7862a97d34cf8fed2bb1292c14721e771 (patch)
tree4578084e679ae306e5071615de9f1293078f08fc /usr.bin
parent4ecbeb26f11905d17a91ae50bb0f510f59332c8b (diff)
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.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/mandoc/man.c16
-rw-r--r--usr.bin/mandoc/man.h4
-rw-r--r--usr.bin/mandoc/man_html.c22
-rw-r--r--usr.bin/mandoc/man_term.c16
-rw-r--r--usr.bin/mandoc/mandocdb.c17
-rw-r--r--usr.bin/mandoc/mdoc.c16
-rw-r--r--usr.bin/mandoc/mdoc.h4
-rw-r--r--usr.bin/mandoc/mdoc_html.c29
-rw-r--r--usr.bin/mandoc/mdoc_man.c18
-rw-r--r--usr.bin/mandoc/mdoc_term.c16
-rw-r--r--usr.bin/mandoc/tree.c6
11 files changed, 53 insertions, 111 deletions
diff --git a/usr.bin/mandoc/man.c b/usr.bin/mandoc/man.c
index 950e7318f95..f5ce4c45aa5 100644
--- a/usr.bin/mandoc/man.c
+++ b/usr.bin/mandoc/man.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: man.c,v 1.104 2015/04/18 17:28:08 schwarze Exp $ */
+/* $OpenBSD: man.c,v 1.105 2015/04/18 17:50:02 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -60,20 +60,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/usr.bin/mandoc/man.h b/usr.bin/mandoc/man.h
index 6dafbdefb35..9ce71704565 100644
--- a/usr.bin/mandoc/man.h
+++ b/usr.bin/mandoc/man.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: man.h,v 1.53 2015/04/18 16:04:40 schwarze Exp $ */
+/* $OpenBSD: man.h,v 1.54 2015/04/18 17:50:02 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/usr.bin/mandoc/man_html.c b/usr.bin/mandoc/man_html.c
index 594d815858b..61f8157b765 100644
--- a/usr.bin/mandoc/man_html.c
+++ b/usr.bin/mandoc/man_html.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: man_html.c,v 1.69 2015/04/18 16:04:40 schwarze Exp $ */
+/* $OpenBSD: man_html.c,v 1.70 2015/04/18 17:50:02 schwarze Exp $ */
/*
* Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -52,7 +52,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);
@@ -146,33 +145,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/usr.bin/mandoc/man_term.c b/usr.bin/mandoc/man_term.c
index d45ae873258..a0cec2a8ad2 100644
--- a/usr.bin/mandoc/man_term.c
+++ b/usr.bin/mandoc/man_term.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: man_term.c,v 1.133 2015/04/18 16:04:40 schwarze Exp $ */
+/* $OpenBSD: man_term.c,v 1.134 2015/04/18 17:50:02 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -139,25 +139,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 &&
@@ -165,7 +160,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;
}
@@ -174,10 +170,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/usr.bin/mandoc/mandocdb.c b/usr.bin/mandoc/mandocdb.c
index 1bb19e44eb5..01dc61f5b95 100644
--- a/usr.bin/mandoc/mandocdb.c
+++ b/usr.bin/mandoc/mandocdb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mandocdb.c,v 1.145 2015/04/18 16:34:03 schwarze Exp $ */
+/* $OpenBSD: mandocdb.c,v 1.146 2015/04/18 17:50:02 schwarze Exp $ */
/*
* Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -1177,19 +1177,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);
@@ -1212,9 +1211,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/usr.bin/mandoc/mdoc.c b/usr.bin/mandoc/mdoc.c
index 40162bac117..5ce72ce465c 100644
--- a/usr.bin/mandoc/mdoc.c
+++ b/usr.bin/mandoc/mdoc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mdoc.c,v 1.134 2015/04/18 17:28:08 schwarze Exp $ */
+/* $OpenBSD: mdoc.c,v 1.135 2015/04/18 17:50:02 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -91,20 +91,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/usr.bin/mandoc/mdoc.h b/usr.bin/mandoc/mdoc.h
index 9527cc53154..5f773453645 100644
--- a/usr.bin/mandoc/mdoc.h
+++ b/usr.bin/mandoc/mdoc.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mdoc.h,v 1.65 2015/04/18 16:04:40 schwarze Exp $ */
+/* $OpenBSD: mdoc.h,v 1.66 2015/04/18 17:50:02 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/usr.bin/mandoc/mdoc_html.c b/usr.bin/mandoc/mdoc_html.c
index 7720dfb0142..7dba7ae3579 100644
--- a/usr.bin/mandoc/mdoc_html.c
+++ b/usr.bin/mandoc/mdoc_html.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mdoc_html.c,v 1.106 2015/04/18 16:04:40 schwarze Exp $ */
+/* $OpenBSD: mdoc_html.c,v 1.107 2015/04/18 17:50:02 schwarze Exp $ */
/*
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -46,7 +46,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);
@@ -262,15 +261,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
@@ -329,29 +319,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/usr.bin/mandoc/mdoc_man.c b/usr.bin/mandoc/mdoc_man.c
index d74278347e2..1a228384d34 100644
--- a/usr.bin/mandoc/mdoc_man.c
+++ b/usr.bin/mandoc/mdoc_man.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mdoc_man.c,v 1.90 2015/04/18 16:04:40 schwarze Exp $ */
+/* $OpenBSD: mdoc_man.c,v 1.91 2015/04/18 17:50:02 schwarze Exp $ */
/*
* Copyright (c) 2011-2015 Ingo Schwarze <schwarze@openbsd.org>
*
@@ -545,16 +545,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");
@@ -565,10 +561,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/usr.bin/mandoc/mdoc_term.c b/usr.bin/mandoc/mdoc_term.c
index 10901e388bd..037597481d2 100644
--- a/usr.bin/mandoc/mdoc_term.c
+++ b/usr.bin/mandoc/mdoc_term.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mdoc_term.c,v 1.217 2015/04/18 16:04:40 schwarze Exp $ */
+/* $OpenBSD: mdoc_term.c,v 1.218 2015/04/18 17:50:02 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -251,25 +251,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;
}
@@ -278,11 +275,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/usr.bin/mandoc/tree.c b/usr.bin/mandoc/tree.c
index fe69f192f55..2752a089397 100644
--- a/usr.bin/mandoc/tree.c
+++ b/usr.bin/mandoc/tree.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tree.c,v 1.32 2015/04/18 16:04:40 schwarze Exp $ */
+/* $OpenBSD: tree.c,v 1.33 2015/04/18 17:50:02 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -39,14 +39,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