bugGNU roff - Bugs: bug #62191, [tbl] use of line continuation...

 
 

bug #62191: [tbl] use of line continuation throws off input line counter

Submitter:  G. Branden Robinson <gbranden>
Submitted:  Wed 16 Mar 2022 07:51:29 AM UTC
   
 
Category:  Preprocessor tbl Severity:  3 - Normal
Item Group:  Warning/Suspicious behaviour Status:  Fixed
Privacy:  Public Assigned to:  gbranden
Open/Closed:  Closed Planned Release:  1.23.0
* Mandatory Fields

Add a New Comment Rich Markup
   

Fri 18 Mar 2022 04:48:05 AM UTC, comment #3: 


commit 0bbdd18872efc3aeaf028740c98ddc1d68b0524e
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
Date:   Wed Mar 16 19:32:39 2022 +1100

    [tbl]: Fix Savannah #62191.

    * src/preproc/tbl/main.cpp (table_input::get): Increment input line
      counter when encountering an escaped newline; this fixes inaccurate
      diagnostics from the formatter at any point in a document after a
      line-continued row of table data.  Also drop a "perhaps" comment.  I
      tested the surmise (setting the FSM state to "START"), and it results
      in bad formatting.

    Fixes <https://savannah.gnu.org/bugs/?62191>.  Problem appears to date
    back to groff 1.02 (June 1991) at the latest.


G. Branden Robinson <gbranden>
Group administrator
Fri 18 Mar 2022 03:09:39 AM UTC, comment #2: 

Let's see if this problem occurs in other preprocessors.

  • eqn: apparently not; you don't need '\' to perform line continuation and in fact attempting to do so provokes an error.


  • grn: also does not admit line continuation.


  • (pre-)html: doesn't even appear to read input files by line.

https://git.savannah.gnu.org/cgit/groff.git/tree/src/preproc/html/pre-html.cpp#n495

  • pic: as eqn.


  • refer: does not treat '\newline' specially.


  • soelim: does not treat '\newline' specially.


Experiments also reveal that eqn, refer, and soelim report accurate diagnostics when encountering trouble after one of their respective "regions".

G. Branden Robinson <gbranden>
Group administrator
Fri 18 Mar 2022 01:54:46 AM UTC, comment #1: 

The fix is a one-liner, except for the need to add braces.


diff --git a/src/preproc/tbl/main.cpp b/src/preproc/tbl/main.cpp
index d6f8a9878..f969a0277 100644
--- a/src/preproc/tbl/main.cpp
+++ b/src/preproc/tbl/main.cpp
@@ -120,8 +120,10 @@ int table_input::get()
       // handle line continuation and uninterpreted leader character
       if ((c = getc(fp)) == '\\') {
        c = getc(fp);
-       if (c == '\n')
-         c = getc(fp);         // perhaps state ought to be START now
+       if (c == '\n') {
+         current_lineno++;
+         c = getc(fp);
+       }
        else if (c == 'a' && compatible_flag) {
          state = LEADER_1;
          return '\\';


G. Branden Robinson <gbranden>
Group administrator
Wed 16 Mar 2022 07:51:29 AM UTC, original submission:  

Problem exists in groff 1.22.4 and persists in Git HEAD.


$ cat EXPERIMENTS/tbl-bad-input-line-number.roff
.this-is-line-1
.TS
L.
foo\
bar\
baz\
qux
.TE
.this-is-line-9
$ nroff -t -ww EXPERIMENTS/tbl-bad-input-line-number.roff >/dev/null
troff: EXPERIMENTS/tbl-bad-input-line-number.roff:1: warning: macro 'this-is-line-1' not defined
troff: EXPERIMENTS/tbl-bad-input-line-number.roff:6: warning: macro 'this-is-line-9' not defined



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

    Date Changed by Updated Field Previous Value => Replaced by
    2022-03-18 gbranden StatusIn Progress Fixed
        Open/ClosedOpen Closed
        Planned ReleaseNone 1.23.0
    2022-03-16 gbranden StatusNone In Progress
        Assigned toNone gbranden

    Back to the top

    Powered by Savane 3.13-bb6a.
    Corresponding source code