bugGNU roff - Bugs: bug #64013, [ms] EQ macro ignores second...

 
 

bug #64013: [ms] EQ macro ignores second argument if first empty

Submitter:  G. Branden Robinson <gbranden>
Submitted:  Thu 06 Apr 2023 05:25:31 PM UTC
   
 
Category:  Macro ms Severity:  3 - Normal
Item Group:  Incorrect behaviour Status:  Fixed
Privacy:  Public Assigned to:  gbranden
Open/Closed:  Closed Planned Release:  1.24.0
* Mandatory Fields

Add a New Comment Rich Markup
   

Mon 10 Jul 2023 08:59:45 AM UTC, comment #4: 

Oh, also there's a regression test.


commit 98cba6b24cbdf831780ff9989604876300a732ac
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
Date:   Fri Apr 7 19:14:23 2023 -0500

    [ms]: Regression-test Savannah #64013.

    * tmac/tests/s_EQ-handles-empty-first-arg.sh: Do it.
    * tmac/tmac.am (tmac_TESTS): Run test.

    Test fails at this commit.


G. Branden Robinson <gbranden>
Group administrator
Mon 10 Jul 2023 08:58:53 AM UTC, comment #3: 


commit 380386369405245707207dc467dd99d9f9a6d45f
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
Date:   Fri Apr 7 20:22:46 2023 -0500

    [ms]: Fix Savannah #64013.

    * tmac/s.tmac (@EQ): Revise argument handling.  If there is only one
      argument and it is not a recognized alignment, warn and treat it as an
      equation label.  If there are two arguments but the first is not a
      recognized alignment, throw a warning diagnostic (but still use
      default alignment with the second argument as label).  An explicitly
      empty first argument is synonymous with "C".

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

    Also tested with:

    .LP
    .EQ "" (1)
    x + y = z
    .EN
    .EQ (2) \" expect warning
    pq = 0
    .EN
    .EQ R (3) \" expect warning
    ab = 1
    .EN
    .EQ
    E = mc sup 2
    .EN


G. Branden Robinson <gbranden>
Group administrator
Sat 08 Apr 2023 01:40:19 AM UTC, comment #2: 

In my branch for pushing next week.


diff --git a/tmac/s.tmac b/tmac/s.tmac
index 6870656b1..7a6ec8283 100644
--- a/tmac/s.tmac
+++ b/tmac/s.tmac
@@ -1885,15 +1885,20 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 .if \\n[tbl@within-table] \
 .      @error .EQ is not allowed within a .TS/.TE table
 .br
+.nr eqn*type -1
 .ds eqn*num "\\$2
-.ie '\\$1'L' .nr eqn*type 0
-.el \{\
-.      ie '\\$1'I' .nr eqn*type 1
-.      el \{\
-.              nr eqn*type 2
-.              if !'\\$1'C' .ds eqn*num "\\$1
+.if '\\$1'L' .nr eqn*type 0
+.if '\\$1'I' .nr eqn*type 1
+.if '\\$1'C' .nr eqn*type 2
+.ie (\\n[eqn*type] < 0) \{\
+.      ie (\\n[.$] = 1) .if !'\\$1'' \{\
+.              ds eqn*msg .EQ: unrecognized alignment '\\$1';
+.              as eqn*msg " assuming it is an equation label
+.              @warning \\*[eqn*msg]
+.              ds eqn*num "\\$1
+.              rm eqn*msg
 .      \}
-.\}
+.el .if !'\\$1'' .@error .EQ: unrecognized alignment '\\$1'
 .di eqn*div
 .in 0
 .if '\*(.T'html' \{\


G. Branden Robinson <gbranden>
Group administrator
Thu 06 Apr 2023 05:26:09 PM UTC, comment #1: 

Postponing; low-hanging fruit for groff 1.24.

G. Branden Robinson <gbranden>
Group administrator
Thu 06 Apr 2023 05:25:31 PM UTC, original submission:  

Given this input:


.LP
Here comes an equation.
.EQ "" 1.1
x + y = z
.EN
.LP
All done.


  • DWB 3.3 ms does not typeset the equation number.
  • Heirloom Doctools ms does.
  • groff 1.22.4 does not.
  • groff Git does not.


I think the correct thing to do is follow Heirloom's behavior here.  For many, many years, groff ms's `EQ` macro was not even documented as accepting a second argument, but the implementation did so.  AT&T ms did so going all the way back to 1975, but it used a tricky method of argument parsing that I think might have malfunctioned if the document author had the temerity to label their equation "L", "I", or "C".

This doesn't seem urgent to fix (for groff 1.23.0 I mean) since it can be worked around by explicitly giving "C" as the first argument to the `EQ` macro.

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

    Date Changed by Updated Field Previous Value => Replaced by
    2023-07-10 gbranden StatusReady for Merge Fixed
        Open/ClosedOpen Closed
        Planned ReleaseNone 1.24.0
    2023-04-21 gbranden StatusIn Progress Ready for Merge
    2023-04-08 gbranden StatusPostponed In Progress
        Planned Release1.24.0 None
    2023-04-06 gbranden StatusConfirmed Postponed
        Planned ReleaseNone 1.24.0

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code