-/* $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>
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)
{
-/* $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>
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 *);
-/* $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>
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);
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
-/* $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>
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 &&
!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;
}
} 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);
}
}
-/* $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>
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);
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)
-/* $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>
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)
{
-/* $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>
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
-/* $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>
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);
};
-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
}
}
-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
-/* $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>
*
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");
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');
}
-/* $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>
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;
}
} 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);
}
-/* $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>
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