summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/mandoc')
-rw-r--r--usr.bin/mandoc/cgi.c10
-rw-r--r--usr.bin/mandoc/chars.c4
-rw-r--r--usr.bin/mandoc/html.c26
-rw-r--r--usr.bin/mandoc/html.h4
-rw-r--r--usr.bin/mandoc/libmandoc.h4
-rw-r--r--usr.bin/mandoc/main.c38
-rw-r--r--usr.bin/mandoc/main.h15
-rw-r--r--usr.bin/mandoc/man_term.c5
-rw-r--r--usr.bin/mandoc/mandoc.h4
-rw-r--r--usr.bin/mandoc/mandocdb.c8
-rw-r--r--usr.bin/mandoc/mdoc_term.c5
-rw-r--r--usr.bin/mandoc/read.c10
-rw-r--r--usr.bin/mandoc/roff.c13
-rw-r--r--usr.bin/mandoc/term.c8
-rw-r--r--usr.bin/mandoc/term.h4
-rw-r--r--usr.bin/mandoc/term_ascii.c20
-rw-r--r--usr.bin/mandoc/term_ps.c15
17 files changed, 91 insertions, 102 deletions
diff --git a/usr.bin/mandoc/cgi.c b/usr.bin/mandoc/cgi.c
index 4cfbfcc2841..d3ac30f826f 100644
--- a/usr.bin/mandoc/cgi.c
+++ b/usr.bin/mandoc/cgi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cgi.c,v 1.38 2014/10/07 18:20:42 schwarze Exp $ */
+/* $OpenBSD: cgi.c,v 1.39 2014/10/28 17:35:42 schwarze Exp $ */
/*
* Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014 Ingo Schwarze <schwarze@usta.de>
@@ -823,6 +823,7 @@ static void
format(const struct req *req, const char *file)
{
struct mparse *mp;
+ struct mchars *mchars;
struct mdoc *mdoc;
struct man *man;
void *vp;
@@ -836,8 +837,9 @@ format(const struct req *req, const char *file)
return;
}
+ mchars = mchars_alloc();
mp = mparse_alloc(MPARSE_SO, MANDOCLEVEL_FATAL, NULL,
- req->q.manpath);
+ mchars, req->q.manpath);
rc = mparse_readfd(mp, fd, file);
close(fd);
@@ -863,10 +865,11 @@ format(const struct req *req, const char *file)
req->q.manpath, file);
pg_error_internal();
mparse_free(mp);
+ mchars_free(mchars);
return;
}
- vp = html_alloc(opts);
+ vp = html_alloc(mchars, opts);
if (NULL != mdoc)
html_mdoc(vp, mdoc);
@@ -875,6 +878,7 @@ format(const struct req *req, const char *file)
html_free(vp);
mparse_free(mp);
+ mchars_free(mchars);
free(opts);
}
diff --git a/usr.bin/mandoc/chars.c b/usr.bin/mandoc/chars.c
index 39adcf92d3e..ef8c6cdc5db 100644
--- a/usr.bin/mandoc/chars.c
+++ b/usr.bin/mandoc/chars.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: chars.c,v 1.33 2014/10/28 13:22:57 schwarze Exp $ */
+/* $OpenBSD: chars.c,v 1.34 2014/10/28 17:35:42 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -102,7 +102,7 @@ mchars_spec2cp(const struct mchars *arg, const char *p, size_t sz)
const struct ln *ln;
ln = find(arg, p, sz);
- return(ln != NULL ? ln->unicode : sz == 1 ? *p : 0xFFFD);
+ return(ln != NULL ? ln->unicode : sz == 1 ? (unsigned char)*p : -1);
}
char
diff --git a/usr.bin/mandoc/html.c b/usr.bin/mandoc/html.c
index a0c2f20eaae..14fe83c629b 100644
--- a/usr.bin/mandoc/html.c
+++ b/usr.bin/mandoc/html.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: html.c,v 1.49 2014/10/27 16:28:30 schwarze Exp $ */
+/* $OpenBSD: html.c,v 1.50 2014/10/28 17:35:42 schwarze Exp $ */
/*
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -125,11 +125,10 @@ static int print_escape(char);
static int print_encode(struct html *, const char *, int);
static void print_metaf(struct html *, enum mandoc_esc);
static void print_attr(struct html *, const char *, const char *);
-static void *ml_alloc(char *);
-static void *
-ml_alloc(char *outopts)
+void *
+html_alloc(const struct mchars *mchars, char *outopts)
{
struct html *h;
const char *toks[5];
@@ -144,7 +143,7 @@ ml_alloc(char *outopts)
h = mandoc_calloc(1, sizeof(struct html));
h->tags.head = NULL;
- h->symtab = mchars_alloc();
+ h->symtab = mchars;
while (outopts && *outopts)
switch (getsubopt(&outopts, UNCONST(toks), &v)) {
@@ -167,20 +166,6 @@ ml_alloc(char *outopts)
return(h);
}
-void *
-html_alloc(char *outopts)
-{
-
- return(ml_alloc(outopts));
-}
-
-void *
-xhtml_alloc(char *outopts)
-{
-
- return(ml_alloc(outopts));
-}
-
void
html_free(void *p)
{
@@ -194,9 +179,6 @@ html_free(void *p)
free(tag);
}
- if (h->symtab)
- mchars_free(h->symtab);
-
free(h);
}
diff --git a/usr.bin/mandoc/html.h b/usr.bin/mandoc/html.h
index 097df293d33..3c55a64bf30 100644
--- a/usr.bin/mandoc/html.h
+++ b/usr.bin/mandoc/html.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: html.h,v 1.28 2014/10/10 15:25:06 schwarze Exp $ */
+/* $OpenBSD: html.h,v 1.29 2014/10/28 17:35:42 schwarze Exp $ */
/*
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -133,7 +133,7 @@ struct html {
struct tagq tags; /* stack of open tags */
struct rofftbl tbl; /* current table */
struct tag *tblt; /* current open table scope */
- struct mchars *symtab; /* character-escapes */
+ const struct mchars *symtab; /* character table */
char *base_man; /* base for manpage href */
char *base_includes; /* base for include href */
char *style; /* style-sheet URI */
diff --git a/usr.bin/mandoc/libmandoc.h b/usr.bin/mandoc/libmandoc.h
index 45a83edf08a..e7484c7b708 100644
--- a/usr.bin/mandoc/libmandoc.h
+++ b/usr.bin/mandoc/libmandoc.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: libmandoc.h,v 1.30 2014/10/16 01:10:06 schwarze Exp $ */
+/* $OpenBSD: libmandoc.h,v 1.31 2014/10/28 17:35:42 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -64,7 +64,7 @@ int man_addspan(struct man *, const struct tbl_span *);
int man_addeqn(struct man *, const struct eqn *);
void roff_free(struct roff *);
-struct roff *roff_alloc(struct mparse *, int);
+struct roff *roff_alloc(struct mparse *, const struct mchars *, int);
void roff_reset(struct roff *);
enum rofferr roff_parseln(struct roff *, int,
char **, size_t *, int, int *);
diff --git a/usr.bin/mandoc/main.c b/usr.bin/mandoc/main.c
index 84a63616ba7..c2b8bb032ed 100644
--- a/usr.bin/mandoc/main.c
+++ b/usr.bin/mandoc/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.101 2014/10/18 15:46:16 schwarze Exp $ */
+/* $OpenBSD: main.c,v 1.102 2014/10/28 17:35:42 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2011, 2012, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -57,7 +57,6 @@ enum outt {
OUTT_TREE, /* -Ttree */
OUTT_MAN, /* -Tman */
OUTT_HTML, /* -Thtml */
- OUTT_XHTML, /* -Txhtml */
OUTT_LINT, /* -Tlint */
OUTT_PS, /* -Tps */
OUTT_PDF /* -Tpdf */
@@ -65,6 +64,7 @@ enum outt {
struct curparse {
struct mparse *mp;
+ struct mchars *mchars; /* character table */
enum mandoclevel wlevel; /* ignore messages below this */
int wstop; /* stop after a file with a warning */
enum outt outtype; /* which output to use */
@@ -346,7 +346,9 @@ main(int argc, char *argv[])
if (use_pager && isatty(STDOUT_FILENO))
spawn_pager();
- curp.mp = mparse_alloc(options, curp.wlevel, mmsg, defos);
+ curp.mchars = mchars_alloc();
+ curp.mp = mparse_alloc(options, curp.wlevel, mmsg,
+ curp.mchars, defos);
/*
* Conditionally start up the lookaside buffer before parsing.
@@ -388,8 +390,8 @@ main(int argc, char *argv[])
if (curp.outfree)
(*curp.outfree)(curp.outdata);
- if (curp.mp)
- mparse_free(curp.mp);
+ mparse_free(curp.mp);
+ mchars_free(curp.mchars);
out:
if (search.argmode != ARG_FILE) {
@@ -472,32 +474,34 @@ parse(struct curparse *curp, int fd, const char *file,
if ( ! (curp->outman && curp->outmdoc)) {
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->outdata = html_alloc(curp->mchars,
+ curp->outopts);
curp->outfree = html_free;
break;
case OUTT_UTF8:
- curp->outdata = utf8_alloc(curp->outopts);
+ curp->outdata = utf8_alloc(curp->mchars,
+ curp->outopts);
curp->outfree = ascii_free;
break;
case OUTT_LOCALE:
- curp->outdata = locale_alloc(curp->outopts);
+ curp->outdata = locale_alloc(curp->mchars,
+ curp->outopts);
curp->outfree = ascii_free;
break;
case OUTT_ASCII:
- curp->outdata = ascii_alloc(curp->outopts);
+ curp->outdata = ascii_alloc(curp->mchars,
+ curp->outopts);
curp->outfree = ascii_free;
break;
case OUTT_PDF:
- curp->outdata = pdf_alloc(curp->outopts);
+ curp->outdata = pdf_alloc(curp->mchars,
+ curp->outopts);
curp->outfree = pspdf_free;
break;
case OUTT_PS:
- curp->outdata = ps_alloc(curp->outopts);
+ curp->outdata = ps_alloc(curp->mchars,
+ curp->outopts);
curp->outfree = pspdf_free;
break;
default:
@@ -506,8 +510,6 @@ parse(struct curparse *curp, int fd, const char *file,
switch (curp->outtype) {
case OUTT_HTML:
- /* FALLTHROUGH */
- case OUTT_XHTML:
curp->outman = html_man;
curp->outmdoc = html_mdoc;
break;
@@ -622,7 +624,7 @@ toptions(struct curparse *curp, char *arg)
else if (0 == strcmp(arg, "locale"))
curp->outtype = OUTT_LOCALE;
else if (0 == strcmp(arg, "xhtml"))
- curp->outtype = OUTT_XHTML;
+ curp->outtype = OUTT_HTML;
else if (0 == strcmp(arg, "ps"))
curp->outtype = OUTT_PS;
else if (0 == strcmp(arg, "pdf"))
diff --git a/usr.bin/mandoc/main.h b/usr.bin/mandoc/main.h
index 307a8fe2947..8733e43e401 100644
--- a/usr.bin/mandoc/main.h
+++ b/usr.bin/mandoc/main.h
@@ -1,4 +1,4 @@
-/* $Id: main.h,v 1.11 2014/04/20 16:44:44 schwarze Exp $ */
+/* $OpenBSD: main.h,v 1.12 2014/10/28 17:35:42 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -32,8 +32,7 @@ struct man;
* terminal output routines with different character settings.
*/
-void *html_alloc(char *);
-void *xhtml_alloc(char *);
+void *html_alloc(const struct mchars *, char *);
void html_mdoc(void *, const struct mdoc *);
void html_man(void *, const struct man *);
void html_free(void *);
@@ -44,13 +43,13 @@ void tree_man(void *, const struct man *);
void man_mdoc(void *, const struct mdoc *);
void man_man(void *, const struct man *);
-void *locale_alloc(char *);
-void *utf8_alloc(char *);
-void *ascii_alloc(char *);
+void *locale_alloc(const struct mchars *, char *);
+void *utf8_alloc(const struct mchars *, char *);
+void *ascii_alloc(const struct mchars *, char *);
void ascii_free(void *);
-void *pdf_alloc(char *);
-void *ps_alloc(char *);
+void *pdf_alloc(const struct mchars *, char *);
+void *ps_alloc(const struct mchars *, char *);
void pspdf_free(void *);
void terminal_mdoc(void *, const struct mdoc *);
diff --git a/usr.bin/mandoc/man_term.c b/usr.bin/mandoc/man_term.c
index e7dc414766e..cb74c28fb24 100644
--- a/usr.bin/mandoc/man_term.c
+++ b/usr.bin/mandoc/man_term.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: man_term.c,v 1.107 2014/10/20 15:49:45 schwarze Exp $ */
+/* $OpenBSD: man_term.c,v 1.108 2014/10/28 17:35:42 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -149,9 +149,6 @@ terminal_man(void *arg, const struct man *man)
p->rmargin = p->maxrmargin = p->defrmargin;
p->tabwidth = term_len(p, 5);
- if (NULL == p->symtab)
- p->symtab = mchars_alloc();
-
n = man_node(man)->child;
meta = man_meta(man);
diff --git a/usr.bin/mandoc/mandoc.h b/usr.bin/mandoc/mandoc.h
index db71dcd8129..487152dee5b 100644
--- a/usr.bin/mandoc/mandoc.h
+++ b/usr.bin/mandoc/mandoc.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mandoc.h,v 1.108 2014/10/26 18:06:28 schwarze Exp $ */
+/* $OpenBSD: mandoc.h,v 1.109 2014/10/28 17:35:42 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -431,7 +431,7 @@ int mchars_spec2cp(const struct mchars *,
const char *mchars_spec2str(const struct mchars *,
const char *, size_t, size_t *);
struct mparse *mparse_alloc(int, enum mandoclevel, mandocmsg,
- const char *);
+ const struct mchars *, const char *);
void mparse_free(struct mparse *);
void mparse_keep(struct mparse *);
enum mandoclevel mparse_open(struct mparse *, int *, const char *,
diff --git a/usr.bin/mandoc/mandocdb.c b/usr.bin/mandoc/mandocdb.c
index e4e0983ef39..3c063feec2d 100644
--- a/usr.bin/mandoc/mandocdb.c
+++ b/usr.bin/mandoc/mandocdb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mandocdb.c,v 1.122 2014/10/27 13:29:30 schwarze Exp $ */
+/* $OpenBSD: mandocdb.c,v 1.123 2014/10/28 17:35:42 schwarze Exp $ */
/*
* Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -415,9 +415,9 @@ mandocdb(int argc, char *argv[])
}
exitcode = (int)MANDOCLEVEL_OK;
- mp = mparse_alloc(mparse_options, MANDOCLEVEL_FATAL, NULL, NULL);
mc = mchars_alloc();
-
+ mp = mparse_alloc(mparse_options, MANDOCLEVEL_FATAL, NULL,
+ mc, NULL);
ohash_init(&mpages, 6, &mpages_info);
ohash_init(&mlinks, 6, &mlinks_info);
@@ -515,8 +515,8 @@ mandocdb(int argc, char *argv[])
}
out:
manpath_free(&dirs);
- mchars_free(mc);
mparse_free(mp);
+ mchars_free(mc);
mpages_free();
ohash_delete(&mpages);
ohash_delete(&mlinks);
diff --git a/usr.bin/mandoc/mdoc_term.c b/usr.bin/mandoc/mdoc_term.c
index ca209b37961..f778add7667 100644
--- a/usr.bin/mandoc/mdoc_term.c
+++ b/usr.bin/mandoc/mdoc_term.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mdoc_term.c,v 1.185 2014/10/20 15:49:45 schwarze Exp $ */
+/* $OpenBSD: mdoc_term.c,v 1.186 2014/10/28 17:35:42 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -259,9 +259,6 @@ terminal_mdoc(void *arg, const struct mdoc *mdoc)
p->rmargin = p->maxrmargin = p->defrmargin;
p->tabwidth = term_len(p, 5);
- if (NULL == p->symtab)
- p->symtab = mchars_alloc();
-
n = mdoc_node(mdoc)->child;
meta = mdoc_meta(mdoc);
diff --git a/usr.bin/mandoc/read.c b/usr.bin/mandoc/read.c
index f45fb3bf28c..4dc8374273d 100644
--- a/usr.bin/mandoc/read.c
+++ b/usr.bin/mandoc/read.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: read.c,v 1.68 2014/10/20 19:21:31 schwarze Exp $ */
+/* $OpenBSD: read.c,v 1.69 2014/10/28 17:35:42 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -50,6 +50,7 @@ struct mparse {
struct man *man; /* man parser */
struct mdoc *mdoc; /* mdoc parser */
struct roff *roff; /* roff parser (!NULL) */
+ const struct mchars *mchars; /* character table */
char *sodest; /* filename pointed to by .so */
const char *file; /* filename of current input file */
struct buf *primary; /* buffer currently being parsed */
@@ -858,8 +859,8 @@ mparse_wait(struct mparse *curp, pid_t child_pid)
}
struct mparse *
-mparse_alloc(int options, enum mandoclevel wlevel,
- mandocmsg mmsg, const char *defos)
+mparse_alloc(int options, enum mandoclevel wlevel, mandocmsg mmsg,
+ const struct mchars *mchars, const char *defos)
{
struct mparse *curp;
@@ -872,7 +873,8 @@ mparse_alloc(int options, enum mandoclevel wlevel,
curp->mmsg = mmsg;
curp->defos = defos;
- curp->roff = roff_alloc(curp, options);
+ curp->mchars = mchars;
+ curp->roff = roff_alloc(curp, curp->mchars, options);
if (curp->options & MPARSE_MDOC)
curp->pmdoc = mdoc_alloc(
curp->roff, curp, curp->defos,
diff --git a/usr.bin/mandoc/roff.c b/usr.bin/mandoc/roff.c
index c12b11275bc..e82f2ff534d 100644
--- a/usr.bin/mandoc/roff.c
+++ b/usr.bin/mandoc/roff.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: roff.c,v 1.108 2014/10/25 15:23:25 schwarze Exp $ */
+/* $OpenBSD: roff.c,v 1.109 2014/10/28 17:35:42 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -105,6 +105,7 @@ struct roffreg {
struct roff {
struct mparse *parse; /* parse point */
+ const struct mchars *mchars; /* character table */
struct roffnode *last; /* leaf of stack */
int *rstack; /* stack of inverted `ie' values */
struct roffreg *regtab; /* number registers */
@@ -474,12 +475,13 @@ roff_free(struct roff *r)
}
struct roff *
-roff_alloc(struct mparse *parse, int options)
+roff_alloc(struct mparse *parse, const struct mchars *mchars, int options)
{
struct roff *r;
r = mandoc_calloc(1, sizeof(struct roff));
r->parse = parse;
+ r->mchars = mchars;
r->options = options;
r->format = options & (MPARSE_MDOC | MPARSE_MAN);
r->rstackpos = -1;
@@ -506,6 +508,8 @@ roff_res(struct roff *r, char **bufp, size_t *szp, int ln, int pos)
char *nbuf; /* new buffer to copy bufp to */
size_t maxl; /* expected length of the escape name */
size_t naml; /* actual length of the escape name */
+ enum mandoc_esc esc; /* type of the escape sequence */
+ int inaml; /* length returned from mandoc_escape() */
int expand_count; /* to avoid infinite loops */
int npos; /* position in numeric expression */
int arg_complete; /* argument not interrupted by eol */
@@ -549,7 +553,10 @@ roff_res(struct roff *r, char **bufp, size_t *szp, int ln, int pos)
res = ubuf;
break;
default:
- if (ESCAPE_ERROR == mandoc_escape(&cp, NULL, NULL))
+ esc = mandoc_escape(&cp, &stnam, &inaml);
+ if (esc == ESCAPE_ERROR ||
+ (esc == ESCAPE_SPECIAL &&
+ mchars_spec2cp(r->mchars, stnam, inaml) < 0))
mandoc_vmsg(MANDOCERR_ESC_BAD,
r->parse, ln, (int)(stesc - *bufp),
"%.*s", (int)(cp - stesc), stesc);
diff --git a/usr.bin/mandoc/term.c b/usr.bin/mandoc/term.c
index 33ed30422c4..53da8ff403b 100644
--- a/usr.bin/mandoc/term.c
+++ b/usr.bin/mandoc/term.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: term.c,v 1.90 2014/10/27 13:29:30 schwarze Exp $ */
+/* $OpenBSD: term.c,v 1.91 2014/10/28 17:35:42 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -40,11 +40,7 @@ void
term_free(struct termp *p)
{
- if (p->buf)
- free(p->buf);
- if (p->symtab)
- mchars_free(p->symtab);
-
+ free(p->buf);
free(p);
}
diff --git a/usr.bin/mandoc/term.h b/usr.bin/mandoc/term.h
index 78d26fc6075..39e4388e524 100644
--- a/usr.bin/mandoc/term.h
+++ b/usr.bin/mandoc/term.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: term.h,v 1.48 2014/10/26 17:11:18 schwarze Exp $ */
+/* $OpenBSD: term.h,v 1.49 2014/10/28 17:35:42 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -85,7 +85,7 @@ struct termp {
#define TERMP_SPLIT (1 << 13) /* Break line before .An. */
int *buf; /* Output buffer. */
enum termenc enc; /* Type of encoding. */
- struct mchars *symtab; /* Encoded-symbol table. */
+ const struct mchars *symtab; /* Character table. */
enum termfont fontl; /* Last font set. */
enum termfont fontq[10]; /* Symmetric fonts. */
int fonti; /* Index of font stack. */
diff --git a/usr.bin/mandoc/term_ascii.c b/usr.bin/mandoc/term_ascii.c
index 862c025ed10..db246938ef4 100644
--- a/usr.bin/mandoc/term_ascii.c
+++ b/usr.bin/mandoc/term_ascii.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: term_ascii.c,v 1.24 2014/10/28 02:43:05 schwarze Exp $ */
+/* $OpenBSD: term_ascii.c,v 1.25 2014/10/28 17:35:42 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -30,7 +30,8 @@
#include "term.h"
#include "main.h"
-static struct termp *ascii_init(enum termenc, char *);
+static struct termp *ascii_init(enum termenc,
+ const struct mchars *, char *);
static double ascii_hspan(const struct termp *,
const struct roffsu *);
static size_t ascii_width(const struct termp *, int);
@@ -48,7 +49,7 @@ static size_t locale_width(const struct termp *, int);
static struct termp *
-ascii_init(enum termenc enc, char *outopts)
+ascii_init(enum termenc enc, const struct mchars *mchars, char *outopts)
{
const char *toks[5];
char *v;
@@ -56,6 +57,7 @@ ascii_init(enum termenc enc, char *outopts)
p = mandoc_calloc(1, sizeof(struct termp));
+ p->symtab = mchars;
p->tabwidth = 5;
p->defrmargin = p->lastrmargin = 78;
@@ -121,24 +123,24 @@ ascii_init(enum termenc enc, char *outopts)
}
void *
-ascii_alloc(char *outopts)
+ascii_alloc(const struct mchars *mchars, char *outopts)
{
- return(ascii_init(TERMENC_ASCII, outopts));
+ return(ascii_init(TERMENC_ASCII, mchars, outopts));
}
void *
-utf8_alloc(char *outopts)
+utf8_alloc(const struct mchars *mchars, char *outopts)
{
- return(ascii_init(TERMENC_UTF8, outopts));
+ return(ascii_init(TERMENC_UTF8, mchars, outopts));
}
void *
-locale_alloc(char *outopts)
+locale_alloc(const struct mchars *mchars, char *outopts)
{
- return(ascii_init(TERMENC_LOCALE, outopts));
+ return(ascii_init(TERMENC_LOCALE, mchars, outopts));
}
static void
diff --git a/usr.bin/mandoc/term_ps.c b/usr.bin/mandoc/term_ps.c
index ed34c4393b5..5c2dfceb20c 100644
--- a/usr.bin/mandoc/term_ps.c
+++ b/usr.bin/mandoc/term_ps.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: term_ps.c,v 1.32 2014/10/27 20:41:16 schwarze Exp $ */
+/* $OpenBSD: term_ps.c,v 1.33 2014/10/28 17:35:42 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -101,7 +101,7 @@ static void ps_printf(struct termp *, const char *, ...);
static void ps_putchar(struct termp *, char);
static void ps_setfont(struct termp *, enum termfont);
static void ps_setwidth(struct termp *, int, size_t);
-static struct termp *pspdf_alloc(char *);
+static struct termp *pspdf_alloc(const struct mchars *, char *);
static void pdf_obj(struct termp *, size_t);
/*
@@ -502,29 +502,29 @@ static const struct font fonts[TERMFONT__MAX] = {
};
void *
-pdf_alloc(char *outopts)
+pdf_alloc(const struct mchars *mchars, char *outopts)
{
struct termp *p;
- if (NULL != (p = pspdf_alloc(outopts)))
+ if (NULL != (p = pspdf_alloc(mchars, outopts)))
p->type = TERMTYPE_PDF;
return(p);
}
void *
-ps_alloc(char *outopts)
+ps_alloc(const struct mchars *mchars, char *outopts)
{
struct termp *p;
- if (NULL != (p = pspdf_alloc(outopts)))
+ if (NULL != (p = pspdf_alloc(mchars, outopts)))
p->type = TERMTYPE_PS;
return(p);
}
static struct termp *
-pspdf_alloc(char *outopts)
+pspdf_alloc(const struct mchars *mchars, char *outopts)
{
struct termp *p;
unsigned int pagex, pagey;
@@ -534,6 +534,7 @@ pspdf_alloc(char *outopts)
char *v;
p = mandoc_calloc(1, sizeof(struct termp));
+ p->symtab = mchars;
p->enc = TERMENC_ASCII;
p->ps = mandoc_calloc(1, sizeof(struct termp_ps));