summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--main.c5
-rw-r--r--mandoc.h6
-rw-r--r--mdoc.710
-rw-r--r--mdoc.h14
-rw-r--r--mdoc_action.c14
-rw-r--r--mdoc_html.c20
-rw-r--r--mdoc_term.c49
-rw-r--r--mdoc_validate.c64
8 files changed, 86 insertions, 96 deletions
diff --git a/main.c b/main.c
index a9bec26b..d397d3dd 100644
--- a/main.c
+++ b/main.c
@@ -1,4 +1,4 @@
-/* $Id: main.c,v 1.86 2010/06/08 13:22:37 kristaps Exp $ */
+/* $Id: main.c,v 1.87 2010/06/12 10:09:19 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -143,12 +143,13 @@ static const char * const mandocerrs[MANDOCERR_MAX] = {
"macro requires argument(s)",
"no title in document",
"missing list type",
+ "missing display type",
"line argument(s) will be lost",
"body argument(s) will be lost",
"column syntax is inconsistent",
"missing font type",
- "missing display type",
"displays may not be nested",
+ "unsupported display type",
"no scope to rewind: syntax violated",
"scope broken, syntax violated",
"line scope broken, syntax violated",
diff --git a/mandoc.h b/mandoc.h
index ae9b2814..d8c25cf2 100644
--- a/mandoc.h
+++ b/mandoc.h
@@ -1,4 +1,4 @@
-/* $Id: mandoc.h,v 1.10 2010/06/03 13:44:36 kristaps Exp $ */
+/* $Id: mandoc.h,v 1.11 2010/06/12 10:09:19 kristaps Exp $ */
/*
* Copyright (c) 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -74,6 +74,7 @@ enum mandocerr {
MANDOCERR_NOARGV, /* macro requires argument(s) */
MANDOCERR_NOTITLE, /* no title in document */
MANDOCERR_LISTTYPE, /* missing list type */
+ MANDOCERR_DISPTYPE, /* missing display type */
MANDOCERR_ARGSLOST, /* line argument(s) will be lost */
MANDOCERR_BODYLOST, /* body argument(s) will be lost */
#define MANDOCERR_ERROR MANDOCERR_BODYLOST
@@ -82,9 +83,8 @@ enum mandocerr {
/* FIXME: this should be a MANDOCERR_ERROR */
MANDOCERR_FONTTYPE, /* missing font type */
/* FIXME: this should be a MANDOCERR_ERROR */
- MANDOCERR_DISPTYPE, /* missing display type */
- /* FIXME: this should be a MANDOCERR_ERROR */
MANDOCERR_NESTEDDISP, /* displays may not be nested */
+ MANDOCERR_BADDISP, /* unsupported display type */
MANDOCERR_SYNTNOSCOPE, /* request scope close w/none open */
MANDOCERR_SYNTSCOPE, /* scope broken, syntax violated */
MANDOCERR_SYNTLINESCOPE, /* line scope broken, syntax violated */
diff --git a/mdoc.7 b/mdoc.7
index b20c16fc..c52dae19 100644
--- a/mdoc.7
+++ b/mdoc.7
@@ -1,4 +1,4 @@
-.\" $Id: mdoc.7,v 1.124 2010/06/07 12:20:07 kristaps Exp $
+.\" $Id: mdoc.7,v 1.125 2010/06/12 10:09:19 kristaps Exp $
.\"
.\" Copyright (c) 2009 Kristaps Dzonsons <kristaps@bsd.lv>
.\"
@@ -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 7 2010 $
+.Dd $Mdocdate: June 12 2010 $
.Dt MDOC 7
.Os
.Sh NAME
@@ -2169,6 +2169,12 @@ Heirloom troff, the other significant troff implementation accepting
.Pp
.Bl -dash -compact
.It
+groff supports a
+.Fl file Ar filename
+argument to
+.Sx \&Bd .
+mandoc does not.
+.It
groff behaves inconsistently when encountering
.Pf non- Sx \&Fa
children of
diff --git a/mdoc.h b/mdoc.h
index 92d775b7..3027400b 100644
--- a/mdoc.h
+++ b/mdoc.h
@@ -1,4 +1,4 @@
-/* $Id: mdoc.h,v 1.83 2010/05/31 10:28:04 kristaps Exp $ */
+/* $Id: mdoc.h,v 1.84 2010/06/12 10:09:19 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -263,6 +263,15 @@ enum mdoc_list {
LIST_tag
};
+enum mdoc_disp {
+ DISP__NONE = 0,
+ DISP_centred,
+ DISP_ragged,
+ DISP_unfilled,
+ DISP_filled,
+ DISP_literal
+};
+
/* Node in AST. */
struct mdoc_node {
struct mdoc_node *parent; /* parent AST node */
@@ -290,7 +299,8 @@ struct mdoc_node {
char *string; /* TEXT */
union {
- enum mdoc_list list; /* for `Bl' nodes */
+ enum mdoc_list list; /* `Bl' nodes */
+ enum mdoc_disp disp; /* `Bd' nodes */
} data;
};
diff --git a/mdoc_action.c b/mdoc_action.c
index f27ef13b..f1c3b236 100644
--- a/mdoc_action.c
+++ b/mdoc_action.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_action.c,v 1.65 2010/06/03 13:44:36 kristaps Exp $ */
+/* $Id: mdoc_action.c,v 1.66 2010/06/12 10:09:19 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -978,20 +978,16 @@ pre_bl(PRE_ARGS)
static int
pre_bd(PRE_ARGS)
{
- int i;
if (MDOC_BLOCK == n->type)
return(pre_offset(m, n));
if (MDOC_BODY != n->type)
return(1);
- /* Enter literal context if `Bd -literal' or `-unfilled'. */
-
- for (n = n->parent, i = 0; i < (int)n->args->argc; i++)
- if (MDOC_Literal == n->args->argv[i].arg)
- m->flags |= MDOC_LITERAL;
- else if (MDOC_Unfilled == n->args->argv[i].arg)
- m->flags |= MDOC_LITERAL;
+ if (DISP_literal == n->data.disp)
+ m->flags |= MDOC_LITERAL;
+ if (DISP_unfilled == n->data.disp)
+ m->flags |= MDOC_LITERAL;
return(1);
}
diff --git a/mdoc_html.c b/mdoc_html.c
index 1ac0139e..0df11dc3 100644
--- a/mdoc_html.c
+++ b/mdoc_html.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_html.c,v 1.78 2010/06/07 11:01:15 kristaps Exp $ */
+/* $Id: mdoc_html.c,v 1.79 2010/06/12 10:09:19 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -1353,7 +1353,7 @@ static int
mdoc_bd_pre(MDOC_ARGS)
{
struct htmlpair tag[2];
- int type, comp, i;
+ int comp, i;
const struct mdoc_node *bl, *nn;
struct roffsu su;
@@ -1366,7 +1366,7 @@ mdoc_bd_pre(MDOC_ARGS)
SCALE_VS_INIT(&su, 0);
- type = comp = 0;
+ comp = 0;
for (i = 0; bl->args && i < (int)bl->args->argc; i++)
switch (bl->args->argv[i].arg) {
case (MDOC_Offset):
@@ -1375,17 +1375,6 @@ mdoc_bd_pre(MDOC_ARGS)
case (MDOC_Compact):
comp = 1;
break;
- case (MDOC_Centred):
- /* FALLTHROUGH */
- case (MDOC_Ragged):
- /* FALLTHROUGH */
- case (MDOC_Filled):
- /* FALLTHROUGH */
- case (MDOC_Unfilled):
- /* FALLTHROUGH */
- case (MDOC_Literal):
- type = bl->args->argv[i].arg;
- break;
default:
break;
}
@@ -1415,7 +1404,8 @@ mdoc_bd_pre(MDOC_ARGS)
return(1);
}
- if (MDOC_Unfilled != type && MDOC_Literal != type)
+ if (DISP_unfilled != n->data.disp &&
+ DISP_literal != n->data.disp)
return(1);
PAIR_CLASS_INIT(&tag[0], "lit");
diff --git a/mdoc_term.c b/mdoc_term.c
index 7b590ed7..f74be21a 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_term.c,v 1.146 2010/06/10 23:24:37 schwarze Exp $ */
+/* $Id: mdoc_term.c,v 1.147 2010/06/12 10:09:19 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -60,7 +60,6 @@ static int arg_hasattr(int, const struct mdoc_node *);
static int arg_getattrs(const int *, int *, size_t,
const struct mdoc_node *);
static int arg_getattr(int, const struct mdoc_node *);
-static int arg_disptype(const struct mdoc_node *);
static void print_bvspace(struct termp *,
const struct mdoc_node *,
const struct mdoc_node *);
@@ -489,35 +488,6 @@ a2width(const struct mdoc_argv *arg, int pos)
}
-static int
-arg_disptype(const struct mdoc_node *n)
-{
- int i, len;
-
- assert(MDOC_BLOCK == n->type);
-
- len = (int)(n->args ? n->args->argc : 0);
-
- for (i = 0; i < len; i++)
- switch (n->args->argv[i].arg) {
- case (MDOC_Centred):
- /* FALLTHROUGH */
- case (MDOC_Ragged):
- /* FALLTHROUGH */
- case (MDOC_Filled):
- /* FALLTHROUGH */
- case (MDOC_Unfilled):
- /* FALLTHROUGH */
- case (MDOC_Literal):
- return(n->args->argv[i].arg);
- default:
- break;
- }
-
- return(-1);
-}
-
-
static size_t
a2offs(const struct mdoc_argv *arg)
{
@@ -1632,7 +1602,7 @@ static int
termp_bd_pre(DECL_ARGS)
{
size_t tabwidth;
- int i, type;
+ int i;
size_t rm, rmax;
const struct mdoc_node *nn;
@@ -1644,9 +1614,6 @@ termp_bd_pre(DECL_ARGS)
nn = n->parent;
- type = arg_disptype(nn);
- assert(-1 != type);
-
if (-1 != (i = arg_getattr(MDOC_Offset, nn)))
p->offset += a2offs(&nn->args->argv[i]);
@@ -1658,7 +1625,8 @@ termp_bd_pre(DECL_ARGS)
* lines are allowed.
*/
- if (MDOC_Literal != type && MDOC_Unfilled != type)
+ if (DISP_literal != n->data.disp &&
+ DISP_unfilled != n->data.disp)
return(1);
tabwidth = p->tabwidth;
@@ -1675,8 +1643,8 @@ termp_bd_pre(DECL_ARGS)
NULL == nn->next)
term_flushln(p);
}
- p->tabwidth = tabwidth;
+ p->tabwidth = tabwidth;
p->rmargin = rm;
p->maxrmargin = rmax;
return(0);
@@ -1687,19 +1655,16 @@ termp_bd_pre(DECL_ARGS)
static void
termp_bd_post(DECL_ARGS)
{
- int type;
size_t rm, rmax;
if (MDOC_BODY != n->type)
return;
- type = arg_disptype(n->parent);
- assert(-1 != type);
-
rm = p->rmargin;
rmax = p->maxrmargin;
- if (MDOC_Literal == type || MDOC_Unfilled == type)
+ if (DISP_literal == n->data.disp ||
+ DISP_unfilled == n->data.disp)
p->rmargin = p->maxrmargin = TERM_MAXMARGIN;
p->flags |= TERMP_NOSPACE;
diff --git a/mdoc_validate.c b/mdoc_validate.c
index e621a2c1..a42fc118 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_validate.c,v 1.92 2010/06/09 19:22:56 kristaps Exp $ */
+/* $Id: mdoc_validate.c,v 1.93 2010/06/12 10:09:19 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -683,43 +683,65 @@ pre_bl(PRE_ARGS)
static int
pre_bd(PRE_ARGS)
{
- int i, type, err;
+ int i;
+ enum mdoc_disp dt;
- if (MDOC_BLOCK != n->type)
+ if (MDOC_BLOCK != n->type) {
+ assert(n->parent);
+ assert(MDOC_BLOCK == n->parent->type);
+ assert(MDOC_Bd == n->parent->tok);
+ assert(DISP__NONE != n->parent->data.disp);
+ n->data.disp = n->parent->data.disp;
return(1);
- if (NULL == n->args) {
- mdoc_nmsg(mdoc, n, MANDOCERR_DISPTYPE);
- return(0);
}
- /* Make sure that only one type of display is specified. */
+ assert(DISP__NONE == n->data.disp);
/* LINTED */
- for (i = 0, err = type = 0; ! err &&
- i < (int)n->args->argc; i++)
+ for (i = 0; n->args && i < (int)n->args->argc; i++) {
+ dt = DISP__NONE;
switch (n->args->argv[i].arg) {
case (MDOC_Centred):
- /* FALLTHROUGH */
+ dt = DISP_centred;
+ break;
case (MDOC_Ragged):
- /* FALLTHROUGH */
+ dt = DISP_ragged;
+ break;
case (MDOC_Unfilled):
- /* FALLTHROUGH */
+ dt = DISP_unfilled;
+ break;
case (MDOC_Filled):
- /* FALLTHROUGH */
+ dt = DISP_filled;
+ break;
case (MDOC_Literal):
- if (0 == type++)
- break;
- if ( ! mdoc_nmsg(mdoc, n, MANDOCERR_DISPREP))
- return(0);
+ dt = DISP_literal;
break;
+ case (MDOC_File):
+ mdoc_nmsg(mdoc, n, MANDOCERR_BADDISP);
+ return(0);
+ case (MDOC_Offset):
+ /* FALLTHROUGH */
+ case (MDOC_Compact):
+ /* FALLTHROUGH */
default:
break;
}
- if (type)
- return(1);
- mdoc_nmsg(mdoc, n, MANDOCERR_DISPTYPE);
- return(0);
+ if (DISP__NONE != dt && n->data.disp != DISP__NONE)
+ if ( ! mdoc_nmsg(mdoc, n, MANDOCERR_DISPREP))
+ return(0);
+
+ if (DISP__NONE != dt && n->data.disp == DISP__NONE)
+ n->data.disp = dt;
+ }
+
+ if (DISP__NONE == n->data.disp) {
+ if ( ! mdoc_nmsg(mdoc, n, MANDOCERR_DISPTYPE))
+ return(0);
+ n->data.disp = DISP_ragged;
+ }
+
+ return(1);
}