version 1.163, 2011/05/20 15:51:18 |
version 1.169, 2014/01/06 00:53:33 |
|
|
/* $Id$ */ |
/* $Id$ */ |
/* |
/* |
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> |
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> |
* Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org> |
* Copyright (c) 2010, 2011, 2012 Ingo Schwarze <schwarze@openbsd.org> |
|
* Copyright (c) 2010 Joerg Sonnenberger <joerg@netbsd.org> |
* |
* |
* Permission to use, copy, modify, and distribute this software for any |
* Permission to use, copy, modify, and distribute this software for any |
* purpose with or without fee is hereby granted, provided that the above |
* purpose with or without fee is hereby granted, provided that the above |
|
|
OUTT_LOCALE, /* -Tlocale */ |
OUTT_LOCALE, /* -Tlocale */ |
OUTT_UTF8, /* -Tutf8 */ |
OUTT_UTF8, /* -Tutf8 */ |
OUTT_TREE, /* -Ttree */ |
OUTT_TREE, /* -Ttree */ |
|
OUTT_MAN, /* -Tman */ |
OUTT_HTML, /* -Thtml */ |
OUTT_HTML, /* -Thtml */ |
OUTT_XHTML, /* -Txhtml */ |
OUTT_XHTML, /* -Txhtml */ |
OUTT_LINT, /* -Tlint */ |
OUTT_LINT, /* -Tlint */ |
Line 84 main(int argc, char *argv[]) |
|
Line 86 main(int argc, char *argv[]) |
|
struct curparse curp; |
struct curparse curp; |
enum mparset type; |
enum mparset type; |
enum mandoclevel rc; |
enum mandoclevel rc; |
|
char *defos; |
|
|
progname = strrchr(argv[0], '/'); |
progname = strrchr(argv[0], '/'); |
if (progname == NULL) |
if (progname == NULL) |
Line 96 main(int argc, char *argv[]) |
|
Line 99 main(int argc, char *argv[]) |
|
type = MPARSE_AUTO; |
type = MPARSE_AUTO; |
curp.outtype = OUTT_ASCII; |
curp.outtype = OUTT_ASCII; |
curp.wlevel = MANDOCLEVEL_FATAL; |
curp.wlevel = MANDOCLEVEL_FATAL; |
|
defos = NULL; |
|
|
/* LINTED */ |
/* LINTED */ |
while (-1 != (c = getopt(argc, argv, "m:O:T:VW:"))) |
while (-1 != (c = getopt(argc, argv, "I:m:O:T:VW:"))) |
switch (c) { |
switch (c) { |
|
case ('I'): |
|
if (strncmp(optarg, "os=", 3)) { |
|
fprintf(stderr, "-I%s: Bad argument\n", |
|
optarg); |
|
return((int)MANDOCLEVEL_BADARG); |
|
} |
|
if (defos) { |
|
fprintf(stderr, "-I%s: Duplicate argument\n", |
|
optarg); |
|
return((int)MANDOCLEVEL_BADARG); |
|
} |
|
defos = mandoc_strdup(optarg + 3); |
|
break; |
case ('m'): |
case ('m'): |
if ( ! moptions(&type, optarg)) |
if ( ! moptions(&type, optarg)) |
return((int)MANDOCLEVEL_BADARG); |
return((int)MANDOCLEVEL_BADARG); |
Line 124 main(int argc, char *argv[]) |
|
Line 141 main(int argc, char *argv[]) |
|
/* NOTREACHED */ |
/* NOTREACHED */ |
} |
} |
|
|
curp.mp = mparse_alloc(type, curp.wlevel, mmsg, &curp); |
curp.mp = mparse_alloc(type, curp.wlevel, mmsg, defos, 0); |
|
|
|
/* |
|
* Conditionally start up the lookaside buffer before parsing. |
|
*/ |
|
if (OUTT_MAN == curp.outtype) |
|
mparse_keep(curp.mp); |
|
|
argc -= optind; |
argc -= optind; |
argv += optind; |
argv += optind; |
|
|
Line 145 main(int argc, char *argv[]) |
|
Line 168 main(int argc, char *argv[]) |
|
(*curp.outfree)(curp.outdata); |
(*curp.outfree)(curp.outdata); |
if (curp.mp) |
if (curp.mp) |
mparse_free(curp.mp); |
mparse_free(curp.mp); |
|
free(defos); |
|
|
return((int)rc); |
return((int)rc); |
} |
} |
|
|
|
|
fprintf(stderr, "usage: %s " |
fprintf(stderr, "usage: %s " |
"[-V] " |
"[-V] " |
"[-foption] " |
"[-Ios=name] " |
"[-mformat] " |
"[-mformat] " |
"[-Ooption] " |
"[-Ooption] " |
"[-Toutput] " |
"[-Toutput] " |
"[-Wlevel] " |
"[-Wlevel]\n" |
"[file...]\n", |
"\t [file ...]\n", |
progname); |
progname); |
|
|
exit((int)MANDOCLEVEL_BADARG); |
exit((int)MANDOCLEVEL_BADARG); |
Line 249 parse(struct curparse *curp, int fd, |
|
Line 273 parse(struct curparse *curp, int fd, |
|
curp->outman = tree_man; |
curp->outman = tree_man; |
curp->outmdoc = tree_mdoc; |
curp->outmdoc = tree_mdoc; |
break; |
break; |
|
case (OUTT_MAN): |
|
curp->outmdoc = man_mdoc; |
|
curp->outman = man_man; |
|
break; |
case (OUTT_PDF): |
case (OUTT_PDF): |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case (OUTT_ASCII): |
case (OUTT_ASCII): |
Line 312 toptions(struct curparse *curp, char *arg) |
|
Line 340 toptions(struct curparse *curp, char *arg) |
|
curp->wlevel = MANDOCLEVEL_WARNING; |
curp->wlevel = MANDOCLEVEL_WARNING; |
} else if (0 == strcmp(arg, "tree")) |
} else if (0 == strcmp(arg, "tree")) |
curp->outtype = OUTT_TREE; |
curp->outtype = OUTT_TREE; |
|
else if (0 == strcmp(arg, "man")) |
|
curp->outtype = OUTT_MAN; |
else if (0 == strcmp(arg, "html")) |
else if (0 == strcmp(arg, "html")) |
curp->outtype = OUTT_HTML; |
curp->outtype = OUTT_HTML; |
else if (0 == strcmp(arg, "utf8")) |
else if (0 == strcmp(arg, "utf8")) |