From 0b4127a628b0da28fe24f16107d14c5255d71a4a Mon Sep 17 00:00:00 2001 From: Kristaps Dzonsons Date: Sun, 5 Dec 2010 15:37:30 +0000 Subject: Merge schwarze@'s changes allowing nested displays. Tweak the patch by making sure output doesn't add a superfluous newline with the nested displays. Also add a COMPATIBILITY note. Rename a macro (DATESIZ) to be in line with OpenBSD (DATESIZE). --- main.c | 2 +- mandoc.h | 3 +-- mdoc.7 | 5 +++++ mdoc_html.c | 4 ++++ mdoc_term.c | 4 ++++ mdoc_validate.c | 16 ++++++---------- 6 files changed, 21 insertions(+), 13 deletions(-) diff --git a/main.c b/main.c index 786757b8..42d48cf7 100644 --- a/main.c +++ b/main.c @@ -146,6 +146,7 @@ static const char * const mandocerrs[MANDOCERR_MAX] = { "NAME section must come first", "bad Boolean value", "child violates parent syntax", + "displays may not be nested", "bad AT&T symbol", "bad standard", "list type repeated", @@ -183,7 +184,6 @@ static const char * const mandocerrs[MANDOCERR_MAX] = { "generic fatal error", "column syntax is inconsistent", - "displays may not be nested", "unsupported display type", "blocks badly nested", "no such block is open", diff --git a/mandoc.h b/mandoc.h index 8398db25..6d7f0136 100644 --- a/mandoc.h +++ b/mandoc.h @@ -69,6 +69,7 @@ enum mandocerr { MANDOCERR_NAMESECFIRST, /* NAME section must come first */ MANDOCERR_BADBOOL, /* bad Boolean value */ MANDOCERR_CHILD, /* child violates parent syntax */ + MANDOCERR_NESTEDDISP, /* displays may not be nested */ MANDOCERR_BADATT, /* bad AT&T symbol */ MANDOCERR_BADSTANDARD, /* bad standard */ MANDOCERR_LISTREP, /* list type repeated */ @@ -106,8 +107,6 @@ enum mandocerr { MANDOCERR_FATAL, /* ===== start of fatal errors ===== */ MANDOCERR_COLUMNS, /* column syntax is inconsistent */ - /* FIXME: this should be a MANDOCERR_ERROR */ - MANDOCERR_NESTEDDISP, /* displays may not be nested */ MANDOCERR_BADDISP, /* unsupported display type */ MANDOCERR_SCOPEFATAL, /* blocks badly nested */ MANDOCERR_SYNTNOSCOPE, /* no scope to rewind: syntax violated */ diff --git a/mdoc.7 b/mdoc.7 index c3badcc4..a73decc0 100644 --- a/mdoc.7 +++ b/mdoc.7 @@ -2739,6 +2739,11 @@ The following problematic behaviour is found in groff: .Pp .Bl -dash -compact .It +Display macros +.Pq Sx \&Bd , Sx \&Dl , and Sx \&D1 +may not be nested. +\*[hist] +.It .Sx \&At with unknown arguments produces no output at all. \*[hist] diff --git a/mdoc_html.c b/mdoc_html.c index 9b8b4c10..7fac0895 100644 --- a/mdoc_html.c +++ b/mdoc_html.c @@ -1331,6 +1331,10 @@ mdoc_bd_pre(MDOC_ARGS) /* FALLTHROUGH */ case (MDOC_Bl): /* FALLTHROUGH */ + case (MDOC_D1): + /* FALLTHROUGH */ + case (MDOC_Dl): + /* FALLTHROUGH */ case (MDOC_Lp): /* FALLTHROUGH */ case (MDOC_Pp): diff --git a/mdoc_term.c b/mdoc_term.c index e5a11f75..8e921d44 100644 --- a/mdoc_term.c +++ b/mdoc_term.c @@ -1592,6 +1592,10 @@ termp_bd_pre(DECL_ARGS) /* FALLTHROUGH */ case (MDOC_Bl): /* FALLTHROUGH */ + case (MDOC_D1): + /* FALLTHROUGH */ + case (MDOC_Dl): + /* FALLTHROUGH */ case (MDOC_Lp): /* FALLTHROUGH */ case (MDOC_Pp): diff --git a/mdoc_validate.c b/mdoc_validate.c index 912730bb..b728d52f 100644 --- a/mdoc_validate.c +++ b/mdoc_validate.c @@ -42,7 +42,7 @@ #define POST_ARGS struct mdoc *mdoc #define NUMSIZ 32 -#define DATESIZ 32 +#define DATESIZE 32 enum check_ineq { CHECK_LT, @@ -575,22 +575,18 @@ pre_display(PRE_ARGS) { struct mdoc_node *node; - /* Display elements (`Bd', `D1'...) cannot be nested. */ - if (MDOC_BLOCK != n->type) return(1); - /* LINTED */ for (node = mdoc->last->parent; node; node = node->parent) if (MDOC_BLOCK == node->type) if (MDOC_Bd == node->tok) break; - if (NULL == node) - return(1); + if (node) + mdoc_nmsg(mdoc, n, MANDOCERR_NESTEDDISP); - mdoc_nmsg(mdoc, n, MANDOCERR_NESTEDDISP); - return(0); + return(1); } @@ -1951,7 +1947,7 @@ pre_literal(PRE_ARGS) static int post_dd(POST_ARGS) { - char buf[DATESIZ]; + char buf[DATESIZE]; struct mdoc_node *n; n = mdoc->last; @@ -1961,7 +1957,7 @@ post_dd(POST_ARGS) return(1); } - if ( ! concat(mdoc, buf, n->child, DATESIZ)) + if ( ! concat(mdoc, buf, n->child, DATESIZE)) return(0); mdoc->meta.date = mandoc_a2time -- cgit