version 1.43, 2009/09/16 22:17:27 |
version 1.46, 2009/10/13 10:57:25 |
|
|
#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, |
#if 1 |
|
OUTT_HTML, |
OUTT_HTML, |
#endif |
|
OUTT_LINT |
OUTT_LINT |
}; |
}; |
|
|
Line 86 struct curparse { |
|
Line 88 struct curparse { |
|
out_man outman; |
out_man outman; |
out_free outfree; |
out_free outfree; |
void *outdata; |
void *outdata; |
|
char *outopts; |
}; |
}; |
|
|
#if 1 |
|
extern void *html_alloc(void); |
|
extern void html_mdoc(void *, const struct mdoc *); |
|
extern void html_man(void *, const struct man *); |
|
extern void html_free(void *); |
|
#endif |
|
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 134 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 144 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); |
Line 441 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) { |
#if 1 |
|
case (OUTT_HTML): |
case (OUTT_HTML): |
curp->outdata = html_alloc(); |
curp->outdata = html_alloc(curp->outopts); |
curp->outman = html_man; |
curp->outman = html_man; |
curp->outmdoc = html_mdoc; |
curp->outmdoc = html_mdoc; |
curp->outfree = html_free; |
curp->outfree = html_free; |
break; |
break; |
#endif |
|
case (OUTT_TREE): |
case (OUTT_TREE): |
curp->outman = tree_man; |
curp->outman = tree_man; |
curp->outmdoc = tree_mdoc; |
curp->outmdoc = tree_mdoc; |
Line 563 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; |
#if 1 |
|
else if (0 == strcmp(arg, "html")) |
else if (0 == strcmp(arg, "html")) |
*tflags = OUTT_HTML; |
*tflags = OUTT_HTML; |
#endif |
|
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 592 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 634 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; |