version 1.42, 2009/09/16 09:41:24 |
version 1.48, 2009/10/26 08:18:16 |
|
|
#include <err.h> |
#include <err.h> |
#include <fcntl.h> |
#include <fcntl.h> |
#include <stdio.h> |
#include <stdio.h> |
|
#include <stdint.h> |
#include <stdlib.h> |
#include <stdlib.h> |
#include <string.h> |
#include <string.h> |
#include <unistd.h> |
#include <unistd.h> |
|
|
#include "mdoc.h" |
#include "mdoc.h" |
#include "man.h" |
#include "man.h" |
|
#include "main.h" |
|
|
|
#define UNCONST(a) ((void *)(uintptr_t)(const void *)(a)) |
|
|
/* Account for FreeBSD and Linux in our declarations. */ |
/* Account for FreeBSD and Linux in our declarations. */ |
|
|
#ifdef __linux__ |
#ifdef __linux__ |
|
|
enum outt { |
enum outt { |
OUTT_ASCII = 0, |
OUTT_ASCII = 0, |
OUTT_TREE, |
OUTT_TREE, |
|
OUTT_HTML, |
OUTT_LINT |
OUTT_LINT |
}; |
}; |
|
|
Line 83 struct curparse { |
|
Line 88 struct curparse { |
|
out_man outman; |
out_man outman; |
out_free outfree; |
out_free outfree; |
void *outdata; |
void *outdata; |
|
char *outopts; |
}; |
}; |
|
|
extern void *ascii_alloc(void); |
|
extern void tree_mdoc(void *, const struct mdoc *); |
|
extern void tree_man(void *, const struct man *); |
|
extern void terminal_mdoc(void *, const struct mdoc *); |
|
extern void terminal_man(void *, const struct man *); |
|
extern void terminal_free(void *); |
|
|
|
static int foptions(int *, char *); |
static int foptions(int *, char *); |
static int toptions(enum outt *, char *); |
static int toptions(enum outt *, char *); |
static int moptions(enum intt *, char *); |
static int moptions(enum intt *, char *); |
Line 125 main(int argc, char *argv[]) |
|
Line 124 main(int argc, char *argv[]) |
|
curp.outtype = OUTT_ASCII; |
curp.outtype = OUTT_ASCII; |
|
|
/* LINTED */ |
/* LINTED */ |
while (-1 != (c = getopt(argc, argv, "f:m:VW:T:"))) |
while (-1 != (c = getopt(argc, argv, "f:m:O:T:VW:"))) |
switch (c) { |
switch (c) { |
case ('f'): |
case ('f'): |
if ( ! foptions(&curp.fflags, optarg)) |
if ( ! foptions(&curp.fflags, optarg)) |
Line 135 main(int argc, char *argv[]) |
|
Line 134 main(int argc, char *argv[]) |
|
if ( ! moptions(&curp.inttype, optarg)) |
if ( ! moptions(&curp.inttype, optarg)) |
return(EXIT_FAILURE); |
return(EXIT_FAILURE); |
break; |
break; |
|
case ('O'): |
|
curp.outopts = optarg; |
|
break; |
case ('T'): |
case ('T'): |
if ( ! toptions(&curp.outtype, optarg)) |
if ( ! toptions(&curp.outtype, optarg)) |
return(EXIT_FAILURE); |
return(EXIT_FAILURE); |
|
|
{ |
{ |
|
|
(void)fprintf(stderr, "usage: %s [-V] [-foption...] " |
(void)fprintf(stderr, "usage: %s [-V] [-foption...] " |
"[-mformat] [-Toutput] [-Werr...]\n", |
"[-mformat] [-Ooption] [-Toutput] " |
__progname); |
"[-Werr...]\n", __progname); |
exit(EXIT_FAILURE); |
exit(EXIT_FAILURE); |
} |
} |
|
|
Line 432 fdesc(struct buf *blk, struct buf *ln, struct curparse |
|
Line 434 fdesc(struct buf *blk, struct buf *ln, struct curparse |
|
|
|
if ( ! (curp->outman && curp->outmdoc)) { |
if ( ! (curp->outman && curp->outmdoc)) { |
switch (curp->outtype) { |
switch (curp->outtype) { |
|
case (OUTT_HTML): |
|
curp->outdata = html_alloc(curp->outopts); |
|
curp->outman = html_man; |
|
curp->outmdoc = html_mdoc; |
|
curp->outfree = html_free; |
|
break; |
case (OUTT_TREE): |
case (OUTT_TREE): |
curp->outman = tree_man; |
curp->outman = tree_man; |
curp->outmdoc = tree_mdoc; |
curp->outmdoc = tree_mdoc; |
Line 546 toptions(enum outt *tflags, char *arg) |
|
Line 554 toptions(enum outt *tflags, char *arg) |
|
*tflags = OUTT_LINT; |
*tflags = OUTT_LINT; |
else if (0 == strcmp(arg, "tree")) |
else if (0 == strcmp(arg, "tree")) |
*tflags = OUTT_TREE; |
*tflags = OUTT_TREE; |
|
else if (0 == strcmp(arg, "html")) |
|
*tflags = OUTT_HTML; |
else { |
else { |
warnx("bad argument: -T%s", arg); |
warnx("bad argument: -T%s", arg); |
return(0); |
return(0); |
|
|
foptions(int *fflags, char *arg) |
foptions(int *fflags, char *arg) |
{ |
{ |
char *v, *o; |
char *v, *o; |
char *toks[7]; |
const char *toks[7]; |
|
|
toks[0] = "ign-scope"; |
toks[0] = "ign-scope"; |
toks[1] = "no-ign-escape"; |
toks[1] = "no-ign-escape"; |
Line 571 foptions(int *fflags, char *arg) |
|
Line 581 foptions(int *fflags, char *arg) |
|
|
|
while (*arg) { |
while (*arg) { |
o = arg; |
o = arg; |
switch (getsubopt(&arg, toks, &v)) { |
switch (getsubopt(&arg, UNCONST(toks), &v)) { |
case (0): |
case (0): |
*fflags |= IGN_SCOPE; |
*fflags |= IGN_SCOPE; |
break; |
break; |
|
|
woptions(int *wflags, char *arg) |
woptions(int *wflags, char *arg) |
{ |
{ |
char *v, *o; |
char *v, *o; |
char *toks[3]; |
const char *toks[3]; |
|
|
toks[0] = "all"; |
toks[0] = "all"; |
toks[1] = "error"; |
toks[1] = "error"; |
Line 613 woptions(int *wflags, char *arg) |
|
Line 623 woptions(int *wflags, char *arg) |
|
|
|
while (*arg) { |
while (*arg) { |
o = arg; |
o = arg; |
switch (getsubopt(&arg, toks, &v)) { |
switch (getsubopt(&arg, UNCONST(toks), &v)) { |
case (0): |
case (0): |
*wflags |= WARN_WALL; |
*wflags |= WARN_WALL; |
break; |
break; |