summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2009-04-12 19:19:57 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2009-04-12 19:19:57 +0000
commit64f804892d86409e054d72a0a2fae9733b46ce16 (patch)
treefdc9f4ad378eaecaa1685480daa123838fff3d15
parent60b9600bd2c7ac00417ebb42873ffe00a80a205f (diff)
downloadmandoc-64f804892d86409e054d72a0a2fae9733b46ce16.tar.gz
mandoc-64f804892d86409e054d72a0a2fae9733b46ce16.tar.zst
mandoc-64f804892d86409e054d72a0a2fae9733b46ce16.zip
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.c7
-rw-r--r--main.c43
-rw-r--r--man.36
-rw-r--r--man.76
-rw-r--r--mandoc.16
-rw-r--r--mandoc_char.76
-rw-r--r--manuals.78
-rw-r--r--mdoc.36
-rw-r--r--mdoc.76
-rw-r--r--mdoc.h3
-rw-r--r--mdoc_macro.c10
-rw-r--r--mdoc_term.c4
-rw-r--r--mdoc_validate.c21
-rw-r--r--term.h5
14 files changed, 84 insertions, 53 deletions
diff --git a/ascii.c b/ascii.c
index b57bc2aa..5812dd17 100644
--- a/ascii.c
+++ b/ascii.c
@@ -1,4 +1,4 @@
-/* $Id: ascii.c,v 1.5 2009/04/05 16:34:22 kristaps Exp $ */
+/* $Id: ascii.c,v 1.6 2009/04/12 19:19:57 kristaps Exp $ */
/*
* Copyright (c) 2009 Kristaps Dzonsons <kristaps@openbsd.org>
*
@@ -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 b092f114..01a13e82 100644
--- a/main.c
+++ b/main.c
@@ -1,4 +1,4 @@
-/* $Id: main.c,v 1.23 2009/04/03 12:27:18 kristaps Exp $ */
+/* $Id: main.c,v 1.24 2009/04/12 19:19:57 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@openbsd.org>
*
@@ -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 8f92e58f..7a138372 100644
--- a/man.3
+++ b/man.3
@@ -1,4 +1,4 @@
-.\" $Id: man.3,v 1.1 2009/03/27 14:56:15 kristaps Exp $
+.\" $Id: man.3,v 1.2 2009/04/12 19:19:57 kristaps Exp $
.\"
.\" Copyright (c) 2009 Kristaps Dzonsons <kristaps@openbsd.org>
.\"
@@ -16,8 +16,8 @@
.\" TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
.\" PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: March 27 2009 $
-.Dt man 3
+.Dd $Mdocdate: April 12 2009 $
+.Dt MAN 3
.Os
.\" SECTION
.Sh NAME
diff --git a/man.7 b/man.7
index f75375c7..b892999c 100644
--- a/man.7
+++ b/man.7
@@ -1,4 +1,4 @@
-.\" $Id: man.7,v 1.8 2009/04/05 16:34:22 kristaps Exp $
+.\" $Id: man.7,v 1.9 2009/04/12 19:19:57 kristaps Exp $
.\"
.\" Copyright (c) 2009 Kristaps Dzonsons <kristaps@openbsd.org>
.\"
@@ -16,8 +16,8 @@
.\" TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
.\" PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: April 5 2009 $
-.Dt man 7
+.Dd $Mdocdate: April 12 2009 $
+.Dt MAN 7
.Os
.\" SECTION
.Sh NAME
diff --git a/mandoc.1 b/mandoc.1
index 951564c7..4eee610a 100644
--- a/mandoc.1
+++ b/mandoc.1
@@ -1,4 +1,4 @@
-.\" $Id: mandoc.1,v 1.13 2009/04/05 16:34:22 kristaps Exp $
+.\" $Id: mandoc.1,v 1.14 2009/04/12 19:19:57 kristaps Exp $
.\"
.\" Copyright (c) 2009 Kristaps Dzonsons <kristaps@openbsd.org>
.\"
@@ -16,8 +16,8 @@
.\" TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
.\" PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: April 5 2009 $
-.Dt mandoc 1
+.Dd $Mdocdate: April 12 2009 $
+.Dt MANDOC 1
.Os
.\" SECTION
.Sh NAME
diff --git a/mandoc_char.7 b/mandoc_char.7
index d95a0177..79a4cfd2 100644
--- a/mandoc_char.7
+++ b/mandoc_char.7
@@ -1,4 +1,4 @@
-.\" $Id: mandoc_char.7,v 1.1 2009/03/27 14:56:15 kristaps Exp $
+.\" $Id: mandoc_char.7,v 1.2 2009/04/12 19:19:57 kristaps Exp $
.\"
.\" Copyright (c) 2009 Kristaps Dzonsons <kristaps@openbsd.org>
.\"
@@ -16,8 +16,8 @@
.\" TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
.\" PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: March 27 2009 $
-.Dt mandoc_char 7
+.Dd $Mdocdate: April 12 2009 $
+.Dt MANDOC_CHAR 7
.Os
.\" SECTION
.Sh NAME
diff --git a/manuals.7 b/manuals.7
index e3ded290..75369d56 100644
--- a/manuals.7
+++ b/manuals.7
@@ -1,4 +1,4 @@
-.\" $Id: manuals.7,v 1.11 2009/04/03 13:17:26 kristaps Exp $
+.\" $Id: manuals.7,v 1.12 2009/04/12 19:19:57 kristaps Exp $
.\"
.\" Copyright (c) 2009 Kristaps Dzonsons <kristaps@openbsd.org>
.\"
@@ -16,8 +16,8 @@
.\" TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
.\" PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: April 3 2009 $
-.Dt manuals 7
+.Dd $Mdocdate: April 12 2009 $
+.Dt MANUALS 7
.Os
.\" SECTION
.Sh NAME
@@ -157,7 +157,7 @@ or
to version-control your work. If you wish the last check-in to effect
your document's date, use the following RCS tag for the date macro:
.Pp
-.Dl \&.Dd $Mdocdate: April 3 2009 $
+.Dl \&.Dd $Mdocdate: April 12 2009 $
.\" SUBSECTION
.Ss Viewing
mdoc documents may be paged to your terminal with
diff --git a/mdoc.3 b/mdoc.3
index 646c9f8f..7d0507aa 100644
--- a/mdoc.3
+++ b/mdoc.3
@@ -1,4 +1,4 @@
-.\" $Id: mdoc.3,v 1.26 2009/03/31 13:50:19 kristaps Exp $
+.\" $Id: mdoc.3,v 1.27 2009/04/12 19:19:57 kristaps Exp $
.\"
.\" Copyright (c) 2009 Kristaps Dzonsons <kristaps@openbsd.org>
.\"
@@ -16,8 +16,8 @@
.\" TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
.\" PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: March 31 2009 $
-.Dt mdoc 3
+.Dd $Mdocdate: April 12 2009 $
+.Dt MDOC 3
.Os
.\" SECTION
.Sh NAME
diff --git a/mdoc.7 b/mdoc.7
index acfa7cd8..fd36207c 100644
--- a/mdoc.7
+++ b/mdoc.7
@@ -1,4 +1,4 @@
-.\" $Id: mdoc.7,v 1.19 2009/03/27 14:56:15 kristaps Exp $
+.\" $Id: mdoc.7,v 1.20 2009/04/12 19:19:57 kristaps Exp $
.\"
.\" Copyright (c) 2009 Kristaps Dzonsons <kristaps@openbsd.org>
.\"
@@ -16,8 +16,8 @@
.\" TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
.\" PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: March 27 2009 $
-.Dt mdoc 7
+.Dd $Mdocdate: April 12 2009 $
+.Dt MDOC 7
.Os
.\" SECTION
.Sh NAME
diff --git a/mdoc.h b/mdoc.h
index 3e0c8297..61e8b9c9 100644
--- a/mdoc.h
+++ b/mdoc.h
@@ -1,4 +1,4 @@
-/* $Id: mdoc.h,v 1.54 2009/03/31 13:50:19 kristaps Exp $ */
+/* $Id: mdoc.h,v 1.55 2009/04/12 19:19:57 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@openbsd.org>
*
@@ -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 3f11ed1e..ce5547c7 100644
--- a/mdoc_macro.c
+++ b/mdoc_macro.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_macro.c,v 1.6 2009/04/02 06:51:44 kristaps Exp $ */
+/* $Id: mdoc_macro.c,v 1.7 2009/04/12 19:19:57 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@openbsd.org>
*
@@ -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 80c22fb8..1885683a 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_term.c,v 1.4 2009/04/03 13:17:26 kristaps Exp $ */
+/* $Id: mdoc_term.c,v 1.5 2009/04/12 19:19:57 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@openbsd.org>
*
@@ -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 c9070dcc..b38dde94 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_validate.c,v 1.3 2009/04/02 16:37:40 kristaps Exp $ */
+/* $Id: mdoc_validate.c,v 1.4 2009/04/12 19:19:57 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@openbsd.org>
*
@@ -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 2ab28fbb..05ec00eb 100644
--- a/term.h
+++ b/term.h
@@ -1,4 +1,4 @@
-/* $Id: term.h,v 1.34 2009/03/26 14:38:11 kristaps Exp $ */
+/* $Id: term.h,v 1.35 2009/04/12 19:19:57 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@openbsd.org>
*
@@ -21,7 +21,8 @@
/* FIXME - clean up tabs. */
-#define INDENT 6
+#define INDENT 5
+#define HALFINDENT 3
__BEGIN_DECLS