aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/term_ascii.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2015-03-27 21:33:20 +0000
committerIngo Schwarze <schwarze@openbsd.org>2015-03-27 21:33:20 +0000
commit3a566c6001cb69c071c16b210bbb84009ab1b662 (patch)
tree1623a89f3236c216a580acbede0a3b507c822c9d /term_ascii.c
parent0376f290310249f2701221cdaaf7138fae3c6989 (diff)
downloadmandoc-3a566c6001cb69c071c16b210bbb84009ab1b662.tar.gz
mandoc-3a566c6001cb69c071c16b210bbb84009ab1b662.tar.zst
mandoc-3a566c6001cb69c071c16b210bbb84009ab1b662.zip
Actually use the new man.conf(5) "output" directive.
Additional functionality, yet minus 45 lines of code.
Diffstat (limited to 'term_ascii.c')
-rw-r--r--term_ascii.c71
1 files changed, 22 insertions, 49 deletions
diff --git a/term_ascii.c b/term_ascii.c
index 4ce4b686..f217b9a4 100644
--- a/term_ascii.c
+++ b/term_ascii.c
@@ -1,15 +1,15 @@
-/* $Id: term_ascii.c,v 1.43 2015/02/16 14:11:41 schwarze Exp $ */
+/* $Id: term_ascii.c,v 1.44 2015/03/27 21:33:20 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
@@ -35,10 +35,11 @@
#include "mandoc_aux.h"
#include "out.h"
#include "term.h"
+#include "manconf.h"
#include "main.h"
-static struct termp *ascii_init(enum termenc,
- const struct mchars *, char *);
+static struct termp *ascii_init(enum termenc, const struct mchars *,
+ const struct manoutput *);
static double ascii_hspan(const struct termp *,
const struct roffsu *);
static size_t ascii_width(const struct termp *, int);
@@ -58,13 +59,11 @@ static size_t locale_width(const struct termp *, int);
static struct termp *
-ascii_init(enum termenc enc, const struct mchars *mchars, char *outopts)
+ascii_init(enum termenc enc, const struct mchars *mchars,
+ const struct manoutput *outopts)
{
- const char *toks[5];
char *v;
struct termp *p;
- const char *errstr;
- int num;
p = mandoc_calloc(1, sizeof(struct termp));
@@ -102,62 +101,36 @@ ascii_init(enum termenc enc, const struct mchars *mchars, char *outopts)
}
#endif
- toks[0] = "indent";
- toks[1] = "width";
- toks[2] = "mdoc";
- toks[3] = "synopsis";
- toks[4] = NULL;
-
- while (outopts && *outopts)
- switch (getsubopt(&outopts, UNCONST(toks), &v)) {
- case 0:
- num = strtonum(v, 0, 1000, &errstr);
- if (!errstr)
- p->defindent = num;
- break;
- case 1:
- num = strtonum(v, 0, 1000, &errstr);
- if (!errstr)
- p->defrmargin = num;
- break;
- case 2:
- /*
- * Temporary, undocumented mode
- * to imitate mdoc(7) output style.
- */
- p->mdocstyle = 1;
- p->defindent = 5;
- break;
- case 3:
- p->synopsisonly = 1;
- break;
- default:
- break;
- }
-
- /* Enforce a lower boundary. */
- if (p->defrmargin < 58)
- p->defrmargin = 58;
+ if (outopts->mdoc) {
+ p->mdocstyle = 1;
+ p->defindent = 5;
+ }
+ if (outopts->indent)
+ p->defindent = outopts->indent;
+ if (outopts->width)
+ p->defrmargin = outopts->width;
+ if (outopts->synopsisonly)
+ p->synopsisonly = 1;
return(p);
}
void *
-ascii_alloc(const struct mchars *mchars, char *outopts)
+ascii_alloc(const struct mchars *mchars, const struct manoutput *outopts)
{
return(ascii_init(TERMENC_ASCII, mchars, outopts));
}
void *
-utf8_alloc(const struct mchars *mchars, char *outopts)
+utf8_alloc(const struct mchars *mchars, const struct manoutput *outopts)
{
return(ascii_init(TERMENC_UTF8, mchars, outopts));
}
void *
-locale_alloc(const struct mchars *mchars, char *outopts)
+locale_alloc(const struct mchars *mchars, const struct manoutput *outopts)
{
return(ascii_init(TERMENC_LOCALE, mchars, outopts));