summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mdoc.c2
-rw-r--r--mdoc.h1
-rw-r--r--mdoc_action.c1
-rw-r--r--mdoc_argv.c10
-rw-r--r--mdoc_html.c1
-rw-r--r--mdoc_macro.c118
-rw-r--r--mdoc_term.c1
-rw-r--r--mdoc_validate.c1
8 files changed, 111 insertions, 24 deletions
diff --git a/mdoc.c b/mdoc.c
index f5373f75..8aeec090 100644
--- a/mdoc.c
+++ b/mdoc.c
@@ -69,7 +69,7 @@ const char *const __mdoc_macronames[MDOC_MAX] = {
/* LINTED */
"Dx", "%Q", "br", "sp",
/* LINTED */
- "%U"
+ "%U", "Ta"
};
const char *const __mdoc_argnames[MDOC_ARG_MAX] = {
diff --git a/mdoc.h b/mdoc.h
index 8b2c9a05..9fcc4d5a 100644
--- a/mdoc.h
+++ b/mdoc.h
@@ -149,6 +149,7 @@ enum mdoct {
MDOC_br,
MDOC_sp,
MDOC__U,
+ MDOC_Ta,
MDOC_MAX
};
diff --git a/mdoc_action.c b/mdoc_action.c
index 3d94c3fd..68e04210 100644
--- a/mdoc_action.c
+++ b/mdoc_action.c
@@ -194,6 +194,7 @@ static const struct actions mdoc_actions[MDOC_MAX] = {
{ NULL, NULL }, /* br */
{ NULL, NULL }, /* sp */
{ NULL, NULL }, /* %U */
+ { NULL, NULL }, /* Ta */
};
#define RSORD_MAX 14
diff --git a/mdoc_argv.c b/mdoc_argv.c
index a01791aa..ac344f44 100644
--- a/mdoc_argv.c
+++ b/mdoc_argv.c
@@ -210,6 +210,7 @@ static int mdoc_argflags[MDOC_MAX] = {
0, /* br */
0, /* sp */
0, /* %U */
+ 0, /* Ta */
};
@@ -347,6 +348,13 @@ mdoc_args(struct mdoc *m, int line, int *pos,
if (MDOC_It != tok)
return(args(m, line, pos, buf, fl, v));
+ /*
+ * We know that we're in an `It', so it's reasonable to expect
+ * us to be sitting in a `Bl'. Someday this may not be the case
+ * (if we allow random `It's sitting out there), so provide a
+ * safe fall-back into the default behaviour.
+ */
+
for (n = m->last; n; n = n->parent)
if (MDOC_Bl == n->tok)
break;
@@ -455,7 +463,7 @@ args(struct mdoc *m, int line, int *pos,
break;
if (pp > *v && ' ' != *(pp - 1))
continue;
- if (' ' == *(pp + 2) || 0 == *(pp + 2))
+ if (' ' == *(pp + 2) || '\0' == *(pp + 2))
break;
}
diff --git a/mdoc_html.c b/mdoc_html.c
index c80d3c73..686c408a 100644
--- a/mdoc_html.c
+++ b/mdoc_html.c
@@ -255,6 +255,7 @@ static const struct htmlmdoc mdocs[MDOC_MAX] = {
{mdoc_sp_pre, NULL}, /* br */
{mdoc_sp_pre, NULL}, /* sp */
{mdoc__x_pre, mdoc__x_post}, /* %U */
+ {NULL, NULL}, /* Ta */
};
diff --git a/mdoc_macro.c b/mdoc_macro.c
index 205512d6..20be5acb 100644
--- a/mdoc_macro.c
+++ b/mdoc_macro.c
@@ -44,13 +44,13 @@ static int in_line_eoln(MACRO_PROT_ARGS);
static int in_line_argn(MACRO_PROT_ARGS);
static int in_line(MACRO_PROT_ARGS);
static int obsolete(MACRO_PROT_ARGS);
+static int phrase_ta(MACRO_PROT_ARGS);
static int append_delims(struct mdoc *,
int, int *, char *);
static enum mdoct lookup(enum mdoct, const char *);
static enum mdoct lookup_raw(const char *);
-static int phrase(struct mdoc *, int, int,
- char *, enum margserr);
+static int phrase(struct mdoc *, int, int, char *);
static enum mdoct rew_alt(enum mdoct);
static int rew_dobreak(enum mdoct,
const struct mdoc_node *);
@@ -186,6 +186,7 @@ const struct mdoc_macro __mdoc_macros[MDOC_MAX] = {
{ in_line_eoln, 0 }, /* br */
{ in_line_eoln, 0 }, /* sp */
{ in_line_eoln, 0 }, /* %U */
+ { phrase_ta, MDOC_CALLABLE | MDOC_PARSED }, /* Ta */
};
const struct mdoc_macro * const mdoc_macros = __mdoc_macros;
@@ -196,7 +197,7 @@ swarn(struct mdoc *mdoc, enum mdoc_type type,
int line, int pos, const struct mdoc_node *p)
{
const char *n, *t, *tt;
- int rc;
+ enum mandocerr ec;
n = t = "<root>";
tt = "block";
@@ -229,11 +230,12 @@ swarn(struct mdoc *mdoc, enum mdoc_type type,
break;
}
- rc = mdoc_vmsg(mdoc, MANDOCERR_SCOPE, line, pos,
- "%s scope breaks %s of %s", tt, t, n);
+ ec = (MDOC_IGN_SCOPE & mdoc->pflags) ?
+ MANDOCERR_SCOPE : MANDOCERR_SYNTSCOPE;
- /* FIXME: logic should be in driver. */
- return(MDOC_IGN_SCOPE & mdoc->pflags ? rc : 0);
+ return(mdoc_vmsg(mdoc, ec, line, pos,
+ "%s scope breaks %s of %s",
+ tt, t, n));
}
@@ -1006,14 +1008,30 @@ blk_full(MACRO_PROT_ARGS)
for ( ; ; ) {
la = *pos;
- /* Initialise last-phrase-type with ARGS_PHRASE. */
- lac = ARGS_ERROR == ac ? ARGS_PHRASE : ac;
+ /* Initialise last-phrase-type with ARGS_PEND. */
+ lac = ARGS_ERROR == ac ? ARGS_PEND : ac;
ac = mdoc_args(m, line, pos, buf, tok, &p);
if (ARGS_ERROR == ac)
return(0);
- if (ARGS_EOLN == ac)
+
+ if (ARGS_EOLN == ac) {
+ if (ARGS_PPHRASE != lac && ARGS_PHRASE != lac)
+ break;
+ /*
+ * This is necessary: if the last token on a
+ * line is a `Ta' or tab, then we'll get
+ * ARGS_EOLN, so we must be smart enough to
+ * reopen our scope if the last parse was a
+ * phrase or partial phrase.
+ */
+ if ( ! rew_sub(MDOC_BODY, m, tok, line, ppos))
+ return(0);
+ if ( ! mdoc_body_alloc(m, line, ppos, tok))
+ return(0);
+ body = m->last;
break;
+ }
/*
* Emit leading punctuation (i.e., punctuation before
@@ -1068,10 +1086,7 @@ blk_full(MACRO_PROT_ARGS)
if (ARGS_PEND == ac && ARGS_PPHRASE == lac)
m->flags |= MDOC_PPHRASE;
- if (ARGS_PEND == ac) {
- if ( ! phrase(m, line, la, buf, lac))
- return(0);
- } else if ( ! phrase(m, line, la, buf, ac))
+ if ( ! phrase(m, line, la, buf))
return(0);
m->flags &= ~MDOC_PPHRASE;
@@ -1624,26 +1639,24 @@ obsolete(MACRO_PROT_ARGS)
* macro is encountered.
*/
static int
-phrase(struct mdoc *m, int line, int ppos, char *buf, enum margserr ac)
+phrase(struct mdoc *m, int line, int ppos, char *buf)
{
int la, pos;
- enum margserr aac;
+ enum margserr ac;
enum mdoct ntok;
char *p;
- assert(ARGS_PHRASE == ac || ARGS_PPHRASE == ac);
-
for (pos = ppos; ; ) {
la = pos;
- aac = mdoc_zargs(m, line, &pos, buf, 0, &p);
+ ac = mdoc_zargs(m, line, &pos, buf, 0, &p);
- if (ARGS_ERROR == aac)
+ if (ARGS_ERROR == ac)
return(0);
- if (ARGS_EOLN == aac)
+ if (ARGS_EOLN == ac)
break;
- ntok = ARGS_QWORD == aac ? MDOC_MAX : lookup_raw(p);
+ ntok = ARGS_QWORD == ac ? MDOC_MAX : lookup_raw(p);
if (MDOC_MAX == ntok) {
if ( ! mdoc_word_alloc(m, line, la, p))
@@ -1660,3 +1673,64 @@ phrase(struct mdoc *m, int line, int ppos, char *buf, enum margserr ac)
}
+static int
+phrase_ta(MACRO_PROT_ARGS)
+{
+ int la;
+ enum mdoct ntok;
+ enum margserr ac;
+ struct mdoc_node *n;
+ char *p;
+
+ /*
+ * FIXME: this is overly restrictive: if the `Ta' is unexpected,
+ * it should simply error out with ARGSLOST.
+ */
+
+ n = m->last;
+ if ( ! rew_sub(MDOC_BODY, m, MDOC_It, line, ppos))
+ return(0);
+
+ /*
+ * FIXME: this is necessary in bogus constructions like
+ * .Bl -column foo bar
+ * .Sy foo Ta bar
+ * It is, however, an ugly way to do it.
+ *
+ * XXX; remove this when the above construct builds an implied
+ * `It' marker.
+ */
+ if (NULL == m->last ||
+ MDOC_BODY != m->last->type ||
+ MDOC_It != m->last->tok) {
+ swarn(m, tok, line, ppos, n);
+ return(0);
+ }
+
+ if ( ! mdoc_body_alloc(m, line, ppos, MDOC_It))
+ return(0);
+
+ for (;;) {
+ la = *pos;
+ ac = mdoc_zargs(m, line, pos, buf, 0, &p);
+
+ if (ARGS_ERROR == ac)
+ return(0);
+ if (ARGS_EOLN == ac)
+ break;
+
+ ntok = ARGS_QWORD == ac ? MDOC_MAX : lookup_raw(p);
+
+ if (MDOC_MAX == ntok) {
+ if ( ! mdoc_word_alloc(m, line, la, p))
+ return(0);
+ continue;
+ }
+
+ if ( ! mdoc_macro(m, ntok, line, la, pos, buf))
+ return(0);
+ return(append_delims(m, line, pos, buf));
+ }
+
+ return(1);
+}
diff --git a/mdoc_term.c b/mdoc_term.c
index 9bd89edc..6344b22d 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -260,6 +260,7 @@ static const struct termact termacts[MDOC_MAX] = {
{ termp_sp_pre, NULL }, /* br */
{ termp_sp_pre, NULL }, /* sp */
{ termp_under_pre, termp____post }, /* %U */
+ { NULL, NULL }, /* Ta */
};
diff --git a/mdoc_validate.c b/mdoc_validate.c
index 8beae48a..4296cc3c 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -268,6 +268,7 @@ const struct valids mdoc_valids[MDOC_MAX] = {
{ NULL, posts_notext }, /* br */
{ NULL, posts_sp }, /* sp */
{ NULL, posts_text1 }, /* %U */
+ { NULL, NULL }, /* Ta */
};