diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2010-03-22 20:43:00 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2010-03-22 20:43:00 +0000 |
commit | 73053debb8031f445c0c27de9776bd2465df36f2 (patch) | |
tree | 985eec33a27ed241fa30b8cb18e31d778390f26c /main.c | |
parent | 1d05ea3140f8ce58f7d6759ce350382c406cb55c (diff) | |
download | mandoc-73053debb8031f445c0c27de9776bd2465df36f2.tar.gz |
Have -Tlint imply -Wall and -fstrict. Based on a patch submitted by Ingo Schwarze.
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 68 |
1 files changed, 37 insertions, 31 deletions
@@ -72,11 +72,11 @@ struct curparse { #define WARN_WALL (1 << 0) /* All-warnings mask. */ #define WARN_WERR (1 << 2) /* Warnings->errors. */ int fflags; -#define IGN_SCOPE (1 << 0) /* Ignore scope errors. */ -#define NO_IGN_ESCAPE (1 << 1) /* Don't ignore bad escapes. */ -#define NO_IGN_MACRO (1 << 2) /* Don't ignore bad macros. */ -#define NO_IGN_CHARS (1 << 3) /* Don't ignore bad chars. */ -#define IGN_ERRORS (1 << 4) /* Ignore failed parse. */ +#define FL_IGN_SCOPE (1 << 0) /* Ignore scope errors. */ +#define FL_NIGN_ESCAPE (1 << 1) /* Don't ignore bad escapes. */ +#define FL_NIGN_MACRO (1 << 2) /* Don't ignore bad macros. */ +#define FL_NIGN_CHARS (1 << 3) /* Don't ignore bad chars. */ +#define FL_IGN_ERRORS (1 << 4) /* Ignore failed parse. */ enum intt inttype; /* Input parsers... */ struct man *man; struct man *lastman; @@ -90,8 +90,12 @@ struct curparse { char outopts[BUFSIZ]; }; +#define FL_STRICT FL_NIGN_ESCAPE | \ + FL_NIGN_MACRO | \ + FL_NIGN_CHARS + static int foptions(int *, char *); -static int toptions(enum outt *, char *); +static int toptions(struct curparse *, char *); static int moptions(enum intt *, char *); static int woptions(int *, char *); static int merr(void *, int, int, const char *); @@ -144,7 +148,7 @@ main(int argc, char *argv[]) (void)strlcat(curp.outopts, ",", BUFSIZ); break; case ('T'): - if ( ! toptions(&curp.outtype, optarg)) + if ( ! toptions(&curp, optarg)) return(EXIT_FAILURE); break; case ('W'): @@ -172,7 +176,7 @@ main(int argc, char *argv[]) curp.fd = STDIN_FILENO; c = fdesc(&blk, &ln, &curp); - if ( ! (IGN_ERRORS & curp.fflags)) + if ( ! (FL_IGN_ERRORS & curp.fflags)) rc = 1 == c ? 1 : 0; else rc = -1 == c ? 0 : 1; @@ -180,7 +184,7 @@ main(int argc, char *argv[]) while (rc && *argv) { c = ffile(&blk, &ln, *argv, &curp); - if ( ! (IGN_ERRORS & curp.fflags)) + if ( ! (FL_IGN_ERRORS & curp.fflags)) rc = 1 == c ? 1 : 0; else rc = -1 == c ? 0 : 1; @@ -244,11 +248,11 @@ man_init(struct curparse *curp) pflags = MAN_IGN_MACRO | MAN_IGN_ESCAPE | MAN_IGN_CHARS; - if (curp->fflags & NO_IGN_MACRO) + if (curp->fflags & FL_NIGN_MACRO) pflags &= ~MAN_IGN_MACRO; - if (curp->fflags & NO_IGN_CHARS) + if (curp->fflags & FL_NIGN_CHARS) pflags &= ~MAN_IGN_CHARS; - if (curp->fflags & NO_IGN_ESCAPE) + if (curp->fflags & FL_NIGN_ESCAPE) pflags &= ~MAN_IGN_ESCAPE; return(man_alloc(curp, pflags, &mancb)); @@ -268,13 +272,13 @@ mdoc_init(struct curparse *curp) pflags = MDOC_IGN_MACRO | MDOC_IGN_ESCAPE | MDOC_IGN_CHARS; - if (curp->fflags & IGN_SCOPE) + if (curp->fflags & FL_IGN_SCOPE) pflags |= MDOC_IGN_SCOPE; - if (curp->fflags & NO_IGN_ESCAPE) + if (curp->fflags & FL_NIGN_ESCAPE) pflags &= ~MDOC_IGN_ESCAPE; - if (curp->fflags & NO_IGN_MACRO) + if (curp->fflags & FL_NIGN_MACRO) pflags &= ~MDOC_IGN_MACRO; - if (curp->fflags & NO_IGN_CHARS) + if (curp->fflags & FL_NIGN_CHARS) pflags &= ~MDOC_IGN_CHARS; return(mdoc_alloc(curp, pflags, &mdoccb)); @@ -546,19 +550,22 @@ moptions(enum intt *tflags, char *arg) static int -toptions(enum outt *tflags, char *arg) +toptions(struct curparse *curp, char *arg) { if (0 == strcmp(arg, "ascii")) - *tflags = OUTT_ASCII; - else if (0 == strcmp(arg, "lint")) - *tflags = OUTT_LINT; + curp->outtype = OUTT_ASCII; + else if (0 == strcmp(arg, "lint")) { + curp->outtype = OUTT_LINT; + curp->wflags |= WARN_WALL; + curp->fflags |= FL_STRICT; + } else if (0 == strcmp(arg, "tree")) - *tflags = OUTT_TREE; + curp->outtype = OUTT_TREE; else if (0 == strcmp(arg, "html")) - *tflags = OUTT_HTML; + curp->outtype = OUTT_HTML; else if (0 == strcmp(arg, "xhtml")) - *tflags = OUTT_XHTML; + curp->outtype = OUTT_XHTML; else { fprintf(stderr, "%s: Bad argument\n", arg); return(0); @@ -587,26 +594,25 @@ foptions(int *fflags, char *arg) o = arg; switch (getsubopt(&arg, UNCONST(toks), &v)) { case (0): - *fflags |= IGN_SCOPE; + *fflags |= FL_IGN_SCOPE; break; case (1): - *fflags |= NO_IGN_ESCAPE; + *fflags |= FL_NIGN_ESCAPE; break; case (2): - *fflags |= NO_IGN_MACRO; + *fflags |= FL_NIGN_MACRO; break; case (3): - *fflags |= NO_IGN_CHARS; + *fflags |= FL_NIGN_CHARS; break; case (4): - *fflags |= IGN_ERRORS; + *fflags |= FL_IGN_ERRORS; break; case (5): - *fflags |= NO_IGN_ESCAPE | - NO_IGN_MACRO | NO_IGN_CHARS; + *fflags |= FL_STRICT; break; case (6): - *fflags &= ~NO_IGN_ESCAPE; + *fflags &= ~FL_NIGN_ESCAPE; break; default: fprintf(stderr, "%s: Bad argument\n", o); |