bugGNU roff - Bugs: bug #61853, [ms] XA does not suppress leader...

 
 

bug #61853: [ms] XA does not suppress leader if given "no" argument

Submitter:  G. Branden Robinson <gbranden>
Submitted:  Wed 19 Jan 2022 07:06:39 AM UTC
   
 
Category:  Macro ms Severity:  3 - Normal
Item Group:  Incorrect behaviour Status:  Fixed
Privacy:  Public Assigned to:  gbranden
Open/Closed:  Closed Planned Release:  1.23.0
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 20 Jan 2022 03:21:59 PM UTC, comment #4: 


commit 2fad998c0c934b5727ccd8b73e4709789a5a0926
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
Date:   Wed Jan 19 19:53:17 2022 +1100

    [ms]: Don't add leaders that don't lead anywhere.

    * tmac/s.tmac (toc*end-entry): If no page number string `toc*num` is
      defined, don't interpolate its emptiness prefixed with a leader (and
      tab).  This makes "no" as the first argument to `XS` and `XA` work as
      documented, suppressing not only the page number but the leader after
      the entry.

    Fixes <https://savannah.gnu.org/bugs/?61853>.


G. Branden Robinson <gbranden>
Group administrator
Wed 19 Jan 2022 08:49:46 AM UTC, comment #3: 

Proposed fix:


diff --git a/tmac/s.tmac b/tmac/s.tmac
index d7bd116e4..7f146a6c3 100644
--- a/tmac/s.tmac
+++ b/tmac/s.tmac
@@ -1802,7 +1802,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 \&\\$*
 ..
 .de toc*end-entry
-\\a\\t\\*[toc*num]
+.if !'\\*[toc*num]'' \\a\\t\\*[toc*num]
 .br
 .rm toc*num
 ..


G. Branden Robinson <gbranden>
Group administrator
Wed 19 Jan 2022 07:36:46 AM UTC, comment #2: 

I see now what the problem with the links was.  Newlines are not
allowed inside the brackets for a titled hyperlink.  That in
turn means that paragraph reflow is busted if you place your own
line breaks (which is necessary for sanity preservation while
using lynx).  These details are not mentioned in the utterly
perfunctory documentation of the syntax, which doesn't explain
how anything is parsed--it just throws the simplest possible
examples at the reader and leaves anyone with greater needs to
sink or swim.  What did I expect?  It's the Markdown
mentality--get something down and throw it over the wall.
Velocity.  Agile.  Kanban.  Move fast.  Break stuff.  Cash out.

Trying again:

Our documentation (in groff_ms(7) from Git HEAD) says:


       .XS [page-number]
       .XA [page-number [indentation]]
       .XE    Begin, supplement, and end a table of contents entry.
              Each entry is associated with page-number (otherwise the
              current page number); a page-number of "no" prevents a
              leader and page number from being emitted for that entry.
              Use of .XA within .XS/.XE is optional; it can be repeated.
              If indentation is present, a supplemental entry is
              indented by that amount; ens are assumed if no unit is
              indicated.  Text on input lines between .XS and .XE is
              stored for later recall by .PX.


Input:


$ cat EXPERIMENTS/toc-example.ms
.NH 1
Introduction
.XS
Introduction
.XE
.PP
Foo bar baz.
.NH 2
Methodology
.XS
        Methodology
.XA
                Fassbinder's Approach
.XA no
                        Charges of unethical conduct
.XA no
                        Aftermath
.XA
                Kahiu's Approach
.XE
.PP
Bar baz qux.
.NH 1
Findings
.XS
Findings
.XE
.PP
Baz qux foo.
.TC


Output:

$ nroff -Tascii -ms EXPERIMENTS/toc-example.ms | cat -s

1.  Introduction

     Foo bar baz.

1.1.  Methodology

     Bar baz qux.

2.  Findings

     Baz qux foo.

                             -i-

                     Table of Contents

Introduction . . . . . . . . . . . . . . . . . . . . . .   1
     Methodology . . . . . . . . . . . . . . . . . . . .   1
          Fassbinder's Approach  . . . . . . . . . . . .   1
               Charges of unethical conduct  . . . . . .
               Aftermath . . . . . . . . . . . . . . . .
          Kahiu's Approach . . . . . . . . . . . . . . .   1
Findings . . . . . . . . . . . . . . . . . . . . . . . .   1


Tuthill's ms.diffs document
(4.2BSD) doesn't document the macro to the level of detail required to
decide the issue (in fact, it doesn't document the closely related `TC`
macro at all), so let's have a look at the
implementation.


