summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2009-02-26 14:56:27 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2009-02-26 14:56:27 +0000
commit69eda203817e9dc1f6bf992ff8af90702f812b24 (patch)
tree8de43f7f541717ff9ad65a09eb8fa558824f8d42
parent854c97785aa7622023610b070d91abae644ed473 (diff)
downloadmandoc-69eda203817e9dc1f6bf992ff8af90702f812b24.tar.gz
Lists (scoped elements) now put delims in-scope.
-rw-r--r--argv.c2
-rw-r--r--macro.c7
-rw-r--r--term.c29
-rw-r--r--validate.c57
4 files changed, 61 insertions, 34 deletions
diff --git a/argv.c b/argv.c
index b72c5696..ca05354a 100644
--- a/argv.c
+++ b/argv.c
@@ -74,7 +74,7 @@ static int mdoc_argflags[MDOC_MAX] = {
0, /* Ed */
0, /* Bl */
0, /* El */
- ARGS_DELIM, /* It */
+ 0, /* It */
ARGS_DELIM, /* Ad */
ARGS_DELIM, /* An */
ARGS_DELIM, /* Ar */
diff --git a/macro.c b/macro.c
index b1f25505..4b2caf26 100644
--- a/macro.c
+++ b/macro.c
@@ -921,11 +921,8 @@ macro_scoped(MACRO_PROT_ARGS)
if (ARGS_ERROR == c)
return(0);
- if (ARGS_PUNCT == c)
- break;
if (ARGS_EOLN == c)
break;
-
if (ARGS_PHRASE == c) {
/*
if ( ! mdoc_phrase(mdoc, line, lastarg, buf))
@@ -952,10 +949,10 @@ macro_scoped(MACRO_PROT_ARGS)
break;
}
- if ( ! rewind_subblock(MDOC_HEAD, mdoc, tok, line, ppos))
- return(0);
if (1 == ppos && ! append_delims(mdoc, line, pos, buf))
return(0);
+ if ( ! rewind_subblock(MDOC_HEAD, mdoc, tok, line, ppos))
+ return(0);
if ( ! mdoc_body_alloc(mdoc, line, ppos, tok))
return(0);
diff --git a/term.c b/term.c
index aa916ba4..e00ae9db 100644
--- a/term.c
+++ b/term.c
@@ -381,7 +381,7 @@ termp_it_pre(DECL_ARGS)
/* Get our list type. */
- for (i = 0; i < (int)bl->argc; i++)
+ for (type = -1, i = 0; i < (int)bl->argc; i++)
switch (bl->argv[i].arg) {
case (MDOC_Bullet):
/* FALLTHROUGH */
@@ -391,27 +391,19 @@ termp_it_pre(DECL_ARGS)
/* FALLTHROUGH */
case (MDOC_Hyphen):
/* FALLTHROUGH */
- case (MDOC_Item):
- /* FALLTHROUGH */
case (MDOC_Tag):
/* FALLTHROUGH */
case (MDOC_Ohang):
type = bl->argv[i].arg;
i = (int)bl->argc;
break;
- case (MDOC_Inset):
- /* FALLTHROUGH */
- case (MDOC_Hang):
- /* FALLTHROUGH */
- case (MDOC_Diag):
- /* FALLTHROUGH */
- case (MDOC_Column):
+ default:
errx(1, "list type not supported");
/* NOTREACHED */
- default:
- break;
}
+ assert(-1 != type);
+
/* Save our existing (inherited) margin and offset. */
pair->offset = p->offset;
@@ -419,7 +411,6 @@ termp_it_pre(DECL_ARGS)
/* Get list width and offset. */
- /* FIXME: auto-size. */
i = arg_getattr(MDOC_Width, bl->argc, bl->argv);
width = i >= 0 ? arg_width(&bl->argv[i]) : 0;
@@ -439,6 +430,7 @@ termp_it_pre(DECL_ARGS)
width = width > 6 ? width : 6;
break;
case (MDOC_Tag):
+ /* FIXME: auto-size. */
if (0 == width)
errx(1, "need non-zero -width");
break;
@@ -465,7 +457,7 @@ termp_it_pre(DECL_ARGS)
else if (MDOC_BODY == node->type)
p->flags |= TERMP_NOLPAD;
break;
- case (MDOC_Ohang):
+ default:
break;
}
@@ -475,6 +467,7 @@ termp_it_pre(DECL_ARGS)
*/
tp = NULL;
+
if (MDOC_HEAD == node->type) {
if (arg_hasattr(MDOC_Bullet, bl->argc, bl->argv))
tp = "\\[bu]";
@@ -488,8 +481,6 @@ termp_it_pre(DECL_ARGS)
}
if (arg_hasattr(MDOC_Hyphen, bl->argc, bl->argv))
tp = "\\-";
- if (arg_hasattr(MDOC_Item, bl->argc, bl->argv))
- tp = "";
}
/* Margin control. */
@@ -505,23 +496,19 @@ termp_it_pre(DECL_ARGS)
/* FALLTHROUGH */
case (MDOC_Hyphen):
/* FALLTHROUGH */
- case (MDOC_Item):
- /* FALLTHROUGH */
case (MDOC_Tag):
if (MDOC_HEAD == node->type)
p->rmargin = p->offset + width;
else if (MDOC_BODY == node->type)
p->offset += width;
break;
- case (MDOC_Ohang):
+ default:
break;
}
if (NULL == tp)
return(1);
- /* XXX - ignoring children. */
-
word(p, tp);
return(0);
}
diff --git a/validate.c b/validate.c
index 3a0acbc4..5584186d 100644
--- a/validate.c
+++ b/validate.c
@@ -540,7 +540,7 @@ pre_display(PRE_ARGS)
static int
pre_bl(PRE_ARGS)
{
- int type, i;
+ int type, i, width, offset;
struct mdoc_arg *argv;
size_t argc;
@@ -551,8 +551,10 @@ pre_bl(PRE_ARGS)
/* Make sure that only one type of list is specified. */
+ type = offset = width = -1;
+
/* LINTED */
- for (i = 0, type = 0; i < (int)argc; i++) {
+ for (i = 0; i < (int)argc; i++) {
argv = &n->data.block.argv[i];
switch (argv->arg) {
@@ -577,18 +579,60 @@ pre_bl(PRE_ARGS)
case (MDOC_Inset):
/* FALLTHROUGH */
case (MDOC_Column):
- if (0 == type++)
+ if (-1 == type) {
+ type = argv->arg;
break;
+ }
return(mdoc_perr(mdoc, argv->line, argv->pos,
"multiple types specified"));
+ case (MDOC_Width):
+ if (-1 == width) {
+ width = argv->arg;
+ break;
+ }
+ return(mdoc_perr(mdoc, argv->line, argv->pos,
+ "multiple -%s arguments",
+ mdoc_argnames[MDOC_Width]));
+ case (MDOC_Offset):
+ if (-1 == offset) {
+ offset = argv->arg;
+ break;
+ }
+ return(mdoc_perr(mdoc, argv->line, argv->pos,
+ "multiple -%s arguments",
+ mdoc_argnames[MDOC_Offset]));
default:
break;
}
}
- if (type)
- return(1);
- return(mdoc_err(mdoc, "no type specified"));
+ if (-1 == type)
+ return(mdoc_err(mdoc, "no type specified"));
+
+ switch (type) {
+ case (MDOC_Column):
+ /* FALLTHROUGH */
+ case (MDOC_Diag):
+ /* FALLTHROUGH */
+ case (MDOC_Inset):
+ /* FALLTHROUGH */
+ case (MDOC_Item):
+ if (-1 == width)
+ break;
+ return(mdoc_nwarn(mdoc, n, WARN_SYNTAX,
+ "superfluous -%s argument",
+ mdoc_argnames[MDOC_Width]));
+ case (MDOC_Tag):
+ if (-1 != width)
+ break;
+ return(mdoc_nwarn(mdoc, n, WARN_SYNTAX,
+ "suggest -%s argument",
+ mdoc_argnames[MDOC_Width]));
+ default:
+ break;
+ }
+
+ return(1);
}
@@ -659,7 +703,6 @@ static int
pre_it(PRE_ARGS)
{
- /* TODO: -width attribute must be specified for -tag. */
/* TODO: children too big for -width? */
if (MDOC_BLOCK != n->type)