summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--action.c81
-rw-r--r--argv.c2
-rw-r--r--mandoc.111
-rw-r--r--mdoc.320
-rw-r--r--validate.c3
5 files changed, 54 insertions, 63 deletions
diff --git a/action.c b/action.c
index 65567d51..37f8848b 100644
--- a/action.c
+++ b/action.c
@@ -32,10 +32,6 @@
* children have been filled in (post-fix order).
*/
-enum merr {
- ENOWIDTH
-};
-
enum mwarn {
WBADSEC,
WNOWIDTH,
@@ -51,7 +47,6 @@ struct actions {
};
static int pwarn(struct mdoc *, int, int, enum mwarn);
-static int perr(struct mdoc *, int, int, enum merr);
static int post_ar(POST_ARGS);
static int post_bl(POST_ARGS);
@@ -69,7 +64,6 @@ static int post_std(POST_ARGS);
static int pre_bd(PRE_ARGS);
static int pre_dl(PRE_ARGS);
-#define merr(m, t) perr((m), (m)->last->line, (m)->last->pos, (t))
#define mwarn(m, t) pwarn((m), (m)->last->line, (m)->last->pos, (t))
const struct actions mdoc_actions[MDOC_MAX] = {
@@ -236,24 +230,6 @@ mdoc_action_post(struct mdoc *m)
static int
-perr(struct mdoc *m, int line, int pos, enum merr type)
-{
- char *p;
-
- p = NULL;
-
- switch (type) {
- case (ENOWIDTH):
- p = "missing width argument";
- break;
- }
-
- assert(p);
- return(mdoc_perr(m, line, pos, p));
-}
-
-
-static int
pwarn(struct mdoc *m, int line, int pos, enum mwarn type)
{
char *p;
@@ -471,6 +447,10 @@ post_os(POST_ARGS)
}
+/*
+ * Calculate the -width for a `Bl -tag' list if it hasn't been provided.
+ * Uses the first head macro.
+ */
static int
post_bl_tagwidth(struct mdoc *m)
{
@@ -479,33 +459,21 @@ post_bl_tagwidth(struct mdoc *m)
char buf[32];
/*
- * If -tag has been specified and -width has not been, then try
- * to intuit our width from the first body element.
- */
-
- if (NULL == (n = m->last->body->child))
- return(1);
-
- /*
* Use the text width, if a text node, or the default macro
* width if a macro.
*/
- n = n->head->child;
+ n = m->last->head->child;
+ sz = 10; /* Default size. */
+
if (n) {
if (MDOC_TEXT != n->type) {
if (0 == (sz = (int)mdoc_macro2len(n->tok)))
- sz = -1;
+ if ( ! mwarn(m, WNOWIDTH))
+ return(0);
} else
sz = (int)strlen(n->string) + 1;
- } else
- sz = -1;
-
- if (-1 == sz) {
- if ( ! mwarn(m, WNOWIDTH))
- return(0);
- sz = 10;
- }
+ }
(void)snprintf(buf, sizeof(buf), "%dn", sz);
@@ -514,26 +482,19 @@ post_bl_tagwidth(struct mdoc *m)
* We're guaranteed that a MDOC_Width doesn't already exist.
*/
- if (NULL == m->last->args) {
- m->last->args = xcalloc
- (1, sizeof(struct mdoc_arg));
- m->last->args->refcnt = 1;
- }
-
n = m->last;
- sz = (int)n->args->argc;
-
- (n->args->argc)++;
+ assert(n->args);
+ (n->args->argc)++;
n->args->argv = xrealloc(n->args->argv,
- n->args->argc * sizeof(struct mdoc_arg));
+ n->args->argc * sizeof(struct mdoc_argv));
- n->args->argv[sz - 1].arg = MDOC_Width;
- n->args->argv[sz - 1].line = m->last->line;
- n->args->argv[sz - 1].pos = m->last->pos;
- n->args->argv[sz - 1].sz = 1;
- n->args->argv[sz - 1].value = xcalloc(1, sizeof(char *));
- n->args->argv[sz - 1].value[0] = xstrdup(buf);
+ n->args->argv[n->args->argc - 1].arg = MDOC_Width;
+ n->args->argv[n->args->argc - 1].line = m->last->line;
+ n->args->argv[n->args->argc - 1].pos = m->last->pos;
+ n->args->argv[n->args->argc - 1].sz = 1;
+ n->args->argv[n->args->argc - 1].value = xcalloc(1, sizeof(char *));
+ n->args->argv[n->args->argc - 1].value[0] = xstrdup(buf);
return(1);
}
@@ -548,14 +509,14 @@ post_bl_width(struct mdoc *m)
char *p;
if (NULL == m->last->args)
- return(merr(m, ENOWIDTH));
+ return(1);
for (i = 0; i < (int)m->last->args->argc; i++)
if (MDOC_Width == m->last->args->argv[i].arg)
break;
if (i == (int)m->last->args->argc)
- return(merr(m, ENOWIDTH));
+ return(1);
p = m->last->args->argv[i].value[0];
diff --git a/argv.c b/argv.c
index fc65f080..d203be76 100644
--- a/argv.c
+++ b/argv.c
@@ -330,7 +330,7 @@ mdoc_argv_free(struct mdoc_arg *p)
if (0 == p->argv[i].sz)
continue;
/* LINTED */
- for (j = 0; j < (int)p->argv[i].sz; j++)
+ for (j = 0; j < (int)p->argv[i].sz; j++)
free(p->argv[i].value[j]);
free(p->argv[i].value);
diff --git a/mandoc.1 b/mandoc.1
index 4b4d8740..c55455fa 100644
--- a/mandoc.1
+++ b/mandoc.1
@@ -184,21 +184,30 @@ utility was written by
.Sh CAVEATS
The
.Nm
-utility doesn't yet know how to display the following:
+utility in
+.Fl T Ns Ar ascii
+mode doesn't yet know how to display the following:
.Pp
.Bl -bullet -compact
.It
The \-hang
.Sq \&Bl
list is not yet supported.
+.\" LIST-ITEM
.It
The \-literal and \-unfilled
.Sq \&Bd
displays types are synonyms, as are \-filled and \-ragged.
+.\" LIST-ITEM
.It
The
.Sq \&Xo/Xc
pair isn't supported.
+.\" LIST-ITEM
+.It
+The
+.Sq \&Bd
+macro doesn't process \-compact .
.El
.Pp
Other macros still aren't supported by virtue of nobody complaining
diff --git a/mdoc.3 b/mdoc.3
index 10f05937..eda5435d 100644
--- a/mdoc.3
+++ b/mdoc.3
@@ -325,4 +325,24 @@ macro.
The
.Sq \&Bsx
macro doesn't yet understand version arguments.
+.\" LIST-ITEM
+.It
+If not given a value, the \-offset argument to
+.Sq \&Bd
+and
+.Sq \&Bl
+should by the width of
+.Qq <string> .
+.\" LIST-ITEM
+.It
+Columns widths in
+.Sq \&Bl -column
+should default to width
+.Qq <stringx>
+if not included.
+.\" LIST-ITEM
+.It
+List-width suffix
+.Qq m
+isn't handled.
.El
diff --git a/validate.c b/validate.c
index 265a7216..c62ea41e 100644
--- a/validate.c
+++ b/validate.c
@@ -839,7 +839,8 @@ pre_bl(PRE_ARGS)
case (MDOC_Tag):
if (-1 != width)
break;
- return(mdoc_nerr(mdoc, n, "missing %s argument",
+ return(mdoc_nwarn(mdoc, n, WARN_SYNTAX,
+ "suggest %s argument",
mdoc_argnames[MDOC_Width]));
default:
break;