summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ascii.c5
-rw-r--r--main.c41
-rw-r--r--man.32
-rw-r--r--man.72
-rw-r--r--mandoc.12
-rw-r--r--mandoc_char.72
-rw-r--r--manuals.72
-rw-r--r--mdoc.32
-rw-r--r--mdoc.72
-rw-r--r--mdoc.h1
-rw-r--r--mdoc_macro.c8
-rw-r--r--mdoc_term.c2
-rw-r--r--mdoc_validate.c19
-rw-r--r--term.h3
14 files changed, 62 insertions, 31 deletions
diff --git a/ascii.c b/ascii.c
index a4850a02..da4cd94f 100644
--- a/ascii.c
+++ b/ascii.c
@@ -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
diff --git a/main.c b/main.c
index f3b479cf..ea05d5cf 100644
--- a/main.c
+++ b/main.c
@@ -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);
diff --git a/man.3 b/man.3
index 8df78583..20054a3c 100644
--- a/man.3
+++ b/man.3
@@ -17,7 +17,7 @@
.\" PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd $Mdocdate$
-.Dt man 3
+.Dt MAN 3
.Os
.\" SECTION
.Sh NAME
diff --git a/man.7 b/man.7
index 447fd986..1b7d2e4c 100644
--- a/man.7
+++ b/man.7
@@ -17,7 +17,7 @@
.\" PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd $Mdocdate$
-.Dt man 7
+.Dt MAN 7
.Os
.\" SECTION
.Sh NAME
diff --git a/mandoc.1 b/mandoc.1
index 2b22a431..0f7d67b7 100644
--- a/mandoc.1
+++ b/mandoc.1
@@ -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
diff --git a/manuals.7 b/manuals.7
index 8e772750..187b4412 100644
--- a/manuals.7
+++ b/manuals.7
@@ -17,7 +17,7 @@
.\" PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd $Mdocdate$
-.Dt manuals 7
+.Dt MANUALS 7
.Os
.\" SECTION
.Sh NAME
diff --git a/mdoc.3 b/mdoc.3
index faf1a894..410bf22f 100644
--- a/mdoc.3
+++ b/mdoc.3
@@ -17,7 +17,7 @@
.\" PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd $Mdocdate$
-.Dt mdoc 3
+.Dt MDOC 3
.Os
.\" SECTION
.Sh NAME
diff --git a/mdoc.7 b/mdoc.7
index b0bef155..26032b48 100644
--- a/mdoc.7
+++ b/mdoc.7
@@ -17,7 +17,7 @@
.\" PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd $Mdocdate$
-.Dt mdoc 7
+.Dt MDOC 7
.Os
.\" SECTION
.Sh NAME
diff --git a/mdoc.h b/mdoc.h
index f9fa728e..a6d43dad 100644
--- a/mdoc.h
+++ b/mdoc.h
@@ -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;
diff --git a/term.h b/term.h
index dca213a0..be8f4eb6 100644
--- a/term.h
+++ b/term.h
@@ -21,7 +21,8 @@
/* FIXME - clean up tabs. */
-#define INDENT 6
+#define INDENT 5
+#define HALFINDENT 3
__BEGIN_DECLS