. \" XA - add index entry
.de XA
.if !'\\*(XL'no' \\a\\t\\*(XL
.if \\n(.$ .ds XL \\$1
.sp \\n(PDu
.if \\n(.$-1 \{\
. nr XI 1
. in \\$2n
.\}
..


(I've changed the control character used for the delimiter in
the output comparison operator to a neutral apostrophe to make
it visible, and in groff outside of compatibility mode, the
control-character contrivance is not necessary.)

The first line of the macro definition is what matters here.
`XA` does not put a copy-mode leader `\a` or tab `\t` or the
contents of the `XL` string (a formatted page number saved by
the `XS` macro) if `XA`'s first argument is "no".

So our implementation needs to change.  I'll look into this.

G. Branden Robinson <gbranden>
Group administrator
Wed 19 Jan 2022 07:18:20 AM UTC, comment #1: 

Sorry for the markup glitches.  I apparently can never remember Savannah/Savane's bespoke syntax for embedding links, and I am also prone to forgetting to include or correctly type "verbatim" markers.

Compounding the issue:

  • You can preview comments, but not an original submission.
  • Savannah will refuse to accept your form submission for many reasons, but bad markup in the comment is not one of them.
G. Branden Robinson <gbranden>
Group administrator
Wed 19 Jan 2022 07:06:39 AM UTC, original submission:  

Our documentation (in groff_ms(7) from Git HEAD) says:


       .XS [page-number]
       .XA [page-number [indentation]]
       .XE    Begin, supplement, and end a table of contents entry.
              Each entry is associated with page-number (otherwise the
              current page number); a page-number of "no" prevents a
              leader and page number from being emitted for that entry.
              Use of .XA within .XS/.XE is optional; it can be repeated.
              If indentation is present, a supplemental entry is
              indented by that amount; ens are assumed if no unit is
              indicated.  Text on input lines between .XS and .XE is
              stored for later recall by .PX.


Input:


$ cat EXPERIMENTS/toc-example.ms
.NH 1
Introduction
.XS
Introduction
.XE
.PP
Foo bar baz.
.NH 2
Methodology
.XS
        Methodology
.XA
                Fassbinder's Approach
.XA no
                        Charges of unethical conduct
.XA no
                        Aftermath
.XA
                Kahiu's Approach
.XE
.PP
Bar baz qux.
.NH 1
Findings
.XS
Findings
.XE
.PP
Baz qux foo.
.TC


Output:
$ nroff -Tascii -ms EXPERIMENTS/toc-example.ms | cat -s

1.  Introduction

     Foo bar baz.

1.1.  Methodology

     Bar baz qux.

2.  Findings

     Baz qux foo.

                             -i-

                     Table of Contents

Introduction . . . . . . . . . . . . . . . . . . . . . .   1
     Methodology . . . . . . . . . . . . . . . . . . . .   1
          Fassbinder's Approach  . . . . . . . . . . . .   1
               Charges of unethical conduct  . . . . . .
               Aftermath . . . . . . . . . . . . . . . .
          Kahiu's Approach . . . . . . . . . . . . . . .   1
Findings . . . . . . . . . . . . . . . . . . . . . . . .   1

-verbatim-

Tuthill's [https://minnie.tuhs.org/cgi-bin/utree.pl?file=4.2BSD/usr/doc/msmacros/ms.diffs
ms.diffs document] (4.2BSD) doesn't document the
macro to the level of detail required to decide the issue (in
fact, it doesn't document the closely related `TC` macro at
all), so let's have a look at the
[https://minnie.tuhs.org/cgi-bin/utree.pl?file=4.2BSD/usr/lib/ms/s.toc
implementation].


. \" XA - add index entry
.de XA
.if !'\\*(XL'no' \\a\\t\\*(XL
.if \\n(.$ .ds XL \\$1
.sp \\n(PDu
.if \\n(.$-1 \{\
. nr XI 1
. in \\$2n
.\}
..


(I've changed the control character used for the delimiter in
the output comparison operator to a neutral apostrophe to make
it visible, and in groff outside of compatibility mode, the
control-character contrivance is not necessary.)

The first line of the macro definition is what matters here.
`XA` does not put a copy-mode leader `\a` or tab `\t` or the
contents of the `XL` string (a formatted page number saved by
the `XS` macro) if `XA`'s first argument is "no".

So our implementation needs to change.  I'll look into this.

G. Branden Robinson <gbranden>
Group administrator

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by gbranden (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-01-20 gbranden StatusIn Progress Fixed
        Open/ClosedOpen Closed
        Planned ReleaseNone 1.23.0
    2022-01-19 gbranden StatusNone In Progress

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code