From: schwarze Date: Thu, 21 Aug 2014 12:56:24 +0000 (+0000) Subject: Right after .Fl, a middle delimiter triggers an empty scope, X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=26c5d88adc8a57f6a3e483511d81299bb2fc86d3;p=openbsd Right after .Fl, a middle delimiter triggers an empty scope, just like a closing delimiter. This didn't work in groff-1.15, but it now works in groff-1.22. After being closed by delimiters, .Nm scopes do not reopen. Do not suppress white space after .Fl if the next node is a text node on the same input line; that can happen for middle delimiters. Fixing an issue reported by jmc@. --- diff --git a/regress/usr.bin/mandoc/mdoc/Ar/punct.in b/regress/usr.bin/mandoc/mdoc/Ar/punct.in index a88df8cf5db..963f7535a81 100644 --- a/regress/usr.bin/mandoc/mdoc/Ar/punct.in +++ b/regress/usr.bin/mandoc/mdoc/Ar/punct.in @@ -1,4 +1,4 @@ -.Dd April 7, 2010 +.Dd August 21, 2014 .Dt AR-PUNCT 1 .Os OpenBSD .Sh NAME @@ -15,3 +15,25 @@ middle .Ar a ) z start .Ar ) z +dot +.Ar . z +comma +.Ar , z +semicolon +.Ar ; z +colon +.Ar : z +quest +.Ar ? z +excl +.Ar ! z +paren +.Ar ) z +bracket +.Ar ] z +bar +.Ar | m +op paren +.Ar ( a +op bracket +.Ar [ a diff --git a/regress/usr.bin/mandoc/mdoc/Ar/punct.out_ascii b/regress/usr.bin/mandoc/mdoc/Ar/punct.out_ascii index 11c1f3dc0e1..77e19558154 100644 --- a/regress/usr.bin/mandoc/mdoc/Ar/punct.out_ascii +++ b/regress/usr.bin/mandoc/mdoc/Ar/punct.out_ascii @@ -5,6 +5,8 @@ NNAAMMEE DDEESSCCRRIIPPTTIIOONN closing punctuation _a) only one _f_i_l_e _._._.) only more than one _f_i_l_e _._._.)) - middle _a) _z start _f_i_l_e _._._.) _z + middle _a) _z start _f_i_l_e _._._.) _z dot _f_i_l_e _._._.. _z comma _f_i_l_e _._._., _z semicolon + _f_i_l_e _._._.; _z colon _f_i_l_e _._._.: _z quest _f_i_l_e _._._.? _z excl _f_i_l_e _._._.! _z paren + _f_i_l_e _._._.) _z bracket _f_i_l_e _._._.] _z bar | _m op paren (_a op bracket [_a -OpenBSD April 7, 2010 OpenBSD +OpenBSD August 21, 2014 OpenBSD diff --git a/regress/usr.bin/mandoc/mdoc/Fl/Makefile b/regress/usr.bin/mandoc/mdoc/Fl/Makefile index 0cb9546ecf8..e9e01a192cd 100644 --- a/regress/usr.bin/mandoc/mdoc/Fl/Makefile +++ b/regress/usr.bin/mandoc/mdoc/Fl/Makefile @@ -1,11 +1,5 @@ -# $OpenBSD: Makefile,v 1.7 2012/07/09 17:52:09 schwarze Exp $ +# $OpenBSD: Makefile,v 1.8 2014/08/21 12:56:24 schwarze Exp $ REGRESS_TARGETS = noarg multiarg parsed punct font -# Do not regenerate the punct output file for now, -# because groff-1.15 and groff-1.20.1 handle -# the bar differently as a .Fl argument. - -SKIP_GROFF ?= punct - .include diff --git a/regress/usr.bin/mandoc/mdoc/Fl/noarg.in b/regress/usr.bin/mandoc/mdoc/Fl/noarg.in index db499ba49f1..0c604dbc36b 100644 --- a/regress/usr.bin/mandoc/mdoc/Fl/noarg.in +++ b/regress/usr.bin/mandoc/mdoc/Fl/noarg.in @@ -1,4 +1,4 @@ -.Dd April 7, 2010 +.Dd August 21, 2014 .Dt FL-NOARG 1 .Os OpenBSD .Sh NAME @@ -9,7 +9,9 @@ Without an argument, it yields .Fl a dash. .Pp -This is true even before punctuation +This is true even before middle +.Fl | and +trailing punctuation .Fl . .Pp Following macros diff --git a/regress/usr.bin/mandoc/mdoc/Fl/noarg.out_ascii b/regress/usr.bin/mandoc/mdoc/Fl/noarg.out_ascii index 282961ab961..d79e7d74f0b 100644 --- a/regress/usr.bin/mandoc/mdoc/Fl/noarg.out_ascii +++ b/regress/usr.bin/mandoc/mdoc/Fl/noarg.out_ascii @@ -6,8 +6,8 @@ NNAAMMEE DDEESSCCRRIIPPTTIIOONN Without an argument, it yields -- a dash. - This is true even before punctuation --. + This is true even before middle -- | --aanndd trailing punctuation --. Following macros --[flag] follow without white space. -OpenBSD April 7, 2010 OpenBSD +OpenBSD August 21, 2014 OpenBSD diff --git a/regress/usr.bin/mandoc/mdoc/Fl/punct.in b/regress/usr.bin/mandoc/mdoc/Fl/punct.in index 681b520356d..ac7eecc744c 100644 --- a/regress/usr.bin/mandoc/mdoc/Fl/punct.in +++ b/regress/usr.bin/mandoc/mdoc/Fl/punct.in @@ -1,4 +1,4 @@ -.Dd April 7, 2010 +.Dd August 21, 2014 .Dt FL-PUNCT 1 .Os OpenBSD .Sh NAME @@ -13,6 +13,8 @@ only more than one .Fl ) ) middle .Fl a ) z +start +.Fl ) z dot .Fl . z comma diff --git a/regress/usr.bin/mandoc/mdoc/Fl/punct.out_ascii b/regress/usr.bin/mandoc/mdoc/Fl/punct.out_ascii index af40edd0ee3..1c72b260019 100644 --- a/regress/usr.bin/mandoc/mdoc/Fl/punct.out_ascii +++ b/regress/usr.bin/mandoc/mdoc/Fl/punct.out_ascii @@ -5,7 +5,8 @@ NNAAMMEE DDEESSCCRRIIPPTTIIOONN closing punctuation --aa) only one --) only more than one --)) middle --aa) --zz - dot --. --zz comma --, --zz semicolon --; --zz colon --: --zz quest --? --zz excl --! --zz - paren --) --zz bracket --] --zz bar | --mm op paren (--aa op bracket [--aa + start --) --zz dot --. --zz comma --, --zz semicolon --; --zz colon --: --zz quest --? --zz + excl --! --zz paren --) --zz bracket --] --zz bar -- | --mm op paren (--aa op bracket + [--aa -OpenBSD April 7, 2010 OpenBSD +OpenBSD August 21, 2014 OpenBSD diff --git a/regress/usr.bin/mandoc/mdoc/Nm/Makefile b/regress/usr.bin/mandoc/mdoc/Nm/Makefile index 02342262c48..46ef3db412a 100644 --- a/regress/usr.bin/mandoc/mdoc/Nm/Makefile +++ b/regress/usr.bin/mandoc/mdoc/Nm/Makefile @@ -1,7 +1,7 @@ -# $OpenBSD: Makefile,v 1.9 2014/08/17 18:42:07 schwarze Exp $ +# $OpenBSD: Makefile,v 1.10 2014/08/21 12:56:24 schwarze Exp $ REGRESS_TARGETS = badNAME badNAMEuse break empty emptyNAME emptyNAMEuse -REGRESS_TARGETS += font long +REGRESS_TARGETS += font long punct LINT_TARGETS = badNAME badNAMEuse break diff --git a/regress/usr.bin/mandoc/mdoc/Nm/punct.in b/regress/usr.bin/mandoc/mdoc/Nm/punct.in new file mode 100644 index 00000000000..254adfdf668 --- /dev/null +++ b/regress/usr.bin/mandoc/mdoc/Nm/punct.in @@ -0,0 +1,39 @@ +.Dd August 21, 2014 +.Dt NM-PUNCT 1 +.Os OpenBSD +.Sh NAME +.Nm Nm-punct +.Nd punctuation handling by the Nm macro +.Sh DESCRIPTION +closing punctuation +.Nm a ) +only one +.Nm ) +only more than one +.Nm ) ) +middle +.Nm a ) z +start +.Nm ) z +dot +.Nm . z +comma +.Nm , z +semicolon +.Nm ; z +colon +.Nm : z +quest +.Nm ? z +excl +.Nm ! z +paren +.Nm ) z +bracket +.Nm ] z +bar +.Nm | m +op paren +.Nm ( a +op bracket +.Nm [ a diff --git a/regress/usr.bin/mandoc/mdoc/Nm/punct.out_ascii b/regress/usr.bin/mandoc/mdoc/Nm/punct.out_ascii new file mode 100644 index 00000000000..1b66f9cf9f2 --- /dev/null +++ b/regress/usr.bin/mandoc/mdoc/Nm/punct.out_ascii @@ -0,0 +1,12 @@ +NM-PUNCT(1) OpenBSD Reference Manual NM-PUNCT(1) + +NNAAMMEE + NNmm--ppuunncctt - punctuation handling by the Nm macro + +DDEESSCCRRIIPPTTIIOONN + closing punctuation aa) only one NNmm--ppuunncctt) only more than one NNmm--ppuunncctt)) + middle aa) zz start NNmm--ppuunncctt) z dot NNmm--ppuunncctt. z comma NNmm--ppuunncctt, z semicolon + NNmm--ppuunncctt; z colon NNmm--ppuunncctt: z quest NNmm--ppuunncctt? z excl NNmm--ppuunncctt! z paren + NNmm--ppuunncctt) z bracket NNmm--ppuunncctt] z bar | mm op paren (aa op bracket [aa + +OpenBSD August 21, 2014 OpenBSD diff --git a/regress/usr.bin/mandoc/mdoc/Pa/Makefile b/regress/usr.bin/mandoc/mdoc/Pa/Makefile index a8859d57f22..5f939fd3ea0 100644 --- a/regress/usr.bin/mandoc/mdoc/Pa/Makefile +++ b/regress/usr.bin/mandoc/mdoc/Pa/Makefile @@ -1,6 +1,6 @@ -# $OpenBSD: Makefile,v 1.3 2012/07/09 17:52:09 schwarze Exp $ +# $OpenBSD: Makefile,v 1.4 2014/08/21 12:56:24 schwarze Exp $ -REGRESS_TARGETS = font +REGRESS_TARGETS = font punct # XXX The FILES target doesn't currently work. diff --git a/regress/usr.bin/mandoc/mdoc/Pa/punct.in b/regress/usr.bin/mandoc/mdoc/Pa/punct.in new file mode 100644 index 00000000000..ea6c81ffa29 --- /dev/null +++ b/regress/usr.bin/mandoc/mdoc/Pa/punct.in @@ -0,0 +1,39 @@ +.Dd August 21, 2014 +.Dt PA-PUNCT 1 +.Os OpenBSD +.Sh NAME +.Nm Pa-punct +.Nd punctuation handling by the Pa macro +.Sh DESCRIPTION +closing punctuation +.Pa a ) +only one +.Pa ) +only more than one +.Pa ) ) +middle +.Pa a ) z +start +.Pa ) z +dot +.Pa . z +comma +.Pa , z +semicolon +.Pa ; z +colon +.Pa : z +quest +.Pa ? z +excl +.Pa ! z +paren +.Pa ) z +bracket +.Pa ] z +bar +.Pa | m +op paren +.Pa ( a +op bracket +.Pa [ a diff --git a/regress/usr.bin/mandoc/mdoc/Pa/punct.out_ascii b/regress/usr.bin/mandoc/mdoc/Pa/punct.out_ascii new file mode 100644 index 00000000000..24db5a17111 --- /dev/null +++ b/regress/usr.bin/mandoc/mdoc/Pa/punct.out_ascii @@ -0,0 +1,11 @@ +PA-PUNCT(1) OpenBSD Reference Manual PA-PUNCT(1) + +NNAAMMEE + PPaa--ppuunncctt - punctuation handling by the Pa macro + +DDEESSCCRRIIPPTTIIOONN + closing punctuation _a) only one _~) only more than one _~)) middle _a) _z + start _~) _z dot _~. _z comma _~, _z semicolon _~; _z colon _~: _z quest _~? _z excl + _~! _z paren _~) _z bracket _~] _z bar | _m op paren (_a op bracket [_a + +OpenBSD August 21, 2014 OpenBSD diff --git a/usr.bin/mandoc/mdoc_html.c b/usr.bin/mandoc/mdoc_html.c index bad18727622..b1435131240 100644 --- a/usr.bin/mandoc/mdoc_html.c +++ b/usr.bin/mandoc/mdoc_html.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_html.c,v 1.80 2014/08/14 00:29:12 schwarze Exp $ */ +/* $Id: mdoc_html.c,v 1.81 2014/08/21 12:56:24 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2014 Ingo Schwarze @@ -638,9 +638,10 @@ mdoc_fl_pre(MDOC_ARGS) print_text(h, "\\-"); - if (n->child) - h->flags |= HTML_NOSPACE; - else if (n->next && n->next->line == n->line) + if ( ! (n->nchild == 0 && + (n->next == NULL || + n->next->type == MDOC_TEXT || + n->next->flags & MDOC_LINE))) h->flags |= HTML_NOSPACE; return(1); diff --git a/usr.bin/mandoc/mdoc_macro.c b/usr.bin/mandoc/mdoc_macro.c index 8f051811eab..07ab244e21f 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.97 2014/08/16 19:47:17 schwarze Exp $ */ +/* $Id: mdoc_macro.c,v 1.98 2014/08/21 12:56:24 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons * Copyright (c) 2010, 2012, 2013 Ingo Schwarze @@ -839,7 +839,7 @@ blk_exp_close(MACRO_PROT_ARGS) static int in_line(MACRO_PROT_ARGS) { - int la, scope, cnt, nc, nl; + int la, scope, cnt, mayopen, nc, nl; enum margverr av; enum mdoct ntok; enum margserr ac; @@ -890,6 +890,7 @@ in_line(MACRO_PROT_ARGS) return(0); } + mayopen = 1; for (cnt = scope = 0;; ) { la = *pos; ac = mdoc_args(mdoc, line, pos, buf, tok, &p); @@ -946,19 +947,19 @@ in_line(MACRO_PROT_ARGS) * If we encounter closing punctuation, no word * has been omitted, no scope is open, and we're * allowed to have an empty element, then start - * a new scope. `Ar', `Fl', and `Li', only do - * this once per invocation. There may be more - * of these (all of them?). + * a new scope. */ - if (0 == cnt && (nc || MDOC_Li == tok) && - DELIM_CLOSE == d && ! scope) { + if ((d == DELIM_CLOSE || + (d == DELIM_MIDDLE && tok == MDOC_Fl)) && + (nc || tok == MDOC_Li) && + !scope && !cnt && mayopen) { if ( ! mdoc_elem_alloc(mdoc, line, ppos, tok, arg)) return(0); - if (MDOC_Ar == tok || MDOC_Li == tok || - MDOC_Fl == tok) - cnt++; scope = 1; + cnt++; + if (MDOC_Li == tok || MDOC_Nm == tok) + mayopen = 0; } /* * Close out our scope, if one is open, before @@ -967,14 +968,12 @@ in_line(MACRO_PROT_ARGS) if (scope && ! rew_elem(mdoc, tok)) return(0); scope = 0; - } else if ( ! scope) { + } else if (mayopen && !scope) { if ( ! mdoc_elem_alloc(mdoc, line, ppos, tok, arg)) return(0); scope = 1; - } - - if (DELIM_NONE == d) cnt++; + } if ( ! dword(mdoc, line, la, p, d, MDOC_JOIN & mdoc_macros[tok].flags)) diff --git a/usr.bin/mandoc/mdoc_man.c b/usr.bin/mandoc/mdoc_man.c index d9c466b42c7..bd91f048580 100644 --- a/usr.bin/mandoc/mdoc_man.c +++ b/usr.bin/mandoc/mdoc_man.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_man.c,v 1.67 2014/08/08 16:17:09 schwarze Exp $ */ +/* $Id: mdoc_man.c,v 1.68 2014/08/21 12:56:24 schwarze Exp $ */ /* * Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze * @@ -1162,7 +1162,8 @@ pre_fl(DECL_ARGS) font_push('B'); print_word("\\-"); - outflags &= ~MMAN_spc; + if (n->nchild) + outflags &= ~MMAN_spc; return(1); } @@ -1171,8 +1172,10 @@ post_fl(DECL_ARGS) { font_pop(); - if (0 == n->nchild && NULL != n->next && - n->next->line == n->line) + if ( ! (n->nchild || + n->next == NULL || + n->next->type == MDOC_TEXT || + n->next->flags & MDOC_LINE)) outflags &= ~MMAN_spc; } diff --git a/usr.bin/mandoc/mdoc_term.c b/usr.bin/mandoc/mdoc_term.c index b37173034d9..962a638f2f8 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.178 2014/08/17 18:42:07 schwarze Exp $ */ +/* $Id: mdoc_term.c,v 1.179 2014/08/21 12:56:24 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze @@ -1073,9 +1073,10 @@ termp_fl_pre(DECL_ARGS) term_fontpush(p, TERMFONT_BOLD); term_word(p, "\\-"); - if (n->child) - p->flags |= TERMP_NOSPACE; - else if (n->next && n->next->line == n->line) + if ( ! (n->nchild == 0 && + (n->next == NULL || + n->next->type == MDOC_TEXT || + n->next->flags & MDOC_LINE))) p->flags |= TERMP_NOSPACE; return(1);