summaryrefslogtreecommitdiffstatshomepage
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
commit0214fa880cd249945951f08bfcf80004d5e6f43f (patch)
tree55b4a2e6eb6657ee1288f835fa1b057fa4e1451d
parentad41f399a1fe056e9e22b214c75f2057a063ef44 (diff)
downloadmandoc-0214fa880cd249945951f08bfcf80004d5e6f43f.tar.gz
mandoc-0214fa880cd249945951f08bfcf80004d5e6f43f.tar.zst
mandoc-0214fa880cd249945951f08bfcf80004d5e6f43f.zip
`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.712
-rw-r--r--mdoc_action.c26
-rw-r--r--mdoc_macro.c14
-rw-r--r--mdoc_term.c13
-rw-r--r--mdoc_validate.c12
5 files changed, 56 insertions, 21 deletions
diff --git a/mdoc.7 b/mdoc.7
index d7ea4253..65121472 100644
--- a/mdoc.7
+++ b/mdoc.7
@@ -1,4 +1,4 @@
-.\" $Id: mdoc.7,v 1.26 2009/06/11 20:02:37 kristaps Exp $
+.\" $Id: mdoc.7,v 1.27 2009/06/12 09:18:00 kristaps Exp $
.\"
.\" Copyright (c) 2009 Kristaps Dzonsons <kristaps@kth.se>
.\"
@@ -14,7 +14,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: June 11 2009 $
+.Dd $Mdocdate: June 12 2009 $
.Dt MDOC 7
.Os
.\" SECTION
@@ -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 d8a28a62..23da04f8 100644
--- a/mdoc_action.c
+++ b/mdoc_action.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_action.c,v 1.9 2009/06/10 20:18:43 kristaps Exp $ */
+/* $Id: mdoc_action.c,v 1.10 2009/06/12 09:18:00 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -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 ef4cc5fc..e54aedc0 100644
--- a/mdoc_macro.c
+++ b/mdoc_macro.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_macro.c,v 1.11 2009/06/11 20:02:37 kristaps Exp $ */
+/* $Id: mdoc_macro.c,v 1.12 2009/06/12 09:18:00 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -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 07aef10c..ec440962 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_term.c,v 1.11 2009/06/11 13:13:44 kristaps Exp $ */
+/* $Id: mdoc_term.c,v 1.12 2009/06/12 09:18:00 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -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 1da8a28d..900f07fc 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_validate.c,v 1.8 2009/06/11 10:34:31 kristaps Exp $ */
+/* $Id: mdoc_validate.c,v 1.9 2009/06/12 09:18:00 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -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);