summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2009-06-12 09:18:00 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2009-06-12 09:18:00 +0000
commit81a387c030a677e4c49c020a270294d21c564320 (patch)
tree5edd66188f498f18a740574c6d45f2d103ab9af4
parentc3b3cef562cad122a19ef12743ef5aa73df002b5 (diff)
downloadmandoc-81a387c030a677e4c49c020a270294d21c564320.tar.gz
`Lk' is correctly handled as CALLABLE (note groff munges nested output).
`Mt' is now CALLABLE. Fixed missing validate/action of zero-element, non-called inline elements. Fixed missing validate/action of nested inline element re-calls. Fixed bogus column argv index in validator.
-rw-r--r--mdoc.78
-rw-r--r--mdoc_action.c24
-rw-r--r--mdoc_macro.c12
-rw-r--r--mdoc_term.c11
-rw-r--r--mdoc_validate.c10
5 files changed, 50 insertions, 15 deletions
diff --git a/mdoc.7 b/mdoc.7
index 9599239b..5c0c5915 100644
--- a/mdoc.7
+++ b/mdoc.7
@@ -455,8 +455,8 @@ then the macro accepts an arbitrary number of arguments.
.It \&.Lb Ta \&No Ta \&No Ta 1
.It \&.Ap Ta Yes Ta Yes Ta 0
.It \&.Lp Ta \&No Ta \&No Ta 0
-.It \&.Lk Ta \&No Ta Yes Ta >0
-.It \&.Mt Ta \&No Ta Yes Ta >0
+.It \&.Lk Ta Yes Ta Yes Ta n
+.It \&.Mt Ta Yes Ta Yes Ta >0
.It \&.Es Ta \&No Ta \&No Ta 0
.It \&.En Ta \&No Ta \&No Ta 0
.El
@@ -481,10 +481,12 @@ compatibility with these systems.
.It
.Sq \&.An ,
.Sq \&.Fo ,
+.Sq \&.Lk ,
.Sq \&.Ms ,
+.Sq \&.Mt ,
and
.Sq \&.St
-historically weren't callable (they are now).
+historically weren't callable.
.\" LIST-ITEM
.It
.Sq \&.It \-nested
diff --git a/mdoc_action.c b/mdoc_action.c
index f0da42b4..96945c4f 100644
--- a/mdoc_action.c
+++ b/mdoc_action.c
@@ -56,6 +56,7 @@ static int post_bl_tagwidth(POST_ARGS);
static int post_dd(POST_ARGS);
static int post_display(POST_ARGS);
static int post_dt(POST_ARGS);
+static int post_lk(POST_ARGS);
static int post_nm(POST_ARGS);
static int post_os(POST_ARGS);
static int post_prol(POST_ARGS);
@@ -179,7 +180,7 @@ const struct actions mdoc_actions[MDOC_MAX] = {
{ NULL, NULL }, /* Lb */
{ NULL, NULL }, /* Ap */
{ NULL, NULL }, /* Lp */
- { NULL, NULL }, /* Lk */
+ { NULL, post_lk }, /* Lk */
{ NULL, NULL }, /* Mt */
{ NULL, NULL }, /* Brq */
{ NULL, NULL }, /* Bro */
@@ -669,6 +670,27 @@ post_bl(POST_ARGS)
static int
+post_lk(POST_ARGS)
+{
+ struct mdoc_node *n;
+
+ if (m->last->child)
+ return(1);
+
+ n = m->last;
+ m->next = MDOC_NEXT_CHILD;
+ /* FIXME: this isn't documented anywhere! */
+ if ( ! mdoc_word_alloc(m, m->last->line,
+ m->last->pos, "~"))
+ return(0);
+
+ m->last = n;
+ m->next = MDOC_NEXT_SIBLING;
+ return(1);
+}
+
+
+static int
post_ar(POST_ARGS)
{
struct mdoc_node *n;
diff --git a/mdoc_macro.c b/mdoc_macro.c
index 0dd18d0b..79134d56 100644
--- a/mdoc_macro.c
+++ b/mdoc_macro.c
@@ -183,8 +183,8 @@ const struct mdoc_macro __mdoc_macros[MDOC_MAX] = {
{ in_line_eoln, 0 }, /* Lb */
{ in_line_argn, MDOC_CALLABLE | MDOC_PARSED }, /* Ap */
{ in_line, 0 }, /* Lp */
- { in_line, MDOC_PARSED }, /* Lk */
- { in_line, MDOC_PARSED }, /* Mt */
+ { in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Lk */
+ { in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Mt */
{ blk_part_imp, MDOC_CALLABLE | MDOC_PARSED }, /* Brq */
{ blk_part_exp, MDOC_CALLABLE | MDOC_PARSED | MDOC_EXPLICIT }, /* Bro */
{ blk_exp_close, MDOC_EXPLICIT | MDOC_CALLABLE | MDOC_PARSED }, /* Brc */
@@ -813,6 +813,8 @@ in_line(MACRO_PROT_ARGS)
/* FALLTHROUGH */
case (MDOC_Fl):
/* FALLTHROUGH */
+ case (MDOC_Lk):
+ /* FALLTHROUGH */
case (MDOC_Ar):
nc = 1;
break;
@@ -868,7 +870,8 @@ in_line(MACRO_PROT_ARGS)
if ( ! mdoc_elem_alloc(mdoc, line, ppos,
tok, arg))
return(0);
- mdoc->next = MDOC_NEXT_SIBLING;
+ if ( ! rew_last(mdoc, mdoc->last))
+ return(0);
} else if ( ! nc && 0 == cnt) {
mdoc_argv_free(arg);
if ( ! pwarn(mdoc, line, ppos, WIGNE))
@@ -923,7 +926,8 @@ in_line(MACRO_PROT_ARGS)
c = mdoc_elem_alloc(mdoc, line, ppos, tok, arg);
if (0 == c)
return(0);
- mdoc->next = MDOC_NEXT_SIBLING;
+ if ( ! rew_last(mdoc, mdoc->last))
+ return(0);
} else if ( ! nc && 0 == cnt) {
mdoc_argv_free(arg);
if ( ! pwarn(mdoc, line, ppos, WIGNE))
diff --git a/mdoc_term.c b/mdoc_term.c
index 6bdfa3c9..5a8c7ddc 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -2119,17 +2119,22 @@ termp_lk_pre(DECL_ARGS)
assert(node->child);
n = node->child;
+ if (NULL == n->next) {
+ TERMPAIR_SETFLAG(p, pair, ttypes[TTYPE_LINK_ANCHOR]);
+ return(1);
+ }
+
p->flags |= ttypes[TTYPE_LINK_ANCHOR];
term_word(p, n->string);
- p->flags &= ~ttypes[TTYPE_LINK_ANCHOR];
p->flags |= TERMP_NOSPACE;
term_word(p, ":");
+ p->flags &= ~ttypes[TTYPE_LINK_ANCHOR];
p->flags |= ttypes[TTYPE_LINK_TEXT];
- for ( ; n; n = n->next)
+ for (n = n->next; n; n = n->next)
term_word(p, n->string);
- p->flags &= ~ttypes[TTYPE_LINK_TEXT];
+ p->flags &= ~ttypes[TTYPE_LINK_TEXT];
return(0);
}
diff --git a/mdoc_validate.c b/mdoc_validate.c
index 63656743..ebd023d8 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -300,7 +300,7 @@ const struct valids mdoc_valids[MDOC_MAX] = {
{ pres_lb, posts_lb }, /* Lb */
{ NULL, NULL }, /* Ap */
{ NULL, posts_pp }, /* Lp */
- { NULL, posts_text }, /* Lk */
+ { NULL, NULL }, /* Lk */
{ NULL, posts_text }, /* Mt */
{ NULL, posts_wline }, /* Brq */
{ NULL, NULL }, /* Bro */
@@ -789,7 +789,7 @@ pre_display(PRE_ARGS)
static int
pre_bl(PRE_ARGS)
{
- int pos, type, width, offset;
+ int pos, col, type, width, offset;
if (MDOC_BLOCK != n->type)
return(1);
@@ -798,7 +798,7 @@ pre_bl(PRE_ARGS)
/* Make sure that only one type of list is specified. */
- type = offset = width = -1;
+ type = offset = width = col = -1;
/* LINTED */
for (pos = 0; pos < (int)n->args->argc; pos++)
@@ -827,6 +827,7 @@ pre_bl(PRE_ARGS)
if (-1 != type)
return(nerr(mdoc, n, EMULTILIST));
type = n->args->argv[pos].arg;
+ col = pos;
break;
case (MDOC_Width):
if (-1 != width)
@@ -876,7 +877,8 @@ pre_bl(PRE_ARGS)
switch (type) {
case (MDOC_Column):
- if (0 == n->args->argv[pos].sz)
+ assert(col >= 0);
+ if (0 == n->args->argv[col].sz)
break;
if ( ! nwarn(mdoc, n, WDEPCOL))
return(0);