diff options
-rw-r--r-- | mdoc.h | 1 | ||||
-rw-r--r-- | mdoc_action.c | 42 | ||||
-rw-r--r-- | mdoc_html.c | 12 | ||||
-rw-r--r-- | mdoc_term.c | 20 | ||||
-rw-r--r-- | mdoc_validate.c | 21 | ||||
-rw-r--r-- | regress/mdoc/Bl/empty-offset.in | 15 |
6 files changed, 46 insertions, 65 deletions
@@ -279,6 +279,7 @@ struct mdoc_bd { }; struct mdoc_bl { + const char *offs; /* -offset */ enum mdoc_list type; /* -tag, -enum, etc. */ int comp; /* -compact */ }; diff --git a/mdoc_action.c b/mdoc_action.c index 21cc2c1d..197115c9 100644 --- a/mdoc_action.c +++ b/mdoc_action.c @@ -68,9 +68,7 @@ static int post_st(POST_ARGS); static int post_std(POST_ARGS); static int pre_bd(PRE_ARGS); -static int pre_bl(PRE_ARGS); static int pre_dl(PRE_ARGS); -static int pre_offset(PRE_ARGS); static const struct actions mdoc_actions[MDOC_MAX] = { { NULL, NULL }, /* Ap */ @@ -84,7 +82,7 @@ static const struct actions mdoc_actions[MDOC_MAX] = { { pre_dl, post_display }, /* Dl */ { pre_bd, post_display }, /* Bd */ { NULL, NULL }, /* Ed */ - { pre_bl, post_bl }, /* Bl */ + { NULL, post_bl }, /* Bl */ { NULL, NULL }, /* El */ { NULL, NULL }, /* It */ { NULL, NULL }, /* Ad */ @@ -937,44 +935,6 @@ pre_dl(PRE_ARGS) } -/* ARGSUSED */ -static int -pre_offset(PRE_ARGS) -{ - int i; - - /* - * Make sure that an empty offset produces an 8n length space as - * stipulated by mdoc.samples. - */ - - for (i = 0; n->args && i < (int)n->args->argc; i++) { - if (MDOC_Offset != n->args->argv[i].arg) - continue; - if (n->args->argv[i].sz) - break; - assert(1 == n->args->refcnt); - /* If no value set, length of <string>. */ - n->args->argv[i].sz++; - n->args->argv[i].value = mandoc_malloc(sizeof(char *)); - n->args->argv[i].value[0] = mandoc_strdup("8n"); - break; - } - - return(1); -} - - -static int -pre_bl(PRE_ARGS) -{ - - if (MDOC_BLOCK == n->type) - return(pre_offset(m, n)); - return(1); -} - - static int pre_bd(PRE_ARGS) { diff --git a/mdoc_html.c b/mdoc_html.c index 98358c04..9a183dd0 100644 --- a/mdoc_html.c +++ b/mdoc_html.c @@ -1035,12 +1035,13 @@ mdoc_it_pre(MDOC_ARGS) if (MDOC_BLOCK != n->type) bl = bl->parent; + SCALE_HS_INIT(&offs, 0); + type = bl->data.Bl.type; comp = bl->data.Bl.comp; - /* Set default width and offset. */ - - SCALE_HS_INIT(&offs, 0); + if (bl->data.Bl.offs) + a2offs(bl->data.Bl.offs, &offs); switch (type) { case (LIST_enum): @@ -1057,8 +1058,6 @@ mdoc_it_pre(MDOC_ARGS) break; } - /* Get width, offset, and compact arguments. */ - wp = -1; for (i = 0; bl->args && i < (int)bl->args->argc; i++) switch (bl->args->argv[i].arg) { @@ -1068,9 +1067,6 @@ mdoc_it_pre(MDOC_ARGS) case (MDOC_Width): a2width(bl->args->argv[i].value[0], &width); break; - case (MDOC_Offset): - a2offs(bl->args->argv[i].value[0], &offs); - break; default: break; } diff --git a/mdoc_term.c b/mdoc_term.c index d8bde3c3..ecf8ad34 100644 --- a/mdoc_term.c +++ b/mdoc_term.c @@ -643,7 +643,7 @@ termp_it_pre(DECL_ARGS) { const struct mdoc_node *bl, *nn; char buf[7]; - int i, keys[3], vals[3]; + int i, keys[2], vals[2]; size_t width, offset, ncols, dcol; enum mdoc_list type; @@ -657,12 +657,11 @@ termp_it_pre(DECL_ARGS) /* Get list width, offset, and list type from argument list. */ keys[0] = MDOC_Width; - keys[1] = MDOC_Offset; - keys[2] = MDOC_Column; + keys[1] = MDOC_Column; - vals[0] = vals[1] = vals[2] = -1; + vals[0] = vals[1] = -1; - arg_getattrs(keys, vals, 3, bl); + arg_getattrs(keys, vals, 2, bl); type = bl->data.Bl.type; @@ -674,8 +673,9 @@ termp_it_pre(DECL_ARGS) width = offset = 0; - if (vals[1] >= 0) - offset = a2offs(bl->args->argv[vals[1]].value[0]); + if (bl->data.Bl.offs) + offset = a2offs(bl->data.Bl.offs); + switch (type) { case (LIST_column): @@ -690,7 +690,7 @@ termp_it_pre(DECL_ARGS) * column. * - For more than 5 columns, add only one column. */ - ncols = bl->args->argv[vals[2]].sz; + ncols = bl->args->argv[vals[1]].sz; /* LINTED */ dcol = ncols < 5 ? 4 : ncols == 5 ? 3 : 1; @@ -703,7 +703,7 @@ termp_it_pre(DECL_ARGS) nn->prev && i < (int)ncols; nn = nn->prev, i++) offset += dcol + a2width - (&bl->args->argv[vals[2]], i); + (&bl->args->argv[vals[1]], i); /* @@ -719,7 +719,7 @@ termp_it_pre(DECL_ARGS) * Use the declared column widths, extended as explained * in the preceding paragraph. */ - width = a2width(&bl->args->argv[vals[2]], i) + dcol; + width = a2width(&bl->args->argv[vals[1]], i) + dcol; break; default: if (vals[0] < 0) diff --git a/mdoc_validate.c b/mdoc_validate.c index 7b2ea1f4..1eaa3ecd 100644 --- a/mdoc_validate.c +++ b/mdoc_validate.c @@ -532,7 +532,8 @@ pre_display(PRE_ARGS) static int pre_bl(PRE_ARGS) { - int i, width, offs, comp, dup; + int i, width, comp, dup; + const char *offs; enum mdoc_list lt; if (MDOC_BLOCK != n->type) { @@ -552,12 +553,13 @@ pre_bl(PRE_ARGS) */ assert(LIST__NONE == n->data.Bl.type); - offs = width = -1; + width = -1; /* LINTED */ for (i = 0; n->args && i < (int)n->args->argc; i++) { lt = LIST__NONE; dup = comp = 0; + offs = NULL; switch (n->args->argv[i].arg) { /* Set list types. */ case (MDOC_Bullet): @@ -604,9 +606,14 @@ pre_bl(PRE_ARGS) width = i; break; case (MDOC_Offset): - if (offs >= 0) - dup++; - offs = i; + /* NB: this can be empty! */ + if (n->args->argv[i].sz) { + offs = n->args->argv[i].value[0]; + dup = (NULL != n->data.Bd.offs); + break; + } + if ( ! mdoc_nmsg(mdoc, n, MANDOCERR_IGNARGV)) + return(0); break; } @@ -617,6 +624,8 @@ pre_bl(PRE_ARGS) if (comp && ! dup) n->data.Bl.comp = comp; + if (offs && ! dup) + n->data.Bl.offs = offs; /* Check: multiple list types. */ @@ -632,7 +641,7 @@ pre_bl(PRE_ARGS) /* The list type should come first. */ if (n->data.Bl.type == LIST__NONE) - if (width >= 0 || offs >= 0 || n->data.Bl.comp) + if (width >= 0 || n->data.Bl.offs || n->data.Bl.comp) if ( ! mdoc_nmsg(mdoc, n, MANDOCERR_LISTFIRST)) return(0); diff --git a/regress/mdoc/Bl/empty-offset.in b/regress/mdoc/Bl/empty-offset.in new file mode 100644 index 00000000..031fe615 --- /dev/null +++ b/regress/mdoc/Bl/empty-offset.in @@ -0,0 +1,15 @@ +.Dd $Mdocdate$ +.Dt FOO 1 +.Os +.Sh NAME +.Nm foo +.Nd bar +.Sh DESCRIPTION +.Bl -tag -width Ds -offset +.It foo +bar +.El +.Bl -tag -width Ds +.It foo +bar +.El |