diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2009-04-12 19:19:57 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2009-04-12 19:19:57 +0000 |
commit | 46efc2522501cd7521cb08c1686de2dbf6544a03 (patch) | |
tree | 838e5d0fddbf9c6b0778c423a3570102f46edc83 | |
parent | 72def18baa480a6e0b55cbe174a49649342cd895 (diff) | |
download | mandoc-46efc2522501cd7521cb08c1686de2dbf6544a03.tar.gz |
Manual .Dt fields CAPITALISED.
Indent set to 5 chars (nroff compat).
Half-indent set to 3 chars (nroff compat).
Default behaviour is loose-y (ignore macro/char/escape).
Added -fstrict.
Added unknown-character ignoring.
-rw-r--r-- | ascii.c | 5 | ||||
-rw-r--r-- | main.c | 41 | ||||
-rw-r--r-- | man.3 | 2 | ||||
-rw-r--r-- | man.7 | 2 | ||||
-rw-r--r-- | mandoc.1 | 2 | ||||
-rw-r--r-- | mandoc_char.7 | 2 | ||||
-rw-r--r-- | manuals.7 | 2 | ||||
-rw-r--r-- | mdoc.3 | 2 | ||||
-rw-r--r-- | mdoc.7 | 2 | ||||
-rw-r--r-- | mdoc.h | 1 | ||||
-rw-r--r-- | mdoc_macro.c | 8 | ||||
-rw-r--r-- | mdoc_term.c | 2 | ||||
-rw-r--r-- | mdoc_validate.c | 19 | ||||
-rw-r--r-- | term.h | 3 |
14 files changed, 62 insertions, 31 deletions
@@ -137,7 +137,10 @@ term_a2ascii(void *arg, const char *p, size_t sz, size_t *rsz) assert(p); assert(sz > 0); - assert(p[0] >= ASCII_PRINT_LO && p[0] <= ASCII_PRINT_HI); + + if (p[0] < ASCII_PRINT_LO || p[0] > ASCII_PRINT_HI) + return(NULL); + /* * Lookup the symbol in the symbol hash. See ascii2htab for the @@ -73,9 +73,9 @@ struct curparse { #define WARN_WERR (1 << 2) /* Warnings->errors. */ int fflags; #define IGN_SCOPE (1 << 0) /* Ignore scope errors. */ -#define IGN_ESCAPE (1 << 1) /* Ignore bad escapes. */ -#define IGN_MACRO (1 << 2) /* Ignore unknown macros. */ -#define NO_IGN_MACRO (1 << 3) +#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. */ enum intt inttype; /* Input parsers. */ struct man *man; struct man *lastman; @@ -256,17 +256,19 @@ mdoc_init(struct curparse *curp) mdoccb.mdoc_err = merr; mdoccb.mdoc_warn = mdocwarn; - pflags = 0; /* XXX */ + pflags = MDOC_IGN_MACRO | MDOC_IGN_ESCAPE | MDOC_IGN_CHARS; if (curp->fflags & IGN_SCOPE) pflags |= MDOC_IGN_SCOPE; - if (curp->fflags & IGN_ESCAPE) - pflags |= MDOC_IGN_ESCAPE; - if (curp->fflags & IGN_MACRO) - pflags |= MDOC_IGN_MACRO; + if (curp->fflags & NO_IGN_ESCAPE) + pflags &= ~MDOC_IGN_ESCAPE; + if (curp->fflags & NO_IGN_MACRO) + pflags &= ~MDOC_IGN_MACRO; + if (curp->fflags & NO_IGN_CHARS) + pflags &= ~MDOC_IGN_CHARS; if (NULL == (mdoc = mdoc_alloc(curp, pflags, &mdoccb))) - warnx("memory allocated"); + warnx("memory exhausted"); return(mdoc); } @@ -548,13 +550,14 @@ static int foptions(int *fflags, char *arg) { char *v; - char *toks[5]; + char *toks[6]; toks[0] = "ign-scope"; - toks[1] = "ign-escape"; - toks[2] = "ign-macro"; - toks[3] = "no-ign-macro"; - toks[4] = NULL; + toks[1] = "no-ign-escape"; + toks[2] = "no-ign-macro"; + toks[3] = "no-ign-chars"; + toks[4] = "strict"; + toks[5] = NULL; while (*arg) switch (getsubopt(&arg, toks, &v)) { @@ -562,13 +565,17 @@ foptions(int *fflags, char *arg) *fflags |= IGN_SCOPE; break; case (1): - *fflags |= IGN_ESCAPE; + *fflags |= NO_IGN_ESCAPE; break; case (2): - *fflags |= IGN_MACRO; + *fflags |= NO_IGN_MACRO; break; case (3): - *fflags |= NO_IGN_MACRO; + *fflags |= NO_IGN_CHARS; + break; + case (4): + *fflags |= NO_IGN_ESCAPE | + NO_IGN_MACRO | NO_IGN_CHARS; break; default: warnx("bad argument: -f%s", arg); @@ -17,7 +17,7 @@ .\" PERFORMANCE OF THIS SOFTWARE. .\" .Dd $Mdocdate$ -.Dt man 3 +.Dt MAN 3 .Os .\" SECTION .Sh NAME @@ -17,7 +17,7 @@ .\" PERFORMANCE OF THIS SOFTWARE. .\" .Dd $Mdocdate$ -.Dt man 7 +.Dt MAN 7 .Os .\" SECTION .Sh NAME @@ -17,7 +17,7 @@ .\" PERFORMANCE OF THIS SOFTWARE. .\" .Dd $Mdocdate$ -.Dt mandoc 1 +.Dt MANDOC 1 .Os .\" SECTION .Sh NAME diff --git a/mandoc_char.7 b/mandoc_char.7 index e65dc9c6..1863bde0 100644 --- a/mandoc_char.7 +++ b/mandoc_char.7 @@ -17,7 +17,7 @@ .\" PERFORMANCE OF THIS SOFTWARE. .\" .Dd $Mdocdate$ -.Dt mandoc_char 7 +.Dt MANDOC_CHAR 7 .Os .\" SECTION .Sh NAME @@ -17,7 +17,7 @@ .\" PERFORMANCE OF THIS SOFTWARE. .\" .Dd $Mdocdate$ -.Dt manuals 7 +.Dt MANUALS 7 .Os .\" SECTION .Sh NAME @@ -17,7 +17,7 @@ .\" PERFORMANCE OF THIS SOFTWARE. .\" .Dd $Mdocdate$ -.Dt mdoc 3 +.Dt MDOC 3 .Os .\" SECTION .Sh NAME @@ -17,7 +17,7 @@ .\" PERFORMANCE OF THIS SOFTWARE. .\" .Dd $Mdocdate$ -.Dt mdoc 7 +.Dt MDOC 7 .Os .\" SECTION .Sh NAME @@ -276,6 +276,7 @@ struct mdoc_node { #define MDOC_IGN_SCOPE (1 << 0) /* Ignore scope violations. */ #define MDOC_IGN_ESCAPE (1 << 1) /* Ignore bad escape sequences. */ #define MDOC_IGN_MACRO (1 << 2) /* Ignore unknown macros. */ +#define MDOC_IGN_CHARS (1 << 3) /* Ignore disallowed chars. */ /* Call-backs for parse messages. */ struct mdoc_cb { diff --git a/mdoc_macro.c b/mdoc_macro.c index 4e4a799d..db22ccf4 100644 --- a/mdoc_macro.c +++ b/mdoc_macro.c @@ -871,9 +871,11 @@ in_line(MACRO_PROT_ARGS) tok, arg)) return(0); mdoc->next = MDOC_NEXT_SIBLING; - } else if ( ! nc && 0 == cnt) + } else if ( ! nc && 0 == cnt) { + mdoc_argv_free(arg); if ( ! pwarn(mdoc, line, ppos, WIGNE)) return(0); + } c = mdoc_macro(mdoc, c, line, la, pos, buf); if (0 == c) return(0); @@ -924,9 +926,11 @@ in_line(MACRO_PROT_ARGS) if (0 == c) return(0); mdoc->next = MDOC_NEXT_SIBLING; - } else if ( ! nc && 0 == cnt) + } else if ( ! nc && 0 == cnt) { + mdoc_argv_free(arg); if ( ! pwarn(mdoc, line, ppos, WIGNE)) return(0); + } if (ppos > 1) return(1); diff --git a/mdoc_term.c b/mdoc_term.c index fa1eb059..4fdc4ac3 100644 --- a/mdoc_term.c +++ b/mdoc_term.c @@ -1842,7 +1842,7 @@ termp_ss_pre(DECL_ARGS) break; case (MDOC_HEAD): TERMPAIR_SETFLAG(p, pair, ttypes[TTYPE_SSECTION]); - p->offset = INDENT / 2; + p->offset = HALFINDENT; break; default: break; diff --git a/mdoc_validate.c b/mdoc_validate.c index 9056c8ae..2a4f8454 100644 --- a/mdoc_validate.c +++ b/mdoc_validate.c @@ -51,6 +51,7 @@ enum merr { }; enum mwarn { + WPRINT, WESCAPE, WWRONGMSEC, WSECOOO, @@ -95,6 +96,7 @@ static int warn_child_gt(struct mdoc *, const char *, int); static int err_child_eq(struct mdoc *, const char *, int); static int warn_child_eq(struct mdoc *, const char *, int); static int count_child(struct mdoc *); +static int warn_print(struct mdoc *, int, int); static int warn_count(struct mdoc *, const char *, int, const char *, int); static int err_count(struct mdoc *, const char *, @@ -460,6 +462,9 @@ pwarn(struct mdoc *m, int line, int pos, enum mwarn type) p = "prologue macros out-of-order"; c = WARN_COMPAT; break; + case (WPRINT): + p = "invalid character"; + break; case (WESCAPE): p = "invalid escape sequence"; break; @@ -497,6 +502,14 @@ pwarn(struct mdoc *m, int line, int pos, enum mwarn type) } +static int +warn_print(struct mdoc *m, int ln, int pos) +{ + if (MDOC_IGN_CHARS & m->pflags) + return(pwarn(m, ln, pos, WPRINT)); + return(perr(m, ln, pos, EPRINT)); +} + static inline int warn_count(struct mdoc *m, const char *k, @@ -699,9 +712,11 @@ check_text(struct mdoc *mdoc, int line, int pos, const char *p) for ( ; *p; p++) { if ('\t' == *p) { if ( ! (MDOC_LITERAL & mdoc->flags)) - return(perr(mdoc, line, pos, EPRINT)); + if ( ! warn_print(mdoc, line, pos)) + return(0); } else if ( ! isprint((u_char)*p)) - return(perr(mdoc, line, pos, EPRINT)); + if ( ! warn_print(mdoc, line, pos)) + return(0); if ('\\' != *p) continue; @@ -21,7 +21,8 @@ /* FIXME - clean up tabs. */ -#define INDENT 6 +#define INDENT 5 +#define HALFINDENT 3 __BEGIN_DECLS |