summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/mandoc/main.c20
-rw-r--r--usr.bin/mandoc/man_term.c16
-rw-r--r--usr.bin/mandoc/mdoc_term.c58
-rw-r--r--usr.bin/mandoc/term.c14
-rw-r--r--usr.bin/mandoc/tree.c8
5 files changed, 55 insertions, 61 deletions
diff --git a/usr.bin/mandoc/main.c b/usr.bin/mandoc/main.c
index f08a38e4e4d..e8f76223343 100644
--- a/usr.bin/mandoc/main.c
+++ b/usr.bin/mandoc/main.c
@@ -1,4 +1,4 @@
-/* $Id: main.c,v 1.15 2009/08/22 17:21:23 schwarze Exp $ */
+/* $Id: main.c,v 1.16 2009/09/21 20:57:57 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -27,8 +27,8 @@
#include "mdoc.h"
#include "man.h"
-typedef int (*out_mdoc)(void *, const struct mdoc *);
-typedef int (*out_man)(void *, const struct man *);
+typedef void (*out_mdoc)(void *, const struct mdoc *);
+typedef void (*out_man)(void *, const struct man *);
typedef void (*out_free)(void *);
struct buf {
@@ -73,10 +73,10 @@ struct curparse {
};
extern void *ascii_alloc(void);
-extern int tree_mdoc(void *, const struct mdoc *);
-extern int tree_man(void *, const struct man *);
-extern int terminal_mdoc(void *, const struct mdoc *);
-extern int terminal_man(void *, const struct man *);
+extern void tree_mdoc(void *, const struct mdoc *);
+extern void tree_man(void *, const struct man *);
+extern void terminal_mdoc(void *, const struct mdoc *);
+extern void terminal_man(void *, const struct man *);
extern void terminal_free(void *);
static int foptions(int *, char *);
@@ -437,11 +437,9 @@ fdesc(struct buf *blk, struct buf *ln, struct curparse *curp)
/* Execute the out device, if it exists. */
if (man && curp->outman)
- if ( ! (*curp->outman)(curp->outdata, man))
- return(-1);
+ (*curp->outman)(curp->outdata, man);
if (mdoc && curp->outmdoc)
- if ( ! (*curp->outmdoc)(curp->outdata, mdoc))
- return(-1);
+ (*curp->outmdoc)(curp->outdata, mdoc);
return(1);
}
diff --git a/usr.bin/mandoc/man_term.c b/usr.bin/mandoc/man_term.c
index 76409496de5..43df65fe3db 100644
--- a/usr.bin/mandoc/man_term.c
+++ b/usr.bin/mandoc/man_term.c
@@ -1,4 +1,4 @@
-/* $Id: man_term.c,v 1.15 2009/09/21 20:28:43 schwarze Exp $ */
+/* $Id: man_term.c,v 1.16 2009/09/21 20:57:57 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -136,15 +136,13 @@ static void fmt_block_vspace(struct termp *,
static int arg_width(const struct man_node *);
-int
+void
man_run(struct termp *p, const struct man *m)
{
struct mtermp mt;
print_head(p, man_meta(m));
p->flags |= TERMP_NOSPACE;
- assert(man_node(m));
- assert(MAN_ROOT == man_node(m)->type);
mt.fl = 0;
mt.lmargin = INDENT;
@@ -153,8 +151,6 @@ man_run(struct termp *p, const struct man *m)
if (man_node(m)->child)
print_body(p, &mt, man_node(m)->child, man_meta(m));
print_foot(p, man_meta(m));
-
- return(1);
}
@@ -921,12 +917,12 @@ print_foot(struct termp *p, const struct man_meta *meta)
char *buf;
if (NULL == (buf = malloc(p->rmargin)))
- err(1, "malloc");
+ err(EXIT_FAILURE, "malloc");
tm = localtime(&meta->date);
if (0 == strftime(buf, p->rmargin, "%B %d, %Y", tm))
- err(1, "strftime");
+ err(EXIT_FAILURE, "strftime");
term_vspace(p);
@@ -961,9 +957,9 @@ print_head(struct termp *p, const struct man_meta *meta)
p->offset = 0;
if (NULL == (buf = malloc(p->rmargin)))
- err(1, "malloc");
+ err(EXIT_FAILURE, "malloc");
if (NULL == (title = malloc(p->rmargin)))
- err(1, "malloc");
+ err(EXIT_FAILURE, "malloc");
if (meta->vol)
(void)strlcpy(buf, meta->vol, p->rmargin);
diff --git a/usr.bin/mandoc/mdoc_term.c b/usr.bin/mandoc/mdoc_term.c
index 041cab9221a..a52872a15cf 100644
--- a/usr.bin/mandoc/mdoc_term.c
+++ b/usr.bin/mandoc/mdoc_term.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_term.c,v 1.54 2009/09/21 20:28:43 schwarze Exp $ */
+/* $Id: mdoc_term.c,v 1.55 2009/09/21 20:57:57 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -280,27 +280,24 @@ static void fmt_block_vspace(struct termp *,
const struct mdoc_node *,
const struct mdoc_node *);
static void print_node(DECL_ARGS);
-static void print_head(struct termp *,
- const struct mdoc_meta *);
+static void print_head(DECL_ARGS);
static void print_body(DECL_ARGS);
-static void print_foot(struct termp *,
- const struct mdoc_meta *);
+static void print_foot(DECL_ARGS);
-int
-mdoc_run(struct termp *p, const struct mdoc *m)
+void
+mdoc_run(struct termp *p, const struct mdoc *mdoc)
{
- /*
- * Main output function. When this is called, assume that the
- * tree is properly formed.
- */
- print_head(p, mdoc_meta(m));
- assert(mdoc_node(m));
- assert(MDOC_ROOT == mdoc_node(m)->type);
- if (mdoc_node(m)->child)
- print_body(p, NULL, mdoc_meta(m), mdoc_node(m)->child);
- print_foot(p, mdoc_meta(m));
- return(1);
+ const struct mdoc_node *n;
+ const struct mdoc_meta *m;
+
+ n = mdoc_node(mdoc);
+ m = mdoc_meta(mdoc);
+
+ print_head(p, NULL, m, n);
+ if (n->child)
+ print_body(p, NULL, m, n->child);
+ print_foot(p, NULL, m, n);
}
@@ -360,8 +357,9 @@ print_node(DECL_ARGS)
}
+/* ARGSUSED */
static void
-print_foot(struct termp *p, const struct mdoc_meta *meta)
+print_foot(DECL_ARGS)
{
struct tm *tm;
char *buf, *os;
@@ -375,14 +373,14 @@ print_foot(struct termp *p, const struct mdoc_meta *meta)
*/
if (NULL == (buf = malloc(p->rmargin)))
- err(1, "malloc");
+ err(EXIT_FAILURE, "malloc");
if (NULL == (os = malloc(p->rmargin)))
- err(1, "malloc");
+ err(EXIT_FAILURE, "malloc");
tm = localtime(&meta->date);
if (0 == strftime(buf, p->rmargin, "%B %e, %Y", tm))
- err(1, "strftime");
+ err(EXIT_FAILURE, "strftime");
(void)strlcpy(os, meta->os, p->rmargin);
@@ -419,8 +417,10 @@ print_foot(struct termp *p, const struct mdoc_meta *meta)
}
+/* FIXME: put in utility library. */
+/* ARGSUSED */
static void
-print_head(struct termp *p, const struct mdoc_meta *meta)
+print_head(DECL_ARGS)
{
char *buf, *title;
@@ -428,9 +428,9 @@ print_head(struct termp *p, const struct mdoc_meta *meta)
p->offset = 0;
if (NULL == (buf = malloc(p->rmargin)))
- err(1, "malloc");
+ err(EXIT_FAILURE, "malloc");
if (NULL == (title = malloc(p->rmargin)))
- err(1, "malloc");
+ err(EXIT_FAILURE, "malloc");
/*
* The header is strange. It has three components, which are
@@ -454,8 +454,7 @@ print_head(struct termp *p, const struct mdoc_meta *meta)
(void)strlcat(buf, ")", p->rmargin);
}
- (void)snprintf(title, p->rmargin, "%s(%d)",
- meta->title, meta->msec);
+ snprintf(title, p->rmargin, "%s(%d)", meta->title, meta->msec);
p->offset = 0;
p->rmargin = (p->maxrmargin - strlen(buf) + 1) / 2;
@@ -488,6 +487,7 @@ print_head(struct termp *p, const struct mdoc_meta *meta)
}
+/* FIXME: put in utility file for front-ends. */
static size_t
arg_width(const struct mdoc_argv *arg, int pos)
{
@@ -514,6 +514,7 @@ arg_width(const struct mdoc_argv *arg, int pos)
}
+/* FIXME: put in utility file for front-ends. */
static int
arg_listtype(const struct mdoc_node *n)
{
@@ -555,6 +556,7 @@ arg_listtype(const struct mdoc_node *n)
}
+/* FIXME: put in utility file for front-ends. */
static size_t
arg_offset(const struct mdoc_argv *arg)
{
@@ -754,7 +756,7 @@ termp_it_pre(DECL_ARGS)
* the 0 will be adjusted to default 10 or, if in the
* last column case, set to stretch to the margin).
*/
- for (i = 0, n = node->prev; n && n &&
+ for (i = 0, n = node->prev; n &&
i < (int)bl->args[vals[2]].argv->sz;
n = n->prev, i++)
offset += arg_width
diff --git a/usr.bin/mandoc/term.c b/usr.bin/mandoc/term.c
index 82a3cdd7bc6..b5615b20126 100644
--- a/usr.bin/mandoc/term.c
+++ b/usr.bin/mandoc/term.c
@@ -1,4 +1,4 @@
-/* $Id: term.c,v 1.12 2009/09/21 20:28:43 schwarze Exp $ */
+/* $Id: term.c,v 1.13 2009/09/21 20:57:57 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -24,9 +24,9 @@
#include "man.h"
#include "mdoc.h"
-extern int man_run(struct termp *,
+extern void man_run(struct termp *,
const struct man *);
-extern int mdoc_run(struct termp *,
+extern void mdoc_run(struct termp *,
const struct mdoc *);
static struct termp *term_alloc(enum termenc);
@@ -51,7 +51,7 @@ ascii_alloc(void)
}
-int
+void
terminal_man(void *arg, const struct man *man)
{
struct termp *p;
@@ -60,11 +60,11 @@ terminal_man(void *arg, const struct man *man)
if (NULL == p->symtab)
p->symtab = term_ascii2htab();
- return(man_run(p, man));
+ man_run(p, man);
}
-int
+void
terminal_mdoc(void *arg, const struct mdoc *mdoc)
{
struct termp *p;
@@ -73,7 +73,7 @@ terminal_mdoc(void *arg, const struct mdoc *mdoc)
if (NULL == p->symtab)
p->symtab = term_ascii2htab();
- return(mdoc_run(p, mdoc));
+ mdoc_run(p, mdoc);
}
diff --git a/usr.bin/mandoc/tree.c b/usr.bin/mandoc/tree.c
index d4c6adc91e5..70e9d64b763 100644
--- a/usr.bin/mandoc/tree.c
+++ b/usr.bin/mandoc/tree.c
@@ -1,4 +1,4 @@
-/* $Id: tree.c,v 1.3 2009/08/22 20:14:37 schwarze Exp $ */
+/* $Id: tree.c,v 1.4 2009/09/21 20:57:57 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -27,22 +27,20 @@ static void print_man(const struct man_node *, int);
/* ARGSUSED */
-int
+void
tree_mdoc(void *arg, const struct mdoc *mdoc)
{
print_mdoc(mdoc_node(mdoc), 0);
- return(1);
}
/* ARGSUSED */
-int
+void
tree_man(void *arg, const struct man *man)
{
print_man(man_node(man), 0);
- return(1);
}