summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--main.c12
-rw-r--r--main.h1
-rw-r--r--man_term.c9
-rw-r--r--mdoc_term.c9
-rw-r--r--term.c12
-rw-r--r--term.h4
-rw-r--r--term_ascii.c24
-rw-r--r--term_ps.c3
8 files changed, 37 insertions, 37 deletions
diff --git a/main.c b/main.c
index d5e57bec..99a44f58 100644
--- a/main.c
+++ b/main.c
@@ -43,6 +43,7 @@ typedef void (*out_free)(void *);
enum outt {
OUTT_ASCII = 0, /* -Tascii */
+ OUTT_LOCALE, /* -Tlocale */
OUTT_TREE, /* -Ttree */
OUTT_HTML, /* -Thtml */
OUTT_XHTML, /* -Txhtml */
@@ -206,9 +207,15 @@ parse(struct curparse *curp, int fd,
switch (curp->outtype) {
case (OUTT_XHTML):
curp->outdata = xhtml_alloc(curp->outopts);
+ curp->outfree = html_free;
break;
case (OUTT_HTML):
curp->outdata = html_alloc(curp->outopts);
+ curp->outfree = html_free;
+ break;
+ case (OUTT_LOCALE):
+ curp->outdata = locale_alloc(curp->outopts);
+ curp->outfree = ascii_free;
break;
case (OUTT_ASCII):
curp->outdata = ascii_alloc(curp->outopts);
@@ -232,7 +239,6 @@ parse(struct curparse *curp, int fd,
case (OUTT_XHTML):
curp->outman = html_man;
curp->outmdoc = html_mdoc;
- curp->outfree = html_free;
break;
case (OUTT_TREE):
curp->outman = tree_man;
@@ -242,6 +248,8 @@ parse(struct curparse *curp, int fd,
/* FALLTHROUGH */
case (OUTT_ASCII):
/* FALLTHROUGH */
+ case (OUTT_LOCALE):
+ /* FALLTHROUGH */
case (OUTT_PS):
curp->outman = terminal_man;
curp->outmdoc = terminal_mdoc;
@@ -299,6 +307,8 @@ toptions(struct curparse *curp, char *arg)
curp->outtype = OUTT_TREE;
else if (0 == strcmp(arg, "html"))
curp->outtype = OUTT_HTML;
+ else if (0 == strcmp(arg, "locale"))
+ curp->outtype = OUTT_LOCALE;
else if (0 == strcmp(arg, "xhtml"))
curp->outtype = OUTT_XHTML;
else if (0 == strcmp(arg, "ps"))
diff --git a/main.h b/main.h
index b3fd2b65..7588749c 100644
--- a/main.h
+++ b/main.h
@@ -41,6 +41,7 @@ void html_free(void *);
void tree_mdoc(void *, const struct mdoc *);
void tree_man(void *, const struct man *);
+void *locale_alloc(char *);
void *ascii_alloc(char *);
void ascii_free(void *);
diff --git a/man_term.c b/man_term.c
index af8e45c6..f390170b 100644
--- a/man_term.c
+++ b/man_term.c
@@ -156,14 +156,7 @@ terminal_man(void *arg, const struct man *man)
p->tabwidth = term_len(p, 5);
if (NULL == p->symtab)
- switch (p->enc) {
- case (TERMENC_ASCII):
- p->symtab = mchars_alloc();
- break;
- default:
- abort();
- /* NOTREACHED */
- }
+ p->symtab = mchars_alloc();
n = man_node(man);
m = man_meta(man);
diff --git a/mdoc_term.c b/mdoc_term.c
index 0ccacd66..bf2997fa 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -264,14 +264,7 @@ terminal_mdoc(void *arg, const struct mdoc *mdoc)
p->tabwidth = term_len(p, 5);
if (NULL == p->symtab)
- switch (p->enc) {
- case (TERMENC_ASCII):
- p->symtab = mchars_alloc();
- break;
- default:
- abort();
- /* NOTREACHED */
- }
+ p->symtab = mchars_alloc();
n = mdoc_node(mdoc);
m = mdoc_meta(mdoc);
diff --git a/term.c b/term.c
index 7556e3b6..09647a07 100644
--- a/term.c
+++ b/term.c
@@ -69,18 +69,6 @@ term_end(struct termp *p)
(*p->end)(p);
}
-
-struct termp *
-term_alloc(enum termenc enc)
-{
- struct termp *p;
-
- p = mandoc_calloc(1, sizeof(struct termp));
- p->enc = enc;
- return(p);
-}
-
-
/*
* Flush a line of text. A "line" is loosely defined as being something
* that should be followed by a newline, regardless of whether it's
diff --git a/term.h b/term.h
index 5bdcd3ba..252b0a2a 100644
--- a/term.h
+++ b/term.h
@@ -22,7 +22,8 @@ __BEGIN_DECLS
struct termp;
enum termenc {
- TERMENC_ASCII
+ TERMENC_ASCII,
+ TERMENC_LOCALE
};
enum termtype {
@@ -94,7 +95,6 @@ struct termp {
struct termp_ps *ps;
};
-struct termp *term_alloc(enum termenc);
void term_tbl(struct termp *, const struct tbl_span *);
void term_free(struct termp *);
void term_newln(struct termp *);
diff --git a/term_ascii.c b/term_ascii.c
index d3f29d02..831621b3 100644
--- a/term_ascii.c
+++ b/term_ascii.c
@@ -31,6 +31,7 @@
#include "term.h"
#include "main.h"
+static struct termp *ascii_init(enum termenc, char *);
static double ascii_hspan(const struct termp *,
const struct roffsu *);
static size_t ascii_width(const struct termp *, int);
@@ -40,15 +41,15 @@ static void ascii_end(struct termp *);
static void ascii_endline(struct termp *);
static void ascii_letter(struct termp *, int);
-
-void *
-ascii_alloc(char *outopts)
+static struct termp *
+ascii_init(enum termenc enc, char *outopts)
{
- struct termp *p;
const char *toks[2];
char *v;
+ struct termp *p;
- p = term_alloc(TERMENC_ASCII);
+ p = mandoc_calloc(1, sizeof(struct termp));
+ p->enc = enc;
p->tabwidth = 5;
p->defrmargin = 78;
@@ -81,6 +82,19 @@ ascii_alloc(char *outopts)
return(p);
}
+void *
+ascii_alloc(char *outopts)
+{
+
+ return(ascii_init(TERMENC_ASCII, outopts));
+}
+
+void *
+locale_alloc(char *outopts)
+{
+
+ return(ascii_init(TERMENC_LOCALE, outopts));
+}
/* ARGSUSED */
static size_t
diff --git a/term_ps.c b/term_ps.c
index 8047407d..91402ff4 100644
--- a/term_ps.c
+++ b/term_ps.c
@@ -434,7 +434,8 @@ pspdf_alloc(char *outopts)
const char *pp;
char *v;
- p = term_alloc(TERMENC_ASCII);
+ p = mandoc_calloc(1, sizeof(struct termp));
+ p->enc = TERMENC_ASCII;
p->ps = mandoc_calloc(1, sizeof(struct termp_ps));
p->advance = ps_advance;