like -Tascii. While adding this, inline term_alloc() (was a one-liner),
remove some switches around the terminal encoding for the symbol table
(unnecessary), and split out ascii_alloc() into ascii_init(), which is
also called from locale_init().
-/* $Id: main.c,v 1.161 2011/03/31 10:53:43 kristaps Exp $ */
+/* $Id: main.c,v 1.162 2011/05/17 14:38:34 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org>
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org>
enum outt {
OUTT_ASCII = 0, /* -Tascii */
enum outt {
OUTT_ASCII = 0, /* -Tascii */
+ OUTT_LOCALE, /* -Tlocale */
OUTT_TREE, /* -Ttree */
OUTT_HTML, /* -Thtml */
OUTT_XHTML, /* -Txhtml */
OUTT_TREE, /* -Ttree */
OUTT_HTML, /* -Thtml */
OUTT_XHTML, /* -Txhtml */
switch (curp->outtype) {
case (OUTT_XHTML):
curp->outdata = xhtml_alloc(curp->outopts);
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);
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);
break;
case (OUTT_ASCII):
curp->outdata = ascii_alloc(curp->outopts);
case (OUTT_XHTML):
curp->outman = html_man;
curp->outmdoc = html_mdoc;
case (OUTT_XHTML):
curp->outman = html_man;
curp->outmdoc = html_mdoc;
- curp->outfree = html_free;
break;
case (OUTT_TREE):
curp->outman = tree_man;
break;
case (OUTT_TREE):
curp->outman = tree_man;
/* FALLTHROUGH */
case (OUTT_ASCII):
/* FALLTHROUGH */
/* FALLTHROUGH */
case (OUTT_ASCII):
/* FALLTHROUGH */
+ case (OUTT_LOCALE):
+ /* FALLTHROUGH */
case (OUTT_PS):
curp->outman = terminal_man;
curp->outmdoc = terminal_mdoc;
case (OUTT_PS):
curp->outman = terminal_man;
curp->outmdoc = terminal_mdoc;
curp->outtype = OUTT_TREE;
else if (0 == strcmp(arg, "html"))
curp->outtype = OUTT_HTML;
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"))
else if (0 == strcmp(arg, "xhtml"))
curp->outtype = OUTT_XHTML;
else if (0 == strcmp(arg, "ps"))
-/* $Id: main.h,v 1.10 2010/07/31 23:52:58 schwarze Exp $ */
+/* $Id: main.h,v 1.11 2011/05/17 14:38:34 kristaps Exp $ */
/*
* Copyright (c) 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
/*
* Copyright (c) 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
void tree_mdoc(void *, const struct mdoc *);
void tree_man(void *, const struct man *);
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 *);
void *ascii_alloc(char *);
void ascii_free(void *);
-/* $Id: man_term.c,v 1.108 2011/04/30 22:14:42 kristaps Exp $ */
+/* $Id: man_term.c,v 1.109 2011/05/17 14:38:34 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org>
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org>
p->tabwidth = term_len(p, 5);
if (NULL == p->symtab)
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);
n = man_node(man);
m = man_meta(man);
-/* $Id: mdoc_term.c,v 1.229 2011/04/30 22:14:42 kristaps Exp $ */
+/* $Id: mdoc_term.c,v 1.230 2011/05/17 14:38:34 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
p->tabwidth = term_len(p, 5);
if (NULL == p->symtab)
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);
n = mdoc_node(mdoc);
m = mdoc_meta(mdoc);
-/* $Id: term.c,v 1.192 2011/05/17 11:55:08 kristaps Exp $ */
+/* $Id: term.c,v 1.193 2011/05/17 14:38:34 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org>
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org>
-
-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
/*
* 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
-/* $Id: term.h,v 1.83 2011/05/15 00:58:48 kristaps Exp $ */
+/* $Id: term.h,v 1.84 2011/05/17 14:38:34 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
struct termp;
enum termenc {
struct termp;
enum termenc {
+ TERMENC_ASCII,
+ TERMENC_LOCALE
-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 *);
void term_tbl(struct termp *, const struct tbl_span *);
void term_free(struct termp *);
void term_newln(struct termp *);
-/* $Id: term_ascii.c,v 1.13 2011/05/14 17:54:42 kristaps Exp $ */
+/* $Id: term_ascii.c,v 1.14 2011/05/17 14:38:34 kristaps Exp $ */
/*
* Copyright (c) 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
/*
* Copyright (c) 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
#include "term.h"
#include "main.h"
#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);
static double ascii_hspan(const struct termp *,
const struct roffsu *);
static size_t ascii_width(const struct termp *, int);
static void ascii_endline(struct termp *);
static void ascii_letter(struct termp *, int);
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)
const char *toks[2];
char *v;
const char *toks[2];
char *v;
- p = term_alloc(TERMENC_ASCII);
+ p = mandoc_calloc(1, sizeof(struct termp));
+ p->enc = enc;
p->tabwidth = 5;
p->defrmargin = 78;
p->tabwidth = 5;
p->defrmargin = 78;
+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
/* ARGSUSED */
static size_t
-/* $Id: term_ps.c,v 1.50 2011/05/15 00:58:48 kristaps Exp $ */
+/* $Id: term_ps.c,v 1.51 2011/05/17 14:38:34 kristaps Exp $ */
/*
* Copyright (c) 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
/*
* Copyright (c) 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
- 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;
p->ps = mandoc_calloc(1, sizeof(struct termp_ps));
p->advance = ps_advance;