summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mdoc.73
-rw-r--r--mdoc_action.c51
-rw-r--r--mdoc_html.c2
-rw-r--r--mdoc_macro.c2
-rw-r--r--mdoc_term.c2
-rw-r--r--mdoc_validate.c50
6 files changed, 54 insertions, 56 deletions
diff --git a/mdoc.7 b/mdoc.7
index a8c83703..ba6ac2f9 100644
--- a/mdoc.7
+++ b/mdoc.7
@@ -2124,6 +2124,9 @@ Examples:
Format a
.Dq mailto:
hyperlink.
+If an argument is not provided, the string
+.Dq \(ti
+is used as a default.
Its syntax is as follows:
.Pp
.D1 Pf \. Sx \&Mt Cm address
diff --git a/mdoc_action.c b/mdoc_action.c
index 9dcc52ed..d7e68b6d 100644
--- a/mdoc_action.c
+++ b/mdoc_action.c
@@ -51,7 +51,6 @@ struct actions {
static int concat(struct mdoc *, char *,
const struct mdoc_node *, size_t);
-static int post_ar(POST_ARGS);
static int post_at(POST_ARGS);
static int post_bl(POST_ARGS);
static int post_bl_head(POST_ARGS);
@@ -61,7 +60,6 @@ static int post_dd(POST_ARGS);
static int post_display(POST_ARGS);
static int post_dt(POST_ARGS);
static int post_lb(POST_ARGS);
-static int post_li(POST_ARGS);
static int post_nm(POST_ARGS);
static int post_os(POST_ARGS);
static int post_pa(POST_ARGS);
@@ -90,7 +88,7 @@ static const struct actions mdoc_actions[MDOC_MAX] = {
{ NULL, NULL }, /* It */
{ NULL, NULL }, /* Ad */
{ NULL, NULL }, /* An */
- { NULL, post_ar }, /* Ar */
+ { NULL, NULL }, /* Ar */
{ NULL, NULL }, /* Cd */
{ NULL, NULL }, /* Cm */
{ NULL, NULL }, /* Dv */
@@ -104,7 +102,7 @@ static const struct actions mdoc_actions[MDOC_MAX] = {
{ NULL, NULL }, /* Ft */
{ NULL, NULL }, /* Ic */
{ NULL, NULL }, /* In */
- { NULL, post_li }, /* Li */
+ { NULL, NULL }, /* Li */
{ NULL, NULL }, /* Nd */
{ NULL, post_nm }, /* Nm */
{ NULL, NULL }, /* Op */
@@ -857,51 +855,6 @@ post_pa(POST_ARGS)
/*
- * Empty `Li' macros get an empty string to make front-ends add an extra
- * space.
- */
-static int
-post_li(POST_ARGS)
-{
- struct mdoc_node *np;
-
- if (n->child)
- return(1);
-
- np = n;
- m->next = MDOC_NEXT_CHILD;
- if ( ! mdoc_word_alloc(m, n->line, n->pos, ""))
- return(0);
- m->last = np;
- return(1);
-}
-
-
-/*
- * The `Ar' macro defaults to two strings "file ..." if no value is
- * provided as an argument.
- */
-static int
-post_ar(POST_ARGS)
-{
- struct mdoc_node *np;
-
- if (n->child)
- return(1);
-
- np = n;
- m->next = MDOC_NEXT_CHILD;
- /* XXX: make into macro values. */
- if ( ! mdoc_word_alloc(m, n->line, n->pos, "file"))
- return(0);
- if ( ! mdoc_word_alloc(m, n->line, n->pos, "..."))
- return(0);
- m->last = np;
- return(1);
-}
-
-
-/*
* Parse the date field in `Dd'.
*/
static int
diff --git a/mdoc_html.c b/mdoc_html.c
index 2edcf9e7..9b8b4c10 100644
--- a/mdoc_html.c
+++ b/mdoc_html.c
@@ -1675,7 +1675,7 @@ mdoc_lk_pre(MDOC_ARGS)
PAIR_HREF_INIT(&tag[1], nn->string);
print_otag(h, TAG_A, 2, tag);
- if (NULL == nn->next)
+ if (NULL == nn || NULL == nn->next)
return(1);
for (nn = nn->next; nn; nn = nn->next)
diff --git a/mdoc_macro.c b/mdoc_macro.c
index 77a13178..34ffd86b 100644
--- a/mdoc_macro.c
+++ b/mdoc_macro.c
@@ -790,7 +790,7 @@ in_line(MACRO_PROT_ARGS)
/* FALLTHROUGH */
case (MDOC_Fl):
/* FALLTHROUGH */
- case (MDOC_Lk):
+ case (MDOC_Mt):
/* FALLTHROUGH */
case (MDOC_Nm):
/* FALLTHROUGH */
diff --git a/mdoc_term.c b/mdoc_term.c
index ff54d2fb..e5a11f75 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -2076,7 +2076,7 @@ termp_lk_pre(DECL_ARGS)
nn = sv = n->child;
- if (NULL == nn->next)
+ if (NULL == nn || NULL == nn->next)
return(1);
for (nn = nn->next; nn; nn = nn->next)
diff --git a/mdoc_validate.c b/mdoc_validate.c
index 693180ec..0fd08dc6 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -85,6 +85,8 @@ static int post_at(POST_ARGS);
static int post_bf(POST_ARGS);
static int post_bl(POST_ARGS);
static int post_bl_head(POST_ARGS);
+static int post_defaults(POST_ARGS);
+static int post_eoln(POST_ARGS);
static int post_dt(POST_ARGS);
static int post_it(POST_ARGS);
static int post_lb(POST_ARGS);
@@ -95,7 +97,6 @@ static int post_sh(POST_ARGS);
static int post_sh_body(POST_ARGS);
static int post_sh_head(POST_ARGS);
static int post_st(POST_ARGS);
-static int post_eoln(POST_ARGS);
static int post_vt(POST_ARGS);
static int pre_an(PRE_ARGS);
static int pre_bd(PRE_ARGS);
@@ -117,6 +118,7 @@ static v_post posts_bf[] = { hwarn_le1, post_bf, NULL };
static v_post posts_bl[] = { bwarn_ge1, post_bl, NULL };
static v_post posts_bool[] = { eerr_eq1, ebool, NULL };
static v_post posts_eoln[] = { post_eoln, NULL };
+static v_post posts_defaults[] = { post_defaults, NULL };
static v_post posts_dt[] = { post_dt, NULL };
static v_post posts_fo[] = { hwarn_eq1, bwarn_ge1, NULL };
static v_post posts_it[] = { post_it, NULL };
@@ -167,7 +169,7 @@ const struct valids mdoc_valids[MDOC_MAX] = {
{ pres_it, posts_it }, /* It */
{ NULL, posts_text }, /* Ad */
{ pres_an, posts_an }, /* An */
- { NULL, NULL }, /* Ar */
+ { NULL, posts_defaults }, /* Ar */
{ NULL, posts_text }, /* Cd */
{ NULL, NULL }, /* Cm */
{ NULL, NULL }, /* Dv */
@@ -181,7 +183,7 @@ const struct valids mdoc_valids[MDOC_MAX] = {
{ NULL, posts_wtext }, /* Ft */
{ NULL, posts_text }, /* Ic */
{ NULL, posts_text1 }, /* In */
- { NULL, NULL }, /* Li */
+ { NULL, posts_defaults }, /* Li */
{ NULL, posts_nd }, /* Nd */
{ NULL, posts_nm }, /* Nm */
{ NULL, posts_wline }, /* Op */
@@ -260,7 +262,7 @@ const struct valids mdoc_valids[MDOC_MAX] = {
{ NULL, posts_lb }, /* Lb */
{ NULL, posts_notext }, /* Lp */
{ NULL, posts_text }, /* Lk */
- { NULL, posts_text }, /* Mt */
+ { NULL, posts_defaults }, /* Mt */
{ NULL, posts_wline }, /* Brq */
{ NULL, NULL }, /* Bro */
{ NULL, NULL }, /* Brc */
@@ -1133,6 +1135,46 @@ post_nm(POST_ARGS)
return(mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_NONAME));
}
+static int
+post_defaults(POST_ARGS)
+{
+ struct mdoc_node *nn;
+
+ /*
+ * The `Ar' defaults to "file ..." if no value is provided as an
+ * argument; the `Mt' macro uses "~"; the `Li' just gets an
+ * empty string.
+ */
+
+ if (mdoc->last->child)
+ return(1);
+
+ nn = mdoc->last;
+ mdoc->next = MDOC_NEXT_CHILD;
+
+ switch (nn->tok) {
+ case (MDOC_Ar):
+ if ( ! mdoc_word_alloc(mdoc, nn->line, nn->pos, "file"))
+ return(0);
+ if ( ! mdoc_word_alloc(mdoc, nn->line, nn->pos, "..."))
+ return(0);
+ break;
+ case (MDOC_Li):
+ if ( ! mdoc_word_alloc(mdoc, nn->line, nn->pos, ""))
+ return(0);
+ break;
+ case (MDOC_Mt):
+ if ( ! mdoc_word_alloc(mdoc, nn->line, nn->pos, "~"))
+ return(0);
+ break;
+ default:
+ abort();
+ /* NOTREACHED */
+ }
+
+ mdoc->last = nn;
+ return(1);
+}
static int
post_at(POST_ARGS)