bugGNU roff - Bugs: bug #62852, [eqn] -C flag interferes with tbl

 
 

bug #62852: [eqn] -C flag interferes with tbl

Submitter:  Bjarni Ingi Gislason <bjarniig>
Submitted:  Mon 01 Aug 2022 11:48:54 PM UTC
   
 
Category:  Preprocessor eqn 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 05 Aug 2022 07:58:47 AM UTC, comment #4: 


commit 7b9e3181df5069037349b0c6292a66bf0ec6259d
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
Date:   Thu Aug 4 07:44:43 2022 -0500

    [eqn]: Recognize "delim on" even if `-C` given.

    * src/preproc/eqn/lex.cpp (do_delim): Recognize "delim on" even in
      compatibility mode, enabling tbl to toggle eqn delimiter recognition
      when it is run in compatibility mode as well.
    * src/preproc/eqn/eqn.1.man (Controlling delimiteres): Update.
    * NEWS: Add item.

    Fixes <https://savannah.gnu.org/bugs/?62852>.  Thanks to Bjarni Ingi
    Gislason for the report.

    Also update editor aid comments; drop old style Emacs file-local
    variable setting.


G. Branden Robinson <gbranden>
Group administrator
Thu 04 Aug 2022 05:26:14 AM UTC, comment #3: 

The "allbox;" line is also unnecessary.

G. Branden Robinson <gbranden>
Group administrator
Thu 04 Aug 2022 05:25:36 AM UTC, comment #2: 

Oh, I forgot to paste the text of the reproducer.


$ cat EXPERIMENTS/eqn-tbl-compatibility-mode.roff
.EQ
delim $$
.EN
.TS
allbox;
L.
$0$
.TE


G. Branden Robinson <gbranden>
Group administrator
Thu 04 Aug 2022 05:24:33 AM UTC, comment #1: 

This affects groff 1.22.4 and, I suspect, every earlier version going back to groff 1.22.2.

I believe the problem to be this.

The -C flag turns on AT&T compatibility mode in both tbl and eqn.  In the latter, this disables special interpretation of the eqn input "delim on".  Instead of re-enabling delimiters that have been shut off with "delim off", it assigns opening and closing delimiters of 'o' and 'n' respectively, just as AT&T eqn would have.

However, even with -C specified, tbl expects "delim on" to work in the GNU eqn way.  GNU tbl brackets portions of the groff input it writes in "delim off"/"delim on" pairs to avoid interference from eqn with the output of formatting-time diagnostics.

For example, we have the following in Git HEAD.


$ sed -n '2190,2207p' src/preproc/tbl/table.cpp
  if ((!(flags & NOWARN)) && (!(flags & EXPAND))) {
    // Protect characters in diagnostic message (especially :, [, ])
    // from being interpreted by eqn.
    prints(".ig\n"
           ".EQ\n"
           "delim off\n"
           ".EN\n"
           "..\n");
    entry_list->set_location();
    prints(".tmc \\n[.F]:\\n[.c]: warning:\n"
           ".tm1 \" table wider than line length minus indentation\n");
    prints(".ig\n"
           ".EQ\n"
           "delim on\n"
           ".EN\n"
           "..\n");
    prints(".nr " EXPAND_REG " 0\n");
  }


I think the discarded special recognition of "delim on" in eqn's compatibility mode is going to have to go.  Even in AT&T documents, I suspect the number of documents using "o" and "n" as delimiters is low to zero.

So I propose to disable this feature, losing an aspect of AT&T eqn compatibility that I believe to be negligible.


diff --git a/src/preproc/eqn/lex.cpp b/src/preproc/eqn/lex.cpp
index 115617b1d..51c5af246 100644
--- a/src/preproc/eqn/lex.cpp
+++ b/src/preproc/eqn/lex.cpp
@@ -1079,7 +1079,7 @@ void do_delim()
       end_delim_saved = end_delim;
       start_delim = end_delim = '\0';
     }
