bugGNU roff - Bugs: bug #60598, tbl reports incorrect line numbers...

 
 

bug #60598: tbl reports incorrect line numbers in diagnostics

Submitter:  G. Branden Robinson <gbranden>
Submitted:  Thu 13 May 2021 10:41:10 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 20 Jan 2022 03:24:34 PM UTC, comment #4: 


commit e4162062cd69ffbe18058f53379f58a53d17d17d
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
Date:   Fri Jan 21 00:02:18 2022 +1100

    [tbl]: Fix incorrect line numbers in diagnostics.

    Line numbers for multiple format-time diagnostics emitted by
    tbl(1)-generated groff input were off by +5 lines.

    * src/preproc/tbl/table.cpp: Fix it.
      (NOP_NAME): Add new preprocessor symbol to construct name of "nop"
      macro to be used as end macros for `ig` requests inside macro
      definitions.

      (table::init_output, table::compute_expand_list,
      table::compute_separation_factor):
        - Move `entry_list->set_location()` calls to more auspicious
          locations.
        - Replace "around line X" language in diagnostic messages with a
          more idiomatic, and less embarrassing, simple report of an
          integer.

      (table::init_output):
        - Add `entry_list->set_location()` call right before emitting
          diagnostic about a table row not fitting on a page.
        - Turn off eqn(1) delimiters when emitting diagnostic about a boxed
          table not fitting on a page (necessitating `.TS H` support), using
          new NOP_NAME-based end macro to achieve this inside a macro
          definition.

      (table::compute_expand_list): Suppress issue of too-wide table
      diagnostic when the `EXPAND` table flag is set (corresponding to the
      `expand` region option), because other code already emits diagnostics
      in this case.

    Fixes <https://savannah.gnu.org/bugs/?60598>.  Problem appears
    to date back to commit 3bc4a53a45, 2013-01-07.


G. Branden Robinson <gbranden>
Group administrator
Thu 20 Jan 2022 12:28:47 PM UTC, comment #3: 

I think I've cracked it.  I had been looking in the wrong place
for the problem; the right place was the injection of `ig`-nored
eqn(1) input to disable and re-enable delimiters to prevent that
program from interfering with production of diagnostic messages.

Unfortunately, these injections were performed after the
`set_location()` function (which ultimately writes `lf`
requests) was called, which is why the line numbers were
consistently off by 5--that's how long the `ig`-nored region
was.

Here's an exercise of the format-time diagnostic messages with
minimal inputs, with output of groff 1.22.4, and then with groff
Git HEAD, with my patch applied to fix this stuff.

These cases are exercised in a unit test also pending a push, so
don't take them too literally (i.e., there are some tab
characters that might not survive the trip through
Savannah/email).


$ cat EXPERIMENTS/tbl-diagnostic-1a.groff
.pl 2v
.TS
L.
T{
.nf
1
2
3
T}
.TE
$ groff -tz EXPERIMENTS/tbl-diagnostic-1a.groff
warning: page 2: table text block will not fit on one page
$ ./build/test-groff -tz EXPERIMENTS/tbl-diagnostic-1a.groff
EXPERIMENTS/tbl-diagnostic-1a.groff:4: warning: table row will not fit on page 2
$ cat EXPERIMENTS/tbl-diagnostic-1b.groff
.pl 2v
.vs 3v
.TS
L.
1
.TE
$ groff -tz EXPERIMENTS/tbl-diagnostic-1b.groff
warning: page 2: table text block will not fit on one page
$ ./build/test-groff -tz EXPERIMENTS/tbl-diagnostic-1b.groff
EXPERIMENTS/tbl-diagnostic-1b.groff:4: warning: table row will not fit on page 2
$ cat EXPERIMENTS/tbl-diagnostic-2.groff
.pl 2v
.vs 3v
.TS
box;
L.
1
.TE
$ groff -tz EXPERIMENTS/tbl-diagnostic-2.groff
error: page 2: table will not fit on one page; use .TS H/.TH with a supporting macro package
$ ./build/test-groff -tz EXPERIMENTS/tbl-diagnostic-2.groff
EXPERIMENTS/tbl-diagnostic-2.groff:5: error: boxed table will not fit on page 2; use .TS H/.TH with a supporting macro package
$ cat EXPERIMENTS/tbl-diagnostic-3.groff
.pl 2v
.ll 10n
.br
.TS
L.
12345678901
.TE
$ groff -tz EXPERIMENTS/tbl-diagnostic-3.groff
warning: file 'EXPERIMENTS/tbl-diagnostic-3.groff', around line 11:
  table wider than line width
