diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2014-10-25 01:03:52 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2014-10-25 01:03:52 +0000 |
commit | dd148a56f3f3e29132148b8f2bace859b7590d34 (patch) | |
tree | 5290383cf43df4fcf23e706458fc63fd96eb8cbf /main.c | |
parent | e3f177878d1b2ecad452ce2d7d08861420b2ffbb (diff) | |
download | mandoc-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.c | 30 |
1 files changed, 28 insertions, 2 deletions
@@ -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) { |