summaryrefslogtreecommitdiffstatshomepage
path: root/mdoc_html.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2011-04-04 16:01:47 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2011-04-04 16:01:47 +0000
commit279e3bd082808b213b41302831a195b058be9883 (patch)
treee814ebb8ded92c752d46b2c46ab153a26b8761ee /mdoc_html.c
parent055583f1f6e50e76afbe2acda2071f46b89b173f (diff)
downloadmandoc-279e3bd082808b213b41302831a195b058be9883.tar.gz
mandoc-279e3bd082808b213b41302831a195b058be9883.tar.zst
mandoc-279e3bd082808b213b41302831a195b058be9883.zip
Make `Rv' do the Right Thing regarding commas and "and" when listing its
output. This also makes it easier to read. While here, remove superfluous assignment to local variables for this and `Mt'.
Diffstat (limited to 'mdoc_html.c')
-rw-r--r--mdoc_html.c47
1 files changed, 27 insertions, 20 deletions
diff --git a/mdoc_html.c b/mdoc_html.c
index 128578d3..a5ba2a1e 100644
--- a/mdoc_html.c
+++ b/mdoc_html.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_html.c,v 1.158 2011/04/04 15:45:12 kristaps Exp $ */
+/* $Id: mdoc_html.c,v 1.159 2011/04/04 16:01:47 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -1628,19 +1628,21 @@ mdoc_lk_pre(MDOC_ARGS)
static int
mdoc_mt_pre(MDOC_ARGS)
{
- struct htmlpair tag[2];
- struct tag *t;
- const struct mdoc_node *nn;
+ struct htmlpair tag[2];
+ struct tag *t;
PAIR_CLASS_INIT(&tag[0], "link-mail");
- for (nn = n->child; nn; nn = nn->next) {
+ for (n = n->child; n; n = n->next) {
+ assert(MDOC_TEXT == n->type);
+
bufinit(h);
bufcat(h, "mailto:");
- bufcat(h, nn->string);
+ bufcat(h, n->string);
+
PAIR_HREF_INIT(&tag[1], h->buf);
t = print_otag(h, TAG_A, 2, tag);
- print_text(h, nn->string);
+ print_text(h, n->string);
print_tagq(h, t);
}
@@ -1766,31 +1768,36 @@ mdoc_ic_pre(MDOC_ARGS)
static int
mdoc_rv_pre(MDOC_ARGS)
{
- const struct mdoc_node *nn;
- struct htmlpair tag;
- struct tag *t;
+ struct htmlpair tag;
+ struct tag *t;
+ int nchild;
if (n->prev)
print_otag(h, TAG_BR, 0, NULL);
print_text(h, "The");
- for (nn = n->child; nn; nn = nn->next) {
+ nchild = n->nchild;
+ for (n = n->child; n; n = n->next) {
+ assert(MDOC_TEXT == n->type);
PAIR_CLASS_INIT(&tag, "fname");
+
t = print_otag(h, TAG_B, 1, &tag);
- print_text(h, nn->string);
+ print_text(h, n->string);
print_tagq(h, t);
-
h->flags |= HTML_NOSPACE;
- if (nn->next && NULL == nn->next->next)
- print_text(h, "(), and");
- else if (nn->next)
- print_text(h, "(),");
- else
- print_text(h, "()");
+ print_text(h, "()");
+
+ if (nchild > 2 && n->next) {
+ h->flags |= HTML_NOSPACE;
+ print_text(h, ",");
+ }
+
+ if (n->next && NULL == n->next->next)
+ print_text(h, "and");
}
- if (n->child && n->child->next)
+ if (nchild > 1)
print_text(h, "functions return");
else
print_text(h, "function returns");