summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2010-05-15 16:48:13 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2010-05-15 16:48:13 +0000
commitbf1e141d36b8475f2b74381f9795521d972b82ab (patch)
tree14dc80be47edf420dbd0bfeb501372188f25a28f /usr.bin/mandoc
parent33e6dc56151b70e65d24adda8a3ca8b09bc7518b (diff)
various improvements regarding errors and warnings Joerg Sonnenberger:
* If the last -column .Bl isn't specified, it is auto-sized. * An invalid .St argument should be a warning, not an error. Just put the argument into the output. * An invalid .At argument should be a warning, not an error. Just print the argument, like new groff does. * Remove warnings concerning manual section (like 1, 6, 8). It was only used for .Ex and not really useful. * Remove warnings concerning page section (like SYNOPSIS). These were only used for .Fd and .Lb and not really useful.
Diffstat (limited to 'usr.bin/mandoc')
-rw-r--r--usr.bin/mandoc/libmdoc.h3
-rw-r--r--usr.bin/mandoc/mdoc.711
-rw-r--r--usr.bin/mandoc/mdoc.c3
-rw-r--r--usr.bin/mandoc/mdoc_action.c31
-rw-r--r--usr.bin/mandoc/mdoc_validate.c94
5 files changed, 41 insertions, 101 deletions
diff --git a/usr.bin/mandoc/libmdoc.h b/usr.bin/mandoc/libmdoc.h
index 6ac17daf5d7..bc4098db736 100644
--- a/usr.bin/mandoc/libmdoc.h
+++ b/usr.bin/mandoc/libmdoc.h
@@ -1,4 +1,4 @@
-/* $Id: libmdoc.h,v 1.32 2010/05/15 13:12:55 schwarze Exp $ */
+/* $Id: libmdoc.h,v 1.33 2010/05/15 16:48:12 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -80,7 +80,6 @@ enum merr {
ENOLINE,
EPROLOOO,
EPROLREP,
- EBADMSEC,
EBADSEC,
EFONT,
EBADDATE,
diff --git a/usr.bin/mandoc/mdoc.7 b/usr.bin/mandoc/mdoc.7
index d9e3578c063..03caa9d3b92 100644
--- a/usr.bin/mandoc/mdoc.7
+++ b/usr.bin/mandoc/mdoc.7
@@ -1,4 +1,4 @@
-.\" $Id: mdoc.7,v 1.29 2010/05/15 15:37:53 schwarze Exp $
+.\" $Id: mdoc.7,v 1.30 2010/05/15 16:48:12 schwarze Exp $
.\"
.\" Copyright (c) 2009 Kristaps Dzonsons <kristaps@bsd.lv>
.\"
@@ -1911,10 +1911,17 @@ This is not the case in mandoc.
In groff, the
.Sx \&Cd ,
.Sx \&Er ,
+.Sx \&Ex ,
and
-.Sx \&Ex
+.Sx \&Rv
macros were stipulated only to occur in certain manual sections.
mandoc does not have these restrictions.
+.It
+Newer groff and mandoc print
+.Qq AT&T UNIX
+prior to unknown arguments of
+.Sx \&At ;
+older groff did nothing.
.El
.Sh SEE ALSO
.Xr mandoc 1 ,
diff --git a/usr.bin/mandoc/mdoc.c b/usr.bin/mandoc/mdoc.c
index e745ec86774..99c8b31be28 100644
--- a/usr.bin/mandoc/mdoc.c
+++ b/usr.bin/mandoc/mdoc.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc.c,v 1.48 2010/05/14 19:52:43 schwarze Exp $ */
+/* $Id: mdoc.c,v 1.49 2010/05/15 16:48:12 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -64,7 +64,6 @@ const char *const __mdoc_merrnames[MERRMAX] = {
"line arguments discouraged", /* ENOLINE */
"prologue macro out of conventional order", /* EPROLOOO */
"prologue macro repeated", /* EPROLREP */
- "invalid manual section", /* EBADMSEC */
"invalid section", /* EBADSEC */
"invalid font mode", /* EFONT */
"invalid date syntax", /* EBADDATE */
diff --git a/usr.bin/mandoc/mdoc_action.c b/usr.bin/mandoc/mdoc_action.c
index 856b38d56c1..fec0c6cc32f 100644
--- a/usr.bin/mandoc/mdoc_action.c
+++ b/usr.bin/mandoc/mdoc_action.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_action.c,v 1.33 2010/05/14 19:52:43 schwarze Exp $ */
+/* $Id: mdoc_action.c,v 1.34 2010/05/15 16:48:12 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -362,9 +362,10 @@ post_st(POST_ARGS)
assert(MDOC_TEXT == n->child->type);
p = mdoc_a2st(n->child->string);
- assert(p);
- free(n->child->string);
- n->child->string = mandoc_strdup(p);
+ if (p != NULL) {
+ free(n->child->string);
+ n->child->string = mandoc_strdup(p);
+ }
return(1);
}
@@ -377,15 +378,27 @@ post_st(POST_ARGS)
static int
post_at(POST_ARGS)
{
- struct mdoc_node *nn;
- const char *p;
+ struct mdoc_node *nn;
+ const char *p, *q;
+ char *buf;
+ size_t sz;
if (n->child) {
assert(MDOC_TEXT == n->child->type);
p = mdoc_a2att(n->child->string);
- assert(p);
- free(n->child->string);
- n->child->string = mandoc_strdup(p);
+ if (p) {
+ free(n->child->string);
+ n->child->string = mandoc_strdup(p);
+ } else {
+ p = "AT&T UNIX ";
+ q = n->child->string;
+ sz = strlen(p) + strlen(q) + 1;
+ buf = mandoc_malloc(sz);
+ strlcpy(buf, p, sz);
+ strlcat(buf, q, sz);
+ free(n->child->string);
+ n->child->string = buf;
+ }
return(1);
}
diff --git a/usr.bin/mandoc/mdoc_validate.c b/usr.bin/mandoc/mdoc_validate.c
index 55416be2caf..239e16f1f9c 100644
--- a/usr.bin/mandoc/mdoc_validate.c
+++ b/usr.bin/mandoc/mdoc_validate.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_validate.c,v 1.52 2010/05/14 19:52:43 schwarze Exp $ */
+/* $Id: mdoc_validate.c,v 1.53 2010/05/15 16:48:12 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -19,7 +19,6 @@
#include <assert.h>
#include <ctype.h>
#include <limits.h>
-#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
@@ -41,8 +40,6 @@ struct valids {
};
static int check_parent(PRE_ARGS, enum mdoct, enum mdoc_type);
-static int check_msec(PRE_ARGS, ...);
-static int check_sec(PRE_ARGS, ...);
static int check_stdarg(PRE_ARGS);
static int check_text(struct mdoc *, int, int, const char *);
static int check_argv(struct mdoc *,
@@ -96,10 +93,7 @@ static int pre_bl(PRE_ARGS);
static int pre_dd(PRE_ARGS);
static int pre_display(PRE_ARGS);
static int pre_dt(PRE_ARGS);
-static int pre_ex(PRE_ARGS);
-static int pre_fd(PRE_ARGS);
static int pre_it(PRE_ARGS);
-static int pre_lb(PRE_ARGS);
static int pre_os(PRE_ARGS);
static int pre_rv(PRE_ARGS);
static int pre_sh(PRE_ARGS);
@@ -135,10 +129,10 @@ static v_pre pres_d1[] = { pre_display, NULL };
static v_pre pres_dd[] = { pre_dd, NULL };
static v_pre pres_dt[] = { pre_dt, NULL };
static v_pre pres_er[] = { NULL, NULL };
-static v_pre pres_ex[] = { pre_ex, NULL };
-static v_pre pres_fd[] = { pre_fd, NULL };
+static v_pre pres_ex[] = { NULL, NULL };
+static v_pre pres_fd[] = { NULL, NULL };
static v_pre pres_it[] = { pre_it, NULL };
-static v_pre pres_lb[] = { pre_lb, NULL };
+static v_pre pres_lb[] = { NULL, NULL };
static v_pre pres_os[] = { pre_os, NULL };
static v_pre pres_rv[] = { pre_rv, NULL };
static v_pre pres_sh[] = { pre_sh, NULL };
@@ -412,52 +406,6 @@ check_stdarg(PRE_ARGS)
static int
-check_sec(PRE_ARGS, ...)
-{
- enum mdoc_sec sec;
- va_list ap;
-
- va_start(ap, n);
-
- for (;;) {
- /* LINTED */
- sec = (enum mdoc_sec)va_arg(ap, int);
- if (SEC_CUSTOM == sec)
- break;
- if (sec != mdoc->lastsec)
- continue;
- va_end(ap);
- return(1);
- }
-
- va_end(ap);
- return(mdoc_nwarn(mdoc, n, EBADSEC));
-}
-
-
-static int
-check_msec(PRE_ARGS, ...)
-{
- va_list ap;
- int msec;
-
- va_start(ap, n);
- for (;;) {
- /* LINTED */
- if (0 == (msec = va_arg(ap, int)))
- break;
- if (msec != mdoc->meta.msec)
- continue;
- va_end(ap);
- return(1);
- }
-
- va_end(ap);
- return(mdoc_nwarn(mdoc, n, EBADMSEC));
-}
-
-
-static int
check_args(struct mdoc *m, const struct mdoc_node *n)
{
int i;
@@ -758,14 +706,6 @@ pre_an(PRE_ARGS)
static int
-pre_lb(PRE_ARGS)
-{
-
- return(check_sec(mdoc, n, SEC_LIBRARY, SEC_CUSTOM));
-}
-
-
-static int
pre_rv(PRE_ARGS)
{
@@ -774,16 +714,6 @@ pre_rv(PRE_ARGS)
static int
-pre_ex(PRE_ARGS)
-{
-
- if ( ! check_msec(mdoc, n, 1, 6, 8, 0))
- return(0);
- return(check_stdarg(mdoc, n));
-}
-
-
-static int
pre_dt(PRE_ARGS)
{
@@ -917,7 +847,7 @@ post_at(POST_ARGS)
return(mdoc_nerr(mdoc, mdoc->last, EATT));
if (mdoc_a2att(mdoc->last->child->string))
return(1);
- return(mdoc_nerr(mdoc, mdoc->last, EATT));
+ return(mdoc_nwarn(mdoc, mdoc->last, EATT));
}
@@ -1035,14 +965,14 @@ post_it(POST_ARGS)
for (i = 0; c && MDOC_HEAD == c->type; c = c->next)
i++;
- if (i < cols || i == (cols + 1)) {
+ if (i < cols) {
if ( ! mdoc_vwarn(mdoc, mdoc->last->line,
mdoc->last->pos, "column "
"mismatch: have %d, want %d",
i, cols))
return(0);
break;
- } else if (i == cols)
+ } else if (i == cols || i == cols + 1)
break;
return(mdoc_verr(mdoc, mdoc->last->line,
@@ -1158,7 +1088,7 @@ post_st(POST_ARGS)
if (mdoc_a2st(mdoc->last->child->string))
return(1);
- return(mdoc_nerr(mdoc, mdoc->last, EBADSTAND));
+ return(mdoc_nwarn(mdoc, mdoc->last, EBADSTAND));
}
@@ -1326,11 +1256,3 @@ post_sh_head(POST_ARGS)
return(1);
}
-
-
-static int
-pre_fd(PRE_ARGS)
-{
-
- return(check_sec(mdoc, n, SEC_SYNOPSIS, SEC_CUSTOM));
-}