summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2011-11-13 13:30:43 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2011-11-13 13:30:43 +0000
commitbac739706ca6196deabb1262a37e3895f8062065 (patch)
tree4785f89937a2fa13dbe660f2bdb4f110f26b2b69
parent9a96128800ce0a7bcaafbc5ab806c729a27dfa4b (diff)
Support -man -Omdoc to format man(7) manuals in mdoc(7) output style;
so far, this is only accepting the option, i will commit the (few) formatting tweaks separately. This is intentionally undocumented for two reasons: (1) We dream of making it the default at some point, so the option will hopefully go away again. (2) It is not needed for production, but mostly for automated man(7) to mdoc(7) output comparisons, to help -Tman development.
-rw-r--r--usr.bin/mandoc/term.h3
-rw-r--r--usr.bin/mandoc/term_ascii.c11
2 files changed, 10 insertions, 4 deletions
diff --git a/usr.bin/mandoc/term.h b/usr.bin/mandoc/term.h
index 1a16bee152d..3b7f4ed33c1 100644
--- a/usr.bin/mandoc/term.h
+++ b/usr.bin/mandoc/term.h
@@ -1,4 +1,4 @@
-/* $Id: term.h,v 1.33 2011/11/13 13:05:23 schwarze Exp $ */
+/* $Id: term.h,v 1.34 2011/11/13 13:30:42 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -52,6 +52,7 @@ struct termp_tbl {
struct termp {
enum termtype type;
struct rofftbl tbl; /* table configuration */
+ int mdocstyle; /* imitate mdoc(7) output */
size_t defindent; /* Default indent for text. */
size_t defrmargin; /* Right margin of the device. */
size_t rmargin; /* Current right margin. */
diff --git a/usr.bin/mandoc/term_ascii.c b/usr.bin/mandoc/term_ascii.c
index af83b5e69dc..7966c60febd 100644
--- a/usr.bin/mandoc/term_ascii.c
+++ b/usr.bin/mandoc/term_ascii.c
@@ -1,4 +1,4 @@
-/* $Id: term_ascii.c,v 1.7 2011/11/13 13:05:23 schwarze Exp $ */
+/* $Id: term_ascii.c,v 1.8 2011/11/13 13:30:42 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -47,7 +47,7 @@ static size_t locale_width(const struct termp *, int);
static struct termp *
ascii_init(enum termenc enc, char *outopts)
{
- const char *toks[3];
+ const char *toks[4];
char *v;
struct termp *p;
@@ -83,7 +83,8 @@ ascii_init(enum termenc enc, char *outopts)
toks[0] = "indent";
toks[1] = "width";
- toks[2] = NULL;
+ toks[2] = "mdoc";
+ toks[3] = NULL;
while (outopts && *outopts)
switch (getsubopt(&outopts, UNCONST(toks), &v)) {
@@ -93,6 +94,10 @@ ascii_init(enum termenc enc, char *outopts)
case (1):
p->defrmargin = (size_t)atoi(v);
break;
+ case (2):
+ p->mdocstyle = 1;
+ p->defindent = 5;
+ break;
default:
break;
}