aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--mdoc.c4
-rw-r--r--mdoc.h3
-rw-r--r--mdoc_action.c3
-rw-r--r--mdoc_argv.c12
-rw-r--r--mdoc_html.c3
-rw-r--r--mdoc_macro.c120
-rw-r--r--mdoc_term.c3
-rw-r--r--mdoc_validate.c3
8 files changed, 119 insertions, 32 deletions
diff --git a/mdoc.c b/mdoc.c
index a1e27576..ba67df40 100644
--- a/mdoc.c
+++ b/mdoc.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc.c,v 1.140 2010/05/30 11:00:53 kristaps Exp $ */
+/* $Id: mdoc.c,v 1.141 2010/05/31 10:28:04 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -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 3476073c..92d775b7 100644
--- a/mdoc.h
+++ b/mdoc.h
@@ -1,4 +1,4 @@
-/* $Id: mdoc.h,v 1.82 2010/05/17 23:57:06 kristaps Exp $ */
+/* $Id: mdoc.h,v 1.83 2010/05/31 10:28:04 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -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 ff1400a3..ddb8b201 100644
--- a/mdoc_action.c
+++ b/mdoc_action.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_action.c,v 1.63 2010/05/30 11:00:53 kristaps Exp $ */
+/* $Id: mdoc_action.c,v 1.64 2010/05/31 10:28:04 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -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 ceba9873..ccc6ed10 100644
--- a/mdoc_argv.c
+++ b/mdoc_argv.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_argv.c,v 1.50 2010/05/30 23:59:59 kristaps Exp $ */
+/* $Id: mdoc_argv.c,v 1.51 2010/05/31 10:28:04 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -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 4e740514..894d605e 100644
--- a/mdoc_html.c
+++ b/mdoc_html.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_html.c,v 1.70 2010/05/30 22:56:02 kristaps Exp $ */
+/* $Id: mdoc_html.c,v 1.71 2010/05/31 10:28:04 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -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 4d52987c..3fdfba06 100644
--- a/mdoc_macro.c
+++ b/mdoc_macro.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_macro.c,v 1.74 2010/05/30 22:56:02 kristaps Exp $ */
+/* $Id: mdoc_macro.c,v 1.75 2010/05/31 10:28:04 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -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 ff04d3a2..d32240f3 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_term.c,v 1.134 2010/05/30 22:56:02 kristaps Exp $ */
+/* $Id: mdoc_term.c,v 1.135 2010/05/31 10:28:04 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -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 6aed3c92..daf00177 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_validate.c,v 1.87 2010/05/30 22:56:02 kristaps Exp $ */
+/* $Id: mdoc_validate.c,v 1.88 2010/05/31 10:28:04 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -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 */
};