aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--TODO6
-rw-r--r--mdoc.c4
-rw-r--r--mdoc.h7
-rw-r--r--mdoc_term.c47
-rw-r--r--mdoc_validate.c19
5 files changed, 70 insertions, 13 deletions
diff --git a/TODO b/TODO
index 538e6e96..f7be45bc 100644
--- a/TODO
+++ b/TODO
@@ -1,6 +1,6 @@
************************************************************************
* Official mandoc TODO.
-* $Id: TODO,v 1.68 2010/12/16 01:00:29 kristaps Exp $
+* $Id: TODO,v 1.69 2010/12/25 13:50:37 kristaps Exp $
************************************************************************
************************************************************************
@@ -132,10 +132,6 @@
or not (run a manual without `Nm blah' to see this). I'm not sure
that this exists in the wild, but it's still an error.
-- .%T should be quoted, not underlined, when .%J is also present,
- to better distinguish the contents of .%T and .%J,
- see for example OpenBSD cat(1)
-
- In .Bl -bullet, the groff bullet is "+\b+\bo\bo", the mandoc bullet
is just "o\bo".
see for example OpenBSD ksh(1)
diff --git a/mdoc.c b/mdoc.c
index a30e8be5..32d2584e 100644
--- a/mdoc.c
+++ b/mdoc.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc.c,v 1.172 2010/12/24 14:00:40 kristaps Exp $ */
+/* $Id: mdoc.c,v 1.173 2010/12/25 13:50:37 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
@@ -484,6 +484,8 @@ mdoc_block_alloc(struct mdoc *m, int line, int pos,
case (MDOC_Bf):
/* FALLTHROUGH */
case (MDOC_Bl):
+ /* FALLTHROUGH */
+ case (MDOC_Rs):
p->norm = mandoc_calloc(1, sizeof(union mdoc_data));
break;
default:
diff --git a/mdoc.h b/mdoc.h
index 69a11005..36e40d19 100644
--- a/mdoc.h
+++ b/mdoc.h
@@ -1,4 +1,4 @@
-/* $Id: mdoc.h,v 1.110 2010/12/24 14:00:40 kristaps Exp $ */
+/* $Id: mdoc.h,v 1.111 2010/12/25 13:50:37 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -353,6 +353,10 @@ struct mdoc_an {
enum mdoc_auth auth; /* -split, etc. */
};
+struct mdoc_rs {
+ int titlejournal; /* whether %T and %J */
+};
+
/*
* Consists of normalised node arguments. These should be used instead
* of iterating through the mdoc_arg pointers of a node: defaults are
@@ -363,6 +367,7 @@ union mdoc_data {
struct mdoc_bd Bd;
struct mdoc_bf Bf;
struct mdoc_bl Bl;
+ struct mdoc_rs Rs;
};
/*
diff --git a/mdoc_term.c b/mdoc_term.c
index 87ec8df8..55d7ef4b 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_term.c,v 1.202 2010/12/24 14:00:40 kristaps Exp $ */
+/* $Id: mdoc_term.c,v 1.203 2010/12/25 13:50:37 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
@@ -68,6 +68,7 @@ static void synopsis_pre(struct termp *,
const struct mdoc_node *);
static void termp____post(DECL_ARGS);
+static void termp__t_post(DECL_ARGS);
static void termp_an_post(DECL_ARGS);
static void termp_bd_post(DECL_ARGS);
static void termp_bk_post(DECL_ARGS);
@@ -85,6 +86,7 @@ static void termp_sh_post(DECL_ARGS);
static void termp_ss_post(DECL_ARGS);
static int termp__a_pre(DECL_ARGS);
+static int termp__t_pre(DECL_ARGS);
static int termp_an_pre(DECL_ARGS);
static int termp_ap_pre(DECL_ARGS);
static int termp_bd_pre(DECL_ARGS);
@@ -174,7 +176,7 @@ static const struct termact termacts[MDOC_MAX] = {
{ NULL, termp____post }, /* %O */
{ NULL, termp____post }, /* %P */
{ NULL, termp____post }, /* %R */
- { termp_under_pre, termp____post }, /* %T */
+ { termp__t_pre, termp__t_post }, /* %T */
{ NULL, termp____post }, /* %V */
{ NULL, NULL }, /* Ac */
{ termp_quote_pre, termp_quote_post }, /* Ao */
@@ -1830,7 +1832,7 @@ static int
termp_quote_pre(DECL_ARGS)
{
- if (MDOC_BODY != n->type)
+ if (MDOC_BODY != n->type && MDOC_ELEM != n->type)
return(1);
switch (n->tok) {
@@ -1853,6 +1855,8 @@ termp_quote_pre(DECL_ARGS)
case (MDOC_Bq):
term_word(p, "[");
break;
+ case (MDOC__T):
+ /* FALLTHROUGH */
case (MDOC_Do):
/* FALLTHROUGH */
case (MDOC_Dq):
@@ -1890,7 +1894,7 @@ static void
termp_quote_post(DECL_ARGS)
{
- if (MDOC_BODY != n->type)
+ if (MDOC_BODY != n->type && MDOC_ELEM != n->type)
return;
p->flags |= TERMP_NOSPACE;
@@ -1915,6 +1919,8 @@ termp_quote_post(DECL_ARGS)
case (MDOC_Bq):
term_word(p, "]");
break;
+ case (MDOC__T):
+ /* FALLTHROUGH */
case (MDOC_Do):
/* FALLTHROUGH */
case (MDOC_Dq):
@@ -2134,6 +2140,39 @@ termp_bk_post(DECL_ARGS)
}
/* ARGSUSED */
+static void
+termp__t_post(DECL_ARGS)
+{
+
+ /*
+ * If we're in an `Rs' and there's a journal present, then quote
+ * us instead of underlining us (for disambiguation).
+ */
+ if (n->parent && MDOC_Rs == n->parent->tok &&
+ n->parent->norm->Rs.titlejournal)
+ termp_quote_post(p, pair, m, n);
+
+ termp____post(p, pair, m, n);
+}
+
+/* ARGSUSED */
+static int
+termp__t_pre(DECL_ARGS)
+{
+
+ /*
+ * If we're in an `Rs' and there's a journal present, then quote
+ * us instead of underlining us (for disambiguation).
+ */
+ if (n->parent && MDOC_Rs == n->parent->tok &&
+ n->parent->norm->Rs.titlejournal)
+ return(termp_quote_pre(p, pair, m, n));
+
+ term_fontpush(p, TERMFONT_UNDER);
+ return(1);
+}
+
+/* ARGSUSED */
static int
termp_under_pre(DECL_ARGS)
{
diff --git a/mdoc_validate.c b/mdoc_validate.c
index 5a102460..b359df7e 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_validate.c,v 1.147 2010/12/24 14:00:40 kristaps Exp $ */
+/* $Id: mdoc_validate.c,v 1.148 2010/12/25 13:50:37 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -1649,8 +1649,19 @@ post_rs(POST_ARGS)
{
struct mdoc_node *nn, *next, *prev;
int i, j;
+ int *tj;
+#define RS_JOURNAL (1 << 0)
+#define RS_TITLE (1 << 1)
- if (MDOC_BODY != mdoc->last->type)
+ /* Mark whether we're carrying both a %T and %J. */
+
+ tj = &mdoc->last->norm->Rs.titlejournal;
+
+ if (MDOC_BLOCK == mdoc->last->type) {
+ if ( ! (RS_JOURNAL & *tj && RS_TITLE & *tj))
+ *tj = 0;
+ return(1);
+ } else if (MDOC_BODY != mdoc->last->type)
return(1);
/*
@@ -1666,6 +1677,10 @@ post_rs(POST_ARGS)
break;
if (i < RSORD_MAX) {
+ if (MDOC__T == rsord[i])
+ *tj |= RS_TITLE;
+ else if (MDOC__J == rsord[i])
+ *tj |= RS_JOURNAL;
next = nn->next;
continue;
}