bugGNU roff - Bugs: bug #59812, tbl: interferes with .nm line...

 
 

bug #59812: tbl: interferes with .nm line numbering

Submitter:  G. Branden Robinson <gbranden>
Submitted:  Mon 04 Jan 2021 03:51:51 AM UTC
   
 
Category:  Preprocessor tbl 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 25 Feb 2021 06:47:08 AM UTC, comment #4: 


commit 633de5c27e299ba9421ca8ba298a5bc90e56ff1c (HEAD -> master, origin/master, origin/HEAD)
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
Date:   Thu Feb 25 17:28:43 2021 +1100

    Fix Savannah #59812.

    Fix bug where having line numbering off but the output line number
    register \n[ln] set to a positive value would cause tbl(1) table rows to
    spontaneously become numbered.  Use new \n[.nm] register to determine
    whether line numbering is enabled.

    * src/preproc/tbl/table.cpp (table::init_output, table::do_row,
      table::do_bottom): Predicate all conditions on \n[ln] additionally on
      \n[.nm].

    Thanks to Olle Lögdahl for the report.  Problem appears to date back to
    commit b69062693d3360efce9d4d63fac337be21e07db7, 20 July 2011.

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

commit b80434b3ebaef62fb8951c4b0b7c3de023742f1d
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
Date:   Thu Feb 25 15:08:56 2021 +1100

    Add regression test for Savannah #59812.

    * src/preproc/tbl/tests/cooperate-with-nm-request.sh: Do it.
    * src/preproc/tbl/tbl.am (tbl_TEST): Run test.

    Test will fail at this commit.

commit 8ebfa98ccdaead192ff13232107d2f376f8115a8
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
Date:   Thu Feb 25 09:32:18 2021 +1100

    Implement new read-only register ".nm".

    It reports the enablement status of output line numbering (caused by the
    .nm request) irrespective of the temporary suspension of numbering with
    the .nn request.  Needed because there was no way to introspect its
    state, tbl(1) needs to do so, and the writable line number register
    \n[ln] is not a reliable proxy for it.

    * src/roff/troff/env.h: Add get_numbering_nodes(), returning `int`,  to
      public interface of `environment` class.
    * src/roff/troff/env.cpp: Implement get_numbering_nodes().

    * src/roff/groff/tests/dot-nm_register_works.sh: Test it.
    * src/roff/groff/groff.am (groff_TESTS): Run test.

    * doc/groff.texi (Miscellaneous):
    * man/groff_diff.7.man (Language/New number registers):
    * man/groff.7.man (Registers/Read-only registers): Document it.

    * NEWS: Add item.


G. Branden Robinson <gbranden>
Group administrator
Tue 23 Feb 2021 05:25:26 PM UTC, comment #3: 

I think the problem here is, as with ".na" and ".ad l", non-orthogonality of internal state inspection windows.  It is compounded in this case by the fact that there are few registers that permit introspection of output line numbering configuration.  The only one available is \(ln, from Unix troff, and which encodes the output line number itself.

However, GNU tbl is testing \(ln to see if output line numbering is enabled.

See src/preproc/tbl/table.cpp:table::init_output().


1817          ".de " REPEATED_NM_SET_MACRO "\n"
1818          ".ie !'\\n(.z'' \\{.nm\n"
1819          "\\!." REPEATED_NM_SET_MACRO " \"\\$1\"\n"
1820          ".\\}\n"
1821          ".el .if \\n[ln] \\{\\\n"
1822          ".if '\\$1'd' .nr " ROW_START_LINE_REG " \\n[ln]\n"
1823          ".if '\\$1's' .nm \\n[" ROW_START_LINE_REG "]\n"
1824          ".if '\\$1'm' .nr " ROW_MAX_LINE_REG " \\n[ln]>?\\n[" ROW_MAX_LINE_REG "]\n"
1825          ".\\}\n"
1826          "..\n"
1827          ".de " REPEATED_NM_SUS_MACRO "\n"
1828          ".ie !'\\n(.z'' \\{.nm\n"
1829          "\\!." REPEATED_NM_SUS_MACRO " \"\\$1\"\n"
1830          ".\\}\n"
1831          ".el .if \\n[ln] \\{\\\n"
1832          ".ie '\\$1's' \\{\\\n"
1833          ".nr " ROW_SAVE_LINE_REG " \\n(ln<?\\n[" ROW_MAX_LINE_REG "]\n"
1834          ".nm +0 \\n[ln]+42\n"
1835          ".\\}\n"
1836          ".el \\{\\\n"
1837          ".nr ln \\n[" ROW_SAVE_LINE_REG "]\n"
1838          ".nm \\n[ln] 1\n"
1839          ".\\}\n"
1840          ".\\}\n"
1841          "..\n");


There's some other stuff doing on here with a diversion named ".nm" that I don't completely understand yet, but I think I'm getting warmer.

Also I wonder what that magic constant "42" on line 1834 is about.

G. Branden Robinson <gbranden>
Group administrator
Tue 23 Feb 2021 04:54:52 PM UTC, comment #2: 

Here's a slightly smaller reproducer.


$ cat ./EXPERIMENTS/nm-and-tbl.roff
.nf
.nm 1
Line numbering is turned on.
.nm
Line numbering is turned off.
.sp
.TS
l.
This is my table.
There are many like it but this one is mine.
.TE


groff output:


$ ./build/test-groff -T utf8 -t EXPERIMENTS/nm-and-tbl.roff | cat -s
  1 Line numbering is turned on.
Line numbering is turned off.

  2 This is my table.
  3 There are many like it but this one is mine.


Heirloom Doctools output:


~/heirloom$ ./bin/tbl ~/src/GIT/groff/EXPERIMENTS/nm-and-tbl.roff | ./bin/nroff | cat -s
  1 Line numbering is turned on.
Line numbering is turned off.

This is my table.
There are many like it but this one is mine.



G. Branden Robinson <gbranden>
Group administrator
Tue 05 Jan 2021 07:18:05 AM UTC, comment #1: 

Tadziu noted:

> If I do


.nr ln 0


> in conjunction with the ".nm", this appears to stop the line numbering in the table.



G. Branden Robinson <gbranden>
Group administrator
Mon 04 Jan 2021 03:51:51 AM UTC, original submission:  

Olle Lögdahl reported an issue with tbl and .nm to the groff development list.

https://lists.gnu.org/archive/html/groff/2020-11/msg00103.html

The attached file demonstrates that tbl re-enables line numbering when it should not.

"...the roff that GNU tbl emits uses .nm itself.  I begin to wonder if there is an environment problem.  Apparently using .nm yourself creates a latent issue that is awakened by a subsequent table."

See attachment.

Problem exists in groff 1.22.4 and I suspect is much older than that.

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:
   

Attached Files
file #50637:  tbl-with-nm.ms added by gbranden (253B - text/x-troff-ms)

 

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 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-02-25 gbranden StatusConfirmed Fixed
        Assigned toNone gbranden
        Open/ClosedOpen Closed
        Planned ReleaseNone 1.23.0
    2021-01-04 gbranden Attached File- Added tbl-with-nm.ms, #50637

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code