diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2009-06-18 01:19:03 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2009-06-18 01:19:03 +0000 |
commit | 9a3901afc3cef857365c7c86696597ead2f7a506 (patch) | |
tree | 6a488cdda354a388904d0b7898347b310d13aa9d /usr.bin | |
parent | f77203dd262928a9f940dd0cc57af4809a3b7641 (diff) |
sync to 1.7.16: make a couple of macros callable, reserve "|",
and some tweaks to .Lk
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/mandoc/mdoc.7 | 75 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_action.c | 29 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_macro.c | 24 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_strings.c | 4 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_term.c | 18 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_validate.c | 4 |
6 files changed, 98 insertions, 56 deletions
diff --git a/usr.bin/mandoc/mdoc.7 b/usr.bin/mandoc/mdoc.7 index 80d272ef303..8f589a1ce7e 100644 --- a/usr.bin/mandoc/mdoc.7 +++ b/usr.bin/mandoc/mdoc.7 @@ -1,4 +1,4 @@ -.\" $Id: mdoc.7,v 1.2 2009/06/14 23:00:57 schwarze Exp $ +.\" $Id: mdoc.7,v 1.3 2009/06/18 01:19:02 schwarze Exp $ .\" .\" Copyright (c) 2009 Kristaps Dzonsons <kristaps@kth.se> .\" @@ -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 14 2009 $ +.Dd $Mdocdate: June 18 2009 $ .Dt MDOC 7 .Os .\" SECTION @@ -31,7 +31,12 @@ language is used to format manuals. In this reference document, we describe the syntax, ontology and structure of the .Nm -language. +language. Our reference implementation is +.Xr mandoc 1 . +The +.Sx COMPATIBILITY +section describes compatibility with +.Xr groff 1 . .\" PARAGRAPH .Pp An @@ -96,6 +101,8 @@ Within a macro line, the following characters are reserved: .Pq question .It \&! .Pq exclamation +.It \&| +.Pq vertical bar .El .\" PARAGRAPH .Pp @@ -393,7 +400,7 @@ then the macro accepts an arbitrary number of arguments. .It \&.Os Ta \&No Ta \&No Ta n .It \&.Pp Ta \&No Ta \&No Ta 0 .It \&.Ad Ta Yes Ta Yes Ta n -.It \&.An Ta \&No Ta Yes Ta n +.It \&.An Ta Yes Ta Yes Ta n .It \&.Ar Ta Yes Ta Yes Ta n .It \&.Cd Ta Yes Ta \&No Ta >0 .It \&.Cm Ta Yes Ta Yes Ta n @@ -405,7 +412,7 @@ then the macro accepts an arbitrary number of arguments. .It \&.Fd Ta \&No Ta \&No Ta >0 .It \&.Fl Ta Yes Ta Yes Ta n .It \&.Fn Ta Yes Ta Yes Ta >0 -.It \&.Ft Ta \&No Ta Yes Ta n +.It \&.Ft Ta Yes Ta Yes Ta n .It \&.Ic Ta Yes Ta Yes Ta >0 .It \&.In Ta \&No Ta \&No Ta n .It \&.Li Ta Yes Ta Yes Ta n @@ -436,7 +443,7 @@ then the macro accepts an arbitrary number of arguments. .It \&.Db Ta \&No Ta \&No Ta 1 .It \&.Em Ta Yes Ta Yes Ta >0 .It \&.Fx Ta Yes Ta Yes Ta n -.It \&.Ms Ta \&No Ta Yes Ta >0 +.It \&.Ms Ta Yes Ta Yes Ta >0 .It \&.No Ta Yes Ta Yes Ta 0 .It \&.Ns Ta Yes Ta Yes Ta 0 .It \&.Nx Ta Yes Ta Yes Ta n @@ -455,8 +462,8 @@ then the macro accepts an arbitrary number of arguments. .It \&.Lb Ta \&No Ta \&No Ta 1 .It \&.Ap Ta Yes Ta Yes Ta 0 .It \&.Lp Ta \&No Ta \&No Ta 0 -.It \&.Lk Ta \&No Ta Yes Ta >0 -.It \&.Mt Ta \&No Ta Yes Ta >0 +.It \&.Lk Ta Yes Ta Yes Ta n +.It \&.Mt Ta Yes Ta Yes Ta >0 .It \&.Es Ta \&No Ta \&No Ta 0 .It \&.En Ta \&No Ta \&No Ta 0 .El @@ -470,29 +477,40 @@ and macros are obsolete. .\" SECTION .Sh COMPATIBILITY -The mdoc language was traditionally a -.Qq roff -macro package; most existing manuals were written with mdoc syntax -dictated by system-dependent roff installations. This section documents -compatibility with these systems. +This section documents compatibility with other roff implementations, at +this time limited to +.Xr groff 1 . +The term +.Qq historic groff +refers to those versions before the +.Pa doc.tmac +file re-write +.Pq somewhere between 1.15 and 1.19 . .Pp .Bl -dash -compact .\" LIST-ITEM .It -.Sq \&.Fo -and -.Sq \&.St -historically weren't always callable. Both are now correctly callable. +Historic groff has many un-callable macros. Most of these (excluding +some block-level macros) are now callable, conforming to the +non-historic groff version. +.\" LIST-ITEM +.It +The vertical bar +.Sq \(Ba +made historic groff +.Qq go orbital +but is a proper delimiter in this implementation. .\" LIST-ITEM .It .Sq \&.It \-nested -is assumed for all lists: any list may be nested and +is assumed for all lists (it wasn't in historic groff): any list may be +nested and .Sq \-enum lists will restart the sequence only for the sub-list. .\" LIST-ITEM .It .Sq \&.It \-column -syntax where column widths may be preceeded by other arguments (instead +syntax where column widths may be preceded by other arguments (instead of proceeded) is not supported. .\" LIST-ITEM .It @@ -501,26 +519,17 @@ The macro only accepts a single parameter. .\" LIST-ITEM .It -The system-name macros ( -.Ns Sq \&.At , -.Sq \&.Bsx , -.Sq \&.Bx , -.Sq \&.Fx , -.Sq \&.Nx , -.Sq \&.Ox , -and -.Sq \&.Ux ) -are callable. -.\" LIST-ITEM -.It Some manuals use .Sq \&.Li incorrectly by following it with a reserved character and expecting the delimiter to render. This is not supported. .\" LIST-ITEM .It -.Sq \&.Cd -is callable. +If an special-character control character +.Sq \e +is escaped, it will +obviously not render the sequence. Even newer versions of groff seem to +dither on this. .El .\" SECTION .Sh SEE ALSO diff --git a/usr.bin/mandoc/mdoc_action.c b/usr.bin/mandoc/mdoc_action.c index 73017d3c04a..8cc1377ed8d 100644 --- a/usr.bin/mandoc/mdoc_action.c +++ b/usr.bin/mandoc/mdoc_action.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_action.c,v 1.2 2009/06/14 23:00:57 schwarze Exp $ */ +/* $Id: mdoc_action.c,v 1.3 2009/06/18 01:19:02 schwarze Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se> * @@ -56,6 +56,7 @@ static int post_bl_tagwidth(POST_ARGS); static int post_dd(POST_ARGS); static int post_display(POST_ARGS); static int post_dt(POST_ARGS); +static int post_lk(POST_ARGS); static int post_nm(POST_ARGS); static int post_os(POST_ARGS); static int post_prol(POST_ARGS); @@ -179,7 +180,7 @@ const struct actions mdoc_actions[MDOC_MAX] = { { NULL, NULL }, /* Lb */ { NULL, NULL }, /* Ap */ { NULL, NULL }, /* Lp */ - { NULL, NULL }, /* Lk */ + { NULL, post_lk }, /* Lk */ { NULL, NULL }, /* Mt */ { NULL, NULL }, /* Brq */ { NULL, NULL }, /* Bro */ @@ -532,7 +533,8 @@ post_bl_tagwidth(struct mdoc *m) * width if a macro. */ - if ((n = m->last->body->child)) { + n = m->last->body->child; + if (n) { assert(MDOC_BLOCK == n->type); assert(MDOC_It == n->tok); n = n->head->child; @@ -664,6 +666,27 @@ post_bl(POST_ARGS) static int +post_lk(POST_ARGS) +{ + struct mdoc_node *n; + + if (m->last->child) + return(1); + + n = m->last; + m->next = MDOC_NEXT_CHILD; + /* FIXME: this isn't documented anywhere! */ + if ( ! mdoc_word_alloc(m, m->last->line, + m->last->pos, "~")) + return(0); + + m->last = n; + m->next = MDOC_NEXT_SIBLING; + return(1); +} + + +static int post_ar(POST_ARGS) { struct mdoc_node *n; diff --git a/usr.bin/mandoc/mdoc_macro.c b/usr.bin/mandoc/mdoc_macro.c index 4cc10a2df70..461af57629f 100644 --- a/usr.bin/mandoc/mdoc_macro.c +++ b/usr.bin/mandoc/mdoc_macro.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_macro.c,v 1.2 2009/06/14 23:00:57 schwarze Exp $ */ +/* $Id: mdoc_macro.c,v 1.3 2009/06/18 01:19:02 schwarze Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se> * @@ -89,7 +89,7 @@ const struct mdoc_macro __mdoc_macros[MDOC_MAX] = { { blk_exp_close, MDOC_EXPLICIT }, /* El */ { blk_full, MDOC_PARSED }, /* It */ { in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Ad */ - { in_line, MDOC_PARSED }, /* An */ + { in_line, MDOC_CALLABLE | MDOC_PARSED }, /* An */ { in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Ar */ { in_line_eoln, MDOC_CALLABLE }, /* Cd */ { in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Cm */ @@ -101,9 +101,9 @@ const struct mdoc_macro __mdoc_macros[MDOC_MAX] = { { in_line_eoln, 0 }, /* Fd */ { in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Fl */ { in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Fn */ - { in_line, MDOC_PARSED }, /* Ft */ + { in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Ft */ { in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Ic */ - { in_line_eoln, 0 }, /* In */ + { in_line_eoln, 0 }, /* In */ /* FIXME: historic usage! */ { in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Li */ { in_line_eoln, 0 }, /* Nd */ { in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Nm */ @@ -145,7 +145,7 @@ const struct mdoc_macro __mdoc_macros[MDOC_MAX] = { { in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Em */ { blk_part_exp, MDOC_CALLABLE | MDOC_PARSED | MDOC_EXPLICIT }, /* Eo */ { in_line_argn, MDOC_CALLABLE | MDOC_PARSED }, /* Fx */ - { in_line, MDOC_PARSED }, /* Ms */ + { in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Ms */ { in_line_argn, MDOC_CALLABLE | MDOC_PARSED }, /* No */ { in_line_argn, MDOC_CALLABLE | MDOC_PARSED }, /* Ns */ { in_line_argn, MDOC_CALLABLE | MDOC_PARSED }, /* Nx */ @@ -183,8 +183,8 @@ const struct mdoc_macro __mdoc_macros[MDOC_MAX] = { { in_line_eoln, 0 }, /* Lb */ { in_line_argn, MDOC_CALLABLE | MDOC_PARSED }, /* Ap */ { in_line, 0 }, /* Lp */ - { in_line, MDOC_PARSED }, /* Lk */ - { in_line, MDOC_PARSED }, /* Mt */ + { in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Lk */ + { in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Mt */ { blk_part_imp, MDOC_CALLABLE | MDOC_PARSED }, /* Brq */ { blk_part_exp, MDOC_CALLABLE | MDOC_PARSED | MDOC_EXPLICIT }, /* Bro */ { blk_exp_close, MDOC_EXPLICIT | MDOC_CALLABLE | MDOC_PARSED }, /* Brc */ @@ -813,6 +813,8 @@ in_line(MACRO_PROT_ARGS) /* FALLTHROUGH */ case (MDOC_Fl): /* FALLTHROUGH */ + case (MDOC_Lk): + /* FALLTHROUGH */ case (MDOC_Ar): nc = 1; break; @@ -868,7 +870,8 @@ in_line(MACRO_PROT_ARGS) if ( ! mdoc_elem_alloc(mdoc, line, ppos, tok, arg)) return(0); - mdoc->next = MDOC_NEXT_SIBLING; + if ( ! rew_last(mdoc, mdoc->last)) + return(0); } else if ( ! nc && 0 == cnt) { mdoc_argv_free(arg); if ( ! pwarn(mdoc, line, ppos, WIGNE)) @@ -923,8 +926,9 @@ in_line(MACRO_PROT_ARGS) c = mdoc_elem_alloc(mdoc, line, ppos, tok, arg); if (0 == c) return(0); - mdoc->next = MDOC_NEXT_SIBLING; - } else if ( ! nc && 0 == cnt) { + if ( ! rew_last(mdoc, mdoc->last)) + return(0); + } else if ( ! nc && 0 == cnt) { mdoc_argv_free(arg); if ( ! pwarn(mdoc, line, ppos, WIGNE)) return(0); diff --git a/usr.bin/mandoc/mdoc_strings.c b/usr.bin/mandoc/mdoc_strings.c index 8efb68018cf..930e48a1831 100644 --- a/usr.bin/mandoc/mdoc_strings.c +++ b/usr.bin/mandoc/mdoc_strings.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_strings.c,v 1.4 2009/06/15 03:42:51 schwarze Exp $ */ +/* $Id: mdoc_strings.c,v 1.5 2009/06/18 01:19:02 schwarze Exp $ */ /* * Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se> * @@ -143,6 +143,8 @@ mdoc_iscdelim(char p) { switch (p) { + case('|'): + /* FALLTHROUGH */ case('.'): /* FALLTHROUGH */ case(','): diff --git a/usr.bin/mandoc/mdoc_term.c b/usr.bin/mandoc/mdoc_term.c index b52f4eecb89..8b4087a224b 100644 --- a/usr.bin/mandoc/mdoc_term.c +++ b/usr.bin/mandoc/mdoc_term.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_term.c,v 1.5 2009/06/17 22:27:34 schwarze Exp $ */ +/* $Id: mdoc_term.c,v 1.6 2009/06/18 01:19:02 schwarze Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se> * @@ -2091,21 +2091,25 @@ termp_lk_pre(DECL_ARGS) { const struct mdoc_node *n; - if (NULL == (n = node->child)) - errx(1, "expected line argument"); + assert(node->child); + n = node->child; + + if (NULL == n->next) { + TERMPAIR_SETFLAG(p, pair, ttypes[TTYPE_LINK_ANCHOR]); + return(1); + } p->flags |= ttypes[TTYPE_LINK_ANCHOR]; term_word(p, n->string); - p->flags &= ~ttypes[TTYPE_LINK_ANCHOR]; p->flags |= TERMP_NOSPACE; term_word(p, ":"); + p->flags &= ~ttypes[TTYPE_LINK_ANCHOR]; p->flags |= ttypes[TTYPE_LINK_TEXT]; - for ( ; n; n = n->next) { + for (n = n->next; n; n = n->next) term_word(p, n->string); - } - p->flags &= ~ttypes[TTYPE_LINK_TEXT]; + p->flags &= ~ttypes[TTYPE_LINK_TEXT]; return(0); } diff --git a/usr.bin/mandoc/mdoc_validate.c b/usr.bin/mandoc/mdoc_validate.c index 50fff14868d..ca8913e0bb7 100644 --- a/usr.bin/mandoc/mdoc_validate.c +++ b/usr.bin/mandoc/mdoc_validate.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_validate.c,v 1.3 2009/06/17 23:18:06 schwarze Exp $ */ +/* $Id: mdoc_validate.c,v 1.4 2009/06/18 01:19:02 schwarze Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se> * @@ -297,7 +297,7 @@ const struct valids mdoc_valids[MDOC_MAX] = { { pres_lb, posts_lb }, /* Lb */ { NULL, NULL }, /* Ap */ { NULL, posts_pp }, /* Lp */ - { NULL, posts_text }, /* Lk */ + { NULL, NULL }, /* Lk */ { NULL, posts_text }, /* Mt */ { NULL, posts_wline }, /* Brq */ { NULL, NULL }, /* Bro */ |