summaryrefslogtreecommitdiffstats
path: root/main.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2014-10-25 01:03:52 +0000
committerIngo Schwarze <schwarze@openbsd.org>2014-10-25 01:03:52 +0000
commitdd148a56f3f3e29132148b8f2bace859b7590d34 (patch)
tree5290383cf43df4fcf23e706458fc63fd96eb8cbf /main.c
parente3f177878d1b2ecad452ce2d7d08861420b2ffbb (diff)
downloadmandoc-dd148a56f3f3e29132148b8f2bace859b7590d34.tar.gz
integrate preconv(1) into mandoc(1);
enhances functionality and reduces code and docs by more than 300 lines
Diffstat (limited to 'main.c')
-rw-r--r--main.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/main.c b/main.c
index 2451ff5e..2c358c75 100644
--- a/main.c
+++ b/main.c
@@ -82,6 +82,7 @@ struct curparse {
char outopts[BUFSIZ]; /* buf of output opts */
};
+static int koptions(int *, char *);
static int moptions(int *, char *);
static void mmsg(enum mandocerr, enum mandoclevel,
const char *, int, int, const char *);
@@ -149,14 +150,15 @@ main(int argc, char *argv[])
memset(&curp, 0, sizeof(struct curparse));
curp.outtype = OUTT_ASCII;
curp.wlevel = MANDOCLEVEL_FATAL;
- options = MPARSE_SO;
+ options = MPARSE_SO | MPARSE_UTF8 | MPARSE_LATIN1;
defos = NULL;
use_pager = 1;
show_usage = 0;
outmode = OUTMODE_DEF;
- while (-1 != (c = getopt(argc, argv, "aC:cfhI:iklM:m:O:S:s:T:VW:w"))) {
+ while (-1 != (c = getopt(argc, argv,
+ "aC:cfhI:iK:klM:m:O:S:s:T:VW:w"))) {
switch (c) {
case 'a':
outmode = OUTMODE_ALL;
@@ -192,6 +194,10 @@ main(int argc, char *argv[])
case 'i':
outmode = OUTMODE_INT;
break;
+ case 'K':
+ if ( ! koptions(&options, optarg))
+ return((int)MANDOCLEVEL_BADARG);
+ break;
case 'k':
search.argmode = ARG_EXPR;
break;
@@ -599,6 +605,26 @@ fail:
}
static int
+koptions(int *options, char *arg)
+{
+
+ if ( ! strcmp(arg, "utf-8")) {
+ *options |= MPARSE_UTF8;
+ *options &= ~MPARSE_LATIN1;
+ } else if ( ! strcmp(arg, "iso-8859-1")) {
+ *options |= MPARSE_LATIN1;
+ *options &= ~MPARSE_UTF8;
+ } else if ( ! strcmp(arg, "us-ascii")) {
+ *options &= ~(MPARSE_UTF8 | MPARSE_LATIN1);
+ } else {
+ fprintf(stderr, "%s: -K%s: Bad argument\n",
+ progname, arg);
+ return(0);
+ }
+ return(1);
+}
+
+static int
moptions(int *options, char *arg)
{