-    else if (c == 'o' && d == 'n' && !compatible_flag) {
+    else if (c == 'o' && d == 'n') {
       start_delim = start_delim_saved;
       end_delim = end_delim_saved;
     }


Here's a simpler reproducer and its behavior with groff 1.22.4 and a patched Git HEAD.


$ groff -Cetz EXPERIMENTS/eqn-tbl-compatibility-mode.roff
eqn:EXPERIMENTS/eqn-tbl-compatibility-mode.roff:122: '\' ignored because followed by newline
eqn:EXPERIMENTS/eqn-tbl-compatibility-mode.roff:123: unquoted escape
eqn:EXPERIMENTS/eqn-tbl-compatibility-mode.roff:36: '\' ignored because followed by newline
eqn:EXPERIMENTS/eqn-tbl-compatibility-mode.roff:87: '\' ignored because followed by newline
eqn:EXPERIMENTS/eqn-tbl-compatibility-mode.roff:8: '\' ignored because followed by newline
eqn:EXPERIMENTS/eqn-tbl-compatibility-mode.roff:8: '\' ignored because followed by newline
troff: EXPERIMENTS/eqn-tbl-compatibility-mode.roff:36: '\&' is not allowed in a name
troff: EXPERIMENTS/eqn-tbl-compatibility-mode.roff:82: '\&' is not allowed in a name
troff: EXPERIMENTS/eqn-tbl-compatibility-mode.roff:82: warning: numeric expression expected (got '\&')
troff: EXPERIMENTS/eqn-tbl-compatibility-mode.roff:87: '\&' is not allowed in a name
troff: EXPERIMENTS/eqn-tbl-compatibility-mode.roff:8: '\&' is not allowed in a name
troff: EXPERIMENTS/eqn-tbl-compatibility-mode.roff:8: warning: numeric expression expected (got '\&')
$ ./build/test-groff -Cetz EXPERIMENTS/eqn-tbl-compatibility-mode.roff
$

G. Branden Robinson <gbranden>
Group administrator
Mon 01 Aug 2022 11:48:54 PM UTC, original submission:  

Subject: Combination of "eqn" and "tbl" in compatibility mode errors

File (prof.eqn):

.EQ
delim $$
.EN
.TS
allbox;
l .
$sum from i=0 to inf x sub i = pi over 2$
.TE


"test-groff -e -t -C -b -ww -z prof.eqn" shows:

eqn:prof.eqn:32: error: '\' ignored because followed by newline
eqn:prof.eqn:77: error: '\' ignored because followed by newline
eqn:prof.eqn:83: error: '\' ignored because followed by newline
eqn:prof.eqn:8: error: '\' ignored because followed by newline
eqn:prof.eqn:8: error: '\' ignored because followed by newline
troff: backtrace: 'prof.eqn':46: string '10'
troff: backtrace: file 'prof.eqn':32
troff:prof.eqn:32: error: '\&' not allowed in a name
troff: backtrace: 'prof.eqn':46: string '10'
troff: backtrace: file 'prof.eqn':32
troff:prof.eqn:32: warning: macro 'e' not defined
troff: backtrace: file 'prof.eqn':58
troff:prof.eqn:58: warning: macro '.' not defined
troff: backtrace: 'prof.eqn':82: string '10'
troff: backtrace: file 'prof.eqn':77
troff:prof.eqn:77: error: '\&' not allowed in a name
troff: backtrace: 'prof.eqn':82: string '10'
troff: backtrace: file 'prof.eqn':77
troff:prof.eqn:77: warning: expected numeric expression, got '\&'
troff: backtrace: 'prof.eqn':83: string '10'
troff: backtrace: file 'prof.eqn':83
troff:prof.eqn:83: error: '\&' not allowed in a name
troff: backtrace: file 'prof.eqn':12
troff:prof.eqn:12: warning: register '3bot' not defined
troff: backtrace: file 'prof.eqn':28
troff:prof.eqn:28: warning: macro 'T#' not defined

Bjarni Ingi Gislason <bjarniig>

 

(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 (Posted a comment)
  • -email is unavailable- added by bjarniig (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 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-08-05 gbranden StatusConfirmed Fixed
        Open/ClosedOpen Closed
        Planned ReleaseNone 1.23.0
    2022-08-04 gbranden SummaryCombination of &quot;eqn&quot; and &quot;tbl&quot; in compatibility mode errors [eqn] -C flag interferes with tbl
    2022-08-04 gbranden CategoryNone Preprocessor eqn
        StatusNone Confirmed
        Assigned toNone gbranden

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code