diff options
-rw-r--r-- | main.c | 12 | ||||
-rw-r--r-- | main.h | 1 | ||||
-rw-r--r-- | man_term.c | 9 | ||||
-rw-r--r-- | mdoc_term.c | 9 | ||||
-rw-r--r-- | term.c | 12 | ||||
-rw-r--r-- | term.h | 4 | ||||
-rw-r--r-- | term_ascii.c | 24 | ||||
-rw-r--r-- | term_ps.c | 3 |
8 files changed, 37 insertions, 37 deletions
@@ -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")) @@ -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 *); @@ -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); @@ -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 @@ -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 @@ -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; |