$ ./build/test-groff -tz EXPERIMENTS/tbl-diagnostic-3.groff
EXPERIMENTS/tbl-diagnostic-3.groff:6: warning: table wider than line length minus indentation
$ cat EXPERIMENTS/tbl-diagnostic-4.groff
.pl 3v
.ll 10n
.TS
expand;
L L.
abcde        fghij
.TE
$ groff -tz EXPERIMENTS/tbl-diagnostic-4.groff
warning: file 'EXPERIMENTS/tbl-diagnostic-4.groff', around line 11:
  table wider than line width
warning: file 'EXPERIMENTS/tbl-diagnostic-4.groff', around line 6:
  table squeezed horizontally to fit line length
$ ./build/test-groff -tz EXPERIMENTS/tbl-diagnostic-4.groff
EXPERIMENTS/tbl-diagnostic-4.groff:6: warning: table column separation reduced to fit line length
$ cat EXPERIMENTS/tbl-diagnostic-5.groff
.pl 3v
.ll 10n
.TS
expand;
L L.
abcd        efgh
.TE
$ groff -tz EXPERIMENTS/tbl-diagnostic-5.groff
warning: file 'EXPERIMENTS/tbl-diagnostic-5.groff', around line 11:
  table wider than line width
warning: file 'EXPERIMENTS/tbl-diagnostic-5.groff', around line 6:
  table squeezed horizontally to fit line length
$ ./build/test-groff -tz EXPERIMENTS/tbl-diagnostic-5.groff
EXPERIMENTS/tbl-diagnostic-5.groff:6: warning: table column separation reduced to fit line length


G. Branden Robinson <gbranden>
Group administrator
Thu 20 Jan 2022 05:17:32 AM UTC, comment #2: 

Here's a simpler reproducer that doesn't escape any newlines.

The numbers are still badly off.


$ cat -n EXPERIMENTS/wrong-line-number.roff
     1  .ll 10n
     2  .TS
     3  L.
     4  12345678901
     5  .TE
     6  .
     7  .TS
     8  Lx.
     9  12345678901
    10  .TE
$ ./build/test-groff -tz EXPERIMENTS/wrong-line-number.roff
EXPERIMENTS/wrong-line-number.roff: around line 9: warning: table wider than line width
EXPERIMENTS/wrong-line-number.roff: around line 14: warning: table wider than line width
$ groff -tz EXPERIMENTS/wrong-line-number.roff
warning: file 'EXPERIMENTS/wrong-line-number.roff', around line 9:
  table wider than line width


(groff 1.22.4 emits only one diagnostic because of bug #61854.)

G. Branden Robinson <gbranden>
Group administrator
Sat 15 May 2021 07:07:09 AM UTC, comment #1: 

This turned out to be harder than I thought; I ended moving the lump in the carpet and making the line counter wrong for tables with text blocks.

Still hammering on this.  The problem isn't where I thought it was.  When columns get populated with data, we need to look out for backslashes before newlines.  I thought main.cpp handled this with its table_input::get() and ::unget() member functions, but it doesn't, and meddling with things there does not help.

G. Branden Robinson <gbranden>
Group administrator
Thu 13 May 2021 10:41:10 AM UTC, original submission:  

...sometimes.

Namely, when input line continuation (\RET) is used inside the table.

Reproducer:

$ nl reproducer.roff
     1  .TS
     2  l l.
     3  foo     bar
     4  baz     qux\
     5          fnord
     6  baz     qux\
     7          fnord
     8  .TE
$ tbl reproducer.roff >/dev/null
tbl:reproducer.roff:4: excess data entry 'fnord' discarded
tbl:reproducer.roff:5: excess data entry 'fnord' discarded


Fortunately, I have a fix.


$ ./build/tbl reproducer.roff >/dev/null
./build/tbl:reproducer.roff:4: error: line continuation escape at line 4
./build/tbl:reproducer.roff:5: error: excess data entry 'fnord' discarded
./build/tbl:reproducer.roff:6: error: line continuation escape at line 6
./build/tbl:reproducer.roff:7: error: excess data entry 'fnord' discarded


I'll be getting rid of those "line continuation escape" diagnostics before committing.

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 3 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